Make port selectable.

This commit is contained in:
con
2009-07-30 11:46:30 +02:00
parent 3419c2561b
commit 8cadee7b99
4 changed files with 41 additions and 6 deletions

View File

@@ -26,7 +26,6 @@
* auto-create run configurations the first time s60 qt is selected. * auto-create run configurations the first time s60 qt is selected.
* Run on device * Run on device
* Finish runner when application exits
* passphrase for signing * passphrase for signing
* time stamp of copied sisx is ridiculous * time stamp of copied sisx is ridiculous
* maybe don't copy the sisx all the time * maybe don't copy the sisx all the time

View File

@@ -52,6 +52,7 @@ S60DeviceRunConfiguration::S60DeviceRunConfiguration(Project *project, const QSt
: RunConfiguration(project), : RunConfiguration(project),
m_proFilePath(proFilePath), m_proFilePath(proFilePath),
m_cachedTargetInformationValid(false), m_cachedTargetInformationValid(false),
m_serialPortName("COM5"),
m_signingMode(SignSelf) m_signingMode(SignSelf)
{ {
if (!m_proFilePath.isEmpty()) if (!m_proFilePath.isEmpty())
@@ -95,6 +96,7 @@ void S60DeviceRunConfiguration::save(PersistentSettingsWriter &writer) const
writer.saveValue("SigningMode", (int)m_signingMode); writer.saveValue("SigningMode", (int)m_signingMode);
writer.saveValue("CustomSignaturePath", m_customSignaturePath); writer.saveValue("CustomSignaturePath", m_customSignaturePath);
writer.saveValue("CustomKeyPath", m_customKeyPath); writer.saveValue("CustomKeyPath", m_customKeyPath);
writer.saveValue("SerialPortName", m_serialPortName);
RunConfiguration::save(writer); RunConfiguration::save(writer);
} }
@@ -106,6 +108,17 @@ void S60DeviceRunConfiguration::restore(const PersistentSettingsReader &reader)
m_signingMode = (SigningMode)reader.restoreValue("SigningMode").toInt(); m_signingMode = (SigningMode)reader.restoreValue("SigningMode").toInt();
m_customSignaturePath = reader.restoreValue("CustomSignaturePath").toString(); m_customSignaturePath = reader.restoreValue("CustomSignaturePath").toString();
m_customKeyPath = reader.restoreValue("CustomKeyPath").toString(); m_customKeyPath = reader.restoreValue("CustomKeyPath").toString();
m_serialPortName = reader.restoreValue("SerialPortName").toString().trimmed();
}
QString S60DeviceRunConfiguration::serialPortName() const
{
return m_serialPortName;
}
void S60DeviceRunConfiguration::setSerialPortName(const QString &name)
{
m_serialPortName = name.trimmed();
} }
QString S60DeviceRunConfiguration::targetName() const QString S60DeviceRunConfiguration::targetName() const
@@ -251,6 +264,12 @@ S60DeviceRunConfigurationWidget::S60DeviceRunConfigurationWidget(S60DeviceRunCon
m_sisxFileLabel = new QLabel(m_runConfiguration->basePackageFilePath() + ".sisx"); m_sisxFileLabel = new QLabel(m_runConfiguration->basePackageFilePath() + ".sisx");
formLayout->addRow(tr("Install File:"), m_sisxFileLabel); formLayout->addRow(tr("Install File:"), m_sisxFileLabel);
QComboBox *serialPorts = new QComboBox;
serialPorts->addItems(QStringList() << "COM1" << "COM2" << "COM3" << "COM4" << "COM5" << "COM6" << "COM7" << "COM8" << "COM9");
serialPorts->setCurrentIndex(m_runConfiguration->serialPortName().mid(3).toInt()-1);
connect(serialPorts, SIGNAL(activated(QString)), this, SLOT(setSerialPort(QString)));
formLayout->addRow(tr("Device on Serial Port:"), serialPorts);
QWidget *signatureWidget = new QWidget(); QWidget *signatureWidget = new QWidget();
QVBoxLayout *layout = new QVBoxLayout(); QVBoxLayout *layout = new QVBoxLayout();
signatureWidget->setLayout(layout); signatureWidget->setLayout(layout);
@@ -312,6 +331,11 @@ void S60DeviceRunConfigurationWidget::updateTargetInformation()
m_sisxFileLabel->setText(m_runConfiguration->basePackageFilePath() + ".sisx"); m_sisxFileLabel->setText(m_runConfiguration->basePackageFilePath() + ".sisx");
} }
void S60DeviceRunConfigurationWidget::setSerialPort(const QString &portName)
{
m_runConfiguration->setSerialPortName(portName.trimmed());
}
void S60DeviceRunConfigurationWidget::selfSignToggled(bool toggle) void S60DeviceRunConfigurationWidget::selfSignToggled(bool toggle)
{ {
if (toggle) if (toggle)
@@ -440,6 +464,7 @@ void S60DeviceRunControl::start()
Qt4Project *project = qobject_cast<Qt4Project *>(rc->project()); Qt4Project *project = qobject_cast<Qt4Project *>(rc->project());
m_serialPortName = rc->serialPortName();
m_targetName = rc->targetName(); m_targetName = rc->targetName();
m_baseFileName = rc->basePackageFilePath(); m_baseFileName = rc->basePackageFilePath();
m_workingDirectory = QFileInfo(m_baseFileName).absolutePath(); m_workingDirectory = QFileInfo(m_baseFileName).absolutePath();
@@ -541,15 +566,21 @@ void S60DeviceRunControl::signsisProcessFinished()
connect(m_adapter, SIGNAL(startingApplication()), this, SLOT(printStartingNotice())); connect(m_adapter, SIGNAL(startingApplication()), this, SLOT(printStartingNotice()));
connect(m_adapter, SIGNAL(applicationRunning(uint)), this, SLOT(printRunNotice(uint))); connect(m_adapter, SIGNAL(applicationRunning(uint)), this, SLOT(printRunNotice(uint)));
//TODO com selection, sisx destination and file path user definable //TODO sisx destination and file path user definable
m_adapter->setTrkServerName("COM5"); m_adapter->setTrkServerName(m_serialPortName);
const QString copySrc(m_baseFileName + ".sisx"); const QString copySrc(m_baseFileName + ".sisx");
const QString copyDst = QString("C:\\Data\\%1.sisx").arg(QFileInfo(m_baseFileName).fileName()); const QString copyDst = QString("C:\\Data\\%1.sisx").arg(QFileInfo(m_baseFileName).fileName());
const QString runFileName = QString("C:\\sys\\bin\\%1.exe").arg(m_targetName); const QString runFileName = QString("C:\\sys\\bin\\%1.exe").arg(m_targetName);
m_adapter->setCopyFileName(copySrc, copyDst); m_adapter->setCopyFileName(copySrc, copyDst);
m_adapter->setInstallFileName(copyDst); m_adapter->setInstallFileName(copyDst);
m_adapter->setFileName(runFileName); m_adapter->setFileName(runFileName);
m_adapter->startServer(); if (!m_adapter->startServer()) {
delete m_adapter;
m_adapter = 0;
error(this, tr("Could not connect to phone on port %1. "
"Check if the phone is connected and if it runs the TRK application.").arg(m_serialPortName));
emit finished();
}
} }
void S60DeviceRunControl::printCopyingNotice() void S60DeviceRunControl::printCopyingNotice()
@@ -594,4 +625,5 @@ void S60DeviceRunControl::processFailed(const QString &program, QProcess::Proces
errorString = tr("Some error has occurred while running %1."); errorString = tr("Some error has occurred while running %1.");
} }
error(this, errorString.arg(program)); error(this, errorString.arg(program));
emit finished();
} }

View File

@@ -60,6 +60,8 @@ public:
void save(ProjectExplorer::PersistentSettingsWriter &writer) const; void save(ProjectExplorer::PersistentSettingsWriter &writer) const;
void restore(const ProjectExplorer::PersistentSettingsReader &reader); void restore(const ProjectExplorer::PersistentSettingsReader &reader);
QString serialPortName() const;
void setSerialPortName(const QString &name);
QString targetName() const; QString targetName() const;
QString basePackageFilePath() const; QString basePackageFilePath() const;
SigningMode signingMode() const; SigningMode signingMode() const;
@@ -82,6 +84,7 @@ private:
QString m_targetName; QString m_targetName;
QString m_baseFileName; QString m_baseFileName;
bool m_cachedTargetInformationValid; bool m_cachedTargetInformationValid;
QString m_serialPortName;
SigningMode m_signingMode; SigningMode m_signingMode;
QString m_customSignaturePath; QString m_customSignaturePath;
QString m_customKeyPath; QString m_customKeyPath;
@@ -97,6 +100,7 @@ public:
private slots: private slots:
void nameEdited(const QString &text); void nameEdited(const QString &text);
void updateTargetInformation(); void updateTargetInformation();
void setSerialPort(const QString &portName);
void selfSignToggled(bool toggle); void selfSignToggled(bool toggle);
void customSignatureToggled(bool toggle); void customSignatureToggled(bool toggle);
void signaturePathChanged(const QString &path); void signaturePathChanged(const QString &path);
@@ -158,6 +162,7 @@ private slots:
private: private:
void processFailed(const QString &program, QProcess::ProcessError errorCode); void processFailed(const QString &program, QProcess::ProcessError errorCode);
QString m_serialPortName;
QString m_targetName; QString m_targetName;
QString m_baseFileName; QString m_baseFileName;
QString m_workingDirectory; QString m_workingDirectory;

View File

@@ -88,11 +88,10 @@ Adapter::~Adapter()
bool Adapter::startServer() bool Adapter::startServer()
{ {
if (!openTrkPort(m_trkServerName)) { if (!openTrkPort(m_trkServerName)) {
qDebug("Unable to connect to TRK server"); logMessage("Unable to connect to TRK server");
return false; return false;
} }
m_timerId = startTimer(100); m_timerId = startTimer(100);
qDebug("Connecting");
sendTrkInitialPing(); sendTrkInitialPing();
sendTrkMessage(TrkConnect); // Connect sendTrkMessage(TrkConnect); // Connect
sendTrkMessage(TrkSupported, CB(handleSupportMask)); sendTrkMessage(TrkSupported, CB(handleSupportMask));