I need to work on a serial protocol that uses the 9th bit as a 'wakeup' bit. All bytes are transmitted with the 9th bit in zero except for the first one, indication the message start.
On the Raspi' usart PL011, I tried to use the method I'm using over the years on a x86, accessing the hardware port itself:
I look at the port addrees on /proc/tty/driver/ttyAMA to get the address:
0: uart:PL011 rev3 mmio:0x3F201000 irq:83
Then I try to open and use the port, like getting the permission:
ioperm (0x3F201000, 7, 1)
I wasn't really expecting this to work since the address is 'mmio:' and not 'port:'. And it doesn't.
So, I tried to use the serial port the basic way, opening a file descriptor and setting the parameters.
2 issues so far:
1 - Mark/Space parity doesn't seem to work. Besides that, even setting the IGNPAR flag on the termios structure, the driver 'drops' received bytes that comes with the wrong parity. I'm logging the transmission on the 'server' machine and bytes are all been sent correctly (code works fine on x86 clients). I read on post here there is a patch to add MARK/SPACE parity and will try it ASAP. Even though, I guess there is nothing to do with the IGNPAR bit, as I was supposed to read all bytes anyway. But this is all irrelevant if not solved issue 2 below:
2 - How can I detect partity error on RAW communication? Today, using the port itself, I can set the port to SPACE and when whe first byte arrives with a MARK, I get the byte and the parity bit error, like this:
int uart_test_receive_char ()
{
return (inb (portcom + UART_LSR) & 0x05);
}
where portcom is the port address. The return value & 1 says there is a byte on the buffer and value & 4 indicates a parity error.
I didn't find a way to check for this using a file descriptor and 'read' or 'select' commands.
Any hint? Thanks!