# README
TCOBSv2
Table of Contents
1. TCOBSv2 Specification
2. TCOBSv2 Framing Encoder and Decoder
2.1. TCOBSv2 Encoding
-
tcobs.h
andtcobsEncode.c
withtcobs.Internal.h
contain the encoder as C-code. - The encoding in Go is possible with
tcobs.go
using the encoder C-code with CGO. - The Go idiomatic usage is to use a
NewEncoder(w io.Writer, size int) (p *encoder)
and its Reader interface (seeread.go
)
2.2. TCOBSv2 Decoding
-
tcobs.h
andtcobDecode.c
withtcobs.Internal.h
contain the encoder as C-code. - The decoding in Go is possible with
tcobs.go
using the decoder C-code with CGO. - The Go idiomatic usage is to use a
NewDecoder(r io.Reader, size int, multi bool) (p *decoder)
and its Writer interface (seewrite.go
)
2.3. TCOBSv2 Testing
-
tcobs_test.go
contains test code. CGO is not supported inside test files but usable through Go functions.- Testing:
go test ./...
:executes the C-code with many test data.
- Testing:
- The test execution can take several seconds. If your computer is slow you can reduce the loop count in the test functions
TestEncodeDecode*
. - The file
tcobsTest.c
contains also some test data but is intended only for debugging.
3. Getting Started
- Add ./tcobsEncode.c and/or ./tcobsDecode.c to your embedded project and use function
TCOBSEncode
and/orTCOBSDecode
to convert a buffer to/from TCOBS format. - After transmitting one (or more) TCOBS package(s) transmit a 0-delimiter byte.
- Encoding and Decoding is currently implemented in Go using the C-code with CGO.
- Encoder and Decoder in other languages are implementable using the TCOBS specification and the given C- and Go-code.
- Contributions are appreciated.
3.1. Prerequisites
- Just a C compiler and, for testing, a Go installation.
3.2. Installation
- To use TCOBSv2 with Go execute
go get github.com/rokath/tcobs/TCOBSv2
3.3. Usage in Go
- For example usage check the tests.
3.3.1. Decoding
- The function
tcobs.CDecode
is usable standalone. - Also it is possible to create a Decoder instance and use the
Read
method.
3.3.2. Encoding
- The function
tcobs.CEncode
is usable standalone. - Also it is possible to create an Encoder instance and use the
Write
method.
# Functions
NewDecoder creates a decoder instance and returns its address.
NewEncoder creates an encoder instance and returns its address.