Code Monkey home page Code Monkey logo

tcobs's Introduction

Hi there πŸ‘‹

Embedded Programming is my passion

  • Still sticking with C (liking function pointer arrays) in micro-controllers.

My favorite PC language is Go

Why?

  • Go is open source, sponsored, professionally developed and used by Google.
  • Go is a multi-purpose language.
  • Go is object oriented.
    • Go uses composition instead of inheritance - programs get cleaner this way.
  • In Go interfaces are implicit - they need no explicit declaration.
    • This allows clean and simple APIs in your code without unneeded dependencies.
  • Go is easy to learn, to use and gives quick programming success.
  • Go is a compiled language, therefore checks a lot before building the code.
    • You get most errors at compile-time and not at run-time as with scripting languages (like Python). The Go compiler itself is fast. It allows script like usage of Go as well.
    • The Go program execution is fast.
      • Could be about half speed of a well written C program - not relevant for normal use cases. To get an equivalent "well written C programm" takes much longer than getting the Go program for a specific task.
  • Go is a managed language making memory leaks impossible.
    • No explicit memory allocation and free.
  • Go supports slices, a very light array management struct.
  • Go has pointers but no pointer arithmetic, making code more reliable this way.
  • Go is designed to use multi-core machines and single-core ones and allows easy multi-threading and inter-process communication.
    • Concurrent programming using Go rotines and channels allow efficient program structures.
    • Parallel execution allows to use the full multicore power of modern systems easyly.
    • Concurrency is not Parallelism by Rob Pike
  • The auto-formatting as languge part is very comfortable.
    • This allows a bunch of helper tools.
  • A testing environment comes with the language. Fuzzying is supported.
    • Simply create my_test.go files inside your Go package and run go test ./... in the project root.
  • You get a stand-alone runnable without libraries dependencies.
    • No missing library anymore.
    • No install ... before running an executable.
  • Many platforms are supprted, also mobile development.
  • Go has an integrated documentation System.
    • Just add comments to your functions.
  • Easy Visibility control: Packages export UppercaseFunction and hide lowerCaseFunction.
  • Go can use C/C++-code and vice versa, but crossing the border takes time, so avoid that in loops.
  • Compatibility: Legacy Go code runs on new Go versions.
  • Go has generics now.

Disadvantages?

  • Not made for small microcontrollers.
  • Not well suited for fast hard real-time applications on sub-millisecond level because of the stop-the-world garbage collector.
    • BUT: The GC gets better and better with new Go versions AND avoiding that Go uses the heap heavily, avoids GC at all.

More Information

Some Details

Examples

Learning

What I use Go for?

  • The Trice tool is written in Go.
  • Test tools stimulating embedded devices under test.

tcobs's People

Contributors

rokath avatar th-sabik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

th-sabik

tcobs's Issues

TCOBSR

Analoguos COBS/R, the last sigil byte could be dropped, when it would be the only one and the then last byte interpreted as sigil byte would cause a sigil byte chain error. When decoding, such situation tells, that the whole message is without any sigil byte.

Comparison with RZCOBS

So I stumbled upon your repo when trying to find a good way to send Capnproto encoded data from MCU. Initially I was going to use the provided packing and then frame it with reverse-cobs. But then I saw the RZCOBS from the same repo owner. Anyway, I ended up using TCOBS since RZCOBS require additional processing of padded zero byte. However, on your roadmap I see that you are making comparison against the V1 of TCOBS, so you may also want to make comparison against RZCOBS too.

Add Reader Timeout option for data-disruption cases

Change

func NewDecoder(r io.Reader, size int, multi bool) (p *decoder) 

into

func NewDecoder(r io.Reader, size int, multi bool, timeOut time.Duration) (p *decoder) 

The timeOut, if 0, does not influence the current Read behaviour. Otherwise, if a successfully decoded package needed internally more than the timeOut, Read returns together with the data an error containing a data-disruption warning.

Use positions instead of repetition to compact data better

Using groups of Z as kind of power-of-3 numbers allows further compression:

Z 1 2 3 11 12 13 21 22 23 31 32 33
count 1 2 3 4 5 6 7 8 9 10 11 12
V 0 1 2 00 01 02 10 11 12 20 21 22
value 0 1 2 0 1 2 3 4 5 6 7 8
  • count = 0
  • count = 1 + value, if 1 Z (1=1+0) = 1...3 (3)
  • count = 4 + value, if 2 Z (4=1+3) = 4...12 (9)
  • count = 13 + value if 3 Z (13=1+12) = 13...41 (27)
  • ...
  • Task: Convert a 0x00 count in a Z sequece.

Similar is possible with F and R. The 0xff acts as F1 and the 0xaa acts as R1.

Add reference test data for TCOBS compression benchmarking

TCOBS looks interesting. I would like to compare it against plain COBS, and other algorithms.
Can you please add some reference test data? For example, just a text file, where each line contains bytes in hex:

01 00 00 00
FF FF FF FF
01 02 01 02 AA BB AA BB
...

Of course I can just use a random data set (and this can also be included later for comparison), but reference test data are preferred, for which TCOBS is being developed in the first place. Such reference examples should at least roughly reflect typical data patterns, the approximate min/max length of messages, and serve as initial benchmark data for anyone interested.

p.s. If text files are inconvenient, the data can be saved in any other format more suitable in your opinion.

Inconsistend decode data can cause panic.

inconsistent TCOBSv1 buffer: [20 202 5 22 68 213 33 64 158 0]
inconsistent TCOBSv1 buffer: [32 209 0]
inconsistent TCOBSv1 buffer: [8 161 133 0]
inconsistent TCOBSv1 buffer: [8 249 89 0]
panic: runtime error: index out of range [-2]

goroutine 1 [running]:
github.com/rokath/tcobs/v1.repeatByte(...)
        C:/Users/ms/go/pkg/mod/github.com/rokath/tcobs@v0.0.0-20230205132339-8d91e904310e/v1/tcobsDecode.go:127
github.com/rokath/tcobs/v1.Decode({0xc00037a000, 0x10000, 0x10000}, {0xc00031af68, 0x1?, 0xf098})
        C:/Users/ms/go/pkg/mod/github.com/rokath/tcobs@v0.0.0-20230205132339-8d91e904310e/v1/tcobsDecode.go:95 +0x552
github.com/rokath/trice/internal/trexDecoder.(*trexDec).nextPackage(0xc0002fc000)
        C:/repos/trice/internal/trexDecoder/trexDecoder.go:148 +0x5d5
github.com/rokath/trice/internal/trexDecoder.(*trexDec).Read(0xc0002fc000, {0xc00034a000, 0x10000, 0x10000})
        C:/repos/trice/internal/trexDecoder/trexDecoder.go:205 +0x55
github.com/rokath/trice/internal/translator.decodeAndComposeLoop({0xc20420, 0xc000092a08}, 0xc00012dd50, {0xc20e18, 0xc0002fc000}, 0xc0000c7ce8?, 0x8add67?)
        C:/repos/trice/internal/translator/translator.go:143 +0x38c
github.com/rokath/trice/internal/translator.Translate({0xc20420?, 0xc000092a08}, 0xc20280?, 0xc000141830, 0xc0002785b8, 0xc000141980, {0x1f25271ee58?, 0xc0000da540})
        C:/repos/trice/internal/translator/translator.go:79 +0xaa7
github.com/rokath/trice/internal/args.logLoop({0xc20420?, 0xc000092a08}, 0xc000142600)
        C:/repos/trice/internal/args/handler.go:200 +0x730
github.com/rokath/trice/internal/args.Handler({0xc20580, 0xc0000ca008}, 0xc000142600, {0xc0000d4000, 0xc000142600?, 0x0?})
        C:/repos/trice/internal/args/handler.go:100 +0x305
main.doit({0xc20580, 0xc0000ca008}, 0xc00005c000?)
        C:/repos/trice/cmd/trice/main.go:44 +0x165
main.main()
        C:/repos/trice/cmd/trice/main.go:31 +0x50

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.