cobs

package
v0.0.0-...-4ebbe9b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package cobs implenments COBS (https://en.wikipedia.org/wiki/Consistent_Overhead_Byte_Stuffing).

Package cobs implenments COBS (https://en.wikipedia.org/wiki/Consistent_Overhead_Byte_Stuffing).

Package cobs implenments COBS (https://en.wikipedia.org/wiki/Consistent_Overhead_Byte_Stuffing).

Package cobs implements COBS. For encoding create an Encoder and use the Write method as shown in TestWrite. For decoding create a Decoder and use the Read method as shown in TestSingleRead and TestMultiRead. It is possible to use only the functions cobs.Decode or cobs.CEncode. Package cobs is also a helper for testing the target C-code. Each C function gets a Go wrapper which ist tested in appropriate test functions. For some reason inside the cobs_test.go an 'import "C"' is not possible.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CDecode

func CDecode(o, i []byte) (n int, e error)

CDecode decodes `i` into `o` and returns number of bytes in `o`. For details see https://en.wikipedia.org/wiki/Consistent_Overhead_Byte_Stuffing. The CDencode implementation is done in C because the aimed use case is an embedded device running C. This function is mainly for testing.

func CEncode

func CEncode(o, i []byte) (n int)

CEncode encodes `i` into `o` and returns number of bytes in `o`. For details see https://en.wikipedia.org/wiki/Consistent_Overhead_Byte_Stuffing. The Encode implementation is done in C because the aimed use case is an embedded device running C. This function is mainly for testing.

func Decode

func Decode(dec, cobs []byte) (n int, e error)

Decode a COBS frame to a slice of bytes.

decoded := dec[:n]

func NewDecoder

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

NewDecoder creates a decoder instance and returns its address. r will be used as inner reader. size is used as size for the inner buffers. Max one decoded COBS package is returned by Read.

func NewEncoder

func NewEncoder(w io.Writer, size int) (p *encoder)

NewEncoder creates an encoder instance and returns its address. w will be used as inner writer and size is used as initial size for the inner buffer.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL