Lely core libraries
2.3.4
|
Go to the documentation of this file.
25 #define LELY_CO_SDO_INLINE extern inline
27 #if !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;
171 co_unsigned32_t *pac)
173 co_unsigned32_t ac = 0;
175 const void *ptr = NULL;
183 type, val, ptr, (
const uint_least8_t *)ptr + nbyte);
195 }
else if (size < nbyte) {
210 #if !LELY_NO_CO_OBJ_FILE
213 co_unsigned32_t *pac)
216 co_unsigned32_t ac = 0;
218 const void *ptr = NULL;
227 goto error_create_fbuf;
230 if (
fwbuf_write(fbuf, ptr, nbyte) != (ssize_t)nbyte) {
255 #endif // !LELY_NO_CO_OBJ_FILE
259 co_unsigned32_t *pac)
264 co_unsigned32_t ac = 0;
288 co_unsigned32_t *pac)
293 co_unsigned32_t ac = 0;
321 #if !LELY_NO_CO_OBJ_FILE
324 co_unsigned32_t *pac)
330 co_unsigned32_t ac = 0;
336 goto error_create_fbuf;
345 size_t nbyte = (size_t)size;
354 if (
frbuf_read(fbuf, ptr, nbyte) != (ssize_t)nbyte) {
375 #endif // !LELY_NO_CO_OBJ_FILE
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...
#define CO_SDO_AC_TIMEOUT
SDO abort code: SDO protocol timed out.
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.
void membuf_init(struct membuf *buf, void *ptr, size_t size)
Initializes a memory buffer.
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_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,...
ssize_t frbuf_read(frbuf_t *buf, void *ptr, size_t size)
Reads bytes from the current position in a read file buffer.
#define CO_SDO_AC_NO_PDO
SDO abort code: Object cannot be mapped to the PDO.
void co_val_fini(co_unsigned16_t type, void *val)
Finalizes a value of the specified data type.
frbuf_t * frbuf_create(const char *filename)
Creates a new read file buffer.
#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_RANGE
SDO abort code: Maximum value is less than minimum value (download only).
#define CO_SDO_AC_NO_MEM
SDO abort code: Out of memory.
fwbuf_t * fwbuf_create(const char *filename)
Creates a new (atomic) write file buffer.
ssize_t fwbuf_write(fwbuf_t *buf, const void *ptr, size_t size)
Writes bytes to the current position in a write file 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.
#define CO_SDO_AC_BLK_CRC
SDO abort code: CRC error (block mode only).
void * membuf_begin(const struct membuf *buf)
Returns a pointer to the first byte in a memory buffer.
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function.
@ ERRNUM_NOMEM
Not enough space.
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.
int fwbuf_commit(fwbuf_t *buf)
Commits all changes to a write file buffer to disk if all previous file operations were successful,...
#define CO_SDO_AC_HARDWARE
SDO abort code: Access failed due to a hardware error.
size_t membuf_size(const struct membuf *buf)
Returns the total number of bytes written to a memory buffer.
#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_AC_TYPE_LEN
SDO abort code: Data type does not match, length of service parameter does not match.
#define CO_SDO_AC_PARAM_HI
SDO abort code: Value of parameter written too high (download only).
void frbuf_destroy(frbuf_t *buf)
Destroys a read file buffer.
size_t membuf_write(struct membuf *buf, const void *ptr, size_t size)
Writes data to a memory buffer.
intmax_t frbuf_get_size(frbuf_t *buf)
Returns the size (in bytes) of the a read file buffer, or -1 on error.
#define CO_SDO_AC_DATA_CTL
SDO abort code: Data cannot be transferred or stored to the application because of local control.
#define CO_SDO_AC_COMPAT
SDO abort code: General internal incompatibility in the device.
#define CO_SDO_AC_PARAM_LO
SDO abort code: Value of parameter written too low (download only).
void set_errnum(errnum_t errnum)
Sets the current (thread-specific) platform-independent error number to errnum.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
ptrdiff_t membuf_seek(struct membuf *buf, ptrdiff_t offset)
Adjusts the position indicator of a memory buffer by offset bytes.
void membuf_clear(struct membuf *buf)
Clears a memory buffer.
struct membuf membuf
A memory buffer for use by the upload/download indication function.
#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_SUB
SDO abort code: Sub-index does not exist.
A CANopen SDO upload/download request.
#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_ERROR
SDO abort code: General error.
@ ERRNUM_INVAL
Invalid argument.
const char * co_sdo_ac2str(co_unsigned32_t ac)
Returns a string describing an SDO abort code.
void co_sdo_req_clear(struct co_sdo_req *req)
Clears a CANopen SDO upload/download request, including its buffer.
int co_sdo_req_first(const struct co_sdo_req *req)
Returns 1 if the specified request includes the first segment, and 0 otherwise.
An read file buffer struct.
size_t size
The total size (in bytes) of the value to be uploaded/downloaded.
#define CO_SDO_AC_NO_DATA
SDO abort code: No data available.
#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_WRITE
SDO abort code: Attempt to write a read only object.
An (atomic) write file buffer struct.
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,...
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,...
void diag(enum diag_severity severity, int errc, const char *format,...)
Emits a diagnostic message.
int co_sdo_req_last(const struct co_sdo_req *req)
Returns 1 if the specified request includes the last segment, and 0 otherwise.
size_t membuf_capacity(const struct membuf *buf)
Returns the number of unused bytes remaining in a memory buffer.
#define CO_SDO_AC_PARAM_VAL
SDO abort code: Invalid value for parameter (download only).
size_t nbyte
The number of bytes available at buf.
const void * buf
A pointer to the next bytes to be uploaded/downloaded.
int co_val_init(co_unsigned16_t type, void *val)
Initializes a value of the specified data type to zero.
void co_sdo_req_init(struct co_sdo_req *req)
Initializes a CANopen SDO upload/download request.
#define CO_SDO_AC_NO_CS
SDO abort code: Client/server command specifier not valid or unknown.
size_t offset
The offset of the bytes at buf.
void fwbuf_destroy(fwbuf_t *buf)
Destroys a write file buffer.
#define CO_SDO_AC_NO_READ
SDO abort code: Attempt to read a write only object.
char * begin
A pointer to the first byte in the 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 co_sdo_req_fini(struct co_sdo_req *req)
Finalizes a CANopen SDO upload/download request.
errnum_t get_errnum(void)
Returns the last (thread-specific) platform-independent error number set by a system call or library ...
#define CO_SDO_AC_DATA
SDO abort code: Data cannot be transferred or stored to the application.
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.
#define CO_SDO_AC_TOGGLE
SDO abort code: Toggle bit not altered.
#define CO_SDO_AC_BLK_SEQ
SDO abort code: Invalid sequence number (block mode only).
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.
static void co_sdo_req_up_buf(struct co_sdo_req *req)
Constructs a CANopen SDO upload request from its internal buffer.
void membuf_fini(struct membuf *buf)
Finalizes a memory buffer.
#define CO_SDO_AC_PARAM
SDO abort code: General parameter incompatibility reason.
#define CO_SDO_AC_BLK_SIZE
SDO abort code: Invalid block size (block mode only).
#define CO_SDO_AC_DATA_DEV
SDO abort code: Data cannot be transferred or stored to the application because of the present device...
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_SDO_AC_NO_ACCESS
SDO abort code: Unsupported access to an object.