Lely core libraries  2.2.5
obj.h File Reference
#include <lely/co/type.h>
#include <stddef.h>
#include <lely/co/def/basic.def>
Include dependency graph for obj.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CO_OBJECT_NULL   0x00
 An object with no data fields.
 
#define CO_OBJECT_DOMAIN   0x02
 A large variable amount of data.
 
#define CO_OBJECT_DEFTYPE   0x05
 A type definitions.
 
#define CO_OBJECT_DEFSTRUCT   0x06
 A record type definition.
 
#define CO_OBJECT_VAR   0x07
 A single value.
 
#define CO_OBJECT_ARRAY   0x08
 A multiple data field object where each data field is a simple variable of the same basic data type.
 
#define CO_OBJECT_RECORD   0x09
 A multiple data field object where the data fields may be any combination of simple variables.
 
#define CO_ACCESS_READ   0x01
 The object can be read.
 
#define CO_ACCESS_WRITE   0x02
 The object can be written.
 
#define CO_ACCESS_TPDO   0x04
 The object can be mapped to a TPDO.
 
#define CO_ACCESS_RPDO   0x08
 The object can be mapped to an RPDO.
 
#define CO_ACCESS_RO   (CO_ACCESS_READ | CO_ACCESS_TPDO)
 Read-only access.
 
#define CO_ACCESS_WO   (CO_ACCESS_WRITE | CO_ACCESS_RPDO)
 Write-only access.
 
#define CO_ACCESS_RW   (CO_ACCESS_RO | CO_ACCESS_WO)
 Read or write access.
 
#define CO_ACCESS_RWR   (CO_ACCESS_RO | CO_ACCESS_WRITE)
 Read or write on process input.
 
#define CO_ACCESS_RWW   (CO_ACCESS_WO | CO_ACCESS_READ)
 Read or write on process output.
 
#define CO_ACCESS_CONST   (CO_ACCESS_RO | 0x10)
 Constant value.
 
#define CO_OBJ_FLAGS_READ   0x01
 Refuse read on scan.
 
#define CO_OBJ_FLAGS_WRITE   0x02
 Refuse write on download.
 
#define CO_OBJ_FLAGS_UPLOAD_FILE   0x04
 If a read access is performed for the object, the data is stored in a file. More...
 
#define CO_OBJ_FLAGS_DOWNLOAD_FILE   0x08
 If a write access is performed for the object, the data is stored in a file. More...
 
#define CO_OBJ_FLAGS_MIN_NODEID   0x10
 The lower limit of the object value is of the form $NODEID { "+" number }.
 
#define CO_OBJ_FLAGS_MAX_NODEID   0x20
 The upper limit of the object value is of the form $NODEID { "+" number }.
 
#define CO_OBJ_FLAGS_DEF_NODEID   0x40
 The default object value is of the form $NODEID { "+" number }.
 
#define CO_OBJ_FLAGS_VAL_NODEID   0x80
 The current object value is of the form $NODEID { "+" number }.
 

Typedefs

typedef 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 Receive-PDO indication. More...
 
typedef 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 Transmit-PDO indication. More...
 

Functions

co_obj_tco_obj_create (co_unsigned16_t idx)
 Creates a CANopen object. More...
 
void co_obj_destroy (co_obj_t *obj)
 Destroys a CANopen object, including its sub-objects. More...
 
co_obj_tco_obj_prev (const co_obj_t *obj)
 Finds the previous object in the object dictionary of a CANopen device. More...
 
co_obj_tco_obj_next (const co_obj_t *obj)
 Finds the next object in the object dictionary of a CANopen device. More...
 
co_dev_tco_obj_get_dev (const co_obj_t *obj)
 Returns a pointer to the CANopen device containing the specified object.
 
co_unsigned16_t co_obj_get_idx (const co_obj_t *obj)
 Returns the index of a CANopen object.
 
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. More...
 
int co_obj_insert_sub (co_obj_t *obj, co_sub_t *sub)
 Inserts a sub-object into a CANopen object. More...
 
int co_obj_remove_sub (co_obj_t *obj, co_sub_t *sub)
 Removes a sub-object from a CANopen object. More...
 
co_sub_tco_obj_find_sub (const co_obj_t *obj, co_unsigned8_t subidx)
 Finds a sub-object in a CANopen object. More...
 
co_sub_tco_obj_first_sub (const co_obj_t *obj)
 Finds the first sub-object (with the lowest sub-index) in a CANopen object. More...
 
co_sub_tco_obj_last_sub (const co_obj_t *obj)
 Finds the last sub-object (with the highest sub-index) in a CANopen object. More...
 
const char * co_obj_get_name (const co_obj_t *obj)
 Returns the name of a CANopen object. More...
 
int co_obj_set_name (co_obj_t *obj, const char *name)
 Sets the name of a CANopen object. More...
 
co_unsigned8_t co_obj_get_code (const co_obj_t *obj)
 Returns the object code of a CANopen object. More...
 
int co_obj_set_code (co_obj_t *obj, co_unsigned8_t code)
 Sets the code (type) of a CANopen object. More...
 
void * co_obj_addressof_val (const co_obj_t *obj)
 Returns the address of the value of a CANopen object. More...
 
size_t co_obj_sizeof_val (const co_obj_t *obj)
 Returns size (in bytes) of the value of a CANopen object. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
co_sub_tco_sub_create (co_unsigned8_t subidx, co_unsigned16_t type)
 Creates a CANopen sub-object. More...
 
void co_sub_destroy (co_sub_t *sub)
 Destroys a CANopen sub-object. More...
 
co_sub_tco_sub_prev (const co_sub_t *sub)
 Finds the previous sub-object in a CANopen object. More...
 
co_sub_tco_sub_next (const co_sub_t *sub)
 Finds the next sub-object in a CANopen object. More...
 
co_obj_tco_sub_get_obj (const co_sub_t *sub)
 Returns the a pointer to the CANopen object containing the specified sub-object.
 
co_unsigned8_t co_sub_get_subidx (const co_sub_t *sub)
 Returns the sub-index of a CANopen sub-object.
 
const char * co_sub_get_name (const co_sub_t *sub)
 Returns the name of a CANopen sub-object. More...
 
int co_sub_set_name (co_sub_t *sub, const char *name)
 Sets the name of a CANopen sub-object. More...
 
co_unsigned16_t co_sub_get_type (const co_sub_t *sub)
 Returns the data type of a CANopen sub-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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
const void * co_sub_addressof_def (const co_sub_t *sub)
 Returns the address of the default value of a CANopen sub-object. More...
 
size_t co_sub_sizeof_def (const co_sub_t *sub)
 Returns size (in bytes) of the default value of a CANopen sub-object. More...
 
const void * co_sub_get_def (const co_sub_t *sub)
 Returns a pointer to the default value of a CANopen sub-object. More...
 
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. More...
 
const void * co_sub_addressof_val (const co_sub_t *sub)
 Returns the address of the current value of a CANopen sub-object. More...
 
size_t co_sub_sizeof_val (const co_sub_t *sub)
 Returns size (in bytes) of the current value of a CANopen sub-object. More...
 
const void * co_sub_get_val (const co_sub_t *sub)
 Returns a pointer to the current value of a CANopen sub-object. More...
 
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. More...
 
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. More...
 
unsigned int co_sub_get_access (const co_sub_t *sub)
 Returns the access type of a CANopen sub-object. More...
 
int co_sub_set_access (co_sub_t *sub, unsigned int access)
 Sets the access type of a CANopen sub-object. More...
 
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. More...
 
void co_sub_set_pdo_mapping (co_sub_t *sub, int pdo_mapping)
 Enables or disables PDO mapping a CANopen sub-object. More...
 
unsigned int co_sub_get_flags (const co_sub_t *sub)
 Returns the object flags of a CANopen sub-object. More...
 
void co_sub_set_flags (co_sub_t *sub, unsigned int flags)
 Sets the object flags of a CANopen sub-object. More...
 
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, or NULL if the attribute does not exist. More...
 
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. More...
 
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, or NULL if the attribute does not exist. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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(). More...
 
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(). More...
 
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_FLAGS_WRITE) is not set. More...
 
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. More...
 
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. More...
 
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. More...
 
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(). More...
 

Detailed Description

This header file is part of the CANopen library; it contains the object dictionary declarations.

Author
J. S. Seldenthuis jseld.nosp@m.enth.nosp@m.uis@l.nosp@m.ely..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file obj.h.

Macro Definition Documentation

◆ CO_OBJ_FLAGS_UPLOAD_FILE

#define CO_OBJ_FLAGS_UPLOAD_FILE   0x04

If a read access is performed for the object, the data is stored in a file.

In this case, the object contains the filename, not the file contents.

Definition at line 96 of file obj.h.

◆ CO_OBJ_FLAGS_DOWNLOAD_FILE

#define CO_OBJ_FLAGS_DOWNLOAD_FILE   0x08

If a write access is performed for the object, the data is stored in a file.

In this case, the object contains the filename, not the file contents.

Definition at line 102 of file obj.h.

Typedef Documentation

◆ co_sub_dn_ind_t

typedef 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 Receive-PDO indication.

In case of an SDO request, this function is invoked for each segment.

Parameters
suba pointer to a CANopen sub-object.
reqa pointer to a CANopen SDO download request. The size, buf, nbyte and offset members of *req are set by the caller.
dataa pointer to user-specified data.
Returns
0 on success, or an SDO abort code on error.

Definition at line 136 of file obj.h.

◆ co_sub_up_ind_t

typedef 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 Transmit-PDO indication.

Parameters
suba pointer to a CANopen sub-object, containing the new value.
reqa pointer to a CANopen SDO upload request. On the first invocation, the size member of *req is set to 0. All members MUST be initialized by the indication function.
dataa pointer to user-specified data.
Returns
0 on success, or an SDO abort code on error.

Definition at line 151 of file obj.h.

Function Documentation

◆ co_obj_create()

co_obj_t* co_obj_create ( co_unsigned16_t  idx)

Creates a CANopen object.

Parameters
idxthe object index.
Returns
a pointer to a new CANopen object, or NULL on error. In the latter case, the error number can be obtained with get_errc().
See also
co_obj_destroy()

Definition at line 106 of file obj.c.

◆ co_obj_destroy()

void co_obj_destroy ( co_obj_t obj)

Destroys a CANopen object, including its sub-objects.

See also
co_obj_create()

Definition at line 118 of file obj.c.

◆ co_obj_prev()

co_obj_t* co_obj_prev ( const co_obj_t obj)

Finds the previous object in the object dictionary of a CANopen device.

Returns
a pointer to the previous object, or NULL if this is the first object.
See also
co_dev_last_obj(), co_obj_next()

Definition at line 128 of file obj.c.

◆ co_obj_next()

co_obj_t* co_obj_next ( const co_obj_t obj)

Finds the next object in the object dictionary of a CANopen device.

Returns
a pointer to the next object, or NULL if this is the first object.
See also
co_dev_first_obj(), co_obj_prev()

Definition at line 137 of file obj.c.

◆ co_obj_get_subidx()

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.

Parameters
obja pointer to a CANopen object.
maxsubidxthe maximum number of sub-indices to return.
subidxan array of at least maxsubidx indices (can be NULL). On success, *idx contains the sub-indices.
Returns
the total number of sub-indices in the object (which may be different from maxsubidx).

Definition at line 162 of file obj.c.

◆ co_obj_insert_sub()

int co_obj_insert_sub ( co_obj_t obj,
co_sub_t sub 
)

Inserts a sub-object into a CANopen object.

This function fails if the sub-object is already part of another object, or of another sub-object with the same sub-index already exists.

Parameters
obja pointer to a CANopen object.
suba pointer to the sub-object to be inserted.
Returns
0 on success, or -1 on error.
See also
co_obj_remove_sub(), co_obj_find_sub()

Definition at line 182 of file obj.c.

◆ co_obj_remove_sub()

int co_obj_remove_sub ( co_obj_t obj,
co_sub_t sub 
)

Removes a sub-object from a CANopen object.

Parameters
obja pointer to a CANopen object.
suba pointer to the sub-object to be removed.
Returns
0 on success, or -1 on error.
See also
co_obj_insert_sub()

Definition at line 205 of file obj.c.

◆ co_obj_find_sub()

co_sub_t* co_obj_find_sub ( const co_obj_t obj,
co_unsigned8_t  subidx 
)

Finds a sub-object in a CANopen object.

Parameters
obja pointer to a CANopen object.
subidxthe object sub-index.
Returns
a pointer to the sub-object if found, or NULL if not.
See also
co_obj_insert_sub()

Definition at line 225 of file obj.c.

◆ co_obj_first_sub()

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.

Returns
a pointer to the first sub-object, or NULL if the object is empty.
See also
co_dev_last_obj(), co_sub_next()

Definition at line 234 of file obj.c.

◆ co_obj_last_sub()

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.

Returns
a pointer to the last sub-object, or NULL if the object is empty.
See also
co_obj_first_sub(), co_sub_prev()

Definition at line 243 of file obj.c.

◆ co_obj_get_name()

const char* co_obj_get_name ( const co_obj_t obj)

Returns the name of a CANopen object.

See also
co_obj_set_name()

Definition at line 254 of file obj.c.

◆ co_obj_set_name()

int co_obj_set_name ( co_obj_t obj,
const char *  name 
)

Sets the name of a CANopen object.

Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
co_obj_get_name()

Definition at line 262 of file obj.c.

◆ co_obj_get_code()

co_unsigned8_t co_obj_get_code ( const co_obj_t obj)

Returns the object code of a CANopen object.

See also
co_obj_set_code()

Definition at line 286 of file obj.c.

◆ co_obj_set_code()

int co_obj_set_code ( co_obj_t obj,
co_unsigned8_t  code 
)

Sets the code (type) of a CANopen object.

Parameters
obja pointer to a CANopen object.
codethe object code (one of CO_OBJECT_NULL, CO_OBJECT_DOMAIN, CO_OBJECT_DEFTYPE, CO_OBJECT_DEFSTRUCT, CO_OBJECT_VAR, CO_OBJECT_ARRAY or CO_OBJECT_RECORD).
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
co_obj_get_code()

Definition at line 294 of file obj.c.

◆ co_obj_addressof_val()

void* co_obj_addressof_val ( const co_obj_t obj)

Returns the address of the value of a CANopen object.

In case of compound data types, this is a pointer to the struct or array containing the members.

See also
co_obj_sizeof_val()

Definition at line 311 of file obj.c.

◆ co_obj_sizeof_val()

size_t co_obj_sizeof_val ( const co_obj_t obj)

Returns size (in bytes) of the value of a CANopen object.

See also
co_obj_addressof_val()

Definition at line 317 of file obj.c.

◆ co_obj_get_val()

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.

In the case of strings or domains, this is the address of a pointer to the first byte in the array.

See also
co_obj_set_val(), co_sub_get_val()

Definition at line 323 of file obj.c.

◆ co_obj_set_val()

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.

Parameters
obja pointer to a CANopen object.
subidxthe object sub-index.
ptra pointer to the bytes to be copied. In case of strings or domains, ptr MUST point to the first byte in the array.
nthe number of bytes at ptr. In case of strings, n SHOULD exclude the terminating null byte(s).
Returns
the number of bytes copied (i.e., n), or 0 on error. In the latter case, the error number can be obtained with get_errc().
See also
co_obj_get_val(), co_sub_set_val()

Definition at line 330 of file obj.c.

◆ co_obj_set_dn_ind()

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.

This function invokes co_sub_set_dn_ind() for all sub-objects.

Parameters
obja pointer to a CANopen object.
inda pointer to the indication function. If ind is NULL, the default indication function will be used.
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to func.
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 372 of file obj.c.

◆ co_obj_set_up_ind()

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.

This function invokes co_sub_set_up_ind() for all sub-objects.

Parameters
obja pointer to a CANopen object.
inda pointer to the indication function. If ind is NULL, the default indication function will be used.
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to func.

Definition at line 382 of file obj.c.

◆ co_sub_create()

co_sub_t* co_sub_create ( co_unsigned8_t  subidx,
co_unsigned16_t  type 
)

Creates a CANopen sub-object.

Parameters
subidxthe object sub-index.
typethe data type of the sub-object value (in the range [1..27]). This MUST be the object index of one of the static data types.
Returns
a pointer to a new CANopen sub-object, or NULL on error. In the latter case, the error number can be obtained with get_errc().
See also
co_sub_destroy()

Definition at line 468 of file obj.c.

◆ co_sub_destroy()

void co_sub_destroy ( co_sub_t sub)

Destroys a CANopen sub-object.

See also
co_sub_create()

Definition at line 493 of file obj.c.

◆ co_sub_prev()

co_sub_t* co_sub_prev ( const co_sub_t sub)

Finds the previous sub-object in a CANopen object.

Returns
a pointer to the previous sub-object, or NULL if this is the first sub-object.
See also
co_obj_last_sub(), co_sub_next()

Definition at line 502 of file obj.c.

◆ co_sub_next()

co_sub_t* co_sub_next ( const co_sub_t sub)

Finds the next sub-object in a CANopen object.

Returns
a pointer to the next sub-object, or NULL if this is the first sub-object.
See also
co_obj_first_sub(), co_sub_prev()

Definition at line 511 of file obj.c.

◆ co_sub_get_name()

const char* co_sub_get_name ( const co_sub_t sub)

Returns the name of a CANopen sub-object.

See also
co_sub_set_name()

Definition at line 538 of file obj.c.

◆ co_sub_set_name()

int co_sub_set_name ( co_sub_t sub,
const char *  name 
)

Sets the name of a CANopen sub-object.

Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
co_sub_get_name()

Definition at line 546 of file obj.c.

◆ co_sub_addressof_min()

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.

In the case of strings or domains, this is the address of the first byte in the array.

See also
co_sub_sizeof_min()

Definition at line 580 of file obj.c.

◆ co_sub_sizeof_min()

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.

In the case of strings or domains, this is the number of bytes in the array.

See also
co_sub_addressof_min()

Definition at line 586 of file obj.c.

◆ co_sub_get_min()

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.

In the case of strings or domains, this is the address of a pointer to the first byte in the array.

See also
co_sub_set_min()

Definition at line 592 of file obj.c.

◆ co_sub_set_min()

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.

Parameters
suba pointer to a CANopen sub-object.
ptra pointer to the bytes to be copied. In case of strings or domains, ptr MUST point to the first byte in the array.
nthe number of bytes at ptr. In case of strings, n SHOULD exclude the terminating null byte(s).
Returns
the number of bytes copied (i.e., n), or 0 on error. In the latter case, the error number can be obtained with get_errc().
See also
co_sub_get_min()

Definition at line 598 of file obj.c.

◆ co_sub_addressof_max()

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.

In the case of strings or domains, this is the address of the first byte in the array.

See also
co_sub_sizeof_max()

Definition at line 607 of file obj.c.

◆ co_sub_sizeof_max()

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.

In the case of strings or domains, this is the number of bytes in the array.

See also
co_sub_addressof_max()

Definition at line 613 of file obj.c.

◆ co_sub_get_max()

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.

In the case of strings or domains, this is the address of a pointer to the first byte in the array.

See also
co_sub_set_max()

Definition at line 619 of file obj.c.

◆ co_sub_set_max()

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.

Parameters
suba pointer to a CANopen sub-object.
ptra pointer to the bytes to be copied. In case of strings or domains, ptr MUST point to the first byte in the array.
nthe number of bytes at ptr. In case of strings, n SHOULD exclude the terminating null byte(s).
Returns
the number of bytes copied (i.e., n), or 0 on error. In the latter case, the error number can be obtained with get_errc().
See also
co_sub_get_max()

Definition at line 625 of file obj.c.

◆ co_sub_addressof_def()

const void* co_sub_addressof_def ( const co_sub_t sub)

Returns the address of the default value of a CANopen sub-object.

In the case of strings or domains, this is the address of the first byte in the array.

See also
co_sub_sizeof_def()

Definition at line 638 of file obj.c.

◆ co_sub_sizeof_def()

size_t co_sub_sizeof_def ( const co_sub_t sub)

Returns size (in bytes) of the default value of a CANopen sub-object.

In the case of strings or domains, this is the number of bytes in the array.

See also
co_sub_addressof_def()

Definition at line 644 of file obj.c.

◆ co_sub_get_def()

const void* co_sub_get_def ( const co_sub_t sub)

Returns a pointer to the default value of a CANopen sub-object.

In the case of strings or domains, this is the address of a pointer to the first byte in the array.

See also
co_sub_set_def()

Definition at line 650 of file obj.c.

◆ co_sub_set_def()

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.

Parameters
suba pointer to a CANopen sub-object.
ptra pointer to the bytes to be copied. In case of strings or domains, ptr MUST point to the first byte in the array.
nthe number of bytes at ptr. In case of strings, n SHOULD exclude the terminating null byte(s).
Returns
the number of bytes copied (i.e., n), or 0 on error. In the latter case, the error number can be obtained with get_errc().
See also
co_sub_get_def()

Definition at line 656 of file obj.c.

◆ co_sub_addressof_val()

const void* co_sub_addressof_val ( const co_sub_t sub)

Returns the address of the current value of a CANopen sub-object.

In the case of strings or domains, this is the address of the first byte in the array.

See also
co_sub_sizeof_val()

Definition at line 667 of file obj.c.

◆ co_sub_sizeof_val()

size_t co_sub_sizeof_val ( const co_sub_t sub)

Returns size (in bytes) of the current value of a CANopen sub-object.

In the case of strings or domains, this is the number of bytes in the array.

See also
co_sub_addressof_val()

Definition at line 673 of file obj.c.

◆ co_sub_get_val()

const void* co_sub_get_val ( const co_sub_t sub)

Returns a pointer to the current value of a CANopen sub-object.

In the case of strings or domains, this is the address of a pointer to the first byte in the array.

See also
co_sub_set_val()

Definition at line 679 of file obj.c.

◆ co_sub_set_val()

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.

Parameters
suba pointer to a CANopen sub-object.
ptra pointer to the bytes to be copied. In case of strings or domains, ptr MUST point to the first byte in the array.
nthe number of bytes at ptr. In case of strings, n SHOULD exclude the terminating null byte(s).
Returns
the number of bytes copied (i.e., n), or 0 on error. In the latter case, the error number can be obtained with get_errc().
See also
co_sub_get_val()

Definition at line 685 of file obj.c.

◆ co_sub_chk_val()

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.

This function checks if the specified type matches that of the sub-object and, in the case of basic types, if the value is within range.

Parameters
suba pointer to a CANopen sub-object.
typethe data type (in the range [1..27]). This MUST be the object index of one of the static data types.
vala pointer to the value to be checked. In the case of strings or domains, this MUST be the address of pointer.
Returns
0 on success, or an SDO abort code on error.

Definition at line 719 of file obj.c.

◆ co_sub_get_access()

unsigned int co_sub_get_access ( const co_sub_t sub)

Returns the access type of a CANopen sub-object.

See also
co_sub_set_access()

Definition at line 745 of file obj.c.

◆ co_sub_set_access()

int co_sub_set_access ( co_sub_t sub,
unsigned int  access 
)

Sets the access type of a CANopen sub-object.

Parameters
suba pointer to a CANopen sub-object.
accessthe access type (one of CO_ACCESS_RO, CO_ACCESS_WO, CO_ACCESS_RW or CO_ACCESS_CONST).
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
co_sub_get_access()

Definition at line 753 of file obj.c.

◆ co_sub_get_pdo_mapping()

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.

See also
co_sub_set_pdo_mapping()

Definition at line 769 of file obj.c.

◆ co_sub_set_pdo_mapping()

void co_sub_set_pdo_mapping ( co_sub_t sub,
int  pdo_mapping 
)

Enables or disables PDO mapping a CANopen sub-object.

See also
co_sub_get_pdo_mapping()

Definition at line 777 of file obj.c.

◆ co_sub_get_flags()

unsigned int co_sub_get_flags ( const co_sub_t sub)

Returns the object flags of a CANopen sub-object.

See also
co_sub_set_flags()

Definition at line 785 of file obj.c.

◆ co_sub_set_flags()

void co_sub_set_flags ( co_sub_t sub,
unsigned int  flags 
)

Sets the object flags of a CANopen sub-object.

See also
co_sub_get_flags()

Definition at line 793 of file obj.c.

◆ co_sub_get_upload_file()

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, or NULL if the attribute does not exist.

See also
co_sub_set_upload_file()

Definition at line 803 of file obj.c.

◆ co_sub_set_upload_file()

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.

Parameters
suba pointer to a CANopen sub-object.
filenamea pointer to the null-terminated string to be copied to the UploadFile attribute.
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
Precondition
the result of co_sub_get_flags() contains CO_OBJ_FLAGS_UPLOAD_FILE.
See also
co_sub_get_upload_file()

Definition at line 815 of file obj.c.

◆ co_sub_get_download_file()

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, or NULL if the attribute does not exist.

See also
co_sub_set_download_file()

Definition at line 830 of file obj.c.

◆ co_sub_set_download_file()

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.

Parameters
suba pointer to a CANopen sub-object.
filenamea pointer to the null-terminated string to be copied to the DownloadFile attribute.
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
Precondition
the result of co_sub_get_flags() contains CO_OBJ_FLAGS_DOWNLOAD_FILE.
See also
co_sub_get_download_file()

Definition at line 842 of file obj.c.

◆ co_sub_get_dn_ind()

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.

Parameters
suba pointer to a CANopen sub-object.
pindthe address at which to store a pointer to the indication function (can be NULL).
pdatathe address at which to store a pointer to user-specified data (can be NULL).
See also
co_sub_set_dn_ind()

Definition at line 859 of file obj.c.

◆ co_sub_set_dn_ind()

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.

This function is invoked by co_sub_dn_ind().

Parameters
suba pointer to a CANopen sub-object.
inda pointer to the indication function. If ind is NULL, the default indication function will be used (which invokes co_sub_on_dn()).
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to func.
See also
co_sub_get_dn_ind()

Definition at line 870 of file obj.c.

◆ co_sub_on_dn()

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.

For a domain value with the CO_OBJ_FLAGS_DOWNLOAD_FILE flag set, this function invokes co_sdo_req_dn_file() to write the value to file. Otherwise the value is read from the SDO download request with co_sdo_req_dn_val() and, if it is within the specified range, written to the object dictionary with co_sub_dn().

Parameters
suba pointer to a CANopen sub-object.
reqa pointer to a CANopen SDO download request.
pacthe address of a value which, on error, contains the SDO abort code (can be NULL).
Returns
0 if all segments have been received and the value has been successfully written to the object dictionary, and -1 if one or more segments remain or an error has occurred. In the latter case, *pac contains the SDO abort code.

Definition at line 879 of file obj.c.

◆ co_sub_dn_ind()

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().

This is used for writing values to the object dictionary. If the indication function returns an error, or the refuse-write-on-download flag (CO_OBJ_FLAGS_WRITE) is set, the value of the sub-object is left untouched.

Parameters
suba pointer to a CANopen sub-object.
reqa pointer to a CANopen SDO download request. All members of *req, except membuf, MUST be set by the caller. The membuf MUST be initialized before the first invocation and MUST only be used by the indication function.
Returns
0 on success, or an SDO abort code on error.
See also
co_sub_dn_ind_val()

Definition at line 916 of file obj.c.

◆ co_sub_dn_ind_val()

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().

This is used for writing values to the object dictionary. If the indication function returns an error, or the refuse-write-on-download flag (CO_OBJ_FLAGS_WRITE) is set, the value of the sub-object is left untouched.

Parameters
suba pointer to a CANopen sub-object.
typethe data type (in the range [1..27]). This MUST be the object index of one of the static data types and SHOULD be the same as the return value of co_sub_get_type().
valthe address of the value to be written. In case of string or domains, this MUST be the address of pointer.
Returns
0 on success, or an SDO abort code on error.
See also
co_sub_dn_ind()

Definition at line 932 of file obj.c.

◆ co_sub_dn()

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_FLAGS_WRITE) is not set.

This function is invoked by the default download indication function.

Parameters
suba pointer to a CANopen sub-object.
vala pointer to the value to be written. In the case of strings or domains, this MUST be the address of pointer (which is set to NULL if the value is moved).
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
co_val_move()

Definition at line 954 of file obj.c.

◆ co_sub_get_up_ind()

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.

Parameters
suba pointer to a CANopen sub-object.
pindthe address at which to store a pointer to the indication function (can be NULL).
pdatathe address at which to store a pointer to user-specified data (can be NULL).
See also
co_sub_set_up_ind()

Definition at line 970 of file obj.c.

◆ co_sub_set_up_ind()

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.

This function is invoked by co_sub_up_ind().

Parameters
suba pointer to a CANopen sub-object.
inda pointer to the indication function. If ind is NULL, the default indication function will be used (which invokes co_sub_on_up()).
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to func.
See also
co_sub_get_up_ind()

Definition at line 981 of file obj.c.

◆ co_sub_on_up()

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.

For a domain value with the CO_OBJ_FLAGS_UPLOAD_FILE flag set, this function invokes co_sdo_req_up_file() to read the value from file. Otherwise the value is read from the object dictionary with co_sub_get_val() and written to the SDO upload request with co_sdo_req_up_val().

Parameters
suba pointer to a CANopen sub-object.
reqa pointer to a CANopen SDO upload request.
pacthe address of a value which, on error, contains the SDO abort code (can be NULL).
Returns
0 on success, or -1 on error. In the latter case, *pac contains the SDO abort code.

Definition at line 992 of file obj.c.

◆ co_sub_up_ind()

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().

This is used for reading values from the object dictionary.

Parameters
suba pointer to a CANopen sub-object.
reqa pointer to a CANopen SDO upload request. The size member of *req MUST be set to 0 on the first invocation. All members MUST be initialized by the indication function.
Returns
0 on success, or an SDO abort code on error.

Definition at line 1019 of file obj.c.