Documentation
¶
Index ¶
Constants ¶
View Source
const ( MNT_Start = "start" MNT_Stop = "stop" MNT_Preop = "preop" MNT_ResetNode = "reset node" MNT_ResetComm = "reset comm" )
View Source
const ( I8 = "I8" I16 = "i16" I32 = "i32" I64 = "i64" U8 = "U8" U16 = "U16" U32 = "U32" U64 = "U64" X8 = "x8" X16 = "x16" X32 = "x32" X64 = "x64" R32 = "r32" R64 = "r64" T = "t" TD = "td" VS = "vs" OS = "os" US = "us" D = "d" HEX = "hex" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CANOpenClient ¶
type CANOpenClient struct {
// contains filtered or unexported fields
}
CANOpenClient 代表 CANOpen 客户端
func NewCANOpenClient ¶
func NewCANOpenClient(host string, port int, timeout time.Duration) *CANOpenClient
NewCANOpenClient 创建新的 CANOpen 客户端
func (*CANOpenClient) SendCommand ¶
func (c *CANOpenClient) SendCommand(cmd Command) (CommandResult, error)
SendCommand 发送单条命令,支持重试
func (*CANOpenClient) SendMultipleCommands ¶
func (c *CANOpenClient) SendMultipleCommands(commands []Command) []CommandResult
SendMultipleCommands 并发发送多条命令
type Command ¶
type Command struct {
CommandID int // 唯一标识符
NodeID int
Index int
SubIndex int
DataType DataType
Content string // 指令内容,如 "[1] r 1000 0"
Timeout time.Duration // 命令超时
MaxRetries int // 最大重试次数
}
Command 代表一条 CANOpen 指令
func ReadSDO ¶
func ReadSDO(cmdID int, nodeID, index, subindex int, dataType DataType, timeout time.Duration, retries int) Command
ReadSDO 生成读取 SDO 的命令
func SetNMTState ¶
SetNMTState 生成设置 NMT 状态的命令
type CommandResult ¶
CommandResult 代表指令执行结果
Click to show internal directories.
Click to hide internal directories.