drewtech

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package drewtech provides a client for DrewTech J2534 devices

Index

Constants

View Source
const (
	MagicByte   uint8 = 0x51
	ChecksumXOR uint8 = 0xE6

	DirectionOut uint8 = 0x01
	DirectionIn  uint8 = 0x00

	FlagRequest       uint8 = 0x01
	FlagRequestFinal  uint8 = 0x00
	FlagResponse      uint8 = 0x81
	FlagResponseFinal uint8 = 0x80

	SubCmdInit           uint8 = 0x00
	SubCmdGetVersion     uint8 = 0x03
	SubCmdClose          uint8 = 0x05
	SubCmdConnect        uint8 = 0x06
	SubCmdDisconnect     uint8 = 0x07
	SubCmdCANTx          uint8 = 0x08
	SubCmdCANRx          uint8 = 0x09
	SubCmdSetConfig      uint8 = 0x0B
	SubCmdGetConfig      uint8 = 0x0C
	SubCmdStartMsgFilter uint8 = 0x0D
	SubCmdStopMsgFilter  uint8 = 0x10
	SubCmdGetStatus      uint8 = 0x11
	SubCmdSetProtocol    uint8 = 0x12
	SubCmdGetSerial      uint8 = 0x13

	ProtocolCAN uint32 = 6

	ParamDataRate       uint32 = 0x04
	ParamBitSamplePoint uint32 = 0x14
	ParamSyncJumpWidth  uint32 = 0x15
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CANFrame

type CANFrame struct {
	ID        uint32
	Data      []byte
	DLC       int
	Timestamp uint32
}

CANFrame represents a CAN bus frame

func (*CANFrame) String

func (f *CANFrame) String() string

type Device

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

Device represents a DrewTech J2534 device

func New

func New(opts ...Option) *Device

New creates a new Device

func (*Device) Close

func (d *Device) Close() error

Close stops the read loop and closes the port

func (*Device) GetChannelConfig

func (d *Device) GetChannelConfig(param uint32) (uint32, error)

GetChannelConfig gets a config parameter from the current channel

func (*Device) GetConfig

func (d *Device) GetConfig(param uint32) (uint32, error)

func (*Device) GetDeviceInfo

func (d *Device) GetDeviceInfo(param uint16) error

func (*Device) GetFirmwareVersion

func (d *Device) GetFirmwareVersion() (string, error)

func (*Device) GetSerial

func (d *Device) GetSerial() (string, error)

func (*Device) GetStatus

func (d *Device) GetStatus() error

func (*Device) Init

func (d *Device) Init() error

func (*Device) Open

func (d *Device) Open(portName string) error

Open opens the serial port and starts the read loop

func (*Device) PassThruClose

func (d *Device) PassThruClose() error

PassThruClose closes the device connection

func (*Device) PassThruConnect

func (d *Device) PassThruConnect(baudRate uint32) error

PassThruConnect connects to CAN bus

func (*Device) PassThruDisconnect

func (d *Device) PassThruDisconnect() error

PassThruDisconnect disconnects from CAN bus

func (*Device) PassThruOpen

func (d *Device) PassThruOpen() error

PassThruOpen performs the full device initialization sequence

func (*Device) PassThruStartMsgFilter

func (d *Device) PassThruStartMsgFilter() error

PassThruStartMsgFilter starts a pass-all filter

func (*Device) PassThruStopMsgFilter

func (d *Device) PassThruStopMsgFilter() error

PassThruStopMsgFilter stops the current filter

func (*Device) PassThruWriteMsgs

func (d *Device) PassThruWriteMsgs(canID uint32, data []byte) error

PassThruWriteMsgs transmits a CAN frame

func (*Device) SetChannelConfig

func (d *Device) SetChannelConfig(param, value uint32) error

SetChannelConfig sets a config parameter on the current channel

type FirmwareInfo

type FirmwareInfo struct {
	FW Version
	BL Version
}

func ExtractVersions

func ExtractVersions(data []byte) FirmwareInfo

type Option

type Option func(*Device)

Option configures the device

func WithCANChannel

func WithCANChannel(ch chan *CANFrame) Option

WithCANChannel sets a channel for receiving CAN frames

func WithCANFrameHandler

func WithCANFrameHandler(handler func(*CANFrame)) Option

WithCANFrameHandler sets the CAN frame callback

func WithErrorHandler

func WithErrorHandler(handler func(error)) Option

WithErrorHandler sets the error callback

type Packet

type Packet struct {
	Length    uint16
	Direction uint8
	Channel   uint8
	Payload   []byte
}

Packet represents a protocol packet

func (*Packet) IsCANRx

func (p *Packet) IsCANRx() bool

func (*Packet) ParseCANFrame

func (p *Packet) ParseCANFrame() (*CANFrame, error)

func (*Packet) Sequence

func (p *Packet) Sequence() uint16

func (*Packet) SubCommand

func (p *Packet) SubCommand() uint8

func (*Packet) ToBytes

func (p *Packet) ToBytes() []byte

type Parser

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

Parser handles streaming packet parsing

func NewParser

func NewParser() *Parser

func (*Parser) Feed

func (p *Parser) Feed(data []byte) ([]*Packet, error)

type Version

type Version struct {
	Major, Minor, Patch, Build byte
}

func (Version) String

func (v Version) String() string

Jump to

Keyboard shortcuts

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