Documentation ¶
Index ¶
Constants ¶
const ( MessageTypeNMT uint16 = 0x000 MessageTypeSync uint16 = 0x080 MessageTypeTimestamp uint16 = 0x100 MessageTypeTPDO1 uint16 = 0x180 MessageTypeRPDO1 uint16 = 0x200 MessageTypeTPDO2 uint16 = 0x280 MessageTypeRPDO2 uint16 = 0x300 MessageTypeTPDO3 uint16 = 0x380 MessageTypeRPDO3 uint16 = 0x400 MessageTypeTPDO4 uint16 = 0x480 MessageTypeRPDO4 uint16 = 0x500 // MessageTypeTSDO represents the type of SDO server response messages MessageTypeTSDO uint16 = 0x580 // MessageTypeRSDO represents the type of SDO client request messages MessageTypeRSDO uint16 = 0x600 MessageTypeHeartbeat uint16 = 0x700 )
const ( // MaskCobID is used to get 11 bits from an uint16 for the COB-ID MaskCobID = 0x7FF // MaskNodeID is used to extract the 7-bit node id from the COB-ID MaskNodeID = 0x7F // MaskMessageType is used to extract the 4-bit message type from the COB-ID MaskMessageType = 0x780 // MaskIDSff is used to extract the valid 11-bit CAN identifier bits from the frame ID of a standard frame format. MaskIDSff = 0x000007FF // MaskIDEff is used to extract the valid 29-bit CAN identifier bits from the frame ID of an extended frame format. MaskIDEff = 0x1FFFFFFF // MaskErr is used to extract the the error flag (0 = data frame, 1 = error message) from the frame ID. MaskErr = 0x20000000 // MaskRtr is used to extract the rtr flag (1 = rtr frame) from the frame ID MaskRtr = 0x40000000 // MaskEff is used to extract the eff flag (0 = standard frame, 1 = extended frame) from the frame ID MaskEff = 0x80000000 )
const ( GoToOperational uint8 = 0x1 GoToStopped uint8 = 0x2 GoToPreOperation uint8 = 0x80 GoToResetNode uint8 = 0x81 GoToResetCommunication uint8 = 0x82 )
const ( BootUp uint8 = 0x0 Stopped uint8 = 0x04 Operational uint8 = 0x05 PreOperational uint8 = 0x7f )
const MPDO uint8 = 0x80
const MaxNodeID uint8 = 0x7F
MaxNodeID defines the highest node id
Variables ¶
var Lock = maplock.New()
var RefDate = time.Date( 1984, 1, 1, 0, 0, 0, 0, time.UTC, )
RefDate is the reference date of CAN timestamp messages.
Functions ¶
func GetAbortCodeText ¶ added in v0.5.2
func GetAbortCodeText(code SDOAbortCode) string
Types ¶
type Client ¶
A Client handles message communication by sending a request and waiting for the response.
type Frame ¶
type Frame struct { // CobID is the 11-bit communication object identifier – CANopen only uses 11-bit identifiers. // Bits 0-6 represent the 7-bit node ID. Bits 7-11 represent the 4-bit message type. CobID uint16 // Rtr represents the Remote Transmit Request flag. Rtr bool // Data contains 8 bytes Data []uint8 }
A Frame represents a CANopen frame.
func CANopenFrame ¶
CANopenFrame returns a CANopen frame from a CAN frame.
func (Frame) CANFrame ¶
CANFrame returns a CAN frame representing the CANopen frame.
CANopen frames are encoded as follows:
------------------------------------------------------- CAN | ID | Length | Flags | Res0 | Res1 | Data | ------------------------------------------------------- CANopen | COB-ID + Rtr | len(Data) | | | | Data | -------------------------------------------------------
func (Frame) MessageType ¶
MessageType returns the message type.
func (*Frame) ObjectIndex ¶ added in v0.6.0
func (frm *Frame) ObjectIndex() ObjectIndex
type ObjectIndex ¶
ObjectIndex represents the index of an object.
func NewObjectIndex ¶
func NewObjectIndex(index uint16, subIndex uint8) ObjectIndex
NewObjectIndex returns an object index from a 2-byte index and 1-byte sub index.
func (*ObjectIndex) Bytes ¶ added in v0.6.0
func (objectIndex *ObjectIndex) Bytes() []byte
func (*ObjectIndex) Compare ¶ added in v0.6.0
func (objectIndex *ObjectIndex) Compare(other ObjectIndex) bool
type Request ¶
type Request struct { // The Frame of the request Frame Frame // The ResponseID of the response frame ResponseID uint32 }
A Request represents a CANopen request published on a CAN bus and received by another CANopen node.
func NewRequest ¶
NewRequest returns a request containing the frame to be sent and the expected response frame id.
type Response ¶
type Response struct { // The response frame Frame Frame // The Request which triggers the response Request *Request }
A Response represents the response which resulted from a request.
type SDOAbortCode ¶ added in v0.6.0
type SDOAbortCode int
const ( SDO_ERR_TOGGLE_BIT SDOAbortCode = 0x05030000 SDO_ERR_TIMEOUT SDOAbortCode = 0x05040000 SDO_ERR_COMMAND SDOAbortCode = 0x05040001 SDO_ERR_BLOCK_SIZE SDOAbortCode = 0x05040002 SDO_ERR_BLOCK_SEQUENCE SDOAbortCode = 0x05040003 SDO_ERR_BLOCK_CRC SDOAbortCode = 0x05040004 SDO_ERR_MEMORY SDOAbortCode = 0x05040005 SDO_ERR_ACCESS_UNSUPPORTED SDOAbortCode = 0x06010000 SDO_ERR_ACCESS_WO SDOAbortCode = 0x06010001 SDO_ERR_ACCESS_RO SDOAbortCode = 0x06010002 SDO_ERR_NO_OBJECT SDOAbortCode = 0x06020000 SDO_ERR_MAPPING_OBJECT SDOAbortCode = 0x06040041 SDO_ERR_MAPPING_LENGTH SDOAbortCode = 0x06040042 SDO_ERR_GENERAL_PARAMETER SDOAbortCode = 0x06040043 SDO_ERR_GENERAL_DEVICE SDOAbortCode = 0x06040047 SDO_ERR_HARDWARE SDOAbortCode = 0x06060000 SDO_ERR_DATATYPE SDOAbortCode = 0x06070010 SDO_ERR_DATATYPE_HIGH SDOAbortCode = 0x06070012 SDO_ERR_DATATYPE_LOW SDOAbortCode = 0x06070013 SDO_ERR_NO_SUB_INDEX SDOAbortCode = 0x06090011 SDO_ERR_VALUE_RANGE SDOAbortCode = 0x06090030 SDO_ERR_VALUE_HIGH SDOAbortCode = 0x06090031 SDO_ERR_VALUE_LOW SDOAbortCode = 0x06090032 SDO_ERR_VALUE_MIN_MAX SDOAbortCode = 0x06090036 SDO_ERR_SDO_CONNECTION SDOAbortCode = 0x060A0023 SDO_ERR_GENERAL SDOAbortCode = 0x08000000 SDO_ERR_DATA_STORE SDOAbortCode = 0x08000020 SDO_ERR_DATA_STORE_LOCAL SDOAbortCode = 0x08000021 SDO_ERR_DATA_STORE_STATE SDOAbortCode = 0x08000022 SDO_ERR_OBJECT_DICTIONARY SDOAbortCode = 0x08000023 SDO_ERR_NO_DATA SDOAbortCode = 0x08000024 NO_ERROR SDOAbortCode = 0x0 )
type TransferAbort ¶ added in v0.0.17
type TransferAbort struct {
AbortCode []uint8
}
func (TransferAbort) Error ¶ added in v0.0.17
func (e TransferAbort) Error() string
type UnexpectedResponseLength ¶ added in v0.0.19
func (UnexpectedResponseLength) Error ¶ added in v0.0.19
func (e UnexpectedResponseLength) Error() string
type UnexpectedSCSResponse ¶ added in v0.0.17
func (UnexpectedSCSResponse) Error ¶ added in v0.0.17
func (e UnexpectedSCSResponse) Error() string
type UnexpectedToggleBit ¶ added in v0.0.17
func (UnexpectedToggleBit) Error ¶ added in v0.0.17
func (e UnexpectedToggleBit) Error() string