The NewLine Serialization Method, or the NewLine Serialization Protocol, is a minimalistic communication protocol designed for various serial communication scenarios. It defines how the serial data stream is separated into individual packets. Due to its simplicity, it is most suited in embedded systems.
There are 4 (four) different characters defined in the NLSM specification.
HEX
0x0A
0x0B
0x1A
0x1B
DEC
10
11
26
27
OCT
0o12
0o13
0o32
0o33
Name
END
ESC
ESC_END
ESC_ESC
Description
End Of Frame character
Escape character
Escaped End Of Frame character
Escaped Escape character
When transmitting data, the sender will pre-process the data according to the following steps:
If ESC character is present, send ESC followed by ESC_ESC instead.
If END character is present, send ESC followed by ESC_END instead.
Append an END character at the end of frame.
When receiving data, the receiver will process the data according to the following steps:
If an ESC character followed by an ESC_ESC character is received, it will be parsed as receiving one ESC character.
If an ESC character followed by an ESC_END character is received, it will be parsed as receiving one END character.
If an END character is received, then the frame is finished. The receiver can proceed to process the data received or continue to receive the following frames.
The Protocol needs to run under 8-bit data mode. (Will not work under 7-bit, 5-bit or other data modes).
The Protocol does not provide data validation. The integrity of data will be ensured by the upper protocols.
The END character is the newline character in ASCII character set, and frames will be separated into different lines in a serial monitor. This is easier to debug and more readable compared to SLIP and COBS.