Lely core libraries
2.3.4
|
Go to the documentation of this file.
54 #if !LELY_NO_CO_RPDO || !LELY_NO_CO_TPDO
63 co_unsigned8_t er,
void *data);
81 co_sync_t *sync, co_unsigned8_t cnt,
void *data);
84 co_unsigned8_t er,
void *data);
182 #if !LELY_NO_CO_RPDO || !LELY_NO_CO_TPDO
190 #if !LELY_NO_CO_RPDO || !LELY_NO_CO_TPDO
215 #if !LELY_NO_CO_RPDO || !LELY_NO_CO_TPDO
230 for (co_unsigned16_t i = 0; i <
CO_NUM_PDOS; i++) {
233 if (!obj_1400 || !obj_1600)
237 realloc(srv->
rpdos, (i + 1) *
sizeof(*rpdos));
246 for (
size_t j = srv->
nrpdo; j < i; j++)
247 srv->
rpdos[j] = NULL;
255 #endif // !LELY_NO_CO_RPDO
262 for (co_unsigned16_t i = 0; i <
CO_NUM_PDOS; i++) {
265 if (!obj_1800 || !obj_1a00)
269 realloc(srv->
tpdos, (i + 1) *
sizeof(*tpdos));
278 for (
size_t j = srv->
ntpdo; j < i; j++)
279 srv->
tpdos[j] = NULL;
286 #endif // !LELY_NO_CO_TPDO
304 for (
size_t i = 0; i < srv->
ntpdo; i++)
313 for (
size_t i = 0; i < srv->
nrpdo; i++)
334 #endif // !LELY_NO_CO_RPDO || !LELY_NO_CO_TPDO
355 realloc(srv->
ssdos, (i + 1) *
sizeof(*ssdos));
364 for (
size_t j = srv->
nssdo; j < i; j++)
365 srv->
ssdos[j] = NULL;
384 realloc(srv->
csdos, (i + 1) *
sizeof(*csdos));
393 for (
size_t j = srv->
ncsdo; j < i; j++)
394 srv->
csdos[j] = NULL;
401 #endif // !LELY_NO_CO_CSDO
419 for (
size_t i = 0; i < srv->
ncsdo; i++)
427 for (
size_t i = 0; i < srv->
nssdo; i++)
452 "unable to initialize SYNC service");
492 #endif // !LELY_NO_CO_SYNC
512 "unable to initialize TIME service");
527 #endif // !LELY_NO_CO_TIME
547 "unable to initialize EMCY service");
562 #endif // !LELY_NO_CO_EMCY
581 "unable to initialize LSS service");
596 #endif // !LELY_NO_CO_LSS
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.
#define CO_NUM_SDOS
The maximum number of Client/Server-SDOs.
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.
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.
#define CO_NUM_PDOS
The maximum number of Receive/Transmit-PDOs.
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.
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.