Lely core libraries
2.2.5
|
Go to the documentation of this file.
26 #ifndef LELY_NO_CO_CSDO
30 #ifndef LELY_NO_CO_EMCY
33 #ifndef LELY_NO_CO_LSS
36 #ifndef LELY_NO_CO_RPDO
40 #ifndef LELY_NO_CO_SYNC
43 #ifndef LELY_NO_CO_TIME
46 #ifndef LELY_NO_CO_TPDO
54 #if !defined(LELY_NO_CO_RPDO) || !defined(LELY_NO_CO_TPDO)
60 #ifndef LELY_NO_CO_RPDO
63 co_unsigned8_t er,
void *data);
73 #ifndef LELY_NO_CO_SYNC
81 co_sync_t *sync, co_unsigned8_t cnt,
void *data);
84 co_unsigned8_t er,
void *data);
87 #ifndef LELY_NO_CO_TIME
95 #ifndef LELY_NO_CO_EMCY
103 #ifndef LELY_NO_CO_LSS
111 #define CO_NUM_PDO 512
114 #define CO_NUM_SDO 128
156 #ifndef LELY_NO_CO_LSS
160 #ifndef LELY_NO_CO_EMCY
164 #ifndef LELY_NO_CO_TIME
168 #ifndef LELY_NO_CO_SYNC
174 #if !defined(LELY_NO_CO_RPDO) || !defined(LELY_NO_CO_TPDO)
182 #if !defined(LELY_NO_CO_RPDO) || !defined(LELY_NO_CO_TPDO)
188 #ifndef LELY_NO_CO_SYNC
192 #ifndef LELY_NO_CO_TIME
196 #ifndef LELY_NO_CO_EMCY
200 #ifndef LELY_NO_CO_LSS
207 #if !defined(LELY_NO_CO_RPDO) || !defined(LELY_NO_CO_TPDO)
221 #ifndef LELY_NO_CO_RPDO
223 for (co_unsigned16_t i = 0; i <
CO_NUM_PDO; i++) {
226 if (!obj_1400 || !obj_1600)
230 realloc(srv->
rpdos, (i + 1) *
sizeof(*rpdos));
237 for (
size_t j = srv->
nrpdo; j < i; j++)
238 srv->
rpdos[j] = NULL;
248 #ifndef LELY_NO_CO_TPDO
250 for (co_unsigned16_t i = 0; i <
CO_NUM_PDO; i++) {
253 if (!obj_1800 || !obj_1a00)
257 realloc(srv->
tpdos, (i + 1) *
sizeof(*tpdos));
264 for (
size_t j = srv->
ntpdo; j < i; j++)
265 srv->
tpdos[j] = NULL;
288 #ifndef LELY_NO_CO_TPDO
290 for (
size_t i = 0; i < srv->
ntpdo; i++)
297 #ifndef LELY_NO_CO_RPDO
299 for (
size_t i = 0; i < srv->
nrpdo; i++)
307 #ifndef LELY_NO_CO_RPDO
320 #endif // !LELY_NO_CO_RPDO || !LELY_NO_CO_TPDO
335 for (co_unsigned8_t i = 0; i <
CO_NUM_SDO; i++) {
343 realloc(srv->
ssdos, (i + 1) *
sizeof(*ssdos));
350 for (
size_t j = srv->
nssdo; j < i; j++)
351 srv->
ssdos[j] = NULL;
359 #ifndef LELY_NO_CO_CSDO
361 for (co_unsigned8_t i = 0; i <
CO_NUM_SDO; i++) {
367 realloc(srv->
csdos, (i + 1) *
sizeof(*csdos));
374 for (
size_t j = srv->
ncsdo; j < i; j++)
375 srv->
csdos[j] = NULL;
398 #ifndef LELY_NO_CO_CSDO
400 for (
size_t i = 0; i < srv->
ncsdo; i++)
408 for (
size_t i = 0; i < srv->
nssdo; i++)
415 #ifndef LELY_NO_CO_SYNC
433 "unable to initialize SYNC service");
473 #endif // !LELY_NO_CO_SYNC
475 #ifndef LELY_NO_CO_TIME
493 "unable to initialize TIME service");
510 #ifndef LELY_NO_CO_EMCY
528 "unable to initialize EMCY service");
545 #ifndef LELY_NO_CO_LSS
562 "unable to initialize LSS service");
static void co_nmt_srv_init_time(struct co_nmt_srv *srv, can_net_t *net, co_dev_t *dev)
Initializes the TIME producer/consumer service.
void co_sync_set_err(co_sync_t *sync, co_sync_err_t *err, void *data)
Sets the error handling function of a SYNC consumer service.
static void co_nmt_srv_sync_ind(co_sync_t *sync, co_unsigned8_t cnt, void *data)
Invokes co_nmt_sync() to handle SYNC objects.
co_lss_t * lss
A pointer to the LSS master/slave service.
#define CO_NMT_SRV_TIME
The TIME producer/consumer service.
int set
The currently enabled CANopen services (any combination of CO_NMT_SRV_PDO, CO_NMT_SRV_SDO,...
static void co_nmt_srv_sync_err(co_sync_t *sync, co_unsigned16_t eec, co_unsigned8_t er, void *data)
Invokes co_nmt_err() to handle SYNC errors.
co_ssdo_t * co_ssdo_create(can_net_t *net, co_dev_t *dev, co_unsigned8_t num)
Creates a new CANopen Server-SDO service.
co_unsigned16_t nrpdo
The number of Receive-PDO services.
co_sync_t * sync
A pointer to the SYNC producer/consumer service.
can_net_t * net
A pointer to a CAN network interface.
co_csdo_t ** csdos
An array of pointers to the Client-SDO services.
co_tpdo_t ** tpdos
An array of pointers to the Transmit-PDO services.
co_emcy_t * emcy
A pointer to the EMCY producer/consumer service.
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function.
co_nmt_t * nmt
A pointer to an NMT master/slave service.
int errno2c(int errnum)
Transforms a standard C error number to a native error code.
static void co_nmt_srv_rpdo_err(co_rpdo_t *pdo, co_unsigned16_t eec, co_unsigned8_t er, void *data)
Invokes co_nmt_err() to handle Receive-PDO errors.
void co_nmt_on_err(co_nmt_t *nmt, co_unsigned16_t eec, co_unsigned8_t er, const co_unsigned8_t msef[5])
Implements the default error handling behavior by generating an EMCY message with co_emcy_push() and ...
static void co_nmt_srv_fini_time(struct co_nmt_srv *srv)
Finalizes the TIME producer/consumer service.
void co_nmt_on_sync(co_nmt_t *nmt, co_unsigned8_t cnt)
Implements the default behavior after a SYNC object is received or transmitted.
void co_nmt_srv_init(struct co_nmt_srv *srv, co_nmt_t *nmt)
Initializes a CANopen NMT service manager.
static void co_nmt_srv_init_pdo(struct co_nmt_srv *srv, can_net_t *net, co_dev_t *dev)
Initializes all Receive/Transmit-PDO services.
static void co_nmt_srv_init_lss(struct co_nmt_srv *srv, co_nmt_t *nmt)
Initializes the LSS master/slave service.
static void co_nmt_srv_fini_emcy(struct co_nmt_srv *srv)
Finalizes the EMCY producer/consumer service.
static void co_nmt_srv_fini_sdo(struct co_nmt_srv *srv)
Finalizes all Server/Client-SDO services.
co_unsigned8_t nssdo
The number of Server-SDO services.
void co_time_destroy(co_time_t *time)
Destroys a CANopen TIME producer/consumer service.
static void co_nmt_srv_fini_sync(struct co_nmt_srv *srv)
Finalizes the SYNC producer/consumer service.
void co_nmt_srv_fini(struct co_nmt_srv *srv)
Finalizes a CANopen NMT service manager.
co_sync_t * co_sync_create(can_net_t *net, co_dev_t *dev)
Creates a new CANopen SYNC producer/consumer service.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
#define CO_NUM_SDO
The maximum number of Client/Server-SDOs.
co_csdo_t * co_csdo_create(can_net_t *net, co_dev_t *dev, co_unsigned8_t num)
Creates a new CANopen Client-SDO service.
static void co_nmt_srv_init_emcy(struct co_nmt_srv *srv, can_net_t *net, co_dev_t *dev)
Initializes the EMCY producer/consumer service.
static void co_nmt_srv_init_sync(struct co_nmt_srv *srv, can_net_t *net, co_dev_t *dev)
Initializes the SYNC producer/consumer service.
A CANopen NMT service manager.
void co_csdo_destroy(co_csdo_t *sdo)
Destroys a CANopen Client-SDO service.
A CANopen NMT master/slave service.
co_time_t * time
A pointer to the TIME producer/consumer service.
void co_tpdo_destroy(co_tpdo_t *pdo)
Destroys a CANopen Transmit-PDO service.
void co_nmt_srv_set(struct co_nmt_srv *srv, co_nmt_t *nmt, int set)
Enables/disables the specified CANopen services.
#define CO_NMT_SRV_SDO
The Server/Client-SDO services.
void co_ssdo_destroy(co_ssdo_t *sdo)
Destroys a CANopen Server-SDO service.
void diag(enum diag_severity severity, int errc, const char *format,...)
Emits a diagnostic message.
co_time_t * co_time_create(can_net_t *net, co_dev_t *dev)
Creates a new CANopen TIME producer/consumer service.
co_dev_t * co_nmt_get_dev(const co_nmt_t *nmt)
Returns a pointer to the CANopen device of an NMT master/slave service.
#define CO_NMT_SRV_PDO
The Receive/Transmit-PDO services.
co_rpdo_t ** rpdos
An array of pointers to the Receive-PDO services.
co_nmt_t * nmt
A pointer to the NMT master/slave service.
void co_emcy_destroy(co_emcy_t *emcy)
Destroys a CANopen EMCY producer/consumer service.
static void co_nmt_srv_fini_lss(struct co_nmt_srv *srv)
Finalizes the EMCY master/slave service.
void co_rpdo_destroy(co_rpdo_t *pdo)
Destroys a CANopen Receive-PDO service.
void co_sync_destroy(co_sync_t *sync)
Destroys a CANopen SYNC producer/consumer service.
#define CO_NMT_SRV_SYNC
The SYNC producer/consumer service.
void co_rpdo_set_err(co_rpdo_t *pdo, co_rpdo_err_t *err, void *data)
Sets the error handling function of a Receive-PDO service.
void co_lss_destroy(co_lss_t *lss)
Destroys a CANopen LSS master/slave service.
co_tpdo_t * co_tpdo_create(can_net_t *net, co_dev_t *dev, co_unsigned16_t num)
Creates a new CANopen Transmit-PDO service.
static void co_nmt_srv_init_sdo(struct co_nmt_srv *srv, can_net_t *net, co_dev_t *dev)
Initializes all Server/Client-SDO services.
co_lss_t * co_lss_create(co_nmt_t *nmt)
Creates a new CANopen LSS master/slave service.
int co_dev_get_lss(const co_dev_t *dev)
Returns 1 if LSS is supported and 0 if not.
#define CO_NMT_SRV_EMCY
The EMCY producer/consumer service.
co_unsigned8_t ncsdo
The number of Client-SDO services.
static void co_nmt_srv_fini_pdo(struct co_nmt_srv *srv)
Finalizes all Receive/Transmit-PDO services.
can_net_t * co_nmt_get_net(const co_nmt_t *nmt)
Returns a pointer to the CAN network of an NMT master/slave service.
co_ssdo_t ** ssdos
An array of pointers to the Server-SDO services.
#define CO_NMT_SRV_LSS
The LSS master/slave service.
co_emcy_t * co_emcy_create(can_net_t *net, co_dev_t *dev)
Creates a new CANopen EMCY producer/consumer service.
A CANopen SYNC producer/consumer service.
co_unsigned16_t ntpdo
The number of Transmit-PDO services.
co_rpdo_t * co_rpdo_create(can_net_t *net, co_dev_t *dev, co_unsigned16_t num)
Creates a new CANopen Receive-PDO service.
#define CO_NUM_PDO
The maximum number of Receive/Transmit-PDOs.
void co_sync_set_ind(co_sync_t *sync, co_sync_ind_t *ind, void *data)
Sets the indication function invoked after a CANopen SYNC message is received or transmitted.
co_obj_t * co_dev_find_obj(const co_dev_t *dev, co_unsigned16_t idx)
Finds an object in the object dictionary of a CANopen device.