Documentation
¶
Overview ¶
Package decoder provides several decoders for differently encoded trice streams.
Index ¶
Constants ¶
const ( // LittleEndian is true for little endian trice data. LittleEndian = true // BigEndian is the flag value for target endianness. BigEndian = false )
const ( // defaultSize is the beginning receive and sync buffer size. DefaultSize = 64 * 1024 // hints is the help information in case of errors. Hints = "att:Hints:Baudrate? Encoding? Interrupt? Overflow? Parameter count? Password? til.json? Version?" )
Variables ¶
var ( // Verbose gives more information on output if set. The value is injected from main packages. Verbose bool // ShowID is used as format string for displaying the first trice ID at the start of each line if not "". ShowID string // decoder.LastTriceID is last decoded ID. It is used for switch -showID. LastTriceID id.TriceID // TestTableMode is a special option for easy decoder test table generation. TestTableMode bool // Unsigned if true, forces hex and in values printed as unsigned values. Unsigned bool DebugOut = false // DebugOut enables debug information. DumpLineByteCount int // DumpLineByteCount is the bytes per line for the dumpDec decoder. InitialCycle = true // InitialCycle is a helper for the cycle counter automatic. TargetTimestamp uint32 // targetTimestamp contains target specific timestamp value. TargetLocation uint32 // targetLocation contains 16 bit file id in high and 16 bit line number in low part. ShowTargetTimestamp string // ShowTargetTimestamp is the format string for target timestamps. LocationInformationFormatString string // LocationInformationFormatString is the format string for target location: line number and file name. TargetTimestampSize int // TargetTimestampSize is set in dependence of trice type. TargetLocationExists bool // TargetLocationExists is set in dependence of p.COBSModeDescriptor. (obsolete) )
Functions ¶
func UReplaceN ¶ added in v0.55.1
UReplaceN checks all format specifier in i and replaces %nu with %nd and returns that result as o.
If a replacement took place on position k u[k] is 1. Afterwards len(u) is amount of found format specifiers. Additional, if UnsignedHex is true, for FormatX specifiers u[k] is also 1. If a float format specifier was found at position k, u[k] is 2, http://www.cplusplus.com/reference/cstdio/printf/ https://www.codingunit.com/printf-format-specifiers-format-conversions-and-formatted-output
Types ¶
type Decoder ¶
Decoder is providing a byte reader returning decoded trice's. SetInput allows switching the input stream to a different source.
type DecoderData ¶ added in v0.55.1
type DecoderData struct {
W io.Writer // io.Stdout or the like
In io.Reader // in is the inner reader, which is used to get raw bytes
InnerBuffer []byte // avoid repeated allocation (trex)
IBuf []byte // iBuf holds unprocessed (raw) bytes for interpretation.
B []byte // read buffer holds a single decoded COBS package, which can contain several trices.
Endian bool // endian is true for LittleEndian and false for BigEndian
TriceSize int // trice head and payload size as number of bytes
ParamSpace int // trice payload size after head
SLen int // string length for TRICE_S
Lut id.TriceIDLookUp // id look-up map for translation
LutMutex *sync.RWMutex // to avoid concurrent map read and map write during map refresh triggered by filewatcher
Li id.TriceIDLookUpLI // location information map
Trice id.TriceFmt // id.TriceFmt // received trice
}
DecoderData is the common data struct for all decoders.
func (*DecoderData) ReadU16 ¶ added in v0.55.1
func (p *DecoderData) ReadU16(b []byte) uint16
ReadU16 returns the 2 b bytes as uint16 according the specified endianness
func (*DecoderData) ReadU32 ¶ added in v0.55.1
func (p *DecoderData) ReadU32(b []byte) uint32
ReadU32 returns the 4 b bytes as uint32 according the specified endianness
func (*DecoderData) ReadU64 ¶ added in v0.55.1
func (p *DecoderData) ReadU64(b []byte) uint64
ReadU64 returns the 8 b bytes as uint64 according the specified endianness
func (*DecoderData) SetInput ¶ added in v0.55.1
func (p *DecoderData) SetInput(r io.Reader)
SetInput allows switching the input stream to a different source.
This function is for easier testing with cycle counters.