IrDA IrPHY/Byte Stuffing in Ragel?
Bob Paddock
graceindustr... at gmail.com
Tue Sep 25 14:36:38 UTC 2007
Before I go off an reinvent the wheel, I was wondering
if anyone has done anything with IrDA or Byte Stuffing
Protocols in Ragel?
I need to write some code to handel the IrDA IrPHY (Physical)
Layer.
Anyone already have a State Chart already in Ragel?
Frame Format:
All payload data is packed into IrPHY frames where each frame consists of:
XBOF (0xFF *or* 0xC0), typically ten, but can be more or less, transmitted,
ignored by receiving end beyond getting the hardware synced up.
0xC0 followed by 0xC0 is XBOF, 0xC0 followed by something else is BOF.
BOF (0xC0), Beginning of Frame
Data Payload data, variable length
FCS 16 bit Frame Check Sequence (CITT-CRC)
EOF (0xC1) End of Frame.
Between the BOF and EOF flags, so that the receiver may easily determine
the start and end of each frame, no payload data or
FCS character may have the same value as the BOF,
EOF or control escape (CE) flags.
If so, these characters are escaped, ie byte-stuffed,
using the CE character (0x7D):
0xC0 -> (0x7D, 0xE0) [^Bit 5]
0xC1 -> (0x7D, 0xE1) ..
0x7D -> (0x7D, 0x5D) ..
Receiving 0x7D 0x7D is an error and you start over.
After the buffer is destuffed it needs parsed.
More information about the ragel-users
mailing list