项目作者: lobaro

项目描述 :
Implementation of SLIP (RFC-1055) and slipmux in Go
高级语言: Go
项目地址: git://github.com/lobaro/slip.git
创建时间: 2016-12-06T14:11:36Z
项目社区:https://github.com/lobaro/slip

开源协议:MIT License

下载


slip & slipmux

Implementation of SLIP (rfc-1055) in GoLang

In addition to the basic SLIP reader and writer there is also a SlipMux implementation, that enables sending different packet types like CoAP and Diagnostic messages over serial line. This is implemented backward compatible to SLIP implementations which support only IP packets.

If needed, further packet types can be implemented by the user of the library.

Install

  1. go get -u github.com/Lobaro/slip

Usage (SLIP)

  1. import github.com/Lobaro/slip

Read Packets

  1. data := []byte{1, 2, 3, slip.END}
  2. reader := slip.NewReader(bytes.NewReader(data))
  3. packet, isPrefix, err := reader.ReadPacket()
  4. // packet == [1, 2, 3]
  5. // isPrefix == false
  6. // err == io.EOF

Write Packets

  1. buf := &bytes.Buffer{}
  2. writer := slip.NewWriter(buf)
  3. err := writer.WritePacket([]byte{1, 2, 3})
  4. // buf.Bytes() == [END, 1, 2, 3, END]