Documentation
¶
Overview ¶
Package txbridge drives the txbridge dongle over TCP (192.168.4.1:1337 or tcp://host[:1337] from cfg.Port). Importing the package registers the "txbridge wifi" adapter.
The wire protocol is framed serial commands (command byte, length, data, 1-byte sum checksum — see gocan v1's pkg/serialcommand): 't' carries CAN frames (idHi, idLo, dlc, data), 'e' errors, and the dongle's host-side features (fast logger streams, WBL readings, RAM read/write) ride on their own command bytes ('r', 'R', 'w', 'W', ...). Those are exposed with the Command/Raw/Subscribe/Request methods on the concrete type; consumers reach them via bus.Adapter() and a type assertion.
Index ¶
- func New(cfg gocan.Config) (gocan.Adapter, error)
- type Txbridge
- func (tx *Txbridge) Close() error
- func (tx *Txbridge) Command(cmd byte, data []byte) error
- func (tx *Txbridge) Open(ctx context.Context, bus *gocan.Bus) error
- func (tx *Txbridge) Raw(data []byte) error
- func (tx *Txbridge) Request(ctx context.Context, cmd byte, data []byte, reply ...byte) (*serialcommand.SerialCommand, error)
- func (tx *Txbridge) Send(ctx context.Context, f gocan.Frame) error
- func (tx *Txbridge) SetFilter(filters []uint32) error
- func (tx *Txbridge) Subscribe(ctx context.Context, cmds ...byte) <-chan *serialcommand.SerialCommand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Txbridge ¶
type Txbridge struct {
// contains filtered or unexported fields
}
func (*Txbridge) Raw ¶
Raw writes bytes to the dongle as-is, for the unframed one-shot commands ("5"/"7"/"8" ECU select, "r"/"s" logger start/stop, "g" gather, ...).
func (*Txbridge) Request ¶
func (tx *Txbridge) Request(ctx context.Context, cmd byte, data []byte, reply ...byte) (*serialcommand.SerialCommand, error)
Request sends one framed command and waits for the first reply carrying one of the given command bytes. Bound it with a context deadline.
func (*Txbridge) Send ¶
Send serializes and writes a single CAN frame; the write completing is the confirmation.
func (*Txbridge) SetFilter ¶
SetFilter installs the dongle's dynamic whitelist: only listed IDs are forwarded over the link (KWP IDs the firmware handles itself always pass). An empty list is a no-op so the firmware keeps its boot default.
func (*Txbridge) Subscribe ¶
func (tx *Txbridge) Subscribe(ctx context.Context, cmds ...byte) <-chan *serialcommand.SerialCommand
Subscribe delivers dongle commands carrying one of the given command bytes until ctx is cancelled. Delivery is non-blocking; slow readers lose commands.