Lely core libraries
2.2.5
|
Go to the documentation of this file.
31 #ifndef LELY_NO_CO_EMCY
35 #if !defined(LELY_NO_CO_MASTER) && !defined(LELY_NO_CO_LSS)
40 #ifndef LELY_NO_CO_RPDO
44 #ifndef LELY_NO_CO_SYNC
47 #ifndef LELY_NO_CO_TIME
50 #ifndef LELY_NO_CO_TPDO
69 #ifndef LELY_NO_CO_CSDO
78 #ifndef LELY_NO_CO_CSDO
82 #if !defined(LELY_NO_CO_MASTER) && !defined(LELY_NO_CO_LSS)
90 #ifndef LELY_NO_CO_MASTER
108 #ifndef LELY_NO_CO_MASTER
138 #ifndef LELY_NO_CO_MASTER
146 int reason,
void *data);
162 int reason,
void *data);
170 co_unsigned8_t st,
void *data);
171 #ifndef LELY_NO_CO_MASTER
179 co_unsigned8_t st,
char es,
void *data);
188 co_unsigned16_t idx, co_unsigned8_t subidx,
size_t size,
189 size_t nbyte,
void *data);
198 co_unsigned16_t idx, co_unsigned8_t subidx,
size_t size,
199 size_t nbyte,
void *data);
201 #ifndef LELY_NO_CO_SYNC
208 #ifndef LELY_NO_CO_TIME
214 co_time_t *time,
const struct timespec *tp,
void *data);
216 #ifndef LELY_NO_CO_EMCY
222 co_unsigned16_t ec, co_unsigned8_t er, co_unsigned8_t msef[5],
225 #ifndef LELY_NO_CO_RPDO
231 const void *ptr,
size_t n,
void *data);
249 #define CO_GW_JOB_SIZE offsetof(struct co_gw_job, req)
261 #ifndef LELY_NO_CO_CSDO
270 co_unsigned8_t subidx, co_unsigned32_t ac,
const void *ptr,
271 size_t n,
void *
data);
274 co_unsigned8_t subidx, co_unsigned32_t ac,
void *
data);
277 co_unsigned8_t subidx,
size_t size,
size_t nbyte,
void *
data);
280 #if !defined(LELY_NO_CO_MASTER) && !defined(LELY_NO_CO_LSS)
294 co_unsigned8_t err, co_unsigned8_t spec,
void *
data);
297 co_unsigned32_t
id,
void *
data);
300 co_unsigned8_t
id,
void *
data);
330 #ifndef LELY_NO_CO_CSDO
333 co_unsigned8_t node,
const struct co_gw_req *req);
336 co_unsigned8_t node,
const struct co_gw_req *req);
342 #ifndef LELY_NO_CO_RPDO
347 #ifndef LELY_NO_CO_TPDO
352 #ifndef LELY_NO_CO_RPDO
357 #ifndef LELY_NO_CO_TPDO
363 #ifndef LELY_NO_CO_MASTER
366 co_unsigned8_t node, co_unsigned8_t cs,
370 co_unsigned8_t node,
const struct co_gw_req *req);
374 co_unsigned8_t node,
const struct co_gw_req *req);
385 #ifndef LELY_NO_CO_EMCY
388 co_unsigned8_t node,
const struct co_gw_req *req);
405 #if !defined(LELY_NO_CO_MASTER) && !defined(LELY_NO_CO_LSS)
450 co_unsigned8_t st,
int iec);
464 return "Request not processed due to internal state";
488 return "LSS command failed because of media error";
490 default:
return "Unknown error code";
497 void *ptr = malloc(
sizeof(
struct __co_gw));
504 __co_gw_free(
void *ptr)
510 __co_gw_init(
struct __co_gw *gw)
515 gw->
net[
id - 1] = NULL;
530 __co_gw_fini(
struct __co_gw *gw)
549 if (!__co_gw_init(gw)) {
584 return gw->
net[
id - 1] ? 0 : -1;
598 gw->
net[
id - 1] = NULL;
609 if (req->
size <
sizeof(*req)) {
618 co_unsigned16_t
net = gw->
def;
620 #ifndef LELY_NO_CO_CSDO
625 #ifndef LELY_NO_CO_RPDO
628 #ifndef LELY_NO_CO_TPDO
631 #ifndef LELY_NO_CO_RPDO
634 #ifndef LELY_NO_CO_TPDO
637 #ifndef LELY_NO_CO_MASTER
651 #ifndef LELY_NO_CO_EMCY
658 #if !defined(LELY_NO_CO_MASTER) && !defined(LELY_NO_CO_LSS)
695 #ifndef LELY_NO_CO_CSDO
699 #ifndef LELY_NO_CO_MASTER
710 #ifndef LELY_NO_CO_EMCY
719 if (par->
node != 0xff)
731 #ifndef LELY_NO_CO_CSDO
735 #ifndef LELY_NO_CO_MASTER
741 #ifndef LELY_NO_CO_EMCY
752 #ifndef LELY_NO_CO_CSDO
754 trace(
"gateway: received 'SDO upload' request");
757 trace(
"gateway: received 'SDO download' request");
760 trace(
"gateway: received 'Configure SDO time-out' request");
763 #ifndef LELY_NO_CO_RPDO
765 trace(
"gateway: received 'Configure RPDO' request");
768 #ifndef LELY_NO_CO_TPDO
770 trace(
"gateway: received 'Configure TPDO' request");
773 #ifndef LELY_NO_CO_RPDO
775 trace(
"gateway: received 'Read PDO data' request");
778 #ifndef LELY_NO_CO_TPDO
780 trace(
"gateway: received 'Write PDO data' request");
783 #ifndef LELY_NO_CO_MASTER
785 trace(
"gateway: received 'Start node' request");
788 trace(
"gateway: received 'Stop node' request");
791 trace(
"gateway: received 'Set node to pre-operational' request");
795 trace(
"gateway: received 'Reset node' request");
799 trace(
"gateway: received 'Reset communication' request");
804 trace(
"gateway: received '%s node guarding' request",
812 trace(
"gateway: received '%s heartbeat consumer' request",
818 trace(
"gateway: received 'Initialize gateway' request");
821 trace(
"gateway: received 'Set heartbeat producer' request");
824 trace(
"gateway: received 'Set node-ID' request");
826 #ifndef LELY_NO_CO_EMCY
829 trace(
"gateway: received '%s emergency consumer' request",
837 trace(
"gateway: received 'Set command time-out' request");
840 trace(
"gateway: received 'Boot-up forwarding' request");
843 trace(
"gateway: received 'Set default network' request");
846 trace(
"gateway: received 'Set default node-ID' request");
849 trace(
"gateway: received 'Get version' request");
852 trace(
"gateway: received 'Set command size' request");
856 #if !defined(LELY_NO_CO_MASTER) && !defined(LELY_NO_CO_LSS)
858 trace(
"gateway: received 'LSS switch state global' request");
861 trace(
"gateway: received 'LSS switch state selective' request");
864 trace(
"gateway: received 'LSS configure node-ID' request");
867 trace(
"gateway: received 'LSS configure bit-rate' request");
870 trace(
"gateway: received 'LSS activate new bit-rate' request");
873 trace(
"gateway: received 'LSS store configuration' request");
876 trace(
"gateway: received 'Inquire LSS address' request");
879 trace(
"gateway: received 'LSS inquire node-ID' request");
882 trace(
"gateway: received 'LSS identify remote slave' request");
885 trace(
"gateway: received 'LSS identify non-configure remote slaves' request");
888 trace(
"gateway: received 'LSS Slowscan' request");
891 trace(
"gateway: received 'LSS Fastscan' request");
947 struct co_gw_net *net = malloc(
sizeof(*net));
958 #ifndef LELY_NO_CO_CSDO
963 #ifndef LELY_NO_CO_CSDO
965 net->
sdo[
id - 1] = NULL;
967 #
if !defined(LELY_NO_CO_MASTER) && !defined(LELY_NO_CO_LSS)
973 #ifndef LELY_NO_CO_MASTER
983 #ifndef LELY_NO_CO_MASTER
992 #ifndef LELY_NO_CO_SYNC
998 #ifndef LELY_NO_CO_TIME
1004 #ifndef LELY_NO_CO_EMCY
1010 #ifndef LELY_NO_CO_RPDO
1012 for (co_unsigned16_t i = 1; i <= 512; i++) {
1027 #ifndef LELY_NO_CO_RPDO
1028 for (co_unsigned16_t i = 1; i <= 512; i++) {
1035 #ifndef LELY_NO_CO_EMCY
1041 #ifndef LELY_NO_CO_TIME
1047 #ifndef LELY_NO_CO_SYNC
1053 #ifndef LELY_NO_CO_MASTER
1059 #ifndef LELY_NO_CO_MASTER
1064 #ifndef LELY_NO_CO_CSDO
1068 #if !defined(LELY_NO_CO_MASTER) && !defined(LELY_NO_CO_LSS)
1084 #ifndef LELY_NO_CO_SYNC
1090 #ifndef LELY_NO_CO_TIME
1096 #ifndef LELY_NO_CO_EMCY
1102 #ifndef LELY_NO_CO_RPDO
1103 for (co_unsigned16_t i = 1; i <= 512; i++) {
1113 #ifndef LELY_NO_CO_SYNC
1119 #ifndef LELY_NO_CO_TIME
1125 #ifndef LELY_NO_CO_EMCY
1139 #ifndef LELY_NO_CO_MASTER
1198 co_nmt_t *
nmt, co_unsigned8_t
id, co_unsigned8_t st,
void *data)
1219 #ifndef LELY_NO_CO_MASTER
1237 net->boot_ind(nmt,
id,
st,
es,
net->boot_data);
1242 co_unsigned8_t subidx,
size_t size,
size_t nbyte,
void *data)
1263 co_unsigned8_t subidx,
size_t size,
size_t nbyte,
void *
data)
1282 #endif // !LELY_NO_CO_MASTER
1284 #ifndef LELY_NO_CO_SYNC
1302 #ifndef LELY_NO_CO_TIME
1318 #ifndef LELY_NO_CO_EMCY
1321 co_unsigned8_t er, co_unsigned8_t msef[5],
void *data)
1354 (*pself)->pself =
pself;
1356 (*pself)->data =
data;
1357 (*pself)->dtor =
dtor;
1385 #ifndef LELY_NO_CO_CSDO
1406 goto error_create_sdo;
1420 goto error_create_job;
1443 co_unsigned32_t ac,
const void *ptr,
size_t n,
void *
data)
1471 memcpy(con->
val, ptr, n);
1488 co_unsigned32_t ac,
void *data)
1507 co_unsigned8_t subidx,
size_t size,
size_t nbyte,
void *
data)
1527 #endif // !LELY_NO_CO_CSDO
1529 #if !defined(LELY_NO_CO_MASTER) && !defined(LELY_NO_CO_LSS)
1595 co_unsigned8_t spec,
void *
data)
1647 else if (
cs != req->
cs)
1665 co_lss_t *lss, co_unsigned8_t cs, co_unsigned8_t
id,
void *
data)
1678 else if (cs != 0x5e)
1734 #endif // !LELY_NO_CO_MASTER && !LELY_NO_CO_LSS
1736 #ifndef LELY_NO_CO_RPDO
1739 size_t n,
void *
data)
1756 ind.
size += ind.
n *
sizeof(*ind.
val);
1762 #ifndef LELY_NO_CO_CSDO
1769 assert(net && net <= CO_GW_NUM_NET && gw->net[net - 1]);
1793 goto error_create_job;
1815 goto error_create_job;
1843 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
1870 goto error_create_job;
1892 goto error_create_job;
1920 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
1924 #ifndef LELY_NO_CO_MASTER
1937 #ifndef LELY_NO_CO_MASTER
1951 #ifndef LELY_NO_CO_RPDO
1957 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
1972 + par->
n *
sizeof(*par->
map)) {
1984 for (co_unsigned8_t i = 0; i < par->
n; i++)
1985 map.map[i] = par->
map[i];
1993 #ifndef LELY_NO_CO_TPDO
1999 assert(net && net <= CO_GW_NUM_NET && gw->net[net - 1]);
2014 + par->
n *
sizeof(*par->
map)) {
2021 .cobid = par->
cobid,
2022 .trans = par->
trans,
2024 .event = par->
event,
2025 .sync = par->
sync };
2029 for (co_unsigned8_t i = 0; i < par->
n; i++)
2030 map.map[i] = par->
map[i];
2038 #ifndef LELY_NO_CO_RPDO
2044 assert(net && net <= CO_GW_NUM_NET && gw->net[net - 1]);
2059 co_unsigned32_t ac = 0;
2067 if (comm->
trans == 0xfc || comm->
trans == 0xfd) {
2078 size_t n =
sizeof(
buf);
2095 con.
size += con.
n *
sizeof(*con.
val);
2103 #ifndef LELY_NO_CO_TPDO
2109 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
2124 + par->
n *
sizeof(*par->
val)) {
2131 co_unsigned32_t ac = 0;
2142 size_t n =
sizeof(buf);
2166 #ifndef LELY_NO_CO_MASTER
2170 co_unsigned8_t cs,
const struct co_gw_req *req)
2173 assert(net && net <= CO_GW_NUM_NET && gw->net[net - 1]);
2194 assert(net && net <= CO_GW_NUM_NET && gw->net[net - 1]);
2199 co_unsigned16_t gt = 0;
2200 co_unsigned8_t ltf = 0;
2224 #endif // !LELY_NO_CO_MASTER
2231 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
2237 co_unsigned16_t ms = 0;
2258 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
2274 co_unsigned16_t rate;
2358 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
2372 co_unsigned32_t ac = 0;
2394 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
2419 #ifndef LELY_NO_CO_EMCY
2437 co_unsigned32_t ac = 0;
2478 #ifndef LELY_NO_CO_MASTER
2480 if (!gw->
net[
id - 1])
2503 assert(net && net <= CO_GW_NUM_NET && gw->net[net - 1]);
2550 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
2578 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
2588 .vendor_id = co_dev_get_val_u32(dev, 0x1018, 0x01),
2589 .product_code = co_dev_get_val_u32(dev, 0x1018, 0x02),
2590 .revision = co_dev_get_val_u32(dev, 0x1018, 0x03),
2591 .serial_nr = co_dev_get_val_u32(dev, 0x1018, 0x04),
2598 #if !defined(LELY_NO_CO_MASTER) && !defined(LELY_NO_CO_LSS)
2605 assert(net && net <= CO_GW_NUM_NET && gw->net[net - 1]);
2641 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
2659 goto error_create_job;
2667 goto error_switch_sel_req;
2672 error_switch_sel_req:
2684 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
2701 goto error_create_job;
2707 goto error_set_id_req;
2724 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
2742 co_unsigned16_t rate;
2744 case 0: rate = 1000;
break;
2745 case 1: rate = 800;
break;
2746 case 2: rate = 500;
break;
2747 case 3: rate = 250;
break;
2748 case 4: rate = 125;
break;
2749 case 6: rate = 50;
break;
2750 case 7: rate = 20;
break;
2751 case 8: rate = 10;
break;
2752 case 9: rate = 0;
break;
2762 goto error_create_job;
2768 goto error_set_rate_req;
2786 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
2822 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
2833 goto error_create_job;
2838 goto error_store_req;
2855 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
2873 goto error_create_job;
2883 goto error_switch_sel_req;
2892 goto error_switch_sel_req;
2901 goto error_switch_sel_req;
2910 goto error_switch_sel_req;
2918 error_switch_sel_req:
2931 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
2942 goto error_create_job;
2947 goto error_get_id_req;
2964 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
2982 goto error_create_job;
2990 goto error_id_slave_req;
3007 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
3018 goto error_create_job;
3024 goto error_id_non_cfg_slave_req;
3029 error_id_non_cfg_slave_req:
3041 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
3059 goto error_create_job;
3067 goto error_slowscan_req;
3084 assert(
net && net <= CO_GW_NUM_NET && gw->
net[
net - 1]);
3102 goto error_create_job;
3110 goto error_fastscan_req;
3122 #endif // !LELY_NO_CO_MASTER && !LELY_NO_CO_LSS
3156 co_unsigned8_t st,
int iec)
3193 #endif // !LELY_NO_CO_GW
struct co_gw_job * lss
A pointer to the LSS job.
co_unsigned16_t net
The network-ID.
co_unsigned16_t net
The network-ID.
static int co_gw_recv_lss_switch(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes an 'LSS switch state global' request.
#define CO_SDO_AC_TIMEOUT
SDO abort code: SDO protocol timed out.
co_unsigned16_t idx
The object index.
void * st_data
A pointer to user-specified data for st_ind.
#define CO_GW_IEC_NO_DEF_NET
CANopen gateway internal error: No default net set.
co_unsigned8_t node
The node-ID.
static void co_gw_net_destroy(struct co_gw_net *net)
Destroys a CANopen network.
void * up_data
A pointer to user-specified data for up_ind.
static int co_gw_recv_lss_get_lssid(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes an 'Inquire LSS address' request.
int srv
The service number (CO_GW_SRV_EC).
#define CO_GW_SRV_LSS_ID_NON_CFG_SLAVE
CANopen gateway service: LSS identify non-configured remote slaves.
int timeout
The SDO timeout (in milliseconds).
size_t size
The size of this struct (in bytes).
#define CO_GW_IEC_PDO_INUSE
CANopen gateway internal error: PDO already used.
int co_lss_switch_req(co_lss_t *lss, co_unsigned8_t mode)
Requests the 'switch state global' service.
The parameters of a CANopen gateway 'Configure SDO time-out' request.
#define CO_BAUD_20
A bit rate of 20 kbit/s.
void co_nmt_get_dn_ind(const co_nmt_t *nmt, co_nmt_sdo_ind_t **pind, void **pdata)
Retrieves the indication function used to notify the user of the progress of the current SDO download...
#define CO_GW_REQ_SET_TPDO_SIZE
The minimum size (in bytes) of a CANopen gateway 'Configure TPDO' request.
co_unsigned16_t gt
The guard time (in milliseconds).
void co_nmt_get_ng_ind(const co_nmt_t *nmt, co_nmt_ng_ind_t **pind, void **pdata)
Retrieves the indication function invoked when a node guarding event occurs.
co_unsigned16_t net
The network-ID.
#define CO_GW_SRV_SDO_DN
CANopen gateway service: SDO download.
co_unsigned32_t cobid
The COB-ID.
#define CO_GW_SRV_GET_VERSION
CANopen gateway service: Get version.
void co_nmt_cs_ind_t(co_nmt_t *nmt, co_unsigned8_t cs, void *data)
The type of a CANopen NMT command indication function, invoked when an NMT command is received (and a...
#define CO_GW_IEC_INTERN
CANopen gateway internal error: Request not processed due to internal state.
size_t size
The size of this struct (in bytes).
void co_nmt_set_hb_ind(co_nmt_t *nmt, co_nmt_hb_ind_t *ind, void *data)
Sets the indication function invoked when a heartbeat event occurs.
size_t size
The size of this struct (in bytes).
static void co_gw_net_sync_ind(co_sync_t *sync, co_unsigned8_t cnt, void *data)
The callback function invoked when a SYNC message is received from a node on a CANopen network.
#define CO_GW_SRV__BOOT
Lely-specific gateway service: Boot slave process completed.
int srv
The service number.
int srv
The service number (CO_GW_SRV_SDO_UP).
static void co_gw_job_sdo_dtor(void *data)
Destroys the Client-SDO service in an SDO upload/download job.
#define CO_GW_SRV_PDO_WRITE
CANopen gateway service: Write PDO data.
#define CO_BAUD_50
A bit rate of 50 kbit/s.
#define CO_GW_SRV__SYNC
Lely-specific gateway service: Synchronization event received.
unsigned cs
A flag indicating whether "boot-up event received" commands should be forwarded (1) or not (0).
co_nmt_cs_ind_t * cs_ind
A pointer to the original NMT command indication function.
void co_nmt_hb_ind_t(co_nmt_t *nmt, co_unsigned8_t id, int state, int reason, void *data)
The type of a CANopen NMT heartbeat indication function, invoked when a heartbeat event occurs (see s...
struct co_gw_net * net[CO_GW_NUM_NET]
An array of pointers to the CANopen networks.
int srv
The service number (CO_GW_SRV__SYNC).
void co_nmt_get_lg_ind(const co_nmt_t *nmt, co_nmt_lg_ind_t **pind, void **pdata)
Retrieves the indication function invoked when a life guarding event occurs.
void co_nmt_set_ng_ind(co_nmt_t *nmt, co_nmt_ng_ind_t *ind, void *data)
Sets the indication function invoked when a node guarding event occurs.
static int co_gw_send_ec(co_gw_t *gw, co_unsigned16_t net, co_unsigned8_t node, co_unsigned8_t st, int iec)
Sends an 'Error control event received' indication.
void * data
A pointer to request-specific data.
co_unsigned32_t nbyte
The transferred bytes.
The parameters of a CANopen gateway 'LSS configure bit-rate' request.
void co_gw_rate_func_t(co_unsigned16_t net, co_unsigned16_t rate, void *data)
The type of a CANopen gateway 'set bit timing' function, invoked when a baudrate switch is needed aft...
int co_dev_dn_req(co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx, const void *ptr, size_t n, co_csdo_dn_con_t *con, void *data)
Submits a download request to a local device.
size_t size
The size of this struct (in bytes).
int iec
The internal error code (0 on success).
#define CO_GW_IEC_TIMEOUT
CANopen gateway internal error: Time-out.
co_unsigned32_t co_dev_cfg_tpdo(const co_dev_t *dev, co_unsigned16_t num, const struct co_pdo_comm_par *comm, const struct co_pdo_map_par *map)
Configures the communication and parameters of a Transmit-PDO service.
size_t size
The size of this struct (in bytes).
int co_lss_set_rate_req(co_lss_t *lss, co_unsigned16_t rate, co_lss_err_ind_t *ind, void *data)
Requests the 'configure bit timing parameters' service.
#define CO_GW_IEC_CAN_OVERFLOW
CANopen gateway internal error: CAN buffer overflow.
int co_lss_store_req(co_lss_t *lss, co_lss_err_ind_t *ind, void *data)
Requests the 'store configuration' service.
#define CO_DEFTYPE_UNSIGNED32
The data type (and object index) of a 32-bit unsigned integer.
static int co_gw_recv_set_tpdo(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes a 'Configure TPDO' request.
static int co_gw_recv_lss_switch_sel(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes an 'LSS switch state selective' request.
co_unsigned16_t net
The network-ID.
#define CO_GW_SRV_NMT_ENTER_PREOP
CANopen gateway service: Set node to pre-operational.
static int co_gw_recv__lss_slowscan(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes an 'LSS Slowscan' request.
co_unsigned8_t n
Number of mapped objects in PDO.
void co_nmt_get_cs_ind(const co_nmt_t *nmt, co_nmt_cs_ind_t **pind, void **pdata)
Retrieves the indication function invoked when an NMT command is received.
const char * co_gw_iec2str(int iec)
Returns a string describing an internal error code.
co_unsigned8_t n
Highest sub-index supported.
co_unsigned32_t co_dev_cfg_rpdo(const co_dev_t *dev, co_unsigned16_t num, const struct co_pdo_comm_par *comm, const struct co_pdo_map_par *map)
Configures the communication and parameters of a Receive-PDO service.
void co_nmt_ng_ind_t(co_nmt_t *nmt, co_unsigned8_t id, int state, int reason, void *data)
The type of a CANopen NMT node guarding indication function, invoked when a node guarding event occur...
A CANopen TIME producer/consumer service.
#define CO_DEFTYPE_UNSIGNED16
The data type (and object index) of a 16-bit unsigned integer.
static int co_gw_recv_nmt_set_hb(co_gw_t *gw, co_unsigned16_t net, co_unsigned8_t node, const struct co_gw_req *req)
Processes a 'Start/Disable heartbeat consumer' request.
void * boot_data
A pointer to user-specified data for boot_ind.
#define CO_GW_IEC_CAN_PASSIVE
CANopen gateway internal error: Error passive.
The common parameters of a CANopen gateway request.
static void co_gw_job_lss_lssid_ind(co_lss_t *lss, co_unsigned8_t cs, co_unsigned32_t id, void *data)
The confirmation function for an 'Inquire LSS address' request.
void co_time_set_ind(co_time_t *time, co_time_ind_t *ind, void *data)
Sets the indication function invoked when a CANopen time stamp is received.
int srv
The service number (CO_GW_SRV_SDO).
#define CO_NUM_NODES
The maximum number of nodes in a CANopen network.
#define CO_GW_IEC_LSS_RATE
CANopen gateway internal error: LSS bit-rate not supported.
The parameters of a CANopen gateway 'LSS inquire node-ID' confirmation.
@ ERRNUM_BUSY
Device or resource busy.
co_unsigned16_t net
The network-ID.
int srv
The service number (CO_GW_SRV_EMCY_START or CO_GW_SRV_EMCY_STOP).
#define CO_SDO_AC_NO_MEM
SDO abort code: Out of memory.
#define CO_GW_SRV_LSS_SWITCH_SEL
CANopen gateway service: LSS switch state selective.
static int errnum2iec(errnum_t errnum)
Converts an error number to an internal error code.
static struct co_gw_job * co_gw_job_create_sdo(struct co_gw_job **pself, struct co_gw_net *net, co_unsigned8_t id, const struct co_gw_req *req)
Creates a new SDO upload/download job.
co_unsigned32_t co_pdo_up(const struct co_pdo_map_par *par, const co_dev_t *dev, struct co_sdo_req *req, uint_least8_t *buf, size_t *pn)
Reads mapped PDO values from the object dictionary through a local SDO upload request.
The common parameters of a CANopen gateway network-level request.
#define CO_GW_NUM_NET
The maximum number of networks in a CANopen gateway.
void * data
A pointer to user-specified data.
#define MIN(a, b)
Returns the minimum of a and b.
static int co_gw_recv_lss_store(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes an 'LSS store configuration' request.
static int co_gw_recv_set_cmd_timeout(co_gw_t *gw, const struct co_gw_req *req)
Processes a 'Set command time-out' request.
int timeout
The command timeout (in milliseconds).
size_t size
The size of this struct (in bytes).
void co_nmt_sdo_ind_t(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned16_t idx, co_unsigned8_t subidx, size_t size, size_t nbyte, void *data)
The type of an SDO request progress indication function, invoked by a CANopen NMT master to notify th...
co_unsigned16_t ec
The emergency error code.
void * dn_data
A pointer to user-specified data for dn_ind.
static int co_gw_recv_nmt_set_ng(co_gw_t *gw, co_unsigned16_t net, co_unsigned8_t node, const struct co_gw_req *req)
Processes a 'Enable/Disable node guarding' request.
#define CO_GW_IEC_HB_RESOLVED
CANopen gateway internal error: Heartbeat started.
#define CO_GW_SRV_NMT_RESET_COMM
CANopen gateway service: Reset communication.
co_unsigned32_t ac
The SDO abort code (0 on success).
size_t size
The size of this struct (in bytes).
char es
The error status (in the range ['A'..'O'], or 0 on success).
The parameters of a CANopen gateway 'LSS switch state selective' request.
#define CO_GW_IEC_PDO_LEN
CANopen gateway internal error: PDO length exceeded.
int co_gw_send_func_t(const struct co_gw_srv *srv, void *data)
The type of a CANopen gateway send callback function, invoked by a gateway when an indication or conf...
static int co_gw_recv_init(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes an 'Initialize gateway' request.
void * data
A pointer to user-specified data.
void co_nmt_lg_ind_t(co_nmt_t *nmt, int state, void *data)
The type of a CANopen NMT life guarding indication function, invoked when a life guarding event occur...
#define CO_GW_SRV_SDO_UP
CANopen gateway service: SDO upload.
void co_nmt_boot_ind_t(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st, char es, void *data)
The type of a CANopen NMT 'boot slave' indication function, invoked when the 'boot slave' process com...
co_sync_t * co_nmt_get_sync(const co_nmt_t *nmt)
Returns a pointer to the SYNC producer/consumer service.
static int co_gw_recv_lss_set_id(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes an 'LSS configure node-ID' request.
#define CO_GW_IEC_HB_OCCURRED
CANopen gateway internal error: Heartbeat lost.
The parameters of a CANopen gateway 'RPDO received' indication.
#define CO_GW_REQ_SDO_DN_SIZE
The minimum size (in bytes) of a CANopen gateway 'SDO download' request.
co_unsigned8_t bitidx
The bit timing index.
The parameters of a CANopen gateway 'Set heartbeat producer' request.
#define CO_GW_SRV_LSS_GET_ID
CANopen gateway service: LSS inquire node-ID.
size_t size
The size of this struct (in bytes).
static struct co_gw_net * co_gw_net_create(co_gw_t *gw, co_unsigned16_t id, co_nmt_t *nmt)
Creates a new CANopen network.
#define CO_GW_IEC_LSS_PARAM
CANopen gateway internal error: LSS parameter storing failed.
void * data
A pointer to user-specified data.
co_unsigned8_t co_dev_get_id(const co_dev_t *dev)
Returns the node-ID of a CANopen device.
static void co_gw_job_sdo_ind(const co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, size_t size, size_t nbyte, void *data)
The progress indication function for an SDO upload/download job.
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function.
struct co_gw_req req
The service parameters of the request.
int timeout
The SDO timeout (in milliseconds).
#define CO_GW_SRV_EMCY
CANopen gateway service: Emergency event received.
static int co_gw_recv_set_id(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes a 'Set node-ID' request.
co_unsigned8_t cnt
The SYNC counter.
co_gw_rate_func_t * rate_func
A pointer to the callback function invoked when a baudrate switch is needed after an 'Initialize gate...
#define CO_GW_SRV_NMT_START
CANopen gateway service: Start node.
co_unsigned8_t subidx
The object sub-index.
#define CO_GW_SRV_EMCY_START
CANopen gateway service: Start emergency consumer.
#define CO_GW_REQ_SET_RPDO_SIZE
The minimum size (in bytes) of a CANopen gateway 'Configure RPDO' request.
@ ERRNUM_NOMEM
Not enough space.
The parameters of a CANopen gateway 'CiA 301 progress indication download' indication.
co_unsigned8_t bitidx
The bit timing index (in the range [0..9]).
void co_gw_get_send_func(const co_gw_t *gw, co_gw_send_func_t **pfunc, void **pdata)
Retrieves the callback function used to send indications and confirmations from a CANopen gateway.
int errno2c(int errnum)
Transforms a standard C error number to a native error code.
int srv
The service number (CO_GW_SRV__LSS_SLOWSCAN or CO_GW_SRV__LSS_FASTSCAN).
#define CO_GW_SRV_SET_CMD_TIMEOUT
CANopen gateway service: Set command time-out.
#define CO_BAUD_125
A bit rate of 125 kbit/s.
co_unsigned16_t net
The network-ID.
#define CO_GW_PROT_HI
The high number of the version of CiA 309-1 implemented by this gateway.
#define CO_EMCY_COBID_VALID
The bit in the EMCY COB-ID specifying whether the EMCY exists and is valid.
The parameters of a Lely-specific gateway 'LSS Slowscan/Fastscan' request.
co_unsigned8_t n
Number of mapped objects in PDO.
co_unsigned8_t node
The node-ID.
co_nmt_st_ind_t * st_ind
A pointer to the original state change event indication function.
co_unsigned16_t type
The data type.
static struct co_gw_job * co_gw_job_create(struct co_gw_job **pself, struct co_gw_net *net, void *data, void(*dtor)(void *data), const struct co_gw_req *req)
Creates a new CANopen gateway network job.
size_t size
The size of this struct (in bytes).
co_unsigned16_t delay
The delay (in milliseconds).
#define CO_GW_SRV_LSS_GET_LSSID
CANopen gateway service: Inquire LSS address.
static int co_gw_recv_lss_switch_rate(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes an 'LSS activate new bit-rate' request.
A PDO communication parameter record.
#define CO_GW_SRV__LSS_FASTSCAN
Lely-specific gateway service: LSS Fastscan.
#define CO_GW_SRV_SET_ID
CANopen gateway service: Set node-ID.
int co_nmt_cs_req(co_nmt_t *nmt, co_unsigned8_t cs, co_unsigned8_t id)
Submits an NMT request to a slave.
@ CO_NMT_EC_TIMEOUT
An NMT error control timeout event.
co_unsigned32_t co_dev_cfg_hb(co_dev_t *dev, co_unsigned8_t id, co_unsigned16_t ms)
Configures heartbeat consumption for the specified node by updating CANopen object 1016 (Consumer hea...
static void co_gw_job_destroy(struct co_gw_job *job)
Destroys a CANopen gateway network job.
The parameters of a CANopen gateway 'Read PDO' confirmation.
co_unsigned16_t ms
The heartbeat time (in milliseconds).
co_unsigned8_t trans
Transmission type.
#define CO_GW_SRV_SET_BOOTUP_IND
CANopen gateway service: Boot-up forwarding.
co_unsigned16_t net
The network-ID.
co_unsigned16_t net
The network-ID.
The parameters of a CANopen gateway 'Read PDO' request.
The parameters of a CANopen gateway 'SDO download' request.
static void co_gw_job_lss_scan_ind(co_lss_t *lss, co_unsigned8_t cs, const struct co_id *id, void *data)
The confirmation function for an 'LSS Slowscan/Fastscan' request.
co_unsigned8_t cs
The command specifier (one of 0x5a, 0x5b, 0x5c or 0x5d).
int co_lss_id_non_cfg_slave_req(co_lss_t *lss, co_lss_cs_ind_t *ind, void *data)
Requests the 'LSS identify non-configured remote slave' service.
size_t size
The size of this struct (in bytes).
co_unsigned32_t map[0x40]
An array of objects to be mapped.
int srv
The service number (CO_GW_SRV_GET_VERSION).
#define CO_NMT_CS_STOP
The NMT command specifier 'stop'.
co_unsigned16_t net
The network-ID.
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.
static int co_gw_recv_nmt_cs(co_gw_t *gw, co_unsigned16_t net, co_unsigned8_t node, co_unsigned8_t cs, const struct co_gw_req *req)
Processes an NMT request.
#define CO_BAUD_AUTO
Automatic bit rate detection.
The parameters of a CANopen gateway 'SDO upload' confirmation.
co_unsigned64_t val[0x40]
An array of object values.
co_unsigned16_t net
The network-ID.
#define CO_GW_SRV_LSS_STORE
CANopen gateway service: LSS store configuration.
co_unsigned8_t n
Number of mapped objects in PDO.
static void co_gw_net_boot_ind(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st, char es, void *data)
The callback function invoked when the 'boot slave' process completes for a node on a CANopen network...
co_sub_t * co_obj_find_sub(const co_obj_t *obj, co_unsigned8_t subidx)
Finds a sub-object in a CANopen object.
co_gw_t * gw
A pointer to the CANopen gateway.
co_unsigned16_t num
The PDO number.
#define CO_GW_SRV_NMT_NG_DISABLE
CANopen gateway service: Disable node guarding.
The parameters of a CANopen gateway 'LSS identify remote slave' request.
#define CO_NMT_CS_START
The NMT command specifier 'start'.
#define CO_BAUD_10
A bit rate of 10 kbit/s.
The common parameters of a CANopen gateway confirmation.
void * lg_data
A pointer to user-specified data for lg_ind.
#define CO_SDO_AC_NO_OBJ
SDO abort code: Object does not exist in the object dictionary.
#define CO_GW_SRV_SET_TPDO
CANopen gateway service: Configure TPDO.
static int co_gw_recv_set_bootup_ind(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes a 'Boot-up forwarding' request.
co_unsigned16_t net
The network-ID.
#define CO_GW_IEC_BAD_NET
CANopen gateway internal error: Unsupported net.
The parameters of a CANopen gateway 'LSS activate new bit-rate' request.
int co_lss_get_serial_nr_req(co_lss_t *lss, co_lss_lssid_ind_t *ind, void *data)
Requests the 'inquire identity serial-number' service.
co_unsigned64_t val[0x40]
An array of object values.
co_unsigned8_t co_nmt_get_st(const co_nmt_t *nmt)
Returns the current state of a CANopen NMT service (one of CO_NMT_ST_BOOTUP, CO_NMT_ST_STOP,...
co_nmt_ng_ind_t * ng_ind
A pointer to the original node guarding event indication function.
co_nmt_sdo_ind_t * up_ind
A pointer to the original SDO upload progress indication function.
static int co_gw_recv_set_node(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes a 'Set default node-ID' request.
size_t size
The size of this struct (in bytes).
#define CO_GW_IEC_NO_MEM
CANopen gateway internal error: Running out of memory.
int iec
The internal error code (0 on success).
co_unsigned8_t bitsel
The bit timing selector.
#define CO_GW_SRV_NMT_NG_ENABLE
CANopen gateway service: Enable node guarding.
static int co_gw_recv__lss_fastscan(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes an 'LSS Fastscan' request.
#define CAN_MAX_LEN
The maximum number of bytes in the payload of a CAN format frame.
int co_lss_slowscan_req(co_lss_t *lss, const struct co_id *lo, const struct co_id *hi, co_lss_scan_ind_t *ind, void *data)
Requests the 'LSS Slowscan' service.
#define CO_GW_JOB_SIZE
The minimum size (in bytes) of a CANopen gateway network job.
#define CO_GW_SRV_LSS_SWITCH
CANopen gateway service: LSS switch state global.
co_tpdo_t * co_nmt_get_tpdo(const co_nmt_t *nmt, co_unsigned16_t n)
Returns a pointer to a Transmit-PDO service.
#define CO_GW_IEC_ST_OCCURRED
CANopen gateway internal error: Wrong NMT state.
@ CO_NMT_EC_RESOLVED
An NMT error control event was resolved.
co_unsigned8_t co_dev_get_netid(const co_dev_t *dev)
Returns the network-ID of a CANopen device.
void * cs_data
A pointer to user-specified data for cs_ind.
#define CO_GW_SRV_EC
CANopen gateway service: Error control event received.
static int co_gw_recv_sdo_dn(co_gw_t *gw, co_unsigned16_t net, co_unsigned8_t node, const struct co_gw_req *req)
Processes an 'SDO download' request.
void set_errnum(errnum_t errnum)
Sets the current (thread-specific) platform-independent error number to errnum.
unsigned bootup_ind
A flag indicating whether "boot-up event received" commands should be forwarded (1) or not (0).
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
void * data
A pointer to user-specified data.
void co_nmt_get_boot_ind(const co_nmt_t *nmt, co_nmt_boot_ind_t **pind, void **pdata)
Retrieves the indication function invoked when a CANopen NMT 'boot slave' process completes.
struct co_gw_job * sdo[CO_NUM_NODES]
An array of pointers to the SDO upload/download jobs.
#define CO_GW_SRV_RPDO
CANopen gateway service: RPDO received.
static void co_gw_net_rpdo_ind(co_rpdo_t *pdo, co_unsigned32_t ac, const void *ptr, size_t n, void *data)
The callback function invoked when a PDO is received from a node on a CANopen network.
#define CO_GW_IEC_LG_OCCURRED
CANopen gateway internal error: Lost connection.
#define LELY_CO_LSS_TIMEOUT
The default LSS timeout (in milliseconds).
uint_least8_t val[1]
The (first byte in the) value.
#define CO_GW_IEC_CAN_INIT
CANopen gateway internal error: CAN init.
static void co_gw_net_up_ind(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned16_t idx, co_unsigned8_t subidx, size_t size, size_t nbyte, void *data)
The callback function invoked to notify the user of the progress of an SDO upload request during the ...
void co_nmt_set_dn_ind(co_nmt_t *nmt, co_nmt_sdo_ind_t *ind, void *data)
Sets the indication function used to notify the user of the progress of the current SDO download requ...
#define CO_GW_SRV_SET_NET
CANopen gateway service: Set default network.
int co_dev_up_req(const co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx, co_csdo_up_con_t *con, void *data)
Submits an upload request to a local device.
co_unsigned8_t sync
The SYNC start value.
#define MAX(a, b)
Returns the maximum of a and b.
int srv
The service number.
The parameters of a CANopen gateway 'Enable node guarding' request.
#define CO_SDO_AC_NO_SUB
SDO abort code: Sub-index does not exist.
struct co_id lo
The lower bound of the LSS address.
co_unsigned8_t st
The state of the node, or 0 in case of a boot-up event.
co_unsigned16_t net
The network-ID.
co_unsigned8_t mode
0 for waiting state, 1 for configuration state.
The parameters of a CANopen gateway 'Boot-up forwarding' request.
int errnum2c(errnum_t errnum)
Transforms a platform-independent error number to a native error code.
A CANopen SDO upload/download request.
The parameters of a CANopen gateway 'Start heartbeat consumer' request.
#define CO_BAUD_250
A bit rate of 250 kbit/s.
A CANopen EMCY producer/consumer service.
static int co_gw_recv_lss_id_slave(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes an 'LSS identify remote slave' request.
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.
errnum
The platform-independent error numbers.
co_unsigned8_t ltf
The lifetime factor.
co_unsigned32_t cobid
The COB-ID.
#define CO_NMT_ST_BOOTUP
The NMT state 'boot-up'.
#define CO_GW_IEC_NO_DEF_NODE
CANopen gateway internal error: No default node set.
The parameters of a CANopen gateway 'Initialize gateway' request.
static void co_gw_net_ng_ind(co_nmt_t *nmt, co_unsigned8_t id, int state, int reason, void *data)
The callback function invoked when a node guarding event occurs for a node on a CANopen network.
size_t size
The size of this struct (in bytes).
A CANopen LSS master/slave service.
co_unsigned16_t ms
The heartbeat time (in milliseconds).
int co_nmt_is_master(const co_nmt_t *nmt)
Returns 1 if the specified CANopen NMT service is a master, and 0 if not.
#define CO_NMT_CS_ENTER_PREOP
The NMT command specifier 'enter pre-operational'.
The parameters of a CANopen gateway 'Start/Stop emergency consumer' request.
The parameters of a CANopen gateway 'Inquire LSS address' confirmation.
void co_csdo_destroy(co_csdo_t *sdo)
Destroys a CANopen Client-SDO service.
struct co_id id_2
In case of an LSS Slowscan request, the upper bound of the LSS address; in case of an LSS Fastscan re...
static int co_gw_recv_set_sdo_timeout(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes a 'Configure SDO time-out' request.
void co_nmt_set_cs_ind(co_nmt_t *nmt, co_nmt_cs_ind_t *ind, void *data)
Sets the indication function invoked when an NMT command is received.
@ ERRNUM_INVAL
Invalid argument.
int srv
The service number (CO_GW_SRV__TIME).
#define CO_GW_SRV_NMT_STOP
CANopen gateway service: Start node.
const struct co_pdo_map_par * co_rpdo_get_map_par(const co_rpdo_t *pdo)
Returns a pointer to the PDO mapping parameter record of a Receive-PDO.
uint_least8_t val[1]
The (first byte in the) value.
The parameters of a CANopen gateway 'Inquire LSS address' request.
The parameters of a Lely-specific gateway 'Synchronization event received' indication.
co_nmt_sdo_ind_t * dn_ind
A pointer to the original SDO download progress indication function.
co_unsigned8_t n
Number of mapped objects in PDO.
static void co_gw_job_lss_err_ind(co_lss_t *lss, co_unsigned8_t cs, co_unsigned8_t err, co_unsigned8_t spec, void *data)
The confirmation function for an 'LSS configure node-ID', 'LSS configure bit-rate' or 'LSS store conf...
static void co_gw_net_st_ind(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st, void *data)
The callback function invoked when a boot-up event or state change is detected for a node on a CANope...
co_unsigned8_t er
The error register.
#define CO_GW_SRV_SET_SDO_TIMEOUT
CANopen gateway service: Configure SDO time-out.
co_unsigned8_t trans
The transmission type.
co_gw_t * co_gw_create(void)
Creates a new CANopen gateway.
co_unsigned32_t co_pdo_map(const struct co_pdo_map_par *par, const co_unsigned64_t *val, co_unsigned8_t n, uint_least8_t *buf, size_t *pn)
Maps values into a PDO.
void co_lss_set_timeout(co_lss_t *lss, int timeout)
Sets the timeout of an LSS master service.
void co_gw_get_rate_func(const co_gw_t *gw, co_gw_rate_func_t **pfunc, void **pdata)
Retrieves the callback function invoked when a baudrate switch is needed after an 'Initialize gateway...
#define CO_GW_SRV_NMT_HB_DISABLE
CANopen gateway service: Disable heartbeat consumer.
size_t size
The size of this struct (in bytes).
The parameters of a CANopen gateway 'Write PDO' request.
#define CO_GW_IEC_BAD_SRV
CANopen gateway internal error: Request not supported.
void * data
A pointer to user-specified data.
The parameters of a CANopen gateway 'Get version' confirmation.
co_unsigned8_t n
Number of mapped objects in PDO.
static void co_gw_job_sdo_dn_con(co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned32_t ac, void *data)
The confirmation function for an 'SDO download' request.
int co_nmt_cs_ind(co_nmt_t *nmt, co_unsigned8_t cs)
Processes an NMT command from the master or the application.
#define CO_GW_IEC_LSS
CANopen gateway internal error: LSS error.
A CANopen NMT master/slave service.
#define CO_SDO_REQ_INIT
The static initializer for struct co_sdo_req.
co_unsigned16_t num
The PDO number.
co_unsigned32_t co_sub_dn_ind_val(co_sub_t *sub, co_unsigned16_t type, const void *val)
Invokes the download indication function of a CANopen sub-object, registered with co_sub_set_dn_ind()...
#define CO_SDO_AC_PDO_LEN
SDO abort code: The number and length of the objects to be mapped would exceed the PDO length.
#define CO_GW_SRV_SET_CMD_SIZE
CANopen gateway service: Set command size.
co_rpdo_t * co_nmt_get_rpdo(const co_nmt_t *nmt, co_unsigned16_t n)
Returns a pointer to a Receive-PDO service.
static int co_gw_recv_set_hb(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes a 'Set heartbeat producer' request.
@ CO_NMT_EC_OCCURRED
An NMT error control event occurred.
int co_nmt_set_id(co_nmt_t *nmt, co_unsigned8_t id)
Sets the pending node-ID.
void co_nmt_get_hb_ind(const co_nmt_t *nmt, co_nmt_hb_ind_t **pind, void **pdata)
Retrieves the indication function invoked when a heartbeat event occurs.
#define CO_GW_IEC_LSS_ID
CANopen gateway internal error: LSS node-ID not supported.
The parameters of a Lely-specific gateway 'Boot slave process completed' indication.
static void co_gw_net_lg_ind(co_nmt_t *nmt, int state, void *data)
The callback function invoked when a life guarding event occurs for a CANopen gateway.
co_unsigned16_t num
The PDO number.
#define CO_GW_SRV__LSS_SLOWSCAN
Lely-specific gateway service: LSS Slowscan.
co_unsigned16_t num
The PDO number.
void * rate_data
A pointer to the user-specified data for rate_func.
void * send_data
A pointer to the user-specified data for send_func.
#define CO_NMT_CS_RESET_NODE
The NMT command specifier 'reset node'.
co_unsigned16_t co_rpdo_get_num(const co_rpdo_t *pdo)
Returns the PDO number of a Receive-PDO.
co_gw_send_func_t * send_func
A pointer to the callback function invoked when an indication or confirmation needs to be sent.
void co_nmt_set_st_ind(co_nmt_t *nmt, co_nmt_st_ind_t *ind, void *data)
Sets the indication function invoked when a state change is detected.
#define CO_GW_SRV_SET_NODE
CANopen gateway service: Set default node-ID.
The parameters of a CANopen gateway 'Configure TPDO' request.
int co_tpdo_event(co_tpdo_t *pdo)
Triggers the transmission of an acyclic or event-driven PDO.
#define CO_GW_SRV_SET_RPDO
CANopen gateway service: Configure RPDO.
int co_gw_recv(co_gw_t *gw, const struct co_gw_req *req)
Receives and processes a request with a CANopen gateway.
co_nmt_hb_ind_t * hb_ind
A pointer to the original heartbeat event indication function.
co_unsigned16_t idx
The object index.
co_unsigned16_t net
The network-ID.
int co_lss_id_slave_req(co_lss_t *lss, const struct co_id *lo, const struct co_id *hi, co_lss_cs_ind_t *ind, void *data)
Requests the 'LSS identify remote slave' service.
@ ERRNUM_PERM
Operation not permitted.
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.
static int co_gw_recv_lss_get_id(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes an 'LSS inquire node-ID' request.
co_unsigned8_t subidx
The object sub-index.
void co_nmt_st_ind_t(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st, void *data)
The type of a CANopen NMT state change indication function, invoked when a state change is detected b...
The parameters of a CANopen gateway 'Configure RPDO' request.
co_unsigned8_t node
The node-ID.
#define CO_GW_IEC_BAD_NODE
CANopen gateway internal error: Unsupported node.
The parameters of a CANopen gateway 'Emergency event received' indication.
int co_csdo_up_req(co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, co_csdo_up_con_t *con, void *data)
Submits an upload request to a remote Server-SDO.
static int co_gw_recv_pdo_write(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes a 'Write PDO data' request.
int srv
The service number (CO_GW_SRV_EMCY).
co_unsigned8_t n
Number of mapped objects in PDO.
int co_gw_fini_net(co_gw_t *gw, co_unsigned16_t id)
Unregisters a CANopen network with a gateway.
static int co_gw_recv_lss_id_non_cfg_slave(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes an 'LSS identify non-configured remote slaves' request.
co_unsigned64_t val[0x40]
An array of object values.
static int co_gw_send_srv(co_gw_t *gw, const struct co_gw_srv *srv)
Invokes the callback function to send a confirmation or indication.
void * ng_data
A pointer to user-specified data for ng_ind.
int iec
The internal error code (0 on success).
The parameters of a CANopen gateway 'Set command time-out' request.
#define CO_BAUD_1000
A bit rate of 1 Mbit/s.
void co_rpdo_set_ind(co_rpdo_t *pdo, co_rpdo_ind_t *ind, void *data)
Sets the indication function invoked when a Receive-PDO error occurs.
static void co_gw_net_cs_ind(co_nmt_t *nmt, co_unsigned8_t cs, void *data)
The callback function invoked when an NMT command is received by a CANopen gateway.
void co_csdo_set_timeout(co_csdo_t *sdo, int timeout)
Sets the timeout of a Client-SDO.
void co_nmt_set_timeout(co_nmt_t *nmt, int timeout)
Sets the default SDO timeout used during the NMT 'boot slave' and 'check configuration' processes.
const void * buf
A pointer to the next bytes to be uploaded/downloaded.
size_t size
The size of this struct (in bytes).
void co_nmt_set_boot_ind(co_nmt_t *nmt, co_nmt_boot_ind_t *ind, void *data)
Sets the indication function invoked when a CANopen NMT 'boot slave' process completes.
static void co_gw_job_lss_nid_ind(co_lss_t *lss, co_unsigned8_t cs, co_unsigned8_t id, void *data)
The confirmation function for an 'LSS inquire node-ID' request.
static void co_gw_net_dn_ind(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned16_t idx, co_unsigned8_t subidx, size_t size, size_t nbyte, void *data)
The callback function invoked to notify the user of the progress of an SDO download request during th...
#define CO_GW_IEC_LSS_MEDIA
CANopen gateway internal error: LSS command failed because of media error.
co_unsigned16_t net
The network-ID.
co_unsigned8_t node
The node-ID.
#define CO_GW_IEC_CAN_BUSOFF
CANopen gateway internal error: Bus off.
#define CO_GW_IEC_NG_OCCURRED
CANopen gateway internal error: Lost guarding message.
co_nmt_lg_ind_t * lg_ind
A pointer to the original life guarding event indication function.
void co_gw_set_rate_func(co_gw_t *gw, co_gw_rate_func_t *func, void *data)
Sets the callback function invoked when a baudrate switch is needed after an 'Initialize gateway' com...
co_time_t * co_nmt_get_time(const co_nmt_t *nmt)
Returns a pointer to the TIME producer/consumer service.
const struct co_pdo_comm_par * co_rpdo_get_comm_par(const co_rpdo_t *pdo)
Returns a pointer to the PDO communication parameter record of a Receive-PDO.
co_unsigned16_t net
The network-ID.
co_unsigned8_t st
The the state of the node (including the toggle bit).
static int co_gw_recv_get_version(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes a 'Get version' request.
The parameters of a CANopen gateway 'LSS switch state global' request.
co_unsigned16_t net
The network-ID.
co_unsigned16_t id
The network-ID.
#define CO_GW_PROT_LO
The low number of the version of CiA 309-1 implemented by this gateway.
co_unsigned16_t inhibit
The inhibit time.
#define CO_GW_SRV_NMT_HB_ENABLE
CANopen gateway service: Start heartbeat consumer.
int srv
The service number (CO_GW_SRV_LSS_GET_LSSID).
co_unsigned16_t event
The event timer.
co_unsigned8_t def
The default node-ID.
int srv
The service number (CO_GW_SRV_PDO_READ).
size_t size
The size of this struct (in bytes).
co_unsigned32_t ac
The SDO abort code (0 on success).
struct co_id hi
The upper bound of the LSS address.
static int co_gw_send_con(co_gw_t *gw, const struct co_gw_req *req, int iec, co_unsigned32_t ac)
Sends a confirmation with an internal error code or SDO abort code.
enum errnum errnum_t
The platform-independent error number type.
int co_lss_set_id_req(co_lss_t *lss, co_unsigned8_t id, co_lss_err_ind_t *ind, void *data)
Requests the 'configure node-ID' service.
int srv
The service number (CO_GW_SRV__BOOT).
struct co_gw_net * net
A pointer to the CANopen network.
void co_emcy_set_ind(co_emcy_t *emcy, co_emcy_ind_t *ind, void *data)
Sets the indication function invoked when a CANopen EMCY message is received.
void * data
A pointer to user-specified data.
#define CO_GW_SRV_LSS_SWITCH_RATE
CANopen gateway service: LSS activate new bit-rate.
int co_lss_switch_sel_req(co_lss_t *lss, const struct co_id *id, co_lss_cs_ind_t *ind, void *data)
Requests the 'switch state selective' service.
co_unsigned32_t co_pdo_dn(const struct co_pdo_map_par *par, co_dev_t *dev, struct co_sdo_req *req, const uint_least8_t *buf, size_t n)
Writes mapped PDO values to the object dictionary through a local SDO download request.
static void co_gw_job_remove(struct co_gw_job *job)
Removes a CANopen gateway network job from its network.
size_t size
The size of this struct (in bytes).
size_t size
The size of this struct (in bytes).
#define CO_GW_CON_SDO_UP_SIZE
The minimum size (in bytes) of a CANopen gateway 'SDO upload' confirmation.
The common parameters of a CANopen gateway service.
#define CO_PDO_MAP_PAR_INIT
The static initializer from struct co_pdo_map_par.
static void co_gw_job_sdo_up_con(co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned32_t ac, const void *ptr, size_t n, void *data)
The confirmation function for an 'SDO upload' request.
The parameters of a Lely-specific gateway 'Time stamp event received' indication.
static int co_gw_recv_set_rpdo(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes a 'Configure RPDO' request.
#define CO_NMT_CS_RESET_COMM
The NMT command specifier 'reset communication'.
#define CO_GW_SRV__TIME
Lely-specific gateway service: Time stamp event received.
#define CO_GW_SRV_LSS_SET_RATE
CANopen gateway service: LSS configure bit-rate.
int co_lss_get_product_code_req(co_lss_t *lss, co_lss_lssid_ind_t *ind, void *data)
Requests the 'inquire identity product-code' service.
void co_csdo_set_up_ind(co_csdo_t *sdo, co_csdo_ind_t *ind, void *data)
Sets the indication function used to notify the user of the progress of the current SDO upload reques...
co_unsigned16_t def
The default network-ID.
int co_csdo_dn_req(co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, const void *ptr, size_t n, co_csdo_dn_con_t *con, void *data)
Submits a download request to a remote Server-SDO.
size_t size
The size of this struct (in bytes).
static void co_gw_job_lss_cs_ind(co_lss_t *lss, co_unsigned8_t cs, void *data)
The confirmation function for an 'LSS switch state selective', 'LSS identify remote slave' or 'LSS id...
void co_sdo_req_fini(struct co_sdo_req *req)
Finalizes a CANopen SDO upload/download request.
#define CO_BAUD_500
A bit rate of 500 kbit/s.
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.
static int co_gw_recv_lss_set_rate(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes an 'LSS configure bit-rate' request.
co_unsigned16_t net
The network-ID.
#define CO_NMT_ST_START
The NMT state 'operational'.
co_unsigned8_t node
The node-ID.
static struct co_gw_job * co_gw_job_create_lss(struct co_gw_job **pself, struct co_gw_net *net, const struct co_gw_req *req)
Creates a new LSS job.
void co_gw_set_send_func(co_gw_t *gw, co_gw_send_func_t *func, void *data)
Sets the callback function used to send indications and confirmations from a CANopen gateway.
static int co_gw_recv_set_net(co_gw_t *gw, const struct co_gw_req *req)
Processes a 'Set default network' request.
co_nmt_boot_ind_t * boot_ind
A pointer to the original 'boot slave' indication function.
co_unsigned32_t ac
The SDO abort code (0 on success).
unsigned int co_dev_get_baud(const co_dev_t *dev)
Returns the supported bit rates of a CANopen device (any combination of CO_BAUD_1000,...
int srv
The service number (CO_GW_SRV_LSS_GET_ID).
int co_lss_get_id_req(co_lss_t *lss, co_lss_nid_ind_t *ind, void *data)
Requests the 'inquire node-ID' service.
int co_nmt_ng_req(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned16_t gt, co_unsigned8_t ltf)
Request the node guarding service for the specified node, even if it is not in the network list.
void co_csdo_set_dn_ind(co_csdo_t *sdo, co_csdo_ind_t *ind, void *data)
Sets the indication function used to notify the user of the progress of the current SDO download requ...
A CANopen gateway network job.
void co_nmt_set_lg_ind(co_nmt_t *nmt, co_nmt_lg_ind_t *ind, void *data)
Sets the indication function invoked when a life guarding event occurs.
#define CO_GW_REQ_PDO_WRITE_SIZE
The minimum size (in bytes) of a CANopen gateway 'Write PDO' request.
int co_lss_fastscan_req(co_lss_t *lss, const struct co_id *id, const struct co_id *mask, co_lss_scan_ind_t *ind, void *data)
Requests the 'LSS Fastscan' service.
co_unsigned8_t msef[5]
The manufacturer-specific error code.
struct co_gw_job ** pself
The address of the pointer to this job in the network.
errnum_t get_errnum(void)
Returns the last (thread-specific) platform-independent error number set by a system call or library ...
The parameters of a Lely-specific gateway 'LSS Slowscan/Fastscan' confirmation.
void co_gw_destroy(co_gw_t *gw)
Destroys a CANopen gateway.
#define CO_GW_SRV_LSS_SET_ID
CANopen gateway service: LSS configure node-ID.
void * hb_data
A pointer to user-specified data for hb_ind.
void co_nmt_get_st_ind(const co_nmt_t *nmt, co_nmt_st_ind_t **pind, void **pdata)
Retrieves the indication function invoked when a state change is detected.
void(* dtor)(void *data)
A pointer to the destructor for data.
static void co_gw_net_emcy_ind(co_emcy_t *emcy, co_unsigned8_t id, co_unsigned16_t ec, co_unsigned8_t er, co_unsigned8_t msef[5], void *data)
The callback function invoked when an EMCY message is received from a node on a CANopen network.
int co_gw_init_net(co_gw_t *gw, co_unsigned16_t id, co_nmt_t *nmt)
Registers a CANopen network with a gateway.
#define CO_GW_IEC_BOOTUP
CANopen gateway internal error: Boot-up.
co_lss_t * co_nmt_get_lss(const co_nmt_t *nmt)
Returns a pointer to the LSS master/slave service.
The parameters of a CANopen gateway 'SDO upload' request.
#define CO_GW_IEC_CAN_ACTIVE
CANopen gateway internal error: CAN active.
co_unsigned32_t cobid
The COB-ID.
#define CO_GW_SRV_EMCY_STOP
CANopen gateway service: Stop emergency consumer.
A PDO mapping parameter record.
co_emcy_t * co_nmt_get_emcy(const co_nmt_t *nmt)
Returns a pointer to the EMCY producer/consumer service.
#define CO_GW_SRV_NMT_RESET_NODE
CANopen gateway service: Reset node.
#define CO_GW_SRV_SDO
CANopen gateway service: CiA 301 progress indication download.
static void co_gw_net_time_ind(co_time_t *time, const struct timespec *tp, void *data)
The callback function invoked when a TIME message is received from a node on a CANopen network.
#define CO_GW_SRV_SET_HB
CANopen gateway service: Set heartbeat producer.
@ CO_NMT_EC_STATE
An NMT error control state change event.
static void co_gw_net_hb_ind(co_nmt_t *nmt, co_unsigned8_t id, int state, int reason, void *data)
The callback function invoked when a heartbeat event occurs for a node on a CANopen network.
int timeout
The command timeout (in milliseconds).
size_t size
The size of this struct (in bytes).
const struct co_pdo_map_par * co_tpdo_get_map_par(const co_tpdo_t *pdo)
Returns a pointer to the PDO mapping parameter record of a Transmit-PDO.
co_unsigned16_t net
The network-ID.
void * data
A pointer to user-specified data.
The parameters of a CANopen gateway 'Error control event received' indication.
A CANopen SYNC producer/consumer service.
co_unsigned32_t len
The length of the value (in bytes).
static int co_gw_recv_set_emcy(co_gw_t *gw, co_unsigned16_t net, co_unsigned8_t node, const struct co_gw_req *req)
Processes a 'Start/Stop emergency consumer' request.
#define CO_GW_SRV_INIT
CANopen gateway service: Initialize gateway.
co_nmt_t * nmt
A pointer to a CANopen NMT master/slave service.
#define CO_GW_IND_RPDO_SIZE
The minimum size (in bytes) of a CANopen gateway 'RPDO received' indication.
co_unsigned8_t co_csdo_get_num(const co_csdo_t *sdo)
Returns the SDO number of a Client-SDO.
#define CO_GW_SRV_LSS_ID_SLAVE
CANopen gateway service: LSS identify remote slave.
int co_lss_get_revision_req(co_lss_t *lss, co_lss_lssid_ind_t *ind, void *data)
Requests the 'inquire identity revision-number' service.
static int co_gw_recv_sdo_up(co_gw_t *gw, co_unsigned16_t net, co_unsigned8_t node, const struct co_gw_req *req)
Processes an 'SDO upload' request.
int co_lss_switch_rate_req(co_lss_t *lss, int delay)
Requests the 'activate bit timing parameters' service.
#define CO_BAUD_800
A bit rate of 800 kbit/s.
#define CO_GW_SRV_PDO_READ
CANopen gateway service: Read PDO data.
co_unsigned8_t trans
The transmission type.
struct co_id id_1
In case of an LSS Slowscan request, the lower bound of the LSS address; in case of an LSS Fastscan re...
size_t size
The size of this struct (in bytes).
#define CO_GW_IEC_SYNTAX
CANopen gateway internal error: Syntax error.
co_unsigned32_t map[0x40]
An array of objects to be mapped.
@ ERRNUM_NOSYS
Function not supported.
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.
int co_lss_get_vendor_id_req(co_lss_t *lss, co_lss_lssid_ind_t *ind, void *data)
Requests the 'inquire identity vendor-ID' service.
co_unsigned32_t map[0x40]
An array of objects to be mapped.
co_unsigned32_t co_pdo_unmap(const struct co_pdo_map_par *par, const uint_least8_t *buf, size_t n, co_unsigned64_t *val, co_unsigned8_t *pn)
Unmaps a PDO into its constituent values.
void * data
A pointer to user-specified data of the SDO upload/download request.
struct co_id id
The LSS address of the slave to be configured.
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.
The common parameters of a CANopen gateway node-level request.
int srv
The service number (CO_GW_SRV_LSS_GET_LSSID).
static int co_gw_recv_pdo_read(co_gw_t *gw, co_unsigned16_t net, const struct co_gw_req *req)
Processes a 'Read PDO data' request.