开发者

Recognizing POSIX-read pauses in microseconds range

I have to realize the J1708-protocol in C++/Linux. I want to implement this completely in user spa开发者_开发百科ce, but I don't know if this is possible.

The problem is that messages are only separated though bit times. A bit time corresponds with the baud rate: 1/baudrate and is on J1708 with baud rate of 9600bps approximately 104.17 microseconds. Every message on this protocol consists of characters that are delimited with 2 bit times (208.34us) – so called “inter-character bit time”. A message consists of an undetermined number of characters and is over/complete if there is a pause of 10 bit times (1041.7us).

My idea is to read via the POSIX terminal interface in blocking mode bytes and count the time between to recognize the end of a message. Is there a chance to realize this with my approach or does anybody have a better idea?

SAE J1708 reference: http://read.pudn.com/downloads133/ebook/567787/saej1708v002.pdf


This is very hardware dependant ! Can you guarantee that :

  • your UART is not in FIFO mode. If it is, then several character will be buffered by the hardware, so you can say goodbye to your timing assumption.

  • No other task (userspace or kernel) will interrupt your read and last for more than 1 msec ?

  • Every character will result in a different read event ? It is similar to the first assumption (no hardware FIFO) but on the driver side.

Given the slow baudrate, maybe you can achieve 1 and 3.

I think implementing this with an OS like linux is either impossible or very inefficient (ie you spend all your processing time polling the hardware).

This kind of "protocol" is better handled by an FPGA or a microcontroller. Ie by a pic demoboard, decode your messages on the PIC board, and send them to your linux processor.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜