111 static int co_ssdo_timer(
const struct timespec *tp,
void *data);
176 #define LELY_CO_DEFINE_STATE(name, ...) \
177 static co_ssdo_state_t *const name = &(co_ssdo_state_t){ __VA_ARGS__ };
213 co_ssdo_t *sdo, const struct timespec *tp);
245 co_ssdo_t *sdo, const struct timespec *tp);
278 co_ssdo_t *sdo, const struct timespec *tp);
302 co_ssdo_t *sdo, const struct timespec *tp);
338 co_ssdo_t *sdo, const struct timespec *tp);
362 co_ssdo_t *sdo, const struct timespec *tp);
379 #undef LELY_CO_DEFINE_STATE
498 __co_ssdo_alloc(
void)
500 void *ptr = malloc(
sizeof(
struct __co_ssdo));
507 __co_ssdo_free(
void *ptr)
530 if (
num != 1 && !obj_1200) {
549 MIN(size,
sizeof(sdo->
par)));
555 goto error_create_recv;
564 goto error_create_timer;
610 assert(sdo->
num >= 1 && sdo->
num <= 128);
632 trace(
"creating Server-SDO %d",
num);
639 goto error_alloc_sdo;
642 if (!__co_ssdo_init(sdo,
net,
dev,
num)) {
660 trace(
"destroying Server-SDO %d", ssdo->
num);
661 __co_ssdo_fini(ssdo);
662 __co_ssdo_free(ssdo);
711 if (sdo->
timeout && timeout <= 0)
727 if (valid_req && valid_res) {
729 uint_least8_t flags = 0;
744 static co_unsigned32_t
753 co_unsigned32_t ac = 0;
764 co_unsigned32_t cobid = val.u32;
765 co_unsigned32_t cobid_old = co_sub_get_val_u32(sub);
766 if (cobid == cobid_old)
775 if (valid && valid_old && canid != canid_old) {
792 co_unsigned32_t cobid = val.u32;
793 co_unsigned32_t cobid_old = co_sub_get_val_u32(sub);
794 if (cobid == cobid_old)
803 if (valid && valid_old && canid != canid_old) {
820 co_unsigned8_t
id = val.u8;
821 co_unsigned8_t id_old = co_sub_get_val_u8(sub);
853 #ifndef LELY_NO_CANFD
855 if (msg->
flags & CAN_FLAG_EDL)
932 co_unsigned8_t cs = msg->
data[0];
950 assert(msg->
len > 0);
951 co_unsigned8_t cs = msg->
data[0];
961 trace(
"SSDO: %04X:%02X: received download request", sdo->
idx,
975 uint_least8_t data[4] = { 0 };
976 memcpy(data, msg->
data + 4, msg->
len - 4);
1020 co_unsigned8_t cs = msg->
data[0];
1035 if (msg->
len < 1 + n)
1075 trace(
"SSDO: %04X:%02X: received upload request", sdo->
idx,
1120 co_unsigned8_t cs = msg->
data[0];
1157 assert(msg->
len > 0);
1158 co_unsigned8_t cs = msg->
data[0];
1175 trace(
"SSDO: %04X:%02X: received block download request", sdo->
idx,
1183 uint_least8_t data[4] = { 0 };
1184 memcpy(data, msg->
data + 4, msg->
len - 4);
1221 co_unsigned8_t cs = msg->
data[0];
1229 if (!seqno || seqno > sdo->
blksize)
1234 if (seqno == sdo->
ackseq + 1) {
1255 if (seqno == sdo->
blksize || last) {
1287 co_unsigned8_t cs = msg->
data[0];
1307 if (sdo->
crc != crc)
1326 assert(msg->
len > 0);
1327 co_unsigned8_t cs = msg->
data[0];
1344 trace(
"SSDO: %04X:%02X: received block upload request", sdo->
idx,
1355 co_unsigned8_t pst = msg->
len > 5 ? msg->
data[5] : 0;
1363 if (pst && sdo->
req.
size <= pst) {
1409 co_unsigned8_t cs = msg->
data[0];
1428 co_unsigned8_t ackseq = msg->
data[1];
1451 sdo->
blksize = (co_unsigned8_t)(
1491 co_unsigned8_t cs = msg->
data[0];
1534 trace(
"SSDO: abort code %08" PRIX32
" (%s)", ac,
co_sdo_ac2str(ac));
1539 static co_unsigned32_t
1557 static co_unsigned32_t
1574 && sdo->
subidx > co_obj_get_val_u8(obj, 0x00))
1581 static co_unsigned32_t
1584 co_unsigned32_t ac = 0;
1596 const uint_least8_t *src = (
const uint_least8_t *)sdo->
req.
buf
1655 assert(nbyte == sdo->
req.
size);
1662 memcpy(msg.
data + 4, buf, nbyte);
1698 memcpy(msg.
data + 1, buf, nbyte);
1764 for (co_unsigned8_t seqno = 1; seqno <= sdo->
blksize;
1765 seqno++, buf += 7, nbyte -= 7) {
1766 co_unsigned8_t cs = seqno;
1767 if (last && nbyte <= 7)
1772 memcpy(msg.
data + 1, buf,
MIN(nbyte, 7));
1783 co_unsigned8_t n = sdo->
req.
size ? (sdo->
req.
size - 1) % 7 + 1 : 0;
@ CAN_FLAG_IDE
The Identifier Extension (IDE) flag.
@ CAN_FLAG_RTR
The Remote Transmission Request (RTR) flag (unavailable in CAN FD format frames).
#define CAN_MASK_EID
The mask used to extract the 29-bit Extended Identifier from a CAN frame.
#define CAN_MAX_LEN
The maximum number of bytes in the payload of a CAN format frame.
#define CAN_MASK_BID
The mask used to extract the 11-bit Base Identifier from a CAN frame.
#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_unsigned8_t co_dev_get_id(const co_dev_t *dev)
Returns the node-ID of a CANopen device.
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.
This header file is part of the CANopen library; it contains the Cyclic Redundancy Check (CRC) declar...
uint_least16_t co_crc(uint_least16_t crc, const uint_least8_t *bp, size_t n)
Computes a CRC-16 checksum.
This header file is part of the utilities library; it contains the byte order (endianness) function d...
uint_least32_t ldle_u32(const uint_least8_t src[4])
Loads a 32-bit unsigned integer in little-endian byte order.
uint_least16_t ldle_u16(const uint_least8_t src[2])
Loads a 16-bit unsigned integer in little-endian byte order.
void stle_u16(uint_least8_t dst[2], uint_least16_t x)
Stores a 16-bit unsigned integer in little-endian byte order.
void stle_u32(uint_least8_t dst[4], uint_least32_t x)
Stores a 32-bit unsigned integer in little-endian byte order.
This header file is part of the utilities library; it contains the native and platform-independent er...
int errnum2c(errnum_t errnum)
Transforms a platform-independent error number to a native error code.
@ ERRNUM_INVAL
Invalid argument.
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.
This header file is part of the CANopen library; it contains the object dictionary declarations.
co_unsigned8_t co_sub_get_subidx(const co_sub_t *sub)
Returns the sub-index of a CANopen sub-object.
co_unsigned32_t co_sub_dn_ind(co_sub_t *sub, struct co_sdo_req *req)
Invokes the download indication function of a CANopen sub-object, registered with co_sub_set_dn_ind()...
co_unsigned16_t co_obj_get_idx(const co_obj_t *obj)
Returns the index of a CANopen 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().
void * co_obj_addressof_val(const co_obj_t *obj)
Returns the address of the value of a CANopen object.
int co_sub_dn(co_sub_t *sub, void *val)
Downloads (moves) a value into a CANopen sub-object if the refuse-write-on-download flag (CO_OBJ_FLAG...
co_unsigned8_t co_obj_get_code(const co_obj_t *obj)
Returns the object code of a CANopen object.
co_sub_t * co_obj_find_sub(const co_obj_t *obj, co_unsigned8_t subidx)
Finds a sub-object in a CANopen object.
#define CO_OBJECT_ARRAY
A multiple data field object where each data field is a simple variable of the same basic data type.
void co_obj_set_dn_ind(co_obj_t *obj, co_sub_dn_ind_t *ind, void *data)
Sets the download indication function for a CANopen object.
co_obj_t * co_sub_get_obj(const co_sub_t *sub)
Returns the a pointer to the CANopen object containing the specified sub-object.
size_t co_obj_sizeof_val(const co_obj_t *obj)
Returns size (in bytes) of the value of a CANopen object.
co_unsigned16_t co_sub_get_type(const co_sub_t *sub)
Returns the data type of a CANopen sub-object.
int co_sdo_req_first(const struct co_sdo_req *req)
Returns 1 if the specified request includes the first segment, and 0 otherwise.
int co_sdo_req_dn_val(struct co_sdo_req *req, co_unsigned16_t type, void *val, co_unsigned32_t *pac)
Copies the next segment of the specified CANopen SDO download request to the internal buffer and,...
#define CO_SDO_AC_TOGGLE
SDO abort code: Toggle bit not altered.
#define CO_SDO_AC_NO_CS
SDO abort code: Client/server command specifier not valid or unknown.
void co_sdo_req_fini(struct co_sdo_req *req)
Finalizes a CANopen SDO upload/download request.
#define CO_SDO_AC_TYPE_LEN
SDO abort code: Data type does not match, length of service parameter does not match.
#define CO_SDO_AC_BLK_SEQ
SDO abort code: Invalid sequence number (block mode only).
#define CO_SDO_AC_NO_SDO
SDO abort code: Resource not available: SDO connection.
#define CO_SDO_AC_NO_OBJ
SDO abort code: Object does not exist in the object dictionary.
#define CO_SDO_COBID_FRAME
The bit in the SDO COB-ID specifying whether to use an 11-bit (0) or 29-bit (1) CAN-ID.
void co_sdo_req_clear(struct co_sdo_req *req)
Clears a CANopen SDO upload/download request, including its buffer.
#define CO_SDO_AC_NO_DATA
SDO abort code: No data available.
#define CO_SDO_AC_NO_SUB
SDO abort code: Sub-index does not exist.
#define CO_SDO_AC_BLK_SIZE
SDO abort code: Invalid block size (block mode only).
#define CO_SDO_COBID_VALID
The bit in the SDO COB-ID specifying whether the SDO exists and is valid.
int co_sdo_req_last(const struct co_sdo_req *req)
Returns 1 if the specified request includes the last segment, and 0 otherwise.
const char * co_sdo_ac2str(co_unsigned32_t ac)
Returns a string describing an SDO abort code.
#define CO_SDO_AC_PARAM_VAL
SDO abort code: Invalid value for parameter (download only).
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.
#define CO_SDO_AC_BLK_CRC
SDO abort code: CRC error (block mode only).
#define CO_SDO_AC_NO_MEM
SDO abort code: Out of memory.
#define CO_SDO_AC_NO_WRITE
SDO abort code: Attempt to write a read only object.
#define MIN(a, b)
Returns the minimum of a and b.
#define MAX(a, b)
Returns the maximum of a and b.
void * membuf_begin(const struct membuf *buf)
Returns a pointer to the first byte in a memory buffer.
size_t membuf_reserve(struct membuf *buf, size_t size)
Resizes a memory buffer, if necessary, to make room for at least an additional size bytes.
void membuf_fini(struct membuf *buf)
Finalizes a memory buffer.
void membuf_flush(struct membuf *buf, size_t size)
Flushes size bytes from the beginning of a memory buffer.
size_t membuf_write(struct membuf *buf, const void *ptr, size_t size)
Writes data to a memory buffer.
void membuf_clear(struct membuf *buf)
Clears a memory buffer.
void membuf_init(struct membuf *buf)
Initializes a memory buffer.
size_t membuf_size(const struct membuf *buf)
Returns the total number of bytes written to a memory buffer.
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.
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.
can_recv_t * can_recv_create(void)
Creates a new CAN frame receiver.
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.
can_timer_t * can_timer_create(void)
Creates a new CAN timer.
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.
void can_timer_destroy(can_timer_t *timer)
Destroys a CAN timer.
This is the internal header file of the CANopen library.
This is the internal header file of the Service Data Object (SDO) declarations.
#define CO_SDO_SEQ_LAST
The mask to get/set the last segment bit from an SDO command byte.
#define CO_SDO_SEG_TOGGLE
The mask to get/set the toggle bit from an SDO command byte.
#define CO_SDO_CCS_DN_INI_REQ
The SDO client command specifier 'download initiate' request.
#define CO_SDO_BLK_SIZE_IND
The SDO size indicator flag indicating that the data set size is indicated.
#define CO_SDO_CS_MASK
The mask to extract the command specifier (CS) from an SDO command byte.
#define CO_SDO_BLK_SIZE_SET(n)
Sets the SDO size indicator, indicating n bytes contain segment data (in the range [0....
#define CO_SDO_INI_SIZE_EXP_GET(cs)
Retrieves the number of bytes containing expedited data from the SDO size indicator.
#define CO_SDO_SCS_UP_SEG_RES
The SDO server command specifier 'upload segment' response.
#define CO_SDO_SEG_SIZE_SET(n)
Sets the SDO size indicator, indicating n bytes contain segment data (in the range [0....
#define CO_SDO_SC_END_BLK
The SDO server/client subcommand 'end block download/upload'.
#define CO_SDO_SCS_UP_INI_RES
The SDO server command specifier 'upload initiate' response.
#define CO_SDO_SCS_DN_SEG_RES
The SDO server command specifier 'download segment' response.
#define CO_SDO_CS_ABORT
The SDO client/server command specifier 'abort transfer' request.
#define CO_SDO_CCS_BLK_DN_REQ
The SDO client command specifier 'block download' request.
#define CO_SDO_CCS_UP_INI_REQ
The SDO client command specifier 'upload initiate' request.
#define CO_SDO_SC_MASK
The mask to extract the subcommand (SC) from an SDO command byte.
#define CO_SDO_BLK_CRC
The SDO CRC support flag.
#define CO_SDO_CCS_DN_SEG_REQ
The SDO client command specifier 'download segment' request.
#define CO_SDO_INI_SIZE_IND
The SDO size indicator flag indicating that the data set size is indicated.
#define CO_SDO_SCS_BLK_DN_RES
The SDO server command specifier 'block download' response.
#define CO_SDO_INI_SIZE_EXP_SET(n)
Sets the SDO size indicator, indicating the expedited transfer of n bytes (in the range [1....
#define CO_SDO_SCS_BLK_UP_RES
The SDO server command specifier 'block upload' response.
#define CO_SDO_MAX_SEQNO
The maximum sequence number (or segments per block).
#define CO_SDO_SEG_SIZE_GET(cs)
Retrieves the number of bytes containing segment data from the SDO size indicator.
#define CO_SDO_SEG_LAST
The mask to get/set the last segment bit from an SDO command byte.
#define CO_SDO_BLK_SIZE_GET(cs)
Retrieves the number of bytes containing segment data from the SDO size indicator.
#define CO_SDO_SC_START_UP
The SDO client subcommand 'start upload'.
#define CO_SDO_SC_BLK_RES
The SDO client/client subcommand 'block download/upload' response.
#define CO_SDO_CCS_BLK_UP_REQ
The SDO client command specifier 'block upload' request.
#define CO_SDO_INI_SIZE_EXP
The SDO size indicator flag indicating expedited transfer.
#define CO_SDO_SCS_DN_INI_RES
The SDO server command specifier 'download initiate' response.
#define CO_SDO_CCS_UP_SEG_REQ
The SDO client command specifier 'upload segment' request.
#define CO_SDO_SC_INI_BLK
The SDO server/client subcommand 'initiate download/upload'.
co_dev_t * co_ssdo_get_dev(const co_ssdo_t *sdo)
Returns a pointer to the CANopen device of a Server-SDO.
static co_ssdo_state_t * co_ssdo_wait_on_abort(co_ssdo_t *sdo, co_unsigned32_t ac)
The 'abort' transition function of the 'waiting' state.
static co_ssdo_state_t * co_ssdo_wait_on_recv(co_ssdo_t *sdo, const struct can_msg *msg)
The 'CAN frame received' transition function of the 'waiting' state.
static void co_ssdo_send_blk_up_ini_res(co_ssdo_t *sdo)
Sends a Server-SDO 'block upload initiate' response.
static co_ssdo_state_t * co_ssdo_up_seg_on_time(co_ssdo_t *sdo, const struct timespec *tp)
The 'timeout' transition function of the 'upload segment' state.
void co_ssdo_destroy(co_ssdo_t *ssdo)
Destroys a CANopen Server-SDO service.
static void co_ssdo_send_dn_seg_res(co_ssdo_t *sdo)
Sends a Server-SDO 'download segment' response.
static co_ssdo_state_t * co_ssdo_up_seg_on_recv(co_ssdo_t *sdo, const struct can_msg *msg)
The 'CAN frame received' transition function of the 'upload segment' state.
static co_ssdo_state_t * co_ssdo_blk_dn_end_on_abort(co_ssdo_t *sdo, co_unsigned32_t ac)
The 'abort' transition function of the 'block download end' state.
co_unsigned8_t co_ssdo_get_num(const co_ssdo_t *sdo)
Returns the SDO number of a Server-SDO.
static co_ssdo_state_t *const co_ssdo_blk_dn_end_state
The 'block download end' state.
static void co_ssdo_init_ini_res(co_ssdo_t *sdo, struct can_msg *msg, co_unsigned8_t cs)
Initializes a Server-SDO download/upload initiate response CAN frame.
static void co_ssdo_send_blk_up_sub_res(co_ssdo_t *sdo, int last)
Sends a Server-SDO 'block upload sub-block' response.
static co_ssdo_state_t * co_ssdo_blk_dn_sub_on_time(co_ssdo_t *sdo, const struct timespec *tp)
The 'timeout' transition function of the 'block download sub-block' state.
static co_ssdo_state_t * co_ssdo_blk_dn_end_on_recv(co_ssdo_t *sdo, const struct can_msg *msg)
The 'CAN frame received' transition function of the 'block download end' state.
static co_unsigned32_t co_ssdo_up_ind(co_ssdo_t *sdo)
Processes an upload indication of a Server-SDO by checking access to the requested sub-object and wri...
static co_ssdo_state_t * co_ssdo_dn_seg_on_time(co_ssdo_t *sdo, const struct timespec *tp)
The 'timeout' transition function of the 'download segment' state.
static void co_ssdo_send_blk_up_end_res(co_ssdo_t *sdo)
Sends a Server-SDO 'block upload end' response.
static co_ssdo_state_t * co_ssdo_blk_up_end_on_recv(co_ssdo_t *sdo, const struct can_msg *msg)
The 'CAN frame received' transition function of the 'block upload end' state.
static co_ssdo_state_t * co_ssdo_blk_up_sub_on_abort(co_ssdo_t *sdo, co_unsigned32_t ac)
The 'block upload initiate' state.
static void co_ssdo_send_up_seg_res(co_ssdo_t *sdo, int last)
Sends a Server-SDO 'upload segment' response.
static co_unsigned32_t co_ssdo_dn_ind(co_ssdo_t *sdo)
Processes a download indication of a Server-SDO by checking access to the requested sub-object and re...
static void co_ssdo_send_blk_dn_sub_res(co_ssdo_t *sdo)
Sends a Server-SDO 'block upload sub-block' response.
static co_ssdo_state_t * co_ssdo_blk_dn_sub_on_recv(co_ssdo_t *sdo, const struct can_msg *msg)
The 'CAN frame received' transition function of the 'block download sub-block' state.
void co_ssdo_set_timeout(co_ssdo_t *sdo, int timeout)
Sets the timeout of a Server-SDO.
static int co_ssdo_update(co_ssdo_t *sdo)
Updates and (de)activates a Server-SDO service.
static void co_ssdo_emit_time(co_ssdo_t *sdo, const struct timespec *tp)
Invokes the 'timeout' transition function of the current state of a Server-SDO service.
static co_ssdo_state_t *const co_ssdo_blk_up_sub_state
The 'block upload sub-block' state.
static co_unsigned32_t co_1200_dn_ind(co_sub_t *sub, struct co_sdo_req *req, void *data)
The download indication function for (all sub-objects of) CANopen objects 1200..127F (SDO server para...
static co_ssdo_state_t * co_ssdo_blk_dn_ini_on_recv(co_ssdo_t *sdo, const struct can_msg *msg)
The 'CAN frame received' transition function of the 'block download initiate' state.
static co_ssdo_state_t *const co_ssdo_blk_up_end_state
The 'block upload end' state.
static int co_ssdo_recv(const struct can_msg *msg, void *data)
The CAN receive callback function for a Server-SDO service.
static int co_ssdo_timer(const struct timespec *tp, void *data)
The CAN timer callback function for a Server-SDO service.
static co_ssdo_state_t *const co_ssdo_dn_seg_state
The 'download segment' state.
static co_ssdo_state_t * co_ssdo_up_ini_on_recv(co_ssdo_t *sdo, const struct can_msg *msg)
The 'CAN frame received' transition function of the 'upload initiate' state.
static co_ssdo_state_t * co_ssdo_up_seg_on_abort(co_ssdo_t *sdo, co_unsigned32_t ac)
The 'upload initiate' state.
static void co_ssdo_emit_recv(co_ssdo_t *sdo, const struct can_msg *msg)
Invokes the 'CAN frame received' transition function of the current state of a Server-SDO service.
static co_unsigned32_t co_ssdo_up_buf(co_ssdo_t *sdo, size_t nbyte)
Copies at most nbyte bytes from a CANopen SDO upload request, obtaining more bytes with co_ssdo_up_in...
static void co_ssdo_send_dn_ini_res(co_ssdo_t *sdo)
Sends a Server-SDO 'download initiate' response.
static co_ssdo_state_t * co_ssdo_abort_res(co_ssdo_t *sdo, co_unsigned32_t ac)
Sends an abort transfer request and aborts any ongoing transfer by invoking co_ssdo_abort_ind().
static co_ssdo_state_t * co_ssdo_dn_ini_on_recv(co_ssdo_t *sdo, const struct can_msg *msg)
The 'CAN frame received' transition function of the 'download initiate' state.
static void co_ssdo_send_abort(co_ssdo_t *sdo, co_unsigned32_t ac)
Sends an abort transfer request.
static void co_ssdo_send_blk_dn_end_res(co_ssdo_t *sdo)
Sends a Server-SDO 'block download end' response.
static co_ssdo_state_t * co_ssdo_blk_dn_end_on_time(co_ssdo_t *sdo, const struct timespec *tp)
The 'timeout' transition function of the 'block download end' state.
static co_ssdo_state_t * co_ssdo_dn_seg_on_abort(co_ssdo_t *sdo, co_unsigned32_t ac)
The 'download initiate' state.
static co_ssdo_state_t *const co_ssdo_blk_dn_sub_state
The 'block download sub-block' state.
static co_ssdo_state_t * co_ssdo_dn_seg_on_recv(co_ssdo_t *sdo, const struct can_msg *msg)
The 'CAN frame received' transition function of the 'download segment' state.
static void co_ssdo_init_seg_res(co_ssdo_t *sdo, struct can_msg *msg, co_unsigned8_t cs)
Initializes a Server-SDO download/upload segment response CAN frame.
static void co_ssdo_send_blk_dn_ini_res(co_ssdo_t *sdo)
Sends a Server-SDO 'block download initiate' response.
static co_ssdo_state_t *const co_ssdo_up_seg_state
The 'upload segment' state.
static co_ssdo_state_t * co_ssdo_blk_up_sub_on_time(co_ssdo_t *sdo, const struct timespec *tp)
The 'timeout' transition function of the 'block upload sub-block' state.
static co_ssdo_state_t * co_ssdo_blk_up_sub_on_recv(co_ssdo_t *sdo, const struct can_msg *msg)
The 'CAN frame received' transition function of the 'block upload sub-block' state.
int co_ssdo_get_timeout(const co_ssdo_t *sdo)
Returns the timeout (in milliseconds) of a Server-SDO.
static co_ssdo_state_t * co_ssdo_blk_up_end_on_abort(co_ssdo_t *sdo, co_unsigned32_t ac)
The 'abort' transition function of the 'block upload end' state.
static co_ssdo_state_t * co_ssdo_blk_up_ini_on_recv(co_ssdo_t *sdo, const struct can_msg *msg)
The 'CAN frame received' transition function of the 'block upload initiate' state.
static co_ssdo_state_t * co_ssdo_abort_ind(co_ssdo_t *sdo)
Processes an abort transfer indication by aborting any ongoing transfer of a Server-SDO and returning...
const struct co_sdo_par * co_ssdo_get_par(const co_ssdo_t *sdo)
Returns a pointer to the SDO parameter record of a Server-SDO.
can_net_t * co_ssdo_get_net(const co_ssdo_t *sdo)
Returns a pointer to the CAN network of a Server-SDO.
static void co_ssdo_enter(co_ssdo_t *sdo, co_ssdo_state_t *next)
Enters the specified state of a Server-SDO service.
static co_ssdo_state_t * co_ssdo_blk_dn_sub_on_abort(co_ssdo_t *sdo, co_unsigned32_t ac)
The 'block download initiate' state.
static co_ssdo_state_t * co_ssdo_blk_up_end_on_time(co_ssdo_t *sdo, const struct timespec *tp)
The 'timeout' transition function of the 'block upload end' state.
static void co_ssdo_send_up_exp_res(co_ssdo_t *sdo)
Sends a Server-SDO 'upload initiate' (expedited) response.
static co_ssdo_state_t *const co_ssdo_wait_state
The 'waiting' state.
static void co_ssdo_emit_abort(co_ssdo_t *sdo, co_unsigned32_t ac)
Invokes the 'abort' transition function of the current state of a Server-SDO service.
static void co_ssdo_send_up_ini_res(co_ssdo_t *sdo)
Sends a Server-SDO 'upload initiate' response.
co_ssdo_t * co_ssdo_create(can_net_t *net, co_dev_t *dev, co_unsigned8_t num)
Creates a new CANopen Server-SDO service.
This header file is part of the CANopen library; it contains the Server-SDO declarations.
This header file is part of the C11 and POSIX compatibility library; it includes <stdlib....
A CANopen Server-SDO state.
co_ssdo_state_t *(* on_recv)(co_ssdo_t *sdo, const struct can_msg *msg)
A pointer to the transition function invoked when a CAN frame has been received.
co_ssdo_state_t *(* on_time)(co_ssdo_t *sdo, const struct timespec *tp)
A pointer to the transition function invoked when a timeout occurs.
co_ssdo_state_t *(* on_abort)(co_ssdo_t *sdo, co_unsigned32_t ac)
A pointer to the transition function invoked when an abort code has been received.
struct co_sdo_par par
The SDO parameter record.
co_unsigned16_t idx
The current object index.
co_ssdo_state_t * state
A pointer to the current state.
can_net_t * net
A pointer to a CAN network interface.
can_recv_t * recv
A pointer to the CAN frame receiver.
int timeout
The SDO timeout (in milliseconds).
co_dev_t * dev
A pointer to a CANopen device.
unsigned gencrc
A flag indicating whether a CRC should be generated.
struct membuf buf
The buffer.
can_timer_t * timer
A pointer to the CAN timer.
co_unsigned16_t crc
The generated CRC.
co_unsigned8_t subidx
The current object sub-index.
struct co_sdo_req req
The SDO request.
co_unsigned8_t blksize
The number of segments per block.
co_unsigned8_t toggle
The current value of the toggle bit.
co_unsigned8_t num
The SDO number.
size_t nbyte
The number of bytes in req already copied to buf.
co_unsigned8_t ackseq
The sequence number of the last successfully received segment.
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).
co_unsigned32_t cobid_res
COB-ID server -> client.
co_unsigned8_t n
Highest sub-index supported.
co_unsigned32_t cobid_req
COB-ID client -> server.
co_unsigned8_t id
Node-ID of SDO's client resp. server.
A CANopen SDO upload/download request.
size_t offset
The offset of the bytes at buf.
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.
size_t nbyte
The number of bytes available at buf.
#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 CANopen library; it contains the CANopen value declarations.
void co_val_fini(co_unsigned16_t type, void *val)
Finalizes a value of the specified data type.