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 // 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? Format specifier? Password? til.json? Version?" UnsignedFormatSpecifier = 0 // %u -> %d SignedFormatSpecifier = 1 // FloatFormatSpecifier = 2 // %f and relatives BooleanFormatSpecifier = 3 // a %t (bool) found PointerFormatSpecifier = 4 // a %p (pointer) found StringFormatSpecifier = 5 // a %s found )
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 uint64 // targetTimestamp contains target specific timestamp value. TargetLocation uint32 // targetLocation contains 16 bit file id in high and 16 bit line number in low part. TargetStamp string // TargetTimeStampUnit is the target timestamps time base for default formatting. TargetStamp32 string // ShowTargetStamp32 is the format string for target timestamps. TargetStamp16 string // ShowTargetStamp16 is the format string for target timestamps. TargetStamp0 string // ShowTargetStamp0 is the format string for target timestamps. TargetTimeStampUnitPassed bool // TargetTimeStampUnitPassed is true when flag was TargetTimeStampUnit passed. ShowTargetStamp32Passed bool // ShowTargetStamp32Passed is true when flag was TargetTimeStamp32 passed. ShowTargetStamp16Passed bool // ShowTargetStamp16Passed is true when flag was TargetTimeStamp16 passed. ShowTargetStamp0Passed bool // ShowTargetStamp0Passed is true when flag was TargetTimeStamp0 passed. 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) PackageFraming string // Framing is used for packing. Valid values COBS, TCOBS, TCOBSv1 (same as TCOBS) IDBits = 14 // IDBits holds count of bits used for ID (used at least in trexDecoder) NewlineIndent = -1 // Used for trice messages containing several newlines in format string for formatting. TriceStatistics bool // Keep the occured count for each Trice log when Trice is closed. IDStat map[id.TriceID]int )
var ( IDLUT id.TriceIDLookUp LILUT id.TriceIDLookUpLI )
Functions ¶
func PrintTriceStatistics ¶ added in v0.72.4
func RecordForStatistics ¶ added in v0.72.4
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 0. 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 TCOBS package, which can contain several trices. B0 []byte // initial value for B 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.