Home

Awesome

canopen

canopen lets you send and received data in a CANopen network.

The library contains basic functionality and doesn't aim to be a complete implementation of the CANopen protocol. You can find a complete CANopen implementation in the CANopenNode project.

CANopen

CANopen is a protocol to communicate on a CAN bus. Data is exchanged between nodes using CANopen frames, which uses a subset of the bytes in a CAN frames. This project extends the can library to interact with a CANopen nodes. Setup your hard- and software as described there.

You can find a very good documentation about CANopen here.

Usage

Setup the CAN bus interface
bus, _ := can.NewBusForInterfaceWithName("can0")
bus.ConnectAndPublish()
CANopen request/response communication

Parts of CANopen protocol are based on request/response communication. The library makes it easy to send a request and wait for the reponse.

// Frame to be sent
payload := []byte{...}
frame := canopen.NewFrame(canopen.MessageTypeRSDO, payload)

// Expected id of response frame
respID := canopen.MessageTypeTSDO

req := canopen.NewRequest(frame, respID)

// Create client which sends request and waits for response
client := &canopen.Client{bus, time.Second * 1}
resp, _ := client.Do(req)

Contact

Matthias Hochgatterer

Github: https://github.com/brutella

Twitter: https://twitter.com/brutella

License

canopen is available under the MIT license. See the LICENSE file for more info.