0

I am working on developing a UART sniffer application on VC++ 2010. I want to read the TX and RX lines of the UART between two of my devices. And i am building intelligence into my UART sniffer application, in order, to differentiate messages, log the traffic and in turn help me debug the system.

I am using two FTDI cables to tap the TX and RX lines of the UART. I have the application ready with most of the application stuff which adds intelligence to my application along with the working COM port read.

I am using tserial.cpp as the underlying COM Port driver for my application.

But, i have an issue, that is the latency involved in reading the COM Ports. the UART that i want to sniff runs at 1Mbits/s. It looks to me like there is large latency while reading the COM Ports. And i usually end up with 400-500 bytes on a read, instead of being able to read individual messages sent on each line (TX and RX).

Can anyone please share your experience and guide me here.As to how to go about reducing this latency?

Thanks, Suhel

suhel
  • 321
  • 3
  • 12
  • I tried lowering the serial buffer, changing timeouts, and number of bytes needed to trigger the data received event, but nothing has made an impact. – suhel May 16 '16 at 15:48
  • There is no such thing as a "message", data sent through a serial port is nothing but a raw stream of bytes. The device and the machine may well implement a protocol, very often necessary. A very simple one is terminating a chunk of bytes with a special character, a line feed is very common. Recognizing such messages back in the raw byte stream is ultimately the job of your program. Do not assume that you can understand everything, there are no mainstream protocol standards beyond the Hayes AT protocol for modems. 1 Mb/sec is very high, you'll be easily bogged down by displaying the data. – Hans Passant May 16 '16 at 15:58
  • @HansPassant, I understand that the data sent on the serial port is raw stream of bytes. But, i have defined a serial protocol with some start and termination bytes. And along with the payload in between, it constitutes a message as per my protocol. There are many such messages. All i want to achieve with the application that i want to develop is to read the raw bytes and interpret the read bytes as per my serial protocol. And as i have mentioned the issue that i am facing is the latency while reading the ports. Hope it is clear now. Thanks for the comment. – suhel May 16 '16 at 16:05
  • As noted, 1 Mb/sec is very high and displaying that much data will be costly. Which of course slows down the rate at which you read from the serial port. Which of course means that there will be a lot of bytes available. It just doesn't matter, your eyes are not nearly good enough to keep up anyway. – Hans Passant May 16 '16 at 16:09
  • @HansPassant, I understand 1 Mb/sec is very high. And, processing the data in turns adds significant overhead. But, it is not that there is some valid data all the time on the lines to be read, right? As i mentioned the lines that i want to sniff are between two ASIC's in my system. And the application that is running on them adds enough overhead as to avoid a non stop data flow. – suhel May 16 '16 at 16:16
  • There seems to be a concept or phenomenon of latency in hardware, but there is no equivalent concept in the RS232C port and the standard API of software. If you need to control such a phenomenon, you will need special hardware and special software with enhanced functions. – kunif Jan 28 '21 at 23:41

1 Answers1

0

Did you tried to set the COM latency ?
If you are on windows, follow this tuto :
How to set Latency Timer settings for virtual COM ports