Qt Linux strange serial behaviour.
-
I had to switch from windows 7 to Linux Ubuntu and my application no longer properly communicates with my arduino device. On windows it was working perfectly but now my communication is not entirely 2 way anymore, it's more like 1.5 way.
I have no problems with reading from the arduino, output looks well:
"\u008F" >> 1 // this '1' is the ammount of bytes send (Qt function) << "6" // received << "2" << "f1" cursor set at 2 241 << "1a" << "2" << "f1" position set at 2 241 "\u008F" >> 1 << "6" << "2" << "f2" cursor set at 2 242 << "1a" << "2" << "f2" position set at 2 242
The arduino on the other hand does not properly read everything, it does read uppercase C, X and L but it does not read N, M and H to name a few examples. The Arduino still uses the exact same program when I was working under Windows. I am working at 115200 baud and I use even parity bit.
In Qt I tried to use even, odd and no parity bits but it does not seem to make any difference at all which is a bit strange. The real strange thing is that I have 0,0 flaws in bytes that Qt receives, it reads everything from 0 to 255.
to set the parity bits I use functions which I copied from the serial terminal example.
void MainWindow::openSerialPort() { Setup::Settings p = settings->settings(); serial->setPortName(p.name); serial->setBaudRate(p.baudRate); serial->setDataBits(p.dataBits); serial->setParity(p.parity); serial->setStopBits(p.stopBits); serial->setPortName(p.name); serial->open(QIODevice::ReadWrite);
And I say again, this exact same software works fine on windows.
During the transition to ubuntu I forgot to safe the arduino code, it is a minor loss but I'd prefer if I would not have to install arduino and write new program to locate the problem. And because the same program worked without flaw on windows I suspect the problem is some kind of library setting of Qt creator's linux variant, but tbh I would not know.
I am always getting a '1' back after I send a byte so no error there. Googling the problem popped up this 2 year old post:
QtSerialPort does not detect parity error under linux