LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Problem with Non-blocking serial port read (https://www.linuxquestions.org/questions/programming-9/problem-with-non-blocking-serial-port-read-279273/)

ZX_SA 01-18-2005 08:50 AM

Problem with Non-blocking serial port read
 
Hi everyone

I've been trying to solve this problem for the last couple of days and as of yet I have no solution:

What I am doing is to use a QSocketNotifier object (from Qt libraries) to notify my program when there is data to be read on the serial port. For those unfamiliar with Qt, QSocketNotifier basically sets a callback for the SIGIO signal and then calls a function in my program from that callback (albeit via Qt's events and also signal/slot mechanism).

The problem is that when I receive a sequence of bytes via the serial port, the first 8 bytes goes missing. I receive only a single SIGIO and then can read only the last bytes. I did however connect an oscilloscope to the serial cable and I am confident that the correct data is being transferred and must be getting lost somewhere inside the PC. The only problem is that I have absolutely no idea where this could be happening nor why!

For an extra twist, today I've discovered that some longer strings does arrive ok. Basically my application is to control CCTV cameras via SONY's VISCA interface and there are four commands that I can send to the camera that would cause the camera to send me a string longer than 8 bytes. Two of these reply packets arrive complete and with the other two I lose the first 8 bytes.

However, none of the strings that I receive is longer than 16 bytes (which I believe is how big the receive buffer in the UART is) so I can't see how the bytes could be lost in the UART.

Some system info:
OS: SuSE 9.2 (but I have exactly the same results with SuSE 9.1 as well)
PC: 3.0GHz Prescott with 1GB RAM on Intel Bayfield (865G) motherboard
Serialport: Onboard 16550A UART (/dev/ttyS0)
Qt version: 3.3.3

I've run out of ideas of what to look at. Any ideas that you may have will be EXTREMELY welcome!

Regards,
ZX_SA


All times are GMT -5. The time now is 03:21 AM.