Unsolved Problems using QSerialPort and an RS232-emulator.
-
Unfortunately, I have no code to offer at this moment, seeing as the code is at another computer I don't have access to at the moment.
So, I have two programs: both are reading from and writing to the same virtual COM-port. I have some problems sending data from the one program, and have the other program listen to this and parse it correctly. The one program sends one bit of data to the other program, that program reads this and sends a corresponding data back and the first program outputs this; and it's during the last step the program doesn't work as expected.
For testing purposes I made it so that when the one program sends ACK to the other program, it will respond with 0x00, 0x00, 0x00. For some reason the data I get back is weird data with NEGATIVE or very huge hex values. I then tried to send NAK, and have it send back 0xFF, 0xFF, 0xFF; but for some reason I get back the exact same data. Like - EXACTLY the same, nothing different at all and still the weird values.
I have absolutely no idea what I have done wrong. Are there anything I could try doing tomorrow when I get access to my computer?
-
I'd say, run the Blocking Master Example and the Blocking Slave Example and see if they work as expected. Then compare the code to your own applications.
-
@wost said in Problems using QSerialPort and an RS232-emulator.:
So, I have two programs: both are reading from and writing to the same virtual COM-port
Sorry, what?
-
Haha, I'm using VSPE to create a virtual COM-port, and I then have two programs that connects to that port. Both can send and receive data from each other. If that makes any sense. :p
-
@wost said
Hi
You should test with other comm software that it works as expected. Then you know its a bug in your code and not the
virtual device. -
I got it to work!
I simplified my code somewhat, and now I don't get any errors or crashes! I tried implementing my own (somewhat confusing) functionality for reading data, and that's not always a good idea. :P
I did this:
connect(&_port, &QSerialPort::readyRead, this, &Worker::_readData);
and then this:
bool Worker::_readData() { _receivedData.append(_port.readAll()); if(_receivedData.count() >= 136) { // It should be this long qDebug() << _receivedData; qDebug() << "done reading..."; _receivedData.clear(); return true; } else { qDebug() << "reading..."; } }