Lely core libraries
2.3.4
|
Go to the documentation of this file.
22 #ifndef LELY_CO_OBJ_H_
23 #define LELY_CO_OBJ_H_
30 #define CO_OBJECT_NULL 0x00
33 #define CO_OBJECT_DOMAIN 0x02
36 #define CO_OBJECT_DEFTYPE 0x05
39 #define CO_OBJECT_DEFSTRUCT 0x06
42 #define CO_OBJECT_VAR 0x07
48 #define CO_OBJECT_ARRAY 0x08
54 #define CO_OBJECT_RECORD 0x09
57 #define CO_ACCESS_READ 0x01
60 #define CO_ACCESS_WRITE 0x02
63 #define CO_ACCESS_TPDO 0x04
66 #define CO_ACCESS_RPDO 0x08
69 #define CO_ACCESS_RO (CO_ACCESS_READ | CO_ACCESS_TPDO)
72 #define CO_ACCESS_WO (CO_ACCESS_WRITE | CO_ACCESS_RPDO)
75 #define CO_ACCESS_RW (CO_ACCESS_RO | CO_ACCESS_WO)
78 #define CO_ACCESS_RWR (CO_ACCESS_RO | CO_ACCESS_WRITE)
81 #define CO_ACCESS_RWW (CO_ACCESS_WO | CO_ACCESS_READ)
84 #define CO_ACCESS_CONST (CO_ACCESS_RO | 0x10)
87 #define CO_OBJ_FLAGS_READ 0x01
90 #define CO_OBJ_FLAGS_WRITE 0x02
96 #define CO_OBJ_FLAGS_UPLOAD_FILE 0x04
102 #define CO_OBJ_FLAGS_DOWNLOAD_FILE 0x08
105 #define CO_OBJ_FLAGS_MIN_NODEID 0x10
108 #define CO_OBJ_FLAGS_MAX_NODEID 0x20
111 #define CO_OBJ_FLAGS_DEF_NODEID 0x40
114 #define CO_OBJ_FLAGS_VAL_NODEID 0x80
120 #define CO_OBJ_FLAGS_PARAMETER_VALUE 0x100
161 void *__co_obj_alloc(
void);
162 void __co_obj_free(
void *ptr);
167 void __co_obj_fini(
struct __co_obj *obj);
186 #endif // !LELY_NO_MALLOC
225 co_unsigned8_t *subidx);
356 #define LELY_CO_DEFINE_TYPE(a, b, c, d) \
357 co_##b##_t co_obj_get_val_##c( \
358 const co_obj_t *obj, co_unsigned8_t subidx); \
359 size_t co_obj_set_val_##c( \
360 co_obj_t *obj, co_unsigned8_t subidx, co_##b##_t c);
361 #include <lely/co/def/basic.def>
362 #undef LELY_CO_DEFINE_TYPE
392 void *__co_sub_alloc(
void);
393 void __co_sub_free(
void *ptr);
397 co_unsigned16_t
type,
void *
val);
398 void __co_sub_fini(
struct __co_sub *sub);
419 #endif // !LELY_NO_MALLOC
634 #define LELY_CO_DEFINE_TYPE(a, b, c, d) \
635 co_##b##_t co_sub_get_val_##c(const co_sub_t *sub); \
636 size_t co_sub_set_val_##c(co_sub_t *sub, co_##b##_t c);
637 #include <lely/co/def/basic.def>
638 #undef LELY_CO_DEFINE_TYPE
894 co_unsigned32_t *pac);
914 #endif // !LELY_CO_OBJ_H_
int co_sub_set_download_file(co_sub_t *sub, const char *filename)
Sets the value of the DownloadFile attribute of a CANopen sub-object.
co_sub_t * co_sub_prev(const co_sub_t *sub)
Finds the previous sub-object in 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...
size_t size
The size (in bytes) of the value at val.
size_t co_obj_sizeof_val(const co_obj_t *obj)
Returns size (in bytes) of the value of a CANopen object.
void co_sub_set_flags(co_sub_t *sub, unsigned int flags)
Sets the object flags of a CANopen sub-object.
co_unsigned16_t idx
The object index.
int co_sub_on_up(const co_sub_t *sub, struct co_sdo_req *req, co_unsigned32_t *pac)
Implements the default behavior when an upload indication is received by a CANopen sub-object.
const void * co_sub_addressof_val(const co_sub_t *sub)
Returns the address of the current value of a CANopen sub-object.
void * val
A pointer to the object value.
co_unsigned32_t co_sub_dn_ind_t(co_sub_t *sub, struct co_sdo_req *req, void *data)
The type of a CANopen sub-object download indication function, invoked by an SDO download request or ...
int co_obj_insert_sub(co_obj_t *obj, co_sub_t *sub)
Inserts a sub-object into a CANopen object.
co_unsigned8_t code
The object code.
void co_sub_get_dn_ind(const co_sub_t *sub, co_sub_dn_ind_t **pind, void **pdata)
Retrieves the download indication function for a CANopen sub-object.
void * val
A pointer to the sub-object value.
void co_sub_set_pdo_mapping(co_sub_t *sub, int pdo_mapping)
Enables or disables PDO mapping a CANopen sub-object.
co_unsigned16_t type
The data type.
size_t co_sub_sizeof_min(const co_sub_t *sub)
Returns size (in bytes) of the lower limit of the value of a CANopen sub-object.
const void * co_sub_get_val(const co_sub_t *sub)
Returns a pointer to the current value of a CANopen sub-object.
co_sub_t * co_sub_next(const co_sub_t *sub)
Finds the next sub-object in a CANopen object.
const char * co_sub_get_download_file(const co_sub_t *sub)
Returns a pointer to the value of the DownloadFile attribute of a CANopen sub-object,...
size_t co_sub_set_min(co_sub_t *sub, const void *ptr, size_t n)
Sets the lower limit of a value of a CANopen sub-object.
void co_obj_destroy(co_obj_t *obj)
Destroys a CANopen object, including its sub-objects.
int co_sub_set_access(co_sub_t *sub, unsigned int access)
Sets the access type of a CANopen sub-object.
int co_sub_get_pdo_mapping(const co_sub_t *sub)
Returns 1 if it is possible to map the specified CANopen sub-object into a PDO, and 0 if not.
const void * co_sub_get_max(const co_sub_t *sub)
Returns a pointer to the upper limit of the value of a CANopen sub-object.
void * co_obj_addressof_val(const co_obj_t *obj)
Returns the address of the value of a CANopen object.
char * name
A pointer to the name of the sub-object.
const void * co_sub_addressof_def(const co_sub_t *sub)
Returns the address of the default value of a CANopen sub-object.
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_sub_t * co_obj_first_sub(const co_obj_t *obj)
Finds the first sub-object (with the lowest sub-index) in a CANopen object.
const void * co_sub_get_min(const co_sub_t *sub)
Returns a pointer to the lower limit of the value of a CANopen sub-object.
char * name
A pointer to the name of the object.
const void * co_sub_addressof_min(const co_sub_t *sub)
Returns the address of the lower limit of the value of a CANopen sub-object.
const char * co_obj_get_name(const co_obj_t *obj)
Returns the name of a CANopen object.
co_obj_t * co_obj_next(const co_obj_t *obj)
Finds the next object in the object dictionary of a CANopen device.
co_unsigned8_t co_obj_get_subidx(const co_obj_t *obj, co_unsigned8_t maxsubidx, co_unsigned8_t *subidx)
Retrieves a list of sub-indices in a CANopen object.
void co_obj_set_up_ind(co_obj_t *obj, co_sub_up_ind_t *ind, void *data)
Sets the upload indication function for a CANopen object.
const char * co_sub_get_upload_file(const co_sub_t *sub)
Returns a pointer to the value of the UploadFile attribute of a CANopen sub-object,...
const void * co_sub_get_def(const co_sub_t *sub)
Returns a pointer to the default value of a CANopen sub-object.
size_t co_sub_sizeof_max(const co_sub_t *sub)
Returns size (in bytes) of the upper limit of the value of a CANopen sub-object.
int co_obj_remove_sub(co_obj_t *obj, co_sub_t *sub)
Removes a sub-object from 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.
const char * co_sub_get_name(const co_sub_t *sub)
Returns the name of a CANopen sub-object.
A CANopen SDO upload/download request.
int co_sub_on_dn(co_sub_t *sub, struct co_sdo_req *req, co_unsigned32_t *pac)
Implements the default behavior when a download indication is received by a CANopen sub-object.
co_dev_t * co_obj_get_dev(const co_obj_t *obj)
Returns a pointer to the CANopen device containing the specified object.
unsigned int co_sub_get_flags(const co_sub_t *sub)
Returns the object flags of a CANopen sub-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.
uint_least32_t pdo_mapping
A flag indicating if it is possible to map this object into a PDO.
const void * co_obj_get_val(const co_obj_t *obj, co_unsigned8_t subidx)
Returns a pointer to the current value of a CANopen sub-object.
size_t co_sub_sizeof_val(const co_sub_t *sub)
Returns the size (in bytes) of 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().
size_t co_sub_set_def(co_sub_t *sub, const void *ptr, size_t n)
Sets the default value of a CANopen sub-object.
int co_sub_set_upload_file(co_sub_t *sub, const char *filename)
Sets the value of the UploadFile attribute of a CANopen sub-object.
size_t co_sub_set_max(co_sub_t *sub, const void *ptr, size_t n)
Sets the upper limit of a value of a CANopen sub-object.
uint_least32_t flags
The object flags.
co_obj_t * co_obj_prev(const co_obj_t *obj)
Finds the previous object in the object dictionary of a CANopen device.
void co_sub_get_up_ind(const co_sub_t *sub, co_sub_up_ind_t **pind, void **pdata)
Retrieves the upload indication function for a CANopen sub-object.
size_t co_sub_sizeof_def(const co_sub_t *sub)
Returns the size (in bytes) of the default value of a CANopen sub-object.
co_unsigned32_t co_sub_dn_ind_val(co_sub_t *sub, co_unsigned16_t type, const void *val)
Invokes the download indication function of a CANopen sub-object, registered with co_sub_set_dn_ind()...
const void * co_sub_addressof_max(const co_sub_t *sub)
Returns the address of the upper limit of the value 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()...
uint_least32_t access
The access type.
co_unsigned16_t co_sub_get_type(const co_sub_t *sub)
Returns the data type of a CANopen sub-object.
int co_sub_set_name(co_sub_t *sub, const char *name)
Sets the name of a CANopen sub-object.
co_sub_t * co_sub_create(co_unsigned8_t subidx, co_unsigned16_t type)
Creates a CANopen sub-object.
int co_obj_set_name(co_obj_t *obj, const char *name)
Sets the name of a CANopen object.
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_chk_val(const co_sub_t *sub, co_unsigned16_t type, const void *val)
Checks if the specifed value would be a valid value for a CANopen sub-object.
co_sub_t * co_obj_last_sub(const co_obj_t *obj)
Finds the last sub-object (with the highest sub-index) in a CANopen object.
co_obj_t * co_obj_create(co_unsigned16_t idx)
Creates a CANopen object.
void co_sub_set_up_ind(co_sub_t *sub, co_sub_up_ind_t *ind, void *data)
Sets the upload indication function for a CANopen sub-object.
void co_sub_set_dn_ind(co_sub_t *sub, co_sub_dn_ind_t *ind, void *data)
Sets the download indication function for a CANopen sub-object.
unsigned int co_sub_get_access(const co_sub_t *sub)
Returns the access type of a CANopen sub-object.
co_unsigned32_t co_sub_up_ind_t(const co_sub_t *sub, struct co_sdo_req *req, void *data)
The type of a CANopen sub-object upload indication function, invoked by an SDO upload request or Tran...
co_unsigned8_t co_obj_get_code(const co_obj_t *obj)
Returns the object code of a CANopen object.
void co_sub_destroy(co_sub_t *sub)
Destroys a CANopen sub-object.
co_unsigned16_t co_obj_get_idx(const co_obj_t *obj)
Returns the index of a CANopen object.
size_t co_sub_set_val(co_sub_t *sub, const void *ptr, size_t n)
Sets the current value of a CANopen sub-object.
co_unsigned8_t subidx
The object sub-index.
int co_obj_set_code(co_obj_t *obj, co_unsigned8_t code)
Sets the code (type) of a CANopen object.
size_t co_obj_set_val(co_obj_t *obj, co_unsigned8_t subidx, const void *ptr, size_t n)
Sets the current value of a CANopen sub-object.