Serial Port Errors

I am using a binary protocol with no block error detection. (Trimble's TSIP protocol) connected to a linux PC. The protocol does use odd parity, so what is the best way for a Linux application to detect parity and framing errors? I can get the driver to substitute a DEL or a DEL+NUL prior to the errored character, but these can alias to perfectly valid sequences of these characters in the packets themselves. Is there a way to find error information out-of-band with IOCTL or SIG processing?

Thanks,

-- James Dabbs, TGA (eliminate digits to get valid email address)

Reply to
James Dabbs
Loading thread data ...

TSIP

the

these

For reliable out-of-band marking, you should use a method similar to the PPP escaping mechanism: pick two special characters, one for the out-of-band marker and the other for escaping. Convert legal data looking like the special characters to a sequence of the escape character and a modified version of the original character (PPP uses inversion of bit 5). Now, the special characters can be guaranteed to always represent the special situation they were reserver for.

HTH

Tauno Voipio tauno voipio @ iki fi

Reply to
Tauno Voipio

I'm not sure I understand what you mean. The OP said that the data stream was binary, where any bytes, or pair of bytes, may occur. In this case how do you pick your special characters, as all maybe valid data. Or have I misunderstood you?

--
Dave Clarke
Reply to
Dave Clarke

This protocol actually does use a scheme similar to what you describe. It just has no block error checking.

I'm was just looking for a reasonable way to detect parity errors, and have since found that the linux serial driver can be configured to prefix errored characters with "255+NUL" while substituting any actual valid '255' characters with "255+255."

framing

PPP

Reply to
James Dabbs

I've been trying to impliment something with the same problems as you, so I've been following this thread.

The documentation I've been looking at (man 3 terminos) doesn't mention that everything will be prefixed, so your discovery is good news to me.

Now all I've got to do is figure out if I can distinguish breaks, which return "255+NUL+NUL", from receving NUL with a framing error, which would also be "255+NUL+NUL".

--
Dave Clarke
Reply to
Dave Clarke

looking

5).

So it seems.

To take the PPP method as an example:

- pick 0x7e (01111110) as the marker, called flag - pick 0x7d as the escape character - invert bit 5 (0x20) to escape a character

A data byte of 0x7e will be sent as two bytes: 0x7d 0x5e, a data byte of 0x7d will be sent as two bytes: 0x7d 0x5d, all other bytes are sent intact.

This is binary-transparent - it transfers all 256 bit combinations intact. Also, in the data there are no input bytes producing either the flag or the escape directly, so it can be trusted that the values 0x7e and 0x7d in the incoming encoded stream are the special characters of flag and escape.

The PPP encoding is a modified method of the bit-synchronous transfer method of SDLC and HDLC. PPP even uses the HDLC headers, so that the frames are marked UD (Unnumbered Data) in the HDLC parlance. A PPP frame has a 16 bit CRC for longitudinal check. The flavour used is the ITU-T CRC (also called CRC-CCITT). For details, see RFC 1549.

HTH

Tauno Voipio tauno voipio @ iki fi

Reply to
Tauno Voipio

OK, I see what you mean now. Unforunately this only applies to an interface where you have control of the protocol used. The application I am writing will accept any data, not data conforming to one protocol, so I can't use that method, but thanks anyway.

--
Dave Clarke
Reply to
Dave Clarke

Take a look at the TIOCGICOUNT ioctl. It gives lots of stats on a serial port including error counts. If you have /proc mounted you can also look in /proc/tty/driver/serial for the same stats.

James Dabbs wrote:

Reply to
Bob Smith

You don't happen to know where there is some documentation for TIOCGICOUNT, and for that matter all of the ioctl options. The man pages seem a bit light on information, and Google only provided bits of code.

--
Dave Clarke
Reply to
Dave Clarke

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.