Documentation
¶
Index ¶
- Constants
- Variables
- func IsDataType(t byte) bool
- func IsFloatType(t byte) bool
- func IsIntegerType(t byte) bool
- func IsNumberType(t byte) bool
- func IsSignedType(t byte) bool
- func IsStringType(t byte) bool
- func IsUnsignedType(t byte) bool
- type DicArray
- func (array *DicArray) AddMember(object DicObject)
- func (array *DicArray) FindIndex(index uint16) DicObject
- func (array *DicArray) FindName(name string) DicObject
- func (array *DicArray) GetBoolVal() *bool
- func (array *DicArray) GetByteVal() *byte
- func (array *DicArray) GetData() []byte
- func (array *DicArray) GetDataLen() int
- func (array *DicArray) GetDataType() byte
- func (array *DicArray) GetFloatVal() *float64
- func (array *DicArray) GetIndex() uint16
- func (array *DicArray) GetIntVal() *int64
- func (array *DicArray) GetName() string
- func (array *DicArray) GetOffset() int
- func (array *DicArray) GetStringVal() *string
- func (array *DicArray) GetSubIndex() uint8
- func (array *DicArray) GetUintVal() *uint64
- func (array *DicArray) IsDicVariable() bool
- func (array *DicArray) Read() error
- func (array *DicArray) Save() error
- func (array *DicArray) SetBoolVal(a bool)
- func (array *DicArray) SetByteVal(a byte)
- func (array *DicArray) SetData(data []byte)
- func (array *DicArray) SetFloatVal(a float64)
- func (array *DicArray) SetIntVal(a int64)
- func (array *DicArray) SetOffset(s int)
- func (array *DicArray) SetSDO(sdo *SDOClient)
- func (array *DicArray) SetSize(s int)
- func (array *DicArray) SetStringVal(a string)
- func (array *DicArray) SetUintVal(a uint64)
- type DicObject
- type DicObjectDic
- type DicRecord
- func (record *DicRecord) AddMember(object DicObject)
- func (record *DicRecord) FindIndex(index uint16) DicObject
- func (record *DicRecord) FindName(name string) DicObject
- func (record *DicRecord) GetBoolVal() *bool
- func (record *DicRecord) GetByteVal() *byte
- func (record *DicRecord) GetData() []byte
- func (record *DicRecord) GetDataLen() int
- func (record *DicRecord) GetDataType() byte
- func (record *DicRecord) GetFloatVal() *float64
- func (record *DicRecord) GetIndex() uint16
- func (record *DicRecord) GetIntVal() *int64
- func (record *DicRecord) GetName() string
- func (record *DicRecord) GetOffset() int
- func (record *DicRecord) GetStringVal() *string
- func (record *DicRecord) GetSubIndex() uint8
- func (record *DicRecord) GetUintVal() *uint64
- func (record *DicRecord) IsDicVariable() bool
- func (record *DicRecord) Read() error
- func (record *DicRecord) Save() error
- func (record *DicRecord) SetBoolVal(a bool)
- func (record *DicRecord) SetByteVal(a byte)
- func (record *DicRecord) SetData(data []byte)
- func (record *DicRecord) SetFloatVal(a float64)
- func (record *DicRecord) SetIntVal(a int64)
- func (record *DicRecord) SetOffset(s int)
- func (record *DicRecord) SetSDO(sdo *SDOClient)
- func (record *DicRecord) SetSize(s int)
- func (record *DicRecord) SetStringVal(a string)
- func (record *DicRecord) SetUintVal(a uint64)
- type DicVariable
- func (variable *DicVariable) AddBitDefinition(name string, bits []byte)
- func (variable *DicVariable) AddMember(object DicObject)
- func (variable *DicVariable) AddValueDescription(name string, des string)
- func (variable *DicVariable) FindIndex(index uint16) DicObject
- func (variable *DicVariable) FindName(name string) DicObject
- func (variable *DicVariable) GetBoolVal() *bool
- func (variable *DicVariable) GetByteVal() *byte
- func (variable *DicVariable) GetData() []byte
- func (variable *DicVariable) GetDataLen() int
- func (variable *DicVariable) GetDataType() byte
- func (variable *DicVariable) GetFloatVal() *float64
- func (variable *DicVariable) GetIndex() uint16
- func (variable *DicVariable) GetIntVal() *int64
- func (variable *DicVariable) GetName() string
- func (variable *DicVariable) GetOffset() int
- func (variable *DicVariable) GetStringVal() *string
- func (variable *DicVariable) GetSubIndex() uint8
- func (variable *DicVariable) GetUintVal() *uint64
- func (variable *DicVariable) IsDicVariable() bool
- func (variable *DicVariable) IsDomainDataType() bool
- func (variable *DicVariable) Read() error
- func (variable *DicVariable) Save() error
- func (variable *DicVariable) SetBoolVal(a bool)
- func (variable *DicVariable) SetByteVal(a byte)
- func (variable *DicVariable) SetData(data []byte)
- func (variable *DicVariable) SetFloatVal(a float64)
- func (variable *DicVariable) SetIntVal(a int64)
- func (variable *DicVariable) SetOffset(s int)
- func (variable *DicVariable) SetSDO(sdo *SDOClient)
- func (variable *DicVariable) SetSize(s int)
- func (variable *DicVariable) SetStringVal(a string)
- func (variable *DicVariable) SetUintVal(a uint64)
- func (variable *DicVariable) Write(data []byte) error
- type INode
- type ISDOClient
- type NMTChangeChan
- type NMTMaster
- func (master *NMTMaster) AcquireChangesChan() *NMTChangeChan
- func (master *NMTMaster) GetStateString() string
- func (master *NMTMaster) ListenForHeartbeat() error
- func (master *NMTMaster) ReleaseChangesChan(id string) error
- func (master *NMTMaster) SendCommand(code int) error
- func (master *NMTMaster) SetState(cmd string) error
- func (master *NMTMaster) UnlistenForHeartbeat() error
- func (master *NMTMaster) WaitForBootup(timeout *time.Duration) error
- type NMTState
- type Network
- func (network *Network) AcquireFramesChan(filterFunc networkFramesChanFilterFunc) *NetworkFramesChan
- func (network *Network) AddNode(node *Node, objectDic *DicObjectDic, uploadEDS bool) *Node
- func (network *Network) GetNode(nodeID int) (*Node, error)
- func (network *Network) ReleaseFramesChan(id string)
- func (network *Network) Run() error
- func (network *Network) Search(limit int, timeout time.Duration) ([]*Node, error)
- func (network *Network) Send(arbID uint32, data []byte) error
- func (network *Network) Stop() error
- type NetworkFramesChan
- type Node
- func (node *Node) AcquireFramesChanFromNetwork(filterFunc networkFramesChanFilterFunc) *NetworkFramesChan
- func (node *Node) FindName(name string) DicObject
- func (node *Node) GetId() int
- func (node *Node) Init()
- func (node *Node) ReleaseFramesChanFromNetwork(id string)
- func (node *Node) Send(arbID uint32, data []byte) error
- func (node *Node) SetNetwork(network *Network)
- func (node *Node) SetObjectDic(objectDic *DicObjectDic)
- func (node *Node) Stop()
- type PDOMap
- func (m *PDOMap) AcquireChangesChan() *PDOMapChangeChan
- func (m *PDOMap) FindIndex(idx int) DicObject
- func (m *PDOMap) FindName(name string) DicObject
- func (m *PDOMap) GetTotalSize() int
- func (m *PDOMap) Listen() error
- func (m *PDOMap) Read() error
- func (m *PDOMap) RebuildData()
- func (m *PDOMap) ReleaseChangesChan(id string) error
- func (m *PDOMap) Save() error
- func (m *PDOMap) SetData(data []byte)
- func (m *PDOMap) Transmit(rebuild bool) error
- func (m *PDOMap) Unlisten()
- func (m *PDOMap) UpdateDataSize()
- type PDOMapChangeChan
- type PDOMaps
- type PDONode
- type SDOClient
- func (sdoClient *SDOClient) FindName(name string) DicObject
- func (sdoClient *SDOClient) Read(index uint16, subIndex uint8) ([]byte, error)
- func (sdoClient *SDOClient) Send(req []byte, expectFunc networkFramesChanFilterFunc, timeout *time.Duration, ...) (*can.Frame, error)
- func (sdoClient *SDOClient) SendRequest(req []byte) error
- func (sdoClient *SDOClient) Write(index uint16, subIndex uint8, forceSegment bool, data []byte) error
- type SDOReader
- type SDOWriter
Constants ¶
const ( DicVar byte = 0x07 DicArr byte = 0x08 DicRec byte = 0x09 )
const ( Boolean byte = 0x1 Integer8 byte = 0x2 Integer16 byte = 0x3 Integer32 byte = 0x4 Integer64 byte = 0x15 Unsigned8 byte = 0x5 Unsigned16 byte = 0x6 Unsigned32 byte = 0x7 Unsigned64 byte = 0x1b Real32 byte = 0x8 Real64 byte = 0x11 VisibleString byte = 0x9 OctetString byte = 0xa UnicodeString byte = 0xb Domain byte = 0xf )
const ( MapPDONotValid int64 = 1 << 31 MapRTRNotAllowed int = 1 << 30 )
const ( SDORequestUpload uint8 = 2 << 5 SDOResponseUpload uint8 = 2 << 5 SDORequestDownload uint8 = 1 << 5 SDOResponseDownload uint8 = 3 << 5 SDORequestSegmentUpload uint8 = 3 << 5 SDOResponseSegmentUpload uint8 = 0 << 5 SDORequestSegmentDownload uint8 = 0 << 5 SDOResponseSegmentDownload uint8 = 1 << 5 SDOExpedited uint8 = 0x2 SDOSizeSpecified uint8 = 0x1 SDOToggleBit uint8 = 0x10 SDONoMoreData uint8 = 0x1 )
Variables ¶
var NMTCommandToState = map[int]int{
1: 5,
2: 4,
80: 80,
96: 96,
128: 127,
129: 0,
130: 0,
}
var NMTCommands = map[string]int{
"OPERATIONAL": 1,
"STOPPED": 2,
"SLEEP": 80,
"STANDBY": 96,
"PRE-OPERATIONAL": 128,
"INITIALISING": 129,
"RESET": 129,
"RESET COMMUNICATION": 130,
}
var NMTStates = map[int]string{
0: "INITIALISING",
4: "STOPPED",
5: "OPERATIONAL",
80: "SLEEP",
96: "STANDBY",
127: "PRE-OPERATIONAL",
}
Functions ¶
func IsDataType ¶
func IsFloatType ¶
func IsIntegerType ¶
func IsNumberType ¶
func IsSignedType ¶
func IsStringType ¶
func IsUnsignedType ¶
Types ¶
type DicArray ¶
type DicArray struct { Description string Index uint16 Name string SDOClient *SDOClient SubIndexes map[uint8]DicObject SubNames map[string]uint8 }
func (*DicArray) GetBoolVal ¶
func (*DicArray) GetByteVal ¶
func (*DicArray) GetDataLen ¶
func (*DicArray) GetDataType ¶
func (*DicArray) GetFloatVal ¶
func (*DicArray) GetStringVal ¶
func (*DicArray) GetSubIndex ¶
func (*DicArray) GetUintVal ¶
func (*DicArray) IsDicVariable ¶
func (*DicArray) SetBoolVal ¶
func (*DicArray) SetByteVal ¶
func (*DicArray) SetFloatVal ¶
func (*DicArray) SetStringVal ¶
func (*DicArray) SetUintVal ¶
type DicObject ¶
type DicObject interface { GetIndex() uint16 GetSubIndex() uint8 GetName() string AddMember(DicObject) FindIndex(uint16) DicObject FindName(string) DicObject GetDataType() byte GetDataLen() int SetSize(int) SetOffset(int) GetOffset() int Read() error Save() error GetData() []byte SetData([]byte) GetStringVal() *string GetFloatVal() *float64 GetUintVal() *uint64 GetIntVal() *int64 GetBoolVal() *bool GetByteVal() *byte SetStringVal(string) SetFloatVal(float64) SetUintVal(uint64) SetIntVal(int64) SetBoolVal(bool) SetByteVal(byte) IsDicVariable() bool SetSDO(*SDOClient) }
type DicObjectDic ¶
type DicObjectDic struct { Baudrate int NodeID int // Map of Object ids to objects Indexes map[uint16]DicObject // Index to map objects names to objects indexs NamesIndex map[string]uint16 }
func DicEDSParse ¶
func DicEDSParse(in interface{}) (*DicObjectDic, error)
DicEDSParse If in is string, it must be a path to a file else if in must be eds data as []byte
func DicMustParse ¶
func DicMustParse(a *DicObjectDic, err error) *DicObjectDic
func NewDicObjectDic ¶
func NewDicObjectDic() *DicObjectDic
func (*DicObjectDic) AddObject ¶
func (objectDic *DicObjectDic) AddObject(object DicObject)
func (*DicObjectDic) FindIndex ¶
func (objectDic *DicObjectDic) FindIndex(index uint16) DicObject
func (*DicObjectDic) FindName ¶
func (objectDic *DicObjectDic) FindName(name string) DicObject
type DicRecord ¶
type DicRecord struct { Description string Index uint16 Name string SDOClient *SDOClient SubIndexes map[uint8]DicObject SubNames map[string]uint8 }
func (*DicRecord) GetBoolVal ¶
func (*DicRecord) GetByteVal ¶
func (*DicRecord) GetDataLen ¶
func (*DicRecord) GetDataType ¶
func (*DicRecord) GetFloatVal ¶
func (*DicRecord) GetStringVal ¶
func (*DicRecord) GetSubIndex ¶
GetSubIndex not applicable
func (*DicRecord) GetUintVal ¶
func (*DicRecord) IsDicVariable ¶
func (*DicRecord) SetBoolVal ¶
func (*DicRecord) SetByteVal ¶
func (*DicRecord) SetFloatVal ¶
func (*DicRecord) SetStringVal ¶
func (*DicRecord) SetUintVal ¶
type DicVariable ¶
type DicVariable struct { Unit string Factor int Min int Max int Default []byte DataType byte AccessType string Description string SDOClient *SDOClient Data []byte Offset int Size int Index uint16 SubIndex uint8 Name string ValueDescriptions map[string]string BitDefinitions map[string][]byte }
func (*DicVariable) AddBitDefinition ¶
func (variable *DicVariable) AddBitDefinition(name string, bits []byte)
func (*DicVariable) AddMember ¶
func (variable *DicVariable) AddMember(object DicObject)
func (*DicVariable) AddValueDescription ¶
func (variable *DicVariable) AddValueDescription(name string, des string)
func (*DicVariable) FindIndex ¶
func (variable *DicVariable) FindIndex(index uint16) DicObject
func (*DicVariable) FindName ¶
func (variable *DicVariable) FindName(name string) DicObject
func (*DicVariable) GetBoolVal ¶
func (variable *DicVariable) GetBoolVal() *bool
func (*DicVariable) GetByteVal ¶
func (variable *DicVariable) GetByteVal() *byte
func (*DicVariable) GetData ¶
func (variable *DicVariable) GetData() []byte
func (*DicVariable) GetDataLen ¶
func (variable *DicVariable) GetDataLen() int
func (*DicVariable) GetDataType ¶
func (variable *DicVariable) GetDataType() byte
func (*DicVariable) GetFloatVal ¶
func (variable *DicVariable) GetFloatVal() *float64
func (*DicVariable) GetIndex ¶
func (variable *DicVariable) GetIndex() uint16
func (*DicVariable) GetIntVal ¶
func (variable *DicVariable) GetIntVal() *int64
func (*DicVariable) GetName ¶
func (variable *DicVariable) GetName() string
func (*DicVariable) GetOffset ¶
func (variable *DicVariable) GetOffset() int
func (*DicVariable) GetStringVal ¶
func (variable *DicVariable) GetStringVal() *string
func (*DicVariable) GetSubIndex ¶
func (variable *DicVariable) GetSubIndex() uint8
func (*DicVariable) GetUintVal ¶
func (variable *DicVariable) GetUintVal() *uint64
func (*DicVariable) IsDicVariable ¶
func (variable *DicVariable) IsDicVariable() bool
func (*DicVariable) IsDomainDataType ¶
func (variable *DicVariable) IsDomainDataType() bool
func (*DicVariable) SetBoolVal ¶
func (variable *DicVariable) SetBoolVal(a bool)
func (*DicVariable) SetByteVal ¶
func (variable *DicVariable) SetByteVal(a byte)
func (*DicVariable) SetData ¶
func (variable *DicVariable) SetData(data []byte)
func (*DicVariable) SetFloatVal ¶
func (variable *DicVariable) SetFloatVal(a float64)
func (*DicVariable) SetIntVal ¶
func (variable *DicVariable) SetIntVal(a int64)
func (*DicVariable) SetOffset ¶
func (variable *DicVariable) SetOffset(s int)
func (*DicVariable) SetSDO ¶
func (variable *DicVariable) SetSDO(sdo *SDOClient)
func (*DicVariable) SetSize ¶
func (variable *DicVariable) SetSize(s int)
func (*DicVariable) SetStringVal ¶
func (variable *DicVariable) SetStringVal(a string)
func (*DicVariable) SetUintVal ¶
func (variable *DicVariable) SetUintVal(a uint64)
func (*DicVariable) Write ¶
func (variable *DicVariable) Write(data []byte) error
Write variable value using SDO
type ISDOClient ¶
type ISDOClient interface { FindName(name string) DicObject Read(index uint16, subIndex uint8) ([]byte, error) Send(req []byte, expectFunc networkFramesChanFilterFunc, timeout *time.Duration, retryCount *int) (*can.Frame, error) SendRequest(req []byte) error Write(index uint16, subIndex uint8, forceSegment bool, data []byte) error }
type NMTChangeChan ¶
type NMTChangeChan struct { C chan NMTState // contains filtered or unexported fields }
type NMTMaster ¶
type NMTMaster struct { NodeID int Network *Network State int StateReceived *int Timestamp *time.Time Listening bool ChangeChans []*NMTChangeChan // contains filtered or unexported fields }
func NewNMTMaster ¶
NewNMTMaster return a new instance of Master
func (*NMTMaster) AcquireChangesChan ¶
func (master *NMTMaster) AcquireChangesChan() *NMTChangeChan
AcquireChangesChan create a new NMTChangeChan
func (*NMTMaster) GetStateString ¶
GetStateString for target node
func (*NMTMaster) ListenForHeartbeat ¶
ListenForHeartbeat listen message on network
func (*NMTMaster) ReleaseChangesChan ¶
ReleaseChangesChan release (close) a NMTChangeChan
func (*NMTMaster) SendCommand ¶
SendCommand to target node
func (*NMTMaster) UnlistenForHeartbeat ¶
UnlistenForHeartbeat listen message on network
type Network ¶
type Network struct { // mutex for FramesChans access sync.Mutex // Bus is the go-can bus Bus can.Bus // Nodes contain the network nodes Nodes map[int]*Node // FramesChans contains a list of chan when is sent each frames from network bus. FramesChans []*NetworkFramesChan // NMTMaster contain nmt control struct NMTMaster *NMTMaster // BusReadErrChan @TODO on go-can BusReadErrChan chan error // contains filtered or unexported fields }
Network represent the global nodes network
func NewNetwork ¶
NewNetwork a new Network with given bus
func (*Network) AcquireFramesChan ¶
func (network *Network) AcquireFramesChan(filterFunc networkFramesChanFilterFunc) *NetworkFramesChan
AcquireFramesChan create a new FrameChan
func (*Network) AddNode ¶
func (network *Network) AddNode(node *Node, objectDic *DicObjectDic, uploadEDS bool) *Node
AddNode add a node to the network
func (*Network) ReleaseFramesChan ¶
ReleaseFramesChan release (close) a FrameChan
type NetworkFramesChan ¶
type NetworkFramesChan struct { ID string C chan *can.Frame Filter networkFramesChanFilterFunc }
NetworkFramesChan contain a Chan, and ID and a Filter function Each FrameChan can have a filter function which return a boolean, and for each frame, the filter func is called. If func return true, the frame is returned, else dont send frame.
func (*NetworkFramesChan) Publish ¶
func (networkFramesCh *NetworkFramesChan) Publish(frm *can.Frame)
type Node ¶
type Node struct { // Each node has an id, which is ArbitrationID & 0x7F ID int Network *Network ObjectDic *DicObjectDic SDOClient *SDOClient PDONode *PDONode NMTMaster *NMTMaster }
Node is a canopen node
func (*Node) AcquireFramesChanFromNetwork ¶ added in v0.0.16
func (node *Node) AcquireFramesChanFromNetwork(filterFunc networkFramesChanFilterFunc) *NetworkFramesChan
AcquireFramesChanFromNetwork gets new Channel for given FilterFunc
func (*Node) ReleaseFramesChanFromNetwork ¶ added in v0.0.16
ReleaseFramesChanFromNetwork free channel with given id from network
func (*Node) SetNetwork ¶
SetNetwork set node.Network to the desired network
func (*Node) SetObjectDic ¶
func (node *Node) SetObjectDic(objectDic *DicObjectDic)
SetObjectDic set node.ObjectDic to the desired ObjectDic
type PDOMap ¶
type PDOMap struct { sync.Mutex PDONode *PDONode ComRecord DicObject MapArray DicObject Enabled bool CobID int RTRAllowed bool TransType byte EventTimer byte Map map[int]DicObject OldData []byte Data []byte Timestamp *time.Time Period *time.Duration IsReceived bool ChangeChans []*PDOMapChangeChan // contains filtered or unexported fields }
func (*PDOMap) AcquireChangesChan ¶
func (m *PDOMap) AcquireChangesChan() *PDOMapChangeChan
AcquireChangesChan create a new PDOMapChangeChan
func (*PDOMap) RebuildData ¶
func (m *PDOMap) RebuildData()
RebuildData rebuild map data object from map variables
func (*PDOMap) ReleaseChangesChan ¶
ReleaseChangesChan release (close) a PDOMapChangeChan
func (*PDOMap) UpdateDataSize ¶
func (m *PDOMap) UpdateDataSize()
type PDOMapChangeChan ¶
type PDOMaps ¶
PDOMaps define a PDO map
func NewPDOMaps ¶
NewPDOMaps create a new Maps
type PDONode ¶
func NewPDONode ¶
type SDOClient ¶
SDOClient represent an SDO client
func NewSDOClient ¶
func (*SDOClient) Send ¶
func (sdoClient *SDOClient) Send( req []byte, expectFunc networkFramesChanFilterFunc, timeout *time.Duration, retryCount *int, ) (*can.Frame, error)
Send message and optionaly wait for response
func (*SDOClient) SendRequest ¶
SendRequest to network bus
type SDOReader ¶
type SDOReader struct { SDOClient *SDOClient Index uint16 SubIndex uint8 Toggle uint8 Pos int Size uint32 Data []byte }
func NewSDOReader ¶
func (*SDOReader) RequestUpload ¶
RequestUpload returns data if EXPEDITED, else nil
type SDOWriter ¶
type SDOWriter struct { SDOClient ISDOClient Index uint16 SubIndex uint8 Toggle uint8 Pos int Size uint32 ForceSegment bool }
func NewSDOWriter ¶
func NewSDOWriter(sdoClient ISDOClient, index uint16, subIndex uint8, forceSegment bool) *SDOWriter
func (*SDOWriter) RequestDownload ¶
RequestDownload returns data if EXPEDITED, else nil