baresynchronizer

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package baresynchronizer reads 4 byte bare trices and syncs internally if byte stream inconsistent.

The sychronisation is possible by detecting a sequence of 4 bytes equal 0x16161616. 0x16161616 is a sync trice: `#define TRICE_RTT_SYNC do{ TRICE16_1( Id(5654), "%d\b\b\b\b", 5654 ); }while(0)`. Because 5654=0x1616 is a reserved TRICE ID and the bare trice byte stream has an ID every 2 bytes it is impossible to have 0x16161616 inside the bare trice byte stream despite of the sync message. On a Read the bare baresynchronizer tries to get a fair amount of bytes and scans them for 0x16161616. If the found 0x16161616 is not on a 4 byte aligned offset, the oldest 1-3 bytes are discarded to adjust the offset. If the baresynchronizer does not find a 0x16161616 sequence it assumes to be in sync. The target should send sync trice messages cyclically. The baresynchronizer does not deliver the 0x16161616 sync packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BareSync

type BareSync struct {
	// contains filtered or unexported fields
}

BareSync has a read method. It reader uses an inner reader.

The inner reader reads a raw byte stream.

func New

func New(input io.Reader) *BareSync

New generates an BareSync instance

func (*BareSync) Read

func (p *BareSync) Read(buf []byte) (int, error)

Read fills buf with a 4 byte bare trice and returns (4, nil) normally.

It tries to find sync frames in advance and adjusts to it. More details in the package description.

Jump to

Keyboard shortcuts

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