Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 1 month ago.
Can we add Byte Stuffing to MODSERIAL?
A nice library, solves some issues I was having.
A feature that it would be good to include in the library is Byte Stuffing with selectable Control, and Escape char's. If enabled the defaults should match ethernet standards I think.
escape = 0x7D converts to 0x7D5D in the stream control = 0x7E converts to 0x7D5E in the stream
An extra callback could then be used on Rx to say "control char" received. Although this is already covered with the autoDetectChar it would be preferable to have a discrete callback.
A new function would be needed to "send" a control char. A method to enable and disable Stuffing on the fly would also be desirable. This would allow the port to be used in both Stuffed (cooked) and Unstuffed (raw) modes easily
I have a userland implementation, but it would really be better done between the buffer and the port.
Thanks for a great platform
Question relating to:
1 Answer
9 years ago.
Hi David,
Just in case someone stumbles upon this post, I developed a frame delimiting class that delimits a data buffer with byte stuffing algorithm.
https://developer.mbed.org/users/Overdrivr/code/FrameDelimiter/
I hesitated a lot on the interface, but in the end I figured it would be cleaner to separate logic from transport. This is not exactly what you were looking for, but it does the job.
For decoding incoming serial data:
[Repo not found]
For encoding outgoing serial data:
[Repo not found]
Out of curiosity, why would this need a specific function, instead of just telling it to send 0x7D5D for example? (eg, 2 putcs).
Also in general it should be fairly straight forward to make a child class of (MOD)Serial which would implement this.
posted by Erik - 25 Sep 2014Hi Erik On the Receive side it is easy enough to extend the class with a special function.
On the Tx side, the reverse really should be done by putc (as the data comes out of the buffer into the uart) so that all functions (eg: printf) correctly byte stuff too. Without fully reimplementing putc in an wrapper class (and even then I don't know that printf etc will use it) I can't see any way to do this.
posted by David Godfrey 30 Sep 2014