Unsolved QTSerialPort doesn't read data after another serial software
-
Hi all,
Let me explain the issue:
I do serial port communication with device, I have several programs that work with this device and one program is written not by me (I do not have access to sources) and is based on some "handmade" asm serial port routine. My current program is just simple serial port monitor based on QSerialPort, readready signal.
When I connect to device and read data everything works perfect, but when I read serial port data using another software (those I have no access to) and then try to read it again with my qt program, I get the situation:
-program opens port
-function, corresponding to readready signal, never callsThe important thing, that I need to reboot my PC to have opportunity to read serial port data with my qt program.
I've done the simple serial port monitor with Python, everything works. So the issue is only with qt realization.
Can you advice me something? What can I check?
-
Maybe the other program sets some other serial port parameters - make sure to specify all parameters the way you need them.
-
#Christian, I am setting all the parameters required (port name, baud rate, flow control, stop bits, parity etc.). As I said, when I start my program everything works perfectly. But, after and only after another program is connected to serial port, works with it, disconnects from it, I can't work with this port anymore (I can open it but not receive data from).
I can do this with my python script, and receive data, but not with qt program.Is there some way I can debug low level serial port flags and settings from qt?
I don't understand this situation, since the port is opening easily, and my function is connected to serial port signal. So the difference between two runs of the completely same program is just run of another program, not connected with qt program in any way.Looks like some bug...
-
-
Either the mystery program is fiddling with a parameter you don't explicitly reset (modem control comes to mind), or it is sending a speed change request to the other device and syncing at a different speed, such that you would need to power cycle/reboot, to reset the other device. I'm assuming you're using usb/rs232 and not a real pc comm port.
It is best practice to reset a serial device to the "tty sane" state and then explicitly set all necessary fields when a program accesses the device. There is no such thing as "simple serial". That's why folks get into trouble; underestimating...and butchering the physical protocols because they feel that they know better than the EIA guys who developed it 50 years ago.
-
@Kent-Dorfman , thank you for the answer. Yes, it is usb/rs232 using ch340.
I don't call serial communication simple. I call my program for this issue simple, cause it is based only on three operations:
- open serial port with required settings
- connect readyread signal to function
- receive data and print it
And as I said before, this works ok when I connect to device all the times before "mystery" program is connected. I assume it changes some parameter I don't catch and thus I cant receive data anymore.
Also, the serial device starts working only when I establish connection. The rest of time is powered off, so I think the state at the port initialization is the same.
@aha_1980 , thank you for the answer
I will send this info as soon as I get to my PCMost interesting, I was doing the "same" logics with Java and Python, and didn't get this situation.
Is there some state when the readyread signal does not emit?I will also try to read data without signal, using just timer and check bytes available. Will send results later.
Thanks guys