Читать книгу Engineering Autonomous Vehicles and Robots - Shaoshan Liu - Страница 39
2.4.5 CANopenNode
ОглавлениеCANopenNode is free and open source CANopen Stack is written in ANSI C in an object-oriented way [6]. It runs on different microcontrollers, as a standalone application, or with a real-time operating system. Stack includes master functionalities.
CANopenNode implements the following CANopen features:
NMT slave to start, stop, reset device. Simple NMT master.
Heartbeat producer–consumer error control.
PDO linking and dynamic mapping for fast exchange of process variables.
SDO expedited, segmented and block transfer for service access to all parameters.
SDO master.
Emergency message.
Sync producer–consumer.
Non-volatile storage.
CANopenNode itself does not have complete working code for any microcontroller. It is only the library with the stack and drivers for different microcontrollers. CANopenNode contains sample codes, which should compile on any system with a template driver, which actually does not access CAN hardware. CANopenNode should be used as a git submodule included in a project with specific hardware and specific application.
Figure 2.4 Flowchart of a typical CANopenNode implementation.
Figure 2.4 shows the flowchart of a typical CANopenNode implementation: when the program starts, it calls CANopen init, and spawns multiple threads. The CAN receive thread listens for any CAN messages and provides fast responses by processing messages and copying data to target CANopen objects. The timer interval thread is a real-time thread that wakes up every millisecond to deal with inputs to and outputs from the object dictionary. The mainline thread handles the processing of time-consuming tasks by calling the corresponding application code.