#define SLIP_END 0300 // indicates end of packet -- decimal 192
#define SLIP_ESC 0333 // indicates byte stuffing -- decimal 219
#define SLIP_ESC_END 0334 // ESC ESC_END means END data byte -- 220
#define SLIP_ESC_ESC 0335 // ESC ESC_ESC means ESC data byte -- 221
# Double-ENDed SLIP
Double-ENDed SLIP is a variant of SLIP that places the SLIP\_END character at the start *and* end of each message. Double-ENDed SLIP has better robustness to stream interruption.
# Encoding
1. Pack the SLIP\_END character at the beginning and end of the message.
2. Replace all instances of SLIP\_END with SLIP\_ESC + SLIP\_ESC\_END in the message contents
3. Replace all instances of SLIP\_ESC with SLIP\_ESC + SLIP\_ESC\_ESC in the message contents
Item #1 is handled in micro-OSC by the functions oscBundleOpen() and oscBundleClose().
Items #2 and #3 are handled by the function oscPackByteQuoted().
# Decoding
1. Enable the parser on first observation of SLIP\_END.
2. Replace all instances of SLIP\_ESC + SLIP\_ESC\_END with SLIP\_END in the message contents
3. Replace all instances of SLIP\_ESC + SLIP\_ESC\_ESC with SLIP\_ESC in the message contents
4. If any SLIP\_ESC is not followed immediately by SLIP\_ESC\_ESC or SLIP\_ESC\_END, the message is invalid. Disable the parser until the next observation of two SLIP\_END characters.
In micro-OSC these details are handled in oscReceive() (see user\osc.c).