$ show rokath/trice
Trice is an embedded logging and tracing toolchain consisting of a lightweight C instrumentation library for microcontrollers and a Go-based host CLI tool. The C library provides variadic macros that emit compact binary records (ID + values) instead of format strings, drastically reducing flash and bandwidth usage. The Go tool manages Trice IDs (insert, clean, bind), decodes incoming binary streams from targets over UART, RTT, TCP/UDP, or file, and displays formatted logs with timestamps, colors, and filtering. It supports multiple buffer strategies (stack, static, double, ring), framing protocols (COBS, TCOBS), optional XTEA encryption, and local logging on the target itself. The architecture is a classic host-target split: the target runs the C library, the host runs the Go CLI. The codebase is well-tested with a large matrix of CGO test configurations and CI pipelines for multiple STM32 example projects. It is actively maintained with frequent releases and a responsive issue tracker.
The LLM identified 5 files worth highlighting for reuse:
Implements XTEA encryption and decryption with a key derived via SHA1. The package is self-contained, has no internal dependencies beyond standard library, and provides a clean API (Encrypt/Decrypt on byte slices). It can be extracted and reused in any Go project needing lightweight symmetric encryption.
Provides a parallel file tree walker with configurable matchers, exclusion patterns, and error aggregation. Uses afero filesystem abstraction for testability. The design is generic and decoupled from trice-specific logic; it can be reused in any Go project that needs to recursively process files with filtering.
Parses C printf format specifiers and normalizes them to Go fmt equivalents. Strips C length modifiers (l, ll, z, etc.) and handles width/precision. This is a standalone utility that could be reused in any tool that needs to interpret C format strings from embedded firmware.
Implements a registry of decoders keyed by encoding type (COBS, TCOBS, dump, char). Decoders are registered via init() and instantiated via NewForEncoding(). This pattern allows easy addition of new framing decoders without modifying core logic. The registry is self-contained and could be extracted for any multi-format decoding system.
Implements TCOBS (Trice COBS) encoding, a custom byte-stuffing algorithm that uses a sigil byte to mark boundaries. The code is a single C file with no dependencies beyond standard integer types. It is portable, efficient, and can be reused in any embedded project needing a lightweight framing protocol.