driver

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RxChannelBufferSize = 1024                  // 接收通道缓冲区大小
	MsgBufferSize       = 1024                  // 消息缓冲区大小
	PollingInterval     = time.Millisecond      // 轮询间隔
	InitDelay           = 20 * time.Millisecond // 初始化延迟
)

缓冲区和轮询配置常量

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter added in v1.1.3

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

Adapter 是连接 udsclient 和 can device 硬件的适配器

func NewAdapter added in v1.1.3

func NewAdapter(dev CANDriver) (*Adapter, error)

NewAdapter 是适配器的构造函数

func (*Adapter) Close added in v1.1.3

func (t *Adapter) Close()

Close 用于停止驱动并释放资源

func (*Adapter) RxFunc added in v1.1.3

func (t *Adapter) RxFunc() (tp_layer.CanMessage, bool)

RxFunc 是接收函数

func (*Adapter) TxFunc added in v1.1.3

func (t *Adapter) TxFunc(msg tp_layer.CanMessage)

TxFunc 是发送函数

type CANDriver

type CANDriver interface {
	Init() error
	Start()
	Stop()
	Write(id int32, data []byte) error
	RxChan() <-chan UnifiedCANMessage
	Context() context.Context
}

CANDriver 定义了CAN/CAN-FD驱动的统一接口

type CanType added in v1.0.4

type CanType byte

CanType 定义 CAN 类型 (与 Windows 版本保持一致)

const (
	CAN   CanType = 0
	CANFD CanType = 1
)

type UnifiedCANMessage

type UnifiedCANMessage struct {
	ID   uint32
	DLC  byte
	Data [64]byte // 使用64字节以兼容CAN-FD
	IsFD bool     // 标志位,用于区分是CAN还是CAN-FD消息
}

UnifiedCANMessage 是一个通用的CAN/CAN-FD消息结构体,用于在channel中传递,它屏蔽了底层 CAN_MSG 和 CANFD_MSG 的差异。

Jump to

Keyboard shortcuts

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