CANopenLinux
CANopenNode on Linux devices
|
Linux socketCAN specific Driver definitions for CANopenNode. More...
Files | |
file | CO_driver_target.h |
Linux socketCAN specific definitions for CANopenNode. | |
Macros | |
#define | CO_DRIVER_MULTI_INTERFACE 0 |
Multi interface support. | |
#define | CO_DRIVER_ERROR_REPORTING 1 |
CAN bus error reporting. | |
Functions | |
CO_ReturnError_t | CO_CANmodule_addInterface (CO_CANmodule_t *CANmodule, int can_ifindex) |
Add socketCAN interface to can driver. | |
bool_t | CO_CANrxBuffer_getInterface (CO_CANmodule_t *CANmodule, uint16_t ident, const void **const CANptrRx, struct timespec *timestamp) |
Check on which interface the last message for one message buffer was received. | |
CO_ReturnError_t | CO_CANtxBuffer_setInterface (CO_CANmodule_t *CANmodule, uint16_t ident, const void *CANptrTx) |
Set which interface should be used for message buffer transmission. | |
bool_t | CO_CANrxFromEpoll (CO_CANmodule_t *CANmodule, struct epoll_event *ev, CO_CANrxMsg_t *buffer, int32_t *msgIndex) |
Receives CAN messages from matching epoll event. | |
Linux socketCAN specific Driver definitions for CANopenNode.
#define CO_DRIVER_MULTI_INTERFACE 0 |
Multi interface support.
Enable this to use interface combining at driver level. This adds functions to broadcast/selective transmit messages on the given interfaces as well as combining all received message into one queue.
If CO_DRIVER_MULTI_INTERFACE is set to 0, then CO_CANmodule_init() adds single socketCAN interface specified by CANptr argument. In case of failure, CO_CANmodule_init() returns CO_ERROR_SYSCALL.
If CO_DRIVER_MULTI_INTERFACE is set to 1, then CO_CANmodule_init() ignores CANptr argument. Interfaces must be added by CO_CANmodule_addInterface() function after CO_CANmodule_init().
Macro is set to 0 (disabled) by default. It can be overridden.
This is not intended to realize interface redundancy!!!
#define CO_DRIVER_ERROR_REPORTING 1 |
CAN bus error reporting.
CO_DRIVER_ERROR_REPORTING enabled adds support for socketCAN error detection and handling functions inside the driver. This is needed when you have CANopen with "0" connected nodes as a use case, as this is normally forbidden in CAN.
Macro is set to 1 (enabled) by default. It can be overridden.
you need to enable error reporting in your kernel driver using:
Of course, the kernel driver for your hardware needs this functionality to be implemented...
CO_ReturnError_t CO_CANmodule_addInterface | ( | CO_CANmodule_t * | CANmodule, |
int | can_ifindex ) |
Add socketCAN interface to can driver.
Function must be called after CO_CANmodule_init.
CANmodule | This object will be initialized. |
can_ifindex | CAN Interface index |
bool_t CO_CANrxBuffer_getInterface | ( | CO_CANmodule_t * | CANmodule, |
uint16_t | ident, | ||
const void **const | CANptrRx, | ||
struct timespec * | timestamp ) |
Check on which interface the last message for one message buffer was received.
It is in the responsibility of the user to check that this information is useful as some messages can be received at any time on any bus.
CANmodule | This object. | |
ident | 11-bit standard CAN Identifier. | |
[out] | CANptrRx | message was received on this interface |
[out] | timestamp | message was received at this time (system clock) |
false | message has never been received, therefore no base address and timestamp are available |
true | base address and timestamp are valid |
CO_ReturnError_t CO_CANtxBuffer_setInterface | ( | CO_CANmodule_t * | CANmodule, |
uint16_t | ident, | ||
const void * | CANptrTx ) |
Set which interface should be used for message buffer transmission.
It is in the responsibility of the user to ensure that the correct interface is used. Some messages need to be transmitted on all interfaces.
If given interface is unknown or NULL is used, a message is transmitted on all available interfaces.
CANmodule | This object. |
ident | 11-bit standard CAN Identifier. |
CANptrTx | use this interface. NULL = not specified |
bool_t CO_CANrxFromEpoll | ( | CO_CANmodule_t * | CANmodule, |
struct epoll_event * | ev, | ||
CO_CANrxMsg_t * | buffer, | ||
int32_t * | msgIndex ) |
Receives CAN messages from matching epoll event.
This function verifies, if epoll event matches event from any CANinterface. In case of match, message is read from CAN and pre-processed for CANopenNode objects. CAN error frames are also processed.
In case of CAN message function searches rxArray from CO_CANmodule_t and if matched it calls the corresponding CANrx_callback, optionally copies received CAN message to buffer and returns index of matched rxArray.
This function can be used in two ways, which can be combined:
CANmodule | This object. | |
ev | Epoll event, which vill be verified for matches. | |
[out] | buffer | Storage for received message or NULL if not used. |
[out] | msgIndex | Index of received message in array from CO_CANmodule_t rxArray, copy of CAN message is available in buffer. |