26 #ifndef LELY_NO_CO_MASTER 39 #ifndef LELY_CO_NMT_BOOT_WAIT_TIMEOUT 40 #define LELY_CO_NMT_BOOT_WAIT_TIMEOUT 1000 44 #ifndef LELY_CO_NMT_BOOT_SDO_RETRY 45 #define LELY_CO_NMT_BOOT_SDO_RETRY 3 49 #ifndef LELY_CO_NMT_BOOT_RTR_TIMEOUT 50 #define LELY_CO_NMT_BOOT_RTR_TIMEOUT 100 54 #ifndef LELY_CO_NMT_BOOT_RESET_TIMEOUT 59 #define LELY_CO_NMT_BOOT_RESET_TIMEOUT 1000 62 #ifndef LELY_CO_NMT_BOOT_CHECK_TIMEOUT 67 #define LELY_CO_NMT_BOOT_CHECK_TIMEOUT 100 131 co_unsigned8_t subidx, co_unsigned32_t ac,
void *data);
140 co_unsigned8_t subidx, co_unsigned32_t ac,
const void *ptr,
141 size_t n,
void *data);
150 co_unsigned32_t ac,
void *data);
198 co_unsigned32_t ac,
const void *ptr,
size_t n);
258 co_unsigned32_t ac,
const void *ptr,
size_t n);
274 #define LELY_CO_DEFINE_STATE(name, ...) \ 275 static co_nmt_boot_state_t *const name = \ 276 &(co_nmt_boot_state_t){ __VA_ARGS__ }; 471 co_unsigned32_t ac, const
void *ptr,
size_t n);
496 co_unsigned32_t ac, const
void *ptr,
size_t n);
596 co_unsigned32_t ac, const
void *ptr,
size_t n);
640 co_unsigned32_t ac, const
void *ptr,
size_t n);
736 #undef LELY_CO_DEFINE_STATE 751 co_unsigned8_t subidx, co_unsigned16_t type,
const void *val);
764 co_unsigned8_t subidx);
780 co_unsigned8_t subidx,
const void *ptr,
size_t n);
790 __co_nmt_boot_alloc(
void)
799 __co_nmt_boot_free(
void *ptr)
824 goto error_create_recv;
831 goto error_create_timer;
840 boot->
start = (
struct timespec){ 0, 0 };
884 goto error_alloc_boot;
887 if (!__co_nmt_boot_init(boot, net, dev, nmt)) {
889 goto error_init_boot;
895 __co_nmt_boot_free(boot);
905 __co_nmt_boot_fini(boot);
906 __co_nmt_boot_free(boot);
968 co_unsigned32_t ac,
void *data)
981 co_unsigned32_t ac,
const void *ptr,
size_t n,
void *data)
1024 assert(boot->
state);
1034 assert(boot->
state);
1044 assert(boot->
state);
1052 const void *ptr,
size_t n)
1055 assert(boot->
state);
1065 assert(boot->
state);
1087 co_unsigned8_t n = co_obj_get_val_u8(obj_1016, 0x00);
1088 for (
size_t i = 1; i <= n; i++) {
1089 co_unsigned32_t val =
1090 co_obj_get_val_u32(obj_1016, i & 0xff);
1091 if (((val >> 16) & 0x7f) == boot->
id)
1092 boot->
ms = val & 0xffff;
1124 if (boot->
es ==
'B') {
1129 co_unsigned32_t boot_time = co_dev_get_val_u32(
1130 boot->
dev, 0x1f89, 0x00);
1133 struct timespec now = { 0, 0 };
1186 const void *ptr,
size_t n)
1198 "SDO abort code %08" PRIX32
1199 " received on upload request of object 1000 (Device type) to node %02X: %s",
1206 co_unsigned32_t device_type =
1207 co_dev_get_val_u32(boot->
dev, 0x1f84, boot->
id);
1224 co_unsigned32_t vendor_id =
1225 co_dev_get_val_u32(boot->
dev, 0x1f85, boot->
id);
1240 const void *ptr,
size_t n)
1246 "SDO abort code %08" PRIX32
1247 " received on upload request of sub-object 1018:01 (Vendor-ID) to node %02X: %s",
1263 co_unsigned32_t product_code =
1264 co_dev_get_val_u32(boot->
dev, 0x1f86, boot->
id);
1279 const void *ptr,
size_t n)
1285 "SDO abort code %08" PRIX32
1286 " received on upload request of sub-object 1018:02 (Product code) to node %02X: %s",
1302 co_unsigned32_t revision =
1303 co_dev_get_val_u32(boot->
dev, 0x1f87, boot->
id);
1318 const void *ptr,
size_t n)
1324 "SDO abort code %08" PRIX32
1325 " received on upload request of sub-object 1018:03 (Revision number) to node %02X: %s",
1341 co_unsigned32_t serial_nr =
1342 co_dev_get_val_u32(boot->
dev, 0x1f88, boot->
id);
1357 const void *ptr,
size_t n)
1363 "SDO abort code %08" PRIX32
1364 " received on upload request of sub-object 1018:04 (Serial number) to node %02X: %s",
1415 if (msg->
len >= 1) {
1492 co_unsigned32_t sw_id =
1493 co_dev_get_val_u32(boot->
dev, 0x1f55, boot->
id);
1513 const void *ptr,
size_t n)
1526 "SDO abort code %08" PRIX32
1527 " received on upload request of sub-object 1F56:01 (Program software identification) to node %02X: %s",
1571 "SDO abort code %08" PRIX32
1572 " received on download request of sub-object 1F51:01 (Program control) to node %02X: %s",
1582 const void *ptr,
size_t n)
1588 co_unsigned8_t val = 0;
1591 (
const uint_least8_t *)ptr + n) && !val)
1599 &(co_unsigned8_t){ 0 }) == -1)
1630 &(co_unsigned8_t){ 3 }) == -1)
1636 "SDO abort code %08" PRIX32
1637 " received on download request of sub-object 1F51:01 (Program control) to node %02X: %s",
1661 "SDO abort code %08" PRIX32
1662 " on upload request of object 1F58:%02X (Program data): %s",
1689 return co_nmt_boot_abort_state;
1732 "SDO abort code %08" PRIX32
1733 " received on download request of sub-object 1F50:01 (Program data) to node %02X: %s",
1761 return co_nmt_boot_abort_state;
1768 const void *ptr,
size_t n)
1774 "SDO abort code %08" PRIX32
1775 " received on upload request of sub-object 1F57:01 (Flash status indication) to node %02X: %s",
1779 co_unsigned32_t val = 0;
1782 (
const uint_least8_t *)ptr + n) || (val & 0x01))
1786 co_unsigned8_t
st = (val >> 1) & 0x7f;
1791 "flash status identification %d: No valid program available",
1796 "flash status identification %d: Data format unknown",
1801 "flash status identification %d: Data format error or data CRC error",
1806 "flash status identification %d: Flash not cleared before write",
1811 "flash status identification %d: Flash write error",
1816 "flash status identification %d: General address error",
1821 "flash status identification %d: Flash secured (= write access currently forbidden)",
1826 "flash status identification %d: Unspecified error",
1832 "flash status identification %d: Manufacturer-specific error: 0x%08" PRIX32
1834 st, (val >> 16) & 0xffff);
1856 const void *ptr,
size_t n)
1862 "SDO abort code %08" PRIX32
1863 " received on upload request of sub-object 1F56:01 (Program software identification) to node %02X: %s",
1881 &(co_unsigned8_t){ 1 }) == -1)
1895 "SDO abort code %08" PRIX32
1896 " received on download request of sub-object 1F51:01 (Program control) to node %02X: %s",
1934 const void *ptr,
size_t n)
1946 "SDO abort code %08" PRIX32
1947 " received on upload request of sub-object 1F51:01 (Program control) to node %02X: %s",
1953 co_unsigned8_t val = 0;
1956 (
const uint_least8_t *)ptr + n) || val != 1)
1973 co_unsigned32_t cfg_date =
1974 co_dev_get_val_u32(boot->
dev, 0x1f26, boot->
id);
1975 co_unsigned32_t cfg_time =
1976 co_dev_get_val_u32(boot->
dev, 0x1f27, boot->
id);
1977 if (!cfg_date || !cfg_time)
1991 const void *ptr,
size_t n)
2004 "SDO abort code %08" PRIX32
2005 " received on upload request of sub-object 1020:01 (Configuration date) to node %02X: %s",
2023 const void *ptr,
size_t n)
2029 "SDO abort code %08" PRIX32
2030 " received on upload request of sub-object 1020:02 (Configuration time) to node %02X: %s",
2064 "SDO abort code %08" PRIX32
2065 " received while updating the configuration of node %02X: %s",
2089 co_unsigned16_t gt = (boot->
assignment >> 16) & 0xffff;
2105 if (msg->
len >= 1) {
2106 co_unsigned8_t
st = msg->
data[0];
2128 co_unsigned16_t type,
const void *val)
2147 const void *ptr,
size_t n)
2157 if (!
co_val_read(type, &val, ptr, (
const uint_least8_t *)ptr + n))
2177 #endif // !LELY_NO_CO_MASTER static co_nmt_boot_state_t * co_nmt_boot_stop_prog_on_enter(co_nmt_boot_t *boot)
The entry function of the 'stop program' state.
static co_nmt_boot_state_t *const co_nmt_boot_abort_state
The 'abort' state.
int co_nmt_cs_req(co_nmt_t *nmt, co_unsigned8_t cs, co_unsigned8_t id)
Submits an NMT request to a slave.
A CANopen SDO upload/download request.
A CAN or CAN FD format frame.
#define CO_NUM_NODES
The maximum number of nodes in a CANopen network.
static void co_nmt_boot_emit_dn_con(co_nmt_boot_t *boot, co_unsigned32_t ac)
Invokes the 'SDO download confirmation' transition function of the current state of a 'boot slave' se...
void co_csdo_set_timeout(co_csdo_t *sdo, int timeout)
Sets the timeout of a Client-SDO.
uint_least32_t id
The identifier (11 or 29 bits, depending on the CAN_FLAG_IDE flag).
A CANopen NMT 'boot slave' state.
static co_nmt_boot_state_t * co_nmt_boot_chk_product_code_on_up_con(co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
The 'SDO upload confirmation' transition function of the 'check product code' state.
A CANopen NMT 'boot slave' service.
static void co_nmt_boot_error_on_leave(co_nmt_boot_t *boot)
The exit function of the 'error' state.
#define CO_NMT_ST_START
The NMT state 'operational'.
uint_least8_t len
The number of bytes in data (or the requested number of bytes in case of a remote frame)...
static int co_nmt_boot_chk(co_nmt_boot_t *boot, co_unsigned16_t idx, co_unsigned8_t subidx, const void *ptr, size_t n)
Compares the result of an SDO upload request to the value of a local sub-object.
size_t size
The total size (in bytes) of the value to be uploaded/downloaded.
static void co_nmt_boot_emit_time(co_nmt_boot_t *boot, const struct timespec *tp)
Invokes the 'timeout' transition function of the current state of a 'boot slave' service.
static void co_nmt_boot_dn_con(co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned32_t ac, void *data)
The CANopen SDO download confirmation callback function for a 'boot slave' service.
static co_nmt_boot_state_t * co_nmt_boot_up_cfg_on_cfg_con(co_nmt_boot_t *boot, co_unsigned32_t ac)
The 'configuration request confirmation' transition unction of the 'update configuration' state...
static co_nmt_boot_state_t * co_nmt_boot_chk_node_on_time(co_nmt_boot_t *boot, const struct timespec *tp)
The 'timeout' transition function of the 'check node state' state.
int co_nmt_cfg_req(co_nmt_t *nmt, co_unsigned8_t id, int timeout, co_nmt_cfg_con_t *con, void *data)
Issues the NMT 'configuration request' for the specified node.
static co_nmt_boot_state_t * co_nmt_boot_chk_device_type_on_enter(co_nmt_boot_t *boot)
The entry function of the 'check device type' state.
static co_nmt_boot_state_t * co_nmt_boot_chk_serial_nr_on_up_con(co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
The 'SDO upload confirmation' transition function of the 'check serial number' state.
void(* on_leave)(co_nmt_boot_t *boot)
A pointer to the function invoked when the current state is left.
void can_timer_timeout(can_timer_t *timer, can_net_t *net, int timeout)
Starts a CAN timer and registers it with a network interface.
static co_nmt_boot_state_t *const co_nmt_boot_chk_product_code_state
The 'check product code' state (see Fig. 5 in CiA 302-2 version 4.1.0).
void co_nmt_boot_con(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st, char es)
The CANopen NMT 'boot slave' confirmation function, invoked when the 'boot slave' process completes...
#define LELY_CO_NMT_BOOT_RESET_TIMEOUT
The timeout (in milliseconds) after sending the NMT 'reset communication' command.
void co_nmt_boot_destroy(co_nmt_boot_t *boot)
Destroys a CANopen NMT 'boot slave' service.
co_nmt_boot_state_t *(* on_recv)(co_nmt_boot_t *boot, const struct can_msg *msg)
A pointer to the transition function invoked when a CAN frame has been received.
void co_sdo_req_clear(struct co_sdo_req *req)
Clears a CANopen SDO upload/download request, including its buffer.
#define LELY_CO_NMT_BOOT_WAIT_TIMEOUT
The timeout (in milliseconds) before trying to boot the slave again.
static co_nmt_boot_state_t *const co_nmt_boot_reset_comm_state
The 'reset communication' state (see Fig. 6 in CiA 302-2 version 4.1.0).
#define CO_NMT_ST_TOGGLE
The mask to get/set the toggle bit from an NMT state.
void set_errnum(errnum_t errnum)
Sets the current (thread-specific) platform-independent error number to errnum.
co_unsigned16_t ms
The consumer heartbeat time (in milliseconds).
void diag(enum diag_severity severity, int errc, const char *format,...)
Emits a diagnostic message.
static co_nmt_boot_state_t * co_nmt_boot_chk_serial_nr_on_enter(co_nmt_boot_t *boot)
The entry function of the 'check serial number' state.
co_nmt_boot_state_t *(* on_cfg_con)(co_nmt_boot_t *boot, co_unsigned32_t ac)
A pointer to the transition function invoked when an NMT 'configuration request' completes.
static int co_nmt_boot_up(co_nmt_boot_t *boot, co_unsigned16_t idx, co_unsigned8_t subidx)
Issues an SDO upload request to the slave.
A union of the CANopen static data types.
void can_net_get_time(const can_net_t *net, struct timespec *tp)
Retrieves the current time of a CAN network interface.
static co_nmt_boot_state_t * co_nmt_boot_chk_device_type_on_up_con(co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
The 'SDO upload confirmation' transition function of the 'check device type' state.
int co_nmt_boot_boot_req(co_nmt_boot_t *boot, co_unsigned8_t id, int timeout, co_csdo_ind_t *dn_ind, co_csdo_ind_t *up_ind, void *data)
Starts a CANopen NMT 'boot slave' service.
static co_nmt_boot_state_t * co_nmt_boot_chk_sw_on_enter(co_nmt_boot_t *boot)
The entry function of the 'check software' state.
static co_nmt_boot_state_t * co_nmt_boot_reset_comm_on_time(co_nmt_boot_t *boot, const struct timespec *tp)
The 'timeout' transition function of the 'reset communication' state.
static co_nmt_boot_state_t *const co_nmt_boot_wait_prog_state
The 'wait till program is started' state (see Fig.
static int co_nmt_boot_recv(const struct can_msg *msg, void *data)
The CAN receive callback function for a 'boot slave' service.
co_nmt_boot_state_t *(* on_dn_con)(co_nmt_boot_t *boot, co_unsigned32_t ac)
A pointer to the transition function invoked when an SDO download request completes.
This is the internal header file of the NMT 'boot slave' declarations.
static co_nmt_boot_state_t * co_nmt_boot_chk_revision_on_enter(co_nmt_boot_t *boot)
The entry function of the 'check revision number' state.
co_dev_t * dev
A pointer to a CANopen device.
#define LELY_CO_NMT_BOOT_RTR_TIMEOUT
The timeout (in milliseconds) after sending a node guarding RTR.
int co_csdo_dn_val_req(co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned16_t type, const void *val, co_csdo_dn_con_t *con, void *data)
Submits a download request to a remote Server-SDO.
static co_nmt_boot_state_t *const co_nmt_boot_chk_cfg_time_state
The 'check configuration time' state (see Fig.
static co_nmt_boot_state_t * co_nmt_boot_wait_flash_on_up_con(co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
The 'SDO upload confirmation' transition function of the 'wait for end of flashing' state...
static co_nmt_boot_state_t * co_nmt_boot_dn_prog_on_enter(co_nmt_boot_t *boot)
The entry function of the 'download program' state.
static co_nmt_boot_state_t * co_nmt_boot_chk_node_on_enter(co_nmt_boot_t *boot)
The entry function of the 'check node state' state.
static co_nmt_boot_state_t * co_nmt_boot_reset_comm_on_enter(co_nmt_boot_t *boot)
The entry function of the 'reset communication' state.
static co_nmt_boot_state_t *const co_nmt_boot_ec_state
The 'start error control' state (see Fig. 11 in CiA 302-2 version 4.1.0).
static co_nmt_boot_state_t *const co_nmt_boot_chk_node_state
The 'check node state' state (see Fig. 6 in CiA 302-2 version 4.1.0).
static void co_nmt_boot_chk_node_on_leave(co_nmt_boot_t *boot)
The exit function of the 'check node state' state.
static co_nmt_boot_state_t * co_nmt_boot_chk_revision_on_up_con(co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
The 'SDO upload confirmation' transition function of the 'check revision number' state.
static co_nmt_boot_state_t *const co_nmt_boot_chk_vendor_id_state
The 'check vendor ID' state (see Fig. 5 in CiA 302-2 version 4.1.0).
This header file is part of the CANopen library; it contains the CANopen value declarations.
static co_nmt_boot_state_t * co_nmt_boot_reset_comm_on_recv(co_nmt_boot_t *boot, const struct can_msg *msg)
The 'CAN frame received' transition function of the 'reset communication' state.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
static co_nmt_boot_state_t *const co_nmt_boot_start_prog_state
The 'start program' state (see Fig. 3 in CiA 302-3 version 4.1.0).
void can_timer_set_func(can_timer_t *timer, can_timer_func_t *func, void *data)
Sets the callback function invoked when a CAN timer is triggered.
int retry
The number of SDO retries remaining.
can_recv_t * can_recv_create(void)
Creates a new CAN frame receiver.
static co_nmt_boot_state_t * co_nmt_boot_chk_vendor_id_on_enter(co_nmt_boot_t *boot)
The entry function of the 'check vendor ID' state.
static co_nmt_boot_state_t * co_nmt_boot_wait_prog_on_up_con(co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
The 'SDO upload confirmation' transition function of the 'wait till program is started' state...
static co_nmt_boot_state_t *const co_nmt_boot_error_state
The 'error' state.
#define CO_DEFTYPE_UNSIGNED32
The data type (and object index) of a 32-bit unsigned integer.
uint_least8_t data[CAN_MSG_MAX_LEN]
The frame payload (in case of a data frame).
static co_nmt_boot_state_t *const co_nmt_boot_up_cfg_state
The 'update configuration' state (see Fig.
This header file is part of the utilities library; it contains the time function declarations.
int co_sdo_req_first(const struct co_sdo_req *req)
Returns 1 if the specified request includes the first segment, and 0 otherwise.
void can_timer_stop(can_timer_t *timer)
Stops a CAN timer and unregisters it with a network interface.
static co_nmt_boot_state_t * co_nmt_boot_stop_prog_on_dn_con(co_nmt_boot_t *boot, co_unsigned32_t ac)
The 'SDO download confirmation' transition function of the 'stop program' state.
co_nmt_boot_state_t *(* on_up_con)(co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
A pointer to the transition function invoked when an SDO upload request completes.
size_t co_val_read(co_unsigned16_t type, void *val, const uint_least8_t *begin, const uint_least8_t *end)
Reads a value of the specified data type from a memory buffer.
can_recv_t * recv
A pointer to the CAN frame receiver.
void can_recv_destroy(can_recv_t *recv)
Destroys a CAN frame receiver.
#define CO_SDO_AC_TIMEOUT
SDO abort code: SDO protocol timed out.
const void * co_sub_get_val(const co_sub_t *sub)
Returns a pointer to the current value of a CANopen sub-object.
The Remote Transmission Request (RTR) flag (unavailable in CAN FD format frames). ...
static co_nmt_boot_state_t * co_nmt_boot_chk_node_on_recv(co_nmt_boot_t *boot, const struct can_msg *msg)
The 'CAN frame received' transition function of the 'check node state' state.
This is the internal header file of the CANopen library.
static co_nmt_boot_state_t * co_nmt_boot_chk_prog_on_up_con(co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
The 'SDO upload confirmation' transition function of the 'check program SW ID' state.
#define LELY_CO_NMT_BOOT_SDO_RETRY
The number of times an SDO request is retried after a timeout.
co_nmt_boot_state_t * state
A pointer to the current state.
static co_nmt_boot_state_t * co_nmt_boot_chk_vendor_id_on_up_con(co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
The 'SDO upload confirmation' transition function of the 'check vendor ID' state. ...
co_unsigned32_t co_sub_up_ind(const co_sub_t *sub, struct co_sdo_req *req)
Invokes the upload indication function of a CANopen sub-object, registered with co_sub_set_up_ind().
#define CO_NMT_ST_BOOTUP
The NMT state 'boot-up'.
static void co_nmt_boot_cfg_con(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned32_t ac, void *data)
The CANopen NMT 'configuration request' confirmation callback function for a 'boot slave' service...
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function...
static co_nmt_boot_state_t * co_nmt_boot_blk_dn_prog_on_enter(co_nmt_boot_t *boot)
The entry function of the 'download program' state.
static co_nmt_boot_state_t * co_nmt_boot_abort_on_enter(co_nmt_boot_t *boot)
The entry function of the 'abort' state.
static co_nmt_boot_state_t *const co_nmt_boot_chk_revision_state
The 'check revision number' state (see Fig. 5 in CiA 302-2 version 4.1.0).
#define CO_NMT_EC_CANID(id)
The CAN identifier used for both node guarding and heartbeat monitoring.
void can_timer_destroy(can_timer_t *timer)
Destroys a CAN timer.
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 NMT master/slave service.
static co_nmt_boot_state_t * co_nmt_boot_start_prog_on_dn_con(co_nmt_boot_t *boot, co_unsigned32_t ac)
The 'SDO download confirmation' transition function of the 'start program' state. ...
#define CO_DEFTYPE_UNSIGNED8
The data type (and object index) of an 8-bit unsigned integer.
static co_nmt_boot_state_t *const co_nmt_boot_chk_serial_nr_state
The 'check serial number' state (see Fig. 5 in CiA 302-2 version 4.1.0).
static void co_nmt_boot_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 CANopen SDO upload confirmation callback function for a 'boot slave' service. ...
static int co_nmt_boot_timer(const struct timespec *tp, void *data)
The CAN timer callback function for a 'boot slave' service.
static co_nmt_boot_state_t * co_nmt_boot_chk_prog_on_enter(co_nmt_boot_t *boot)
The entry function of the 'check program SW ID state.
static co_nmt_boot_state_t *const co_nmt_boot_chk_prog_state
The 'check program SW ID' state (see Fig. 8 in CiA 302-2 version 4.1.0).
static co_nmt_boot_state_t * co_nmt_boot_stop_prog_on_up_con(co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
The 'SDO upload confirmation' transition function of the 'stop program' state.
static co_nmt_boot_state_t * co_nmt_boot_clear_prog_on_dn_con(co_nmt_boot_t *boot, co_unsigned32_t ac)
The 'SDO download confirmation' transition function of the 'clear program' state. ...
int errno2c(int errnum)
Transforms a standard C error number to a native error code.
This header file is part of the utilities library; it contains the diagnostic declarations.
static co_nmt_boot_state_t * co_nmt_boot_chk_product_code_on_enter(co_nmt_boot_t *boot)
The entry function of the 'check product code' state.
void co_csdo_ind_t(const co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, size_t size, size_t nbyte, void *data)
The type of a CANopen Client-SDO request progress indication function, used to notify the user of the...
static co_nmt_boot_state_t * co_nmt_boot_wait_on_time(co_nmt_boot_t *boot, const struct timespec *tp)
The 'timeout' transition function of the 'wait asynchronously' state.
int timeout
The SDO timeout (in milliseconds).
co_unsigned8_t id
The node-ID.
static void co_nmt_boot_emit_up_con(co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
Invokes the 'SDO upload confirmation' transition function of the current state of a 'boot slave' serv...
static co_nmt_boot_state_t * co_nmt_boot_clear_prog_on_enter(co_nmt_boot_t *boot)
The entry function of the 'clear program' state.
int co_val_cmp(co_unsigned16_t type, const void *v1, const void *v2)
Compares two values of the specified data type.
#define LELY_CO_NMT_BOOT_CHECK_TIMEOUT
The timeout (in milliseconds) before checking the flash status indication or the program control of a...
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.
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 co_nmt_boot_state_t *const co_nmt_boot_clear_prog_state
The 'clear program' state (see Fig. 3 in CiA 302-3 version 4.1.0).
const char * co_sdo_ac2str(co_unsigned32_t ac)
Returns a string describing an SDO abort code.
void can_recv_set_func(can_recv_t *recv, can_recv_func_t *func, void *data)
Sets the callback function used to process CAN frames with a receiver.
uint_least8_t flags
The flags (any combination of CAN_FLAG_IDE, CAN_FLAG_RTR, CAN_FLAG_FDF, CAN_FLAG_BRS and CAN_FLAG_ESI...
static co_nmt_boot_state_t * co_nmt_boot_chk_cfg_date_on_up_con(co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
The 'SDO upload confirmation' transition function of the 'check configuration date' state...
static co_nmt_boot_state_t *const co_nmt_boot_blk_dn_prog_state
The 'download program' state (see Fig. 3 in CiA 302-3 version 4.1.0).
static co_nmt_boot_state_t * co_nmt_boot_ec_on_recv(co_nmt_boot_t *boot, const struct can_msg *msg)
The 'CAN frame received' transition function of the 'start error control' state.
static co_nmt_boot_state_t *const co_nmt_boot_chk_sw_state
The 'check software' state (see Fig. 6 in CiA 302-2 version 4.1.0).
int_least64_t timespec_diff_msec(const struct timespec *t1, const struct timespec *t2)
Returns the time difference (in milliseconds) between *t1 and *t2.
can_timer_t * can_timer_create(void)
Creates a new CAN timer.
struct timespec start
The time at which the 'boot slave' request was received.
void co_csdo_destroy(co_csdo_t *sdo)
Destroys a CANopen Client-SDO service.
co_csdo_t * sdo
A pointer to the Client-SDO used to access slave objects.
void can_recv_stop(can_recv_t *recv)
Stops a CAN frame receiver from processing frames and unregisters it with the network interface...
static co_nmt_boot_state_t *const co_nmt_boot_stop_prog_state
The 'stop program' state (see Fig. 3 in CiA 302-3 version 4.1.0).
static void co_nmt_boot_emit_recv(co_nmt_boot_t *boot, const struct can_msg *msg)
Invokes the 'CAN frame received' transition function of the current state of a 'boot slave' service...
co_sub_t * co_dev_find_sub(const co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx)
Finds a sub-object in the object dictionary of a CANopen device.
static co_nmt_boot_state_t * co_nmt_boot_chk_cfg_time_on_up_con(co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
The 'SDO upload confirmation' transition function of the 'check configuration time' state...
static co_nmt_boot_state_t * co_nmt_boot_wait_flash_on_time(co_nmt_boot_t *boot, const struct timespec *tp)
The 'timeout' transition function of the 'wait for end of flashing' state.
void co_val_fini(co_unsigned16_t type, void *val)
Finalizes a value of the specified data type.
int can_net_send(can_net_t *net, const struct can_msg *msg)
Sends a CAN frame from a network interface.
static co_nmt_boot_state_t * co_nmt_boot_wait_prog_on_enter(co_nmt_boot_t *boot)
The entry function of the 'wait till program is started' state.
static co_nmt_boot_state_t *const co_nmt_boot_wait_flash_state
The 'check flashing' state (see Fig. 3 in CiA 302-3 version 4.1.0).
static co_nmt_boot_state_t * co_nmt_boot_blk_dn_prog_on_dn_con(co_nmt_boot_t *boot, co_unsigned32_t ac)
The 'SDO download confirmation' transition function of the 'download program' state.
static co_nmt_boot_state_t *const co_nmt_boot_dn_prog_state
The 'download program' state (see Fig. 3 in CiA 302-3 version 4.1.0).
struct co_sdo_req req
The CANopen SDO upload request used for reading sub-objects.
co_nmt_t * nmt
A pointer to an NMT master service.
static void co_nmt_boot_emit_cfg_con(co_nmt_boot_t *boot, co_unsigned32_t ac)
Invokes the 'configuration request confirmation' transition function of the current state of a 'boot ...
can_timer_t * timer
A pointer to the CAN timer.
void co_sdo_req_init(struct co_sdo_req *req)
Initializes a CANopen SDO upload/download request.
co_unsigned8_t st
The state of the node (including the toggle bit).
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.
This header file is part of the CANopen library; it contains the device description declarations...
const void * buf
A pointer to the next bytes to be uploaded/downloaded.
static co_nmt_boot_state_t * co_nmt_boot_chk_sw_on_up_con(co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
The 'SDO upload confirmation' transition function of the 'check software' state.
can_net_t * net
A pointer to a CAN network interface.
static void co_nmt_boot_enter(co_nmt_boot_t *boot, co_nmt_boot_state_t *next)
Enters the specified state of a 'boot slave' service and invokes the exit and entry functions...
static co_nmt_boot_state_t * co_nmt_boot_ec_on_enter(co_nmt_boot_t *boot)
The entry function of the 'start error control' state.
static co_nmt_boot_state_t * co_nmt_boot_wait_flash_on_enter(co_nmt_boot_t *boot)
The entry function of the 'wait for end of flashing' state.
This header file is part of the C11 and POSIX compatibility library; it includes <stdlib.h> and defines any missing functionality.
void co_sdo_req_fini(struct co_sdo_req *req)
Finalizes a CANopen SDO upload/download request.
co_unsigned16_t co_sub_get_type(const co_sub_t *sub)
Returns the data type of a CANopen sub-object.
static co_nmt_boot_state_t *const co_nmt_boot_chk_device_type_state
The 'check device type' state (see Fig. 5 in CiA 302-2 version 4.1.0).
static co_nmt_boot_state_t *const co_nmt_boot_chk_cfg_date_state
The 'check configuration date' state (see Fig.
co_nmt_boot_state_t *(* on_time)(co_nmt_boot_t *boot, const struct timespec *tp)
A pointer to the transition function invoked when a timeout occurs.
static co_nmt_boot_state_t * co_nmt_boot_chk_cfg_date_on_enter(co_nmt_boot_t *boot)
The entry function of the 'check configuration date' state.
co_nmt_boot_t * co_nmt_boot_create(can_net_t *net, co_dev_t *dev, co_nmt_t *nmt)
Creates a new CANopen NMT 'boot slave' service.
static int co_nmt_boot_send_rtr(co_nmt_boot_t *boot)
Sends a node guarding RTR to the slave.
#define CO_NMT_CS_RESET_COMM
The NMT command specifier 'reset communication'.
static co_nmt_boot_state_t * co_nmt_boot_error_on_enter(co_nmt_boot_t *boot)
The entry function of the 'error' state.
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...
This header file is part of the CANopen library; it contains the object dictionary declarations...
#define CAN_MSG_INIT
The static initializer for can_msg.
static co_nmt_boot_state_t * co_nmt_boot_up_cfg_on_enter(co_nmt_boot_t *boot)
The entry function of the 'update configuration' state.
void can_recv_start(can_recv_t *recv, can_net_t *net, uint_least32_t id, uint_least8_t flags)
Registers a CAN frame receiver with a network interface and starts processing frames.
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.
co_unsigned32_t assignment
The NMT slave assignment (object 1F81).
static co_nmt_boot_state_t *const co_nmt_boot_wait_state
The 'wait asynchronously' state.
int co_sdo_req_last(const struct co_sdo_req *req)
Returns 1 if the specified request includes the last segment, and 0 otherwise.
static co_nmt_boot_state_t * co_nmt_boot_ec_on_time(co_nmt_boot_t *boot, const struct timespec *tp)
The 'timeout' transition function of the 'start error control' state.
static co_nmt_boot_state_t * co_nmt_boot_dn_prog_on_dn_con(co_nmt_boot_t *boot, co_unsigned32_t ac)
The 'SDO download confirmation' transition function of the 'download program' state.
int co_csdo_blk_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 block download request to a remote Server-SDO.
static co_nmt_boot_state_t * co_nmt_boot_start_prog_on_enter(co_nmt_boot_t *boot)
The entry function of the 'start program' state.
static co_nmt_boot_state_t * co_nmt_boot_wait_prog_on_time(co_nmt_boot_t *boot, const struct timespec *tp)
The 'timeout' transition function of the 'wait till program is started' state.
co_nmt_boot_state_t *(* on_enter)(co_nmt_boot_t *boot)
A pointer to the function invoked when a new state is entered.
static int co_nmt_boot_dn(co_nmt_boot_t *boot, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned16_t type, const void *val)
Issues an SDO download request to the slave.