Hello friends i have small problem. i have finished a small project. where i retrieve some data from RS232 interface and save that data to the data base and the display the converted data in a QTableView. Now my problem is the program retrieves data properly for a while and then the data retrieval is stopped. According to what i have noticed it stops after updating around 20 rows into the data base. I looked into the code so much but cud't figure out where i am going wrong. not able to know why the data from the port is not retrieved after some duration.
this is the code where i am retrieving the data from the port, i am calling this function every 120 mili seconds when the user clicks Acquire Button, i am getting huge data some 700 channels of data every 1.6 seconds.
void datareceiver::myexport1()
{
qint64 i;
char buff[4096];
quint16 r;
if(port->bytesAvailable())
{
quint16 r;
inscnt++;
numBytes = port->bytesAvailable();
data = port->read(numBytes % 2 ? numBytes : numBytes-1);
newdata.append(data);
// Save the data in newdata into data base after data manipulation
}
else
{
switch( QMessageBox::warning( this,
","RS232 Interface is not connected properly.
Try to re
-connection again. \n \n
Do you want to
continue.
" , "Yes", "No"/*, "Leave Anyway"*/, 0, 1 ) )
{
case 0:
break;
case 1:
exit(1);
break;
}
QSound::play("notify.wav");
qLed->setColor(Qt::red);
label_3->setText("LINK FAILURE");
pushButton_6->setDisabled(false);
}
void datareceiver::myexport1()
{
qint64 i;
char buff[4096];
QByteArray result;
quint16 r;
if(port->bytesAvailable())
{
quint16 r;
inscnt++;
numBytes = port->bytesAvailable();
data = port->read(numBytes % 2 ? numBytes : numBytes-1);
newdata.append(data);
// Save the data in newdata into data base after data manipulation
}
else
{
switch( QMessageBox::warning( this,","RS232 Interface is not connected properly. Try to re-connection again. \n \n Do you want to continue." ,
"Yes", "No"/*, "Leave Anyway"*/, 0, 1 ) )
{
case 0:
break;
case 1:
exit(1);
break;
}
QSound::play("notify.wav");
qLed->setColor(Qt::red);
label_3->setText("LINK FAILURE");
pushButton_6->setDisabled(false);
}
To copy to clipboard, switch view to plain text mode
I am assuming that the timer is stopped but there is no event where i am stopping the timer is stopped.
Do you find any problem in this part of the code that this might be happening.
Added after 1 21 minutes:
Thank you
some one pls help me out with this problem, just not able to figure out where i am going wrong why the data retrieval. It is not the problem of the Timer its some problem with the port or the way i am reading the data from the serial port. Do you find any mistakes in this part of the code.??
Thank you
Bookmarks