I have the following two problems with a break condition on the serial device:
Despite I set IGNBRK, I receive a break condition (3 times 0x00). (The break condition is caused by a baud rate mismatch, 4800 instead of 115200 baud)
After I received this break condition, the serial device is somehow unavailable. I have to close and reopen the device in order to be able to receive further data. The serial device seems to be still open and the file descriptor is still associated with the device, but if I rearm the resource manager notifier (ionotify, see below) I do not get any pulse anymore.
Here follows my source code. I tried to reduce the code to its essential elements, therefore I eliminated all the error detection and handling.
I’m not sure why a baud rate error would appear as a break. I don’t know how QNX 6 handles framing errors, which is what I think this is. It is plausible that this misinterpretation might occur.
As to the stuck condition, I’d look into whether the device is paused such as when one receives XOFF. If you stty the device, there’s some bit turned on when this happens, pended or some such.
Problem 1)
A break condition is interpreted if the line is put on space for longer than a frame duration. A frame duration on 115200 (8N1) is approx 86.8us, which is less than a single “space” on 4800 baud (208us). Well, of course this is also a framing error.
If its any consolation, Linux also returns null’s with IGNBRK and ~BRKINT.
To the uart, a break at 115200 baud is as short as 0.008 ms (10-bit times). A single character at 4800 baud is 24x longer (about 2ms). So obviously, most any character sent at 4800 is going to cause a “break” condition on the uart.
However, since the 115200 uart is sampling so much faster, it may also detect a variable number of VALID null characters when the 4800 baud signal transitions from a 0->1 or 1->0.
If you test characters received at 115200 against various characters sent at 4800, you will see that a different number of chars are framed up - depending on the bits in the character. For example produces two, ‘j’ gives four and ‘h’ gives three- the most common.
Bottom line, NULLs are framed up and since you disabled BRK processing in the uart, there is no way to know how they were created - so they are returned as characters.
I looked at this issue a little bit deeper in detail and it seems like your statement is right, denkelly.
Every transiton from 1 to 0 is interpreted as 0x00. If I send 0x10 I receive 2 times 0x00, once for the start bit (during idle the line is high) and once for the transition within the byte.
According to that, I receive 5 times 0x00 if I send 0x55 (0b01010101, LSB is sent first). I tried this with a couple other values.
It does not matter if I enable or disable IGNBRK, I receive the exact same values for the same bytes.
Well I will handle problem #1 as follows: Enable IGNBRK and ignore incoming data if it equals 0x00.
Unfortunately I’m still stuck with problem #2.
I could simply close and reopen the connection every time I receive a 0x00 byte, but I do not feel very confortable with this workaround. Does anyone else have an idea what I could try or can I give you further information?