node-serialport-slip

The node-serialport-slip is an implementation of the Serial Line Internet Protocol (RFC 1055) designed to work over serial ports and modem connections. node-serialport-slip extends node-serialport library which is bult to access serial ports.

Since SLIP is a subclass of SerialPort it's worth to read node-serialport docs first.

Where new Buffer([0x10, 0x11, 0x12]) is data that needs to be sent. serialport-slip adds a special END byte to it
, which distinguishes datagram boundaries in the byte stream, also
if the END byte occurs in the data to be sent, the two byte sequence ESC, ESC_END is sent instead,
if the ESC byte occurs in the data, the two byte sequence ESC, ESC_ESC is sent.

Default END, ESC, ESC_END, ESC_ESC hex values are in the following teble:

Hex value

Abbreviation

Description

0xC0

END

Frame End

0xDB

ESC

Frame Escape

0xDC

ESC_END

Transposed Frame End

0xDD

ESC_ESC

Transposed Frame Escape

You are able to extend escaping rules and redefine default hex values, read "Extending protocol" section for details.

Each time incoming message occurs slip object fires 'message' event, so in order to handle messages you can do something like:

slip.on('message',function(message){

console.log('Message recieved', message)

})

Extending protocol

Default protocol settings are:

{

"messageMaxLength":256,

"endByte":0xC0,

"escapeByte":0xDB,

"escapeRules":[

{

"initialFragment":0xC0,

"replacement":0xDC

},

{

"initialFragment":0xDB,

"replacement":0xDD

}

]

}

You can change settings using third argument while SLIP instantiation like so:

var slip =newSLIP("path-to-port",{

baudrate:57600

},{

'endByte':0xC3,

"escapeRules":[

{

"initialFragment":0xC3,

"replacement":0xDC

},

{

"initialFragment":0xDB,

"replacement":0xDD

}

]

});

This will change default 0xC0 value for END byte to 0xC3, and add new escaping rule.