PDA

View Full Version : Detecting Serial port events on specific lines



jamierobertson
14th January 2019, 21:05
Hi,

I'd like to be able to be notified on hi / lo signal changes on serial lines such as the RING, DCD, CTS line.

In this case it's for detecting a time synchronization pulse.

Is this possible with QSerialPort somehow?


Thanks

Jamie

d_stranz
15th January 2019, 02:22
You have access to the status of these lines through the QSerialPort::pinoutSignals() method. However, except for DTR and RTS, there are no signals emitted when these lines change level. You might be able to look into the implementation of QSerialPort where DTR and RTS are handled to see if at that low level there is access to these lines. If so, you may be able to derive a class from QSerialPort and add level change signals for the lines you are interested in. The assumption here is that if pinoutSignals() can tell you the status of those lines, then somewhere in the internals it must be reading them and maybe responding to changes.

kuzulis
15th January 2019, 13:35
It is impossible with QSerialPort.

jamierobertson
15th January 2019, 16:21
Thanks for the replies.

I did look through the source code and could only calls that emitted the DTR and RTS notifier signals as responses to changes made on the application side rather than actual system events.

I think I'll try and use winAPI to do it.

Thanks

d_stranz
15th January 2019, 18:00
I think I'll try and use winAPI to do it.

I figured you'd end up having to dip into system calls. QSerialPort is too high-level and abstract.