Table of Contents
-
- 3.1. TCOBS Encoding
- 3.2. TCOBS Decoding
- 3.3. TCOBS Testing
-
- 4.1. Prerequisites
- 4.2. Installation
- 4.3. Usage in Go
-
- 8.1. Acknowledgments
- TCOBS is a variant of COBS combined with real-time RLE data compression especially for short messages containing integers.
- The consistent overhead with TCOBS is 1 byte for each starting 31 bytes in the worst case, when no compression is possible. (Example: A 1000 bytes buffer can be encoded with max 33 additional bytes.) This is more compared to the original COBS with +1 byte for each starting 254 bytes but if the data contain integer numbers, as communication packets often do, the encoded data will be statistically shorter with TCOBS compared to the legacy COBS.
-
tcobs.h
andtcobs.c
contain the encoder as C-code. - The encoding in Go is possible with
tcobs.go
usingtcobs.c
with CGO. - The Go idiomatic usage is to use a
NewEncoder(w io.Writer, size int) (p *encoder)
and its Reader interface (seeread.go
)
-
tcobs.go
contains the decoder as Go-code. - The decoding in C is not implemented (yet).
- The Go idiomatic usage is to use a
NewDecoder(r io.Reader, size int, multi bool) (p *decoder)
and its Writer interface (seewrite.go
)
-
tcobs_test.go
contains test code. CGO is not supported inside test files but usable through Go functions. - The test execution can take several seconds. If your computer is slow you can reduce the loop count in the test functions
TestEncodeDecode*
.
- Add ./tcobs.c to your embedded project and use function
TCOBSEncode
to convert a buffer into TCOBS format. - After transmitting one (or more) TCOBS package(s) transmit a 0-delimiter byte.
- Decoding is currently implemented in Go.
- Encoder and Decoder in other languages are easy to implement using the TCOBS specification and the given C- and Go-code.
- Contributions are appreciated.
- Just a C compiler and, for testing, a Go installation.
- To use TCOBS with Go execute
go get github.com/rokath/tcobs
- For example usage check the tests.
- The function
tcobs.Decode
is usable standalone. - Also it is possible to create a Decoder instance and use the
Read
method.
- The function
tcobs.CEncode
is usable standalone. - Also it is possible to create an Encoder instance and use the
Write
method.
- Add Changelog
- Add back to top links
- Add Go Reader & Writer interface
- Add decode function in C
- Add Additional Templates w/ Examples
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Working on your first Pull Request? You can learn how from this free series How to Contribute to an Open Source Project on GitHub
Distributed under the MIT License. See LICENSE.txt
for more information.
Thomas Höhenleitner - th@seerose.net Project Link: https://github.com/rokath/tcobs
Common Object Byte Stuffing with optimized Run-Length Encoding
Explore the docs »
View Code
·
Report Bug
·
Request Feature