GPS Sensor data to view on ui
-
Hi guys,
So I've written the code for getting data from serial port and it's successful. Further when i connect the GPS Sensor and try to extract the string. The append function doesn't display any data on the ui (QTextbox). Can anyone help?
Here is the code of the read and write data in the file function:void MainWindow::serialReceived()
{
QByteArray serialData;
serialData = serial->readAll();
QString receivedData = QString::fromStdString(serialData.toStdString());char t0[512]; static char t1[512]; static int wp=0; unsigned int i=0; QString filename="/home/user/Desktop/Programs/Readserial2/gotdata.txt"; QFile file( filename ); if(file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) { QTextStream stream( &file ); strcpy(t0,serialData); for (i=0;i<strlen(t0);i++) { ui->receiver->append(receivedData); t1[wp++]=t0[i]; wp%=512; t1[wp]=0; if(t0[i] == '\n') { wp=0; if(checksum_gps(t1)) { if(memcmp("$GPRMC",t1,6)==0 || memcmp("$GPRMC",t1,6)==0) { strcat(t1,timestamp()); stream<<t1; ui->contdata->append(t1); } } } } stream << t1 << endl; fflush(stdout); file.close(); }
}
-
@Shivam-Sharma What did you check so far?
Is serialReceived() called?
Is file.open() successful?
Why do you call ui->receiver->append(receivedData); inside the for loop?
What does strlen(t0) return? -
@jsulm
Yes, serialReceived() is called?
Yes, file.open() is successful?
sorry deleted this, it was a commented :ui->receiver->append(receivedData);
strlen(t0) gives the length, so that the loop runs only for that length. -
@Shivam-Sharma said in GPS Sensor data to view on ui:
strlen(t0) gives the length
I know what it does, but does it return a number > 0 in your case?
Did you tryqDebug() << receivedData?