26#if !LELY_NO_CO_MASTER && !LELY_NO_CO_NMT_BOOT
41#ifndef LELY_CO_NMT_BOOT_WAIT_TIMEOUT
43#define LELY_CO_NMT_BOOT_WAIT_TIMEOUT 1000
46#ifndef LELY_CO_NMT_BOOT_SDO_RETRY
48#define LELY_CO_NMT_BOOT_SDO_RETRY 3
52#ifndef LELY_CO_NMT_BOOT_RTR_TIMEOUT
54#define LELY_CO_NMT_BOOT_RTR_TIMEOUT 100
58#ifndef LELY_CO_NMT_BOOT_RESET_TIMEOUT
63#define LELY_CO_NMT_BOOT_RESET_TIMEOUT 1000
66#ifndef LELY_CO_NMT_BOOT_CHECK_TIMEOUT
71#define LELY_CO_NMT_BOOT_CHECK_TIMEOUT 100
135 co_unsigned8_t subidx, co_unsigned32_t ac,
void *data);
144 co_unsigned8_t subidx, co_unsigned32_t ac,
const void *ptr,
145 size_t n,
void *data);
154 co_unsigned32_t ac,
void *data);
202 co_unsigned32_t ac,
const void *ptr,
size_t n);
262 co_unsigned32_t ac,
const void *ptr,
size_t n);
278#define LELY_CO_DEFINE_STATE(name, ...) \
279 static co_nmt_boot_state_t *const name = \
280 &(co_nmt_boot_state_t){ __VA_ARGS__ };
475 co_unsigned32_t ac, const
void *ptr,
size_t n);
500 co_unsigned32_t ac, const
void *ptr,
size_t n);
600 co_unsigned32_t ac, const
void *ptr,
size_t n);
644 co_unsigned32_t ac, const
void *ptr,
size_t n);
740#undef LELY_CO_DEFINE_STATE
755 co_unsigned8_t subidx, co_unsigned16_t type,
const void *val);
768 co_unsigned8_t subidx);
784 co_unsigned8_t subidx,
const void *ptr,
size_t n);
796__co_nmt_boot_alloc(
void)
807__co_nmt_boot_free(
void *ptr)
832 goto error_create_recv;
839 goto error_create_timer;
848 boot->
start = (
struct timespec){ 0, 0 };
892 goto error_alloc_boot;
895 if (!__co_nmt_boot_init(boot, net, dev, nmt)) {
897 goto error_init_boot;
903 __co_nmt_boot_free(boot);
913 __co_nmt_boot_fini(boot);
914 __co_nmt_boot_free(boot);
976 co_unsigned32_t ac,
void *data)
989 co_unsigned32_t ac,
const void *ptr,
size_t n,
void *data)
1032 assert(boot->
state);
1042 assert(boot->
state);
1052 assert(boot->
state);
1060 const void *ptr,
size_t n)
1063 assert(boot->
state);
1073 assert(boot->
state);
1095 co_unsigned8_t n = co_obj_get_val_u8(obj_1016, 0x00);
1096 for (
size_t i = 1; i <= n; i++) {
1097 co_unsigned32_t val =
1098 co_obj_get_val_u32(obj_1016, i & 0xff);
1099 if (((val >> 16) & 0x7f) == boot->
id)
1100 boot->
ms = val & 0xffff;
1132 if (boot->
es ==
'B') {
1137 co_unsigned32_t boot_time = co_dev_get_val_u32(
1138 boot->
dev, 0x1f89, 0x00);
1141 struct timespec now = { 0, 0 };
1194 const void *ptr,
size_t n)
1207 "SDO abort code %08" PRIX32
1208 " received on upload request of object 1000 (Device type) to node %02X: %s",
1216 co_unsigned32_t device_type =
1217 co_dev_get_val_u32(boot->
dev, 0x1f84, boot->
id);
1234 co_unsigned32_t vendor_id =
1235 co_dev_get_val_u32(boot->
dev, 0x1f85, boot->
id);
1250 const void *ptr,
size_t n)
1257 "SDO abort code %08" PRIX32
1258 " received on upload request of sub-object 1018:01 (Vendor-ID) to node %02X: %s",
1275 co_unsigned32_t product_code =
1276 co_dev_get_val_u32(boot->
dev, 0x1f86, boot->
id);
1291 const void *ptr,
size_t n)
1298 "SDO abort code %08" PRIX32
1299 " received on upload request of sub-object 1018:02 (Product code) to node %02X: %s",
1316 co_unsigned32_t revision =
1317 co_dev_get_val_u32(boot->
dev, 0x1f87, boot->
id);
1332 const void *ptr,
size_t n)
1339 "SDO abort code %08" PRIX32
1340 " received on upload request of sub-object 1018:03 (Revision number) to node %02X: %s",
1357 co_unsigned32_t serial_nr =
1358 co_dev_get_val_u32(boot->
dev, 0x1f88, boot->
id);
1373 const void *ptr,
size_t n)
1380 "SDO abort code %08" PRIX32
1381 " received on upload request of sub-object 1018:04 (Serial number) to node %02X: %s",
1437 if (msg->
len >= 1) {
1514 co_unsigned32_t sw_id =
1515 co_dev_get_val_u32(boot->
dev, 0x1f55, boot->
id);
1535 const void *ptr,
size_t n)
1549 "SDO abort code %08" PRIX32
1550 " received on upload request of sub-object 1F56:01 (Program software identification) to node %02X: %s",
1600 "SDO abort code %08" PRIX32
1601 " received on download request of sub-object 1F51:01 (Program control) to node %02X: %s",
1612 const void *ptr,
size_t n)
1618 co_unsigned8_t val = 0;
1621 (
const uint_least8_t *)ptr + n) && !val)
1629 &(co_unsigned8_t){ 0 }) == -1)
1660 &(co_unsigned8_t){ 3 }) == -1)
1667 "SDO abort code %08" PRIX32
1668 " received on download request of sub-object 1F51:01 (Program control) to node %02X: %s",
1694 "SDO abort code %08" PRIX32
1695 " on upload request of object 1F58:%02X (Program data): %s",
1767 "SDO abort code %08" PRIX32
1768 " received on download request of sub-object 1F50:01 (Program data) to node %02X: %s",
1804 const void *ptr,
size_t n)
1814 "SDO abort code %08" PRIX32
1815 " received on upload request of sub-object 1F57:01 (Flash status indication) to node %02X: %s",
1820 co_unsigned32_t val = 0;
1823 (
const uint_least8_t *)ptr + n) || (val & 0x01))
1827 co_unsigned8_t st = (val >> 1) & 0x7f;
1832 "flash status identification %d: No valid program available",
1837 "flash status identification %d: Data format unknown",
1842 "flash status identification %d: Data format error or data CRC error",
1847 "flash status identification %d: Flash not cleared before write",
1852 "flash status identification %d: Flash write error",
1857 "flash status identification %d: General address error",
1862 "flash status identification %d: Flash secured (= write access currently forbidden)",
1867 "flash status identification %d: Unspecified error",
1874 "flash status identification %d: Manufacturer-specific error: 0x%08" PRIX32
1876 st, (val >> 16) & 0xffff);
1899 const void *ptr,
size_t n)
1906 "SDO abort code %08" PRIX32
1907 " received on upload request of sub-object 1F56:01 (Program software identification) to node %02X: %s",
1926 &(co_unsigned8_t){ 1 }) == -1)
1948 "SDO abort code %08" PRIX32
1949 " received on download request of sub-object 1F51:01 (Program control) to node %02X: %s",
1988 const void *ptr,
size_t n)
2001 "SDO abort code %08" PRIX32
2002 " received on upload request of sub-object 1F51:01 (Program control) to node %02X: %s",
2009 co_unsigned8_t val = 0;
2010 const uint_least8_t *
const begin = ptr;
2011 const uint_least8_t *
const end = begin != NULL ? begin + n : NULL;
2030 co_unsigned32_t cfg_date =
2031 co_dev_get_val_u32(boot->
dev, 0x1f26, boot->
id);
2032 co_unsigned32_t cfg_time =
2033 co_dev_get_val_u32(boot->
dev, 0x1f27, boot->
id);
2034 if (!cfg_date || !cfg_time)
2048 const void *ptr,
size_t n)
2062 "SDO abort code %08" PRIX32
2063 " received on upload request of sub-object 1020:01 (Configuration date) to node %02X: %s",
2082 const void *ptr,
size_t n)
2089 "SDO abort code %08" PRIX32
2090 " received on upload request of sub-object 1020:02 (Configuration time) to node %02X: %s",
2130 "SDO abort code %08" PRIX32
2131 " received while updating the configuration of node %02X: %s",
2157 co_unsigned16_t gt = (boot->
assignment >> 16) & 0xffff;
2174 if (msg->
len >= 1) {
2175 co_unsigned8_t st = msg->
data[0];
2197 co_unsigned16_t type,
const void *val)
2216 const void *ptr,
size_t n)
2227 if (!
co_val_read(type, &val, ptr, (
const uint_least8_t *)ptr + n))
@ CAN_FLAG_RTR
The Remote Transmission Request (RTR) flag (unavailable in CAN FD format frames).
#define CAN_MSG_INIT
The static initializer for can_msg.
This header file is part of the CANopen library; it contains the device description declarations.
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_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.
#define CO_NUM_NODES
The maximum number of nodes in a CANopen network.
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.
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.
void co_csdo_set_timeout(co_csdo_t *sdo, int timeout)
Sets the timeout of a Client-SDO.
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.
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...
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...
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...
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.
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.
void co_csdo_destroy(co_csdo_t *sdo)
Destroys a CANopen Client-SDO service.
This header file is part of the utilities library; it contains the diagnostic declarations.
void diag(enum diag_severity severity, int errc, const char *format,...)
Emits a diagnostic message.
@ ERRNUM_INVAL
Invalid argument.
@ ERRNUM_INPROGRESS
Operation in progress.
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
int errno2c(int errnum)
Transforms a standard C error number to a native error code.
void set_errnum(errnum_t errnum)
Sets the current (thread-specific) platform-independent error number to errnum.
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 co_sdo_req_fini(struct co_sdo_req *req)
Finalizes a CANopen SDO upload/download request.
void co_sdo_req_clear(struct co_sdo_req *req)
Clears a CANopen SDO upload/download request, including its buffer.
const char * co_sdo_ac2str(co_unsigned32_t ac)
Returns a string describing an SDO abort code.
int co_sdo_req_last(const struct co_sdo_req *req)
Returns 1 if the specified request includes the last segment, and 0 otherwise.
void co_sdo_req_init(struct co_sdo_req *req)
Initializes a CANopen SDO upload/download request.
#define CO_SDO_AC_TIMEOUT
SDO abort code: SDO protocol timed out.
void can_timer_stop(can_timer_t *timer)
Stops a CAN timer and unregisters it with a network interface.
int can_net_send(can_net_t *net, const struct can_msg *msg)
Sends a CAN frame from a network interface.
can_timer_t * can_timer_create(void)
Creates a new CAN timer.
void can_net_get_time(const can_net_t *net, struct timespec *tp)
Retrieves the current time of a CAN network interface.
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.
void can_recv_stop(can_recv_t *recv)
Stops a CAN frame receiver from processing frames and unregisters it with the network interface.
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.
void can_recv_destroy(can_recv_t *recv)
Destroys a CAN frame receiver.
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.
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.
can_recv_t * can_recv_create(void)
Creates a new CAN frame receiver.
void can_timer_destroy(can_timer_t *timer)
Destroys a CAN timer.
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 CO_NMT_ST_BOOTUP
The NMT state 'boot-up'.
#define CO_NMT_EC_CANID(id)
The CAN identifier used for both node guarding and heartbeat monitoring.
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.
#define CO_NMT_ST_START
The NMT state 'operational'.
#define CO_NMT_ST_TOGGLE
The mask to get/set the toggle bit from an NMT 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.
#define CO_NMT_CS_RESET_COMM
The NMT command specifier 'reset communication'.
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.
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 *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 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 co_nmt_boot_state_t *const co_nmt_boot_chk_cfg_time_state
The 'check configuration time' state (see Fig.
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...
static co_nmt_boot_state_t * co_nmt_boot_error_on_enter(co_nmt_boot_t *boot)
The entry function of the 'error' state.
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.
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 * 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 *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_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_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_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.
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 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.
static co_nmt_boot_state_t *const co_nmt_boot_up_cfg_state
The 'update configuration' state (see Fig.
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.
#define LELY_CO_NMT_BOOT_RTR_TIMEOUT
The timeout (in milliseconds) after sending a node guarding RTR.
static void co_nmt_boot_error_on_leave(co_nmt_boot_t *boot)
The exit function of the 'error' state.
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 ...
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.
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_chk_cfg_date_on_enter(co_nmt_boot_t *boot)
The entry function of the 'check configuration date' state.
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_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_enter(co_nmt_boot_t *boot)
The entry function of the 'wait for end of flashing' 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 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 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 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.
static co_nmt_boot_state_t *const co_nmt_boot_wait_prog_state
The 'wait till program is started' state (see Fig.
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.
void co_nmt_boot_destroy(co_nmt_boot_t *boot)
Destroys a CANopen NMT 'boot slave' service.
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.
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.
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.
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 *const co_nmt_boot_chk_product_code_state
The 'check product code' state (see Fig. 5 in CiA 302-2 version 4.1.0).
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 * 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.
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 * co_nmt_boot_ec_on_enter(co_nmt_boot_t *boot)
The entry function of the 'start error control' state.
#define LELY_CO_NMT_BOOT_CHECK_TIMEOUT
The timeout (in milliseconds) before checking the flash status indication or the program control of a...
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 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 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_chk_product_code_on_enter(co_nmt_boot_t *boot)
The entry function of the 'check product code' state.
static int co_nmt_boot_timer(const struct timespec *tp, void *data)
The CAN timer callback function for a 'boot slave' service.
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 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).
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.
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 * 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.
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.
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 *const co_nmt_boot_chk_vendor_id_state
The 'check vendor ID' state (see Fig. 5 in CiA 302-2 version 4.1.0).
#define LELY_CO_NMT_BOOT_WAIT_TIMEOUT
The timeout (in milliseconds) before trying to boot the slave again.
#define LELY_CO_NMT_BOOT_RESET_TIMEOUT
The timeout (in milliseconds) after sending the NMT 'reset communication' command.
static int co_nmt_boot_send_rtr(co_nmt_boot_t *boot)
Sends a node guarding RTR to the slave.
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.
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.
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).
static co_nmt_boot_state_t *const co_nmt_boot_wait_state
The 'wait asynchronously' 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_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.
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).
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.
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 *const co_nmt_boot_reset_comm_state
The 'reset communication' 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.
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_up(co_nmt_boot_t *boot, co_unsigned16_t idx, co_unsigned8_t subidx)
Issues an SDO upload request to the slave.
static int co_nmt_boot_recv(const struct can_msg *msg, void *data)
The CAN receive callback function for a 'boot slave' service.
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.
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_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_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_error_state
The 'error' state.
#define LELY_CO_NMT_BOOT_SDO_RETRY
The number of times an SDO request is retried after a timeout.
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.
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_abort_state
The 'abort' state.
static co_nmt_boot_state_t *const co_nmt_boot_chk_cfg_date_state
The 'check configuration date' state (see Fig.
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.
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).
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 * 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 *const co_nmt_boot_clear_prog_state
The 'clear program' state (see Fig. 3 in CiA 302-3 version 4.1.0).
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.
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.
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 * 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 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.
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 * 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.
This is the internal header file of the NMT 'boot slave' declarations.
This header file is part of the CANopen library; it contains the object dictionary declarations.
const void * co_sub_get_val(const co_sub_t *sub)
Returns a pointer to the current value of a CANopen sub-object.
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().
co_unsigned16_t co_sub_get_type(const co_sub_t *sub)
Returns the data type of a CANopen sub-object.
This is the internal header file of the CANopen library.
This header file is part of the C11 and POSIX compatibility library; it includes <stdlib....
A CANopen NMT 'boot slave' 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.
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.
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.
void(* on_leave)(co_nmt_boot_t *boot)
A pointer to the function invoked when the current state is left.
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.
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.
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.
A CANopen NMT 'boot slave' service.
can_recv_t * recv
A pointer to the CAN frame receiver.
struct co_sdo_req req
The CANopen SDO upload request used for reading sub-objects.
can_timer_t * timer
A pointer to the CAN timer.
co_nmt_t * nmt
A pointer to an NMT master service.
can_net_t * net
A pointer to a CAN network interface.
co_nmt_boot_state_t * state
A pointer to the current state.
co_unsigned32_t assignment
The NMT slave assignment (object 1F81).
co_unsigned16_t ms
The consumer heartbeat time (in milliseconds).
int retry
The number of SDO retries remaining.
co_csdo_t * sdo
A pointer to the Client-SDO used to access slave objects.
co_unsigned8_t id
The node-ID.
co_dev_t * dev
A pointer to a CANopen device.
struct timespec start
The time at which the 'boot slave' request was received.
int timeout
The SDO timeout (in milliseconds).
co_unsigned8_t st
The state of the node (including the toggle bit).
A CANopen NMT master/slave service.
A CAN or CAN FD format frame.
uint_least8_t data[CAN_MSG_MAX_LEN]
The frame payload (in case of a data frame).
uint_least32_t id
The identifier (11 or 29 bits, depending on the CAN_FLAG_IDE flag).
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...
uint_least8_t len
The number of bytes in data (or the requested number of bytes in case of a remote frame).
A CANopen SDO upload/download request.
size_t size
The total size (in bytes) of the value to be uploaded/downloaded.
const void * buf
A pointer to the next bytes to be uploaded/downloaded.
int co_type_is_array(co_unsigned16_t type)
Returns 1 if the specified (static) data type is an array, and 0 if not.
#define CO_DEFTYPE_UNSIGNED8
The data type (and object index) of an 8-bit unsigned integer.
#define CO_DEFTYPE_UNSIGNED32
The data type (and object index) of a 32-bit unsigned integer.
A union of the CANopen static data types.
This header file is part of the utilities library; it contains the time function declarations.
int_least64_t timespec_diff_msec(const struct timespec *t1, const struct timespec *t2)
Returns the time difference (in milliseconds) between *t1 and *t2.
This header file is part of the CANopen library; it contains the CANopen value declarations.
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.
int co_val_cmp(co_unsigned16_t type, const void *v1, const void *v2)
Compares two values of the specified data type.