Thank you very much for your help
Unfortunately
QCoreApplication::processEvents()
To copy to clipboard, switch view to plain text mode
has a bizarre effect.
Here is a snipet of my code.
void Ui_MainGUI::startMainRoutine() {
string errTxt;
double testValue;
wxParameters wxStn;
if(w->toolBox_WX->currentIndex() == 0){
wxStn.stnName = "Lacrosse WS2300";
wxStn.stnInterface = "SERIAL";
wxStn.stnProtocol = "SERIAL";
wxStn.stnPort = w->cmbo_2300Port->currentText().toLocal8Bit().data();
wxStn.stnDataBit = w->cmbo_2300DataBits->currentText().toLocal8Bit().data();
wxStn.stnParity = w->cmbo_2300Parity->currentText().toLocal8Bit().data();
wxStn.stnStopBit = w->cmbo_2300StopBits->currentText().toLocal8Bit().data();
wxStn.stnBaud = w->cmbo_2300Speed->currentText().toInt();
wxStn.stnPollFreq = w->spin_2300PollFreq->text().toInt();
wxStn.stnRetries = w->spin_2300Retries->text().toInt();
wxStn.stnTimeout = w->spin_2300Timeout->text().toInt();
}
w->ledt_2300Status->setText("Connecting...");
if(!(MainRoutine.connStn(wxStn, stnNumber, &errTxt))){
w->ledt_2300Status->setText("ERROR");
QMessageBox::critical(this, tr
("ERROR"), tr
("%1").
arg(err
));
return;
}
w->ledt_2300Status->setText("Testing Connection.");
if(!(MainRoutine.testStn(stnNumber, &testValue, &errTxt))){
w->ledt_2300Status->setText("ERROR");
QMessageBox::critical(this, tr
("ERROR"), tr
("%1").
arg(err
));
return;
}
w->ledt_2300Status->setText("ACTIVE");
return;
}
void Ui_MainGUI::startMainRoutine() {
string errTxt;
double testValue;
wxParameters wxStn;
if(w->toolBox_WX->currentIndex() == 0){
wxStn.stnName = "Lacrosse WS2300";
wxStn.stnInterface = "SERIAL";
wxStn.stnProtocol = "SERIAL";
wxStn.stnPort = w->cmbo_2300Port->currentText().toLocal8Bit().data();
wxStn.stnDataBit = w->cmbo_2300DataBits->currentText().toLocal8Bit().data();
wxStn.stnParity = w->cmbo_2300Parity->currentText().toLocal8Bit().data();
wxStn.stnStopBit = w->cmbo_2300StopBits->currentText().toLocal8Bit().data();
wxStn.stnBaud = w->cmbo_2300Speed->currentText().toInt();
wxStn.stnPollFreq = w->spin_2300PollFreq->text().toInt();
wxStn.stnRetries = w->spin_2300Retries->text().toInt();
wxStn.stnTimeout = w->spin_2300Timeout->text().toInt();
}
w->ledt_2300Status->setText("Connecting...");
QCoreApplication::processEvents();
if(!(MainRoutine.connStn(wxStn, stnNumber, &errTxt))){
w->ledt_2300Status->setText("ERROR");
QString err = QString::fromStdString(errTxt);
QMessageBox::critical(this, tr("ERROR"), tr("%1").arg(err));
return;
}
w->ledt_2300Status->setText("Testing Connection.");
QCoreApplication::processEvents();
if(!(MainRoutine.testStn(stnNumber, &testValue, &errTxt))){
w->ledt_2300Status->setText("ERROR");
QString err = QString::fromStdString(errTxt);
QMessageBox::critical(this, tr("ERROR"), tr("%1").arg(err));
return;
}
w->ledt_2300Status->setText("ACTIVE");
return;
}
To copy to clipboard, switch view to plain text mode
1] wxParameters wxStn is a struct which looks like this:
struct wxParameters {
const char *stnName;
const char *stnInterface;
const char *stnProtocol;
const char *stnPort;
const char *stnDataBit;
const char *stnParity;
const char *stnStopBit;
int stnBaud;
int stnPollFreq;
int stnTimeout;
int stnRetries;
};
struct wxParameters {
const char *stnName;
const char *stnInterface;
const char *stnProtocol;
const char *stnPort;
const char *stnDataBit;
const char *stnParity;
const char *stnStopBit;
int stnBaud;
int stnPollFreq;
int stnTimeout;
int stnRetries;
};
To copy to clipboard, switch view to plain text mode
2] The call at line 29 fails because wxStn.stnPort is full of garbage.
If I take the processEvents() away then the code works perfectly alas without the QLineEdit being updated until the call returns.
Do you have any idea why my const char *stnPort is full of garbage?
Many thanks
Nikki
Bookmarks