CanFestival86 Library

CanFestival86 is the x86 porting version of CanFestival, which can run on the 86Duino One board with built-in CAN Port.

CanFestival is an open source CANopen Stack, which covers the core communication system of the CANopen CiA DS-301 standard, and also includes important implementations such as CiA DS-302 Configuration Manager and CiA DS-305 LSS.
It supports quite a lot of platforms and can run in PC environment or common Embedded System. Now it can run on DMP x86/Dos platform through CanFestival86 Library.

 

Original code

The original CanFestival86 code can be downloaded on the Github page.

 

Examples

The built-in master_node and slave_node sample code show the operation process of the CanFestival core.
For detailed CanFestval Library installation, line connection, master_node and slave_node examples, please refer to Running the CanFestival86 Example.

 

CanFestival86 Category

The CanFestival86 category provides several important function wrappers for CanFestival, which is convenient for users to use, so you can run the CanFestival Master or Slave node in just a few lines of code.

– bool begin(CO_Data *node_data, unsigned long baudrate);
Start CAN Bus and Timer and bind to the CanFestival node data structure.

– bool set86NodeId(UNS8 nodeid);
Set the node CANopen Node-ID.

– bool set86State(e_nodeState state);
設定節點 CANopen NMT State Machine。

– void setVerbose(bool is_verbose);
Sets whether to output CanFestival core messages on Serial Monitor.
To output messages, set is_verbose to true, otherwise false.

– void dumpRuntimeInfo();
If you set is_verbose to true through the setVerbose() function, you can call dumpRuntimeInfo() in loop() to print out the core message.

– sdoWrite(UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS32 size, void *data, UNS32 timeout_ms = 1000);
This is a blocking SDO Download function, which requests that data be written to the SDO Server's OD. The blocking sdoWrite blocks and waits until the server responds or timeout after sending an SDO request.
Note that do not place this function in the callback function for use, otherwise the SDO result that is passed back cannot be read (this is because many callback functions are called in an interrupt, and other interrupt signals are blocked at this time).

– bool sdoWriteAsync(UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS32 size, void *data, SDOCallback_t Callback = &sdoWriteDefaultCallback);
This is an asynchronous SDO Download function, which requests that the SDO Client writes data to the OD of the SDO Server. The asynchronous sdoWriteAsync function can be used anywhere, but it needs to implement 1 Callback function, which provides calls when SDO communication is completed, and internally implements the judgment and processing of SDO communication results.
CanFestival86 Lib provides the preset Callback function sdoWriteDefaultCallback(), where the function judges the communication result and releases the occupied transfer line. Users can use preset Callbacks that implement custom functions on their own.

– bool sdoRead(UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS32 *size, void *data, UNS32 timeout_ms = 1000);
This is a blocking SDO Upload function, where the SDO Client requests to read the OD data to the SDO Server. The blocking sdoRead blocks and waits until the server responds or timeout after sending an SDO request.
Please provide the space size of the data buffer in advance in the size parameter, and the size size returned after the function call is the size of the real data.
Note that do not place this function in the callback function for use, otherwise the SDO result that is passed back cannot be read (this is because many callback functions are called in an interrupt, and other interrupt signals are blocked at this time).

– bool sdoReadAsync(UNS8 nodeId, UNS16 index, UNS8 subIndex, SDOCallback_t Callback);
This is an asynchronous SDO Upload function, where the SDO Client requests to read OD data to the SDO Server. The asynchronous sdoReadAsync function can be used anywhere, but it needs to implement 1 Callback function, which provides calls when SDO communication is completed, and internally implements the judgment and processing of SDO communication results.
CanFestival86 Lib does not provide a preset Callback function for sdoReadAsync because the user must write the Callback itself to store and read specific data.
sdoReadAsync() also does not design parameters to transfer address information for storing data, because the function implementation and data structure provided by CanFestival currently does not design this function. Please specify the storage location in Callback by yourself, or use the blocking sdoRead() function instead.

 

Limitations of use

The CanFestival86 function library uses the 86Duino internal MCM Timer when it is operating, so it cannot operate simultaneously with other functions that also use the same MCM Timer, such as the TimerOne function library.


Function library reference main page

The text of the 86Duino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.