25 #define LELY_CO_SDO_INLINE extern inline
27 #ifndef LELY_NO_CO_OBJ_FILE
51 struct co_sdo_req *req,
const void **pptr,
size_t *pnbyte);
60 case 0:
return "Success";
64 return "Client/server command specifier not valid or unknown";
73 return "Object does not exist in the object dictionary";
76 return "The number and length of the objects to be mapped would exceed the PDO length";
77 case CO_SDO_AC_PARAM:
return "General parameter incompatibility reason";
79 return "General internal incompatibility in the device";
82 return "Data type does not match, length of service parameter does not match";
84 return "Data type does not match, length of service parameter too high";
86 return "Data type does not match, length of service parameter too low";
92 return "Maximum value is less than minimum value";
96 return "Data cannot be transferred or stored to the application";
98 return "Data cannot be transferred or stored to the application because of local control";
100 return "Data cannot be transferred or stored to the application because of the present device state";
102 return "Object dictionary dynamic generation fails or no object dictionary is present";
104 default:
return "Unknown abort code";
140 co_unsigned32_t *pac)
142 co_unsigned32_t ac = 0;
166 co_unsigned32_t *pac)
168 co_unsigned32_t ac = 0;
170 const void *ptr = NULL;
178 type, val, ptr, (
const uint_least8_t *)ptr + nbyte);
190 }
else if (size < nbyte) {
205 #ifndef LELY_NO_CO_OBJ_FILE
208 co_unsigned32_t *pac)
211 co_unsigned32_t ac = 0;
213 const void *ptr = NULL;
222 goto error_create_fbuf;
225 if (
fwbuf_write(fbuf, ptr, nbyte) != (ssize_t)nbyte) {
254 co_unsigned32_t *pac)
259 co_unsigned32_t ac = 0;
281 co_unsigned32_t *pac)
286 co_unsigned32_t ac = 0;
312 #ifndef LELY_NO_CO_OBJ_FILE
315 co_unsigned32_t *pac)
321 co_unsigned32_t ac = 0;
327 goto error_create_fbuf;
336 size_t nbyte = (size_t)size;
345 if (
frbuf_read(fbuf, ptr, nbyte) != (ssize_t)nbyte) {
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_NOMEM
Not enough space.
@ 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.
errnum_t get_errnum(void)
Returns the last (thread-specific) platform-independent error number set by a system call or library ...
void set_errnum(errnum_t errnum)
Sets the current (thread-specific) platform-independent error number to errnum.
This header file is part of the utilities library; it contains the read file buffer declarations.
intmax_t frbuf_get_size(frbuf_t *buf)
Returns the size (in bytes) of the a read file buffer, or -1 on error.
frbuf_t * frbuf_create(const char *filename)
Creates a new read file buffer.
void frbuf_destroy(frbuf_t *buf)
Destroys a read file buffer.
ssize_t frbuf_read(frbuf_t *buf, void *ptr, size_t size)
Reads bytes from the current position in a read file buffer.
This header file is part of the utilities library; it contains the (atomic) write file buffer declara...
ssize_t fwbuf_write(fwbuf_t *buf, const void *ptr, size_t size)
Writes bytes to the current position in a write file buffer.
void fwbuf_destroy(fwbuf_t *buf)
Destroys a write file buffer.
int fwbuf_commit(fwbuf_t *buf)
Commits all changes to a write file buffer to disk if all previous file operations were successful,...
fwbuf_t * fwbuf_create(const char *filename)
Creates a new (atomic) write file buffer.
This header file is part of the CANopen library; it contains the Service Data Object (SDO) declaratio...
int co_sdo_req_first(const struct co_sdo_req *req)
Returns 1 if the specified request includes the first segment, and 0 otherwise.
#define CO_SDO_AC_TYPE_LEN_LO
SDO abort code: Data type does not match, length of service parameter too low.
#define CO_SDO_AC_PARAM_LO
SDO abort code: Value of parameter written too low (download only).
#define CO_SDO_AC_NO_READ
SDO abort code: Attempt to read a write only object.
#define CO_SDO_AC_NO_OD
SDO abort code: Object dictionary dynamic generation fails or no object dictionary is present (e....
#define CO_SDO_AC_TOGGLE
SDO abort code: Toggle bit not altered.
#define CO_SDO_AC_TYPE_LEN_HI
SDO abort code: Data type does not match, length of service parameter too high.
#define CO_SDO_AC_NO_CS
SDO abort code: Client/server command specifier not valid or unknown.
#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_ACCESS
SDO abort code: Unsupported access to an object.
#define CO_SDO_AC_ERROR
SDO abort code: General error.
#define CO_SDO_AC_PARAM
SDO abort code: General parameter incompatibility reason.
#define CO_SDO_AC_DATA
SDO abort code: Data cannot be transferred or stored to the application.
#define CO_SDO_AC_HARDWARE
SDO abort code: Access failed due to a hardware error.
#define CO_SDO_AC_NO_SDO
SDO abort code: Resource not available: SDO connection.
#define CO_SDO_AC_DATA_DEV
SDO abort code: Data cannot be transferred or stored to the application because of the present device...
#define CO_SDO_AC_PARAM_HI
SDO abort code: Value of parameter written too high (download only).
#define CO_SDO_AC_NO_OBJ
SDO abort code: Object does not exist in the object dictionary.
#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_AC_DATA_CTL
SDO abort code: Data cannot be transferred or stored to the application because of local control.
int co_sdo_req_last(const struct co_sdo_req *req)
Returns 1 if the specified request includes the last segment, and 0 otherwise.
#define CO_SDO_AC_PARAM_VAL
SDO abort code: Invalid value for parameter (download only).
#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_SDO_AC_NO_PDO
SDO abort code: Object cannot be mapped to the PDO.
#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_COMPAT
SDO abort code: General internal incompatibility in the device.
#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 CO_SDO_AC_PARAM_RANGE
SDO abort code: Maximum value is less than minimum value (download only).
ptrdiff_t membuf_seek(struct membuf *buf, ptrdiff_t offset)
Adjusts the position indicator of a memory buffer by offset bytes.
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.
size_t membuf_capacity(const struct membuf *buf)
Returns the number of unused bytes remaining in a memory buffer.
size_t membuf_write(struct membuf *buf, const void *ptr, size_t size)
Writes data to a memory buffer.
void * membuf_alloc(struct membuf *buf, size_t *size)
Creates region of *size bytes in a memory buffer, starting at the current position indicator given by...
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.
static void co_sdo_req_up_buf(struct co_sdo_req *req)
Constructs a CANopen SDO upload request from its internal buffer.
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,...
static int co_sdo_req_dn_buf(struct co_sdo_req *req, const void **pptr, size_t *pnbyte)
Copies the next segment of the specified CANopen SDO download request to the internal buffer.
int co_sdo_req_up_val(struct co_sdo_req *req, co_unsigned16_t type, const void *val, co_unsigned32_t *pac)
Writes the specified value to a buffer and constructs a CANopen SDO upload request.
int co_sdo_req_up(struct co_sdo_req *req, const void *ptr, size_t n, co_unsigned32_t *pac)
Writes the specified bytes to a buffer and constructs a CANopen SDO upload request.
void co_sdo_req_fini(struct co_sdo_req *req)
Finalizes a CANopen SDO upload/download request.
int co_sdo_req_dn_file(struct co_sdo_req *req, const char *filename, co_unsigned32_t *pac)
Copies the next segment of the specified CANopen SDO download request to the internal buffer and,...
int co_sdo_req_up_file(struct co_sdo_req *req, const char *filename, co_unsigned32_t *pac)
Loads the specified file into a buffer and constructs a CANopen SDO upload 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.
void co_sdo_req_init(struct co_sdo_req *req)
Initializes a CANopen SDO upload/download request.
int co_sdo_req_dn(struct co_sdo_req *req, const void **pptr, size_t *pnbyte, co_unsigned32_t *pac)
Copies the next segment of the specified CANopen SDO download request to the internal buffer and,...
This is the internal header file of the CANopen library.
An read file buffer struct.
An (atomic) write file buffer struct.
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.
struct membuf membuf
A memory buffer for use by the upload/download indication function.
size_t nbyte
The number of bytes available at buf.
char * begin
A pointer to the first byte in the buffer.
int co_type_is_array(co_unsigned16_t type)
Returns 1 if the specified (static) data type is an array, and 0 if not.
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_init(co_unsigned16_t type, void *val)
Initializes a value of the specified data type to zero.
size_t co_val_write(co_unsigned16_t type, const void *val, uint_least8_t *begin, uint_least8_t *end)
Writes a value of the specified data type to a memory buffer.
void co_val_fini(co_unsigned16_t type, void *val)
Finalizes a value of the specified data type.