Lely core libraries
2.3.4
|
This file is part of the CANopen library; it contains the implementation of the object dictionary. More...
#include "co.h"
#include <lely/co/detail/obj.h>
#include <lely/co/dev.h>
#include <lely/co/sdo.h>
#include <lely/util/cmp.h>
#include <lely/util/errnum.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <lely/co/def/basic.def>
Go to the source code of this file.
Functions | |
static void | co_obj_update (co_obj_t *obj) |
Updates an object by allocating a new memory region containing the members and moving the old values. | |
static void | co_obj_clear (co_obj_t *obj) |
Destroys all sub-objects. | |
co_obj_t * | co_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_t * | co_obj_prev (const co_obj_t *obj) |
Finds the previous object in the object dictionary of a CANopen device. More... | |
co_obj_t * | co_obj_next (const co_obj_t *obj) |
Finds the next object in the object dictionary of a CANopen device. More... | |
co_dev_t * | co_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 maxidx, 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_t * | co_obj_find_sub (const co_obj_t *obj, co_unsigned8_t subidx) |
Finds a sub-object in a CANopen object. More... | |
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. More... | |
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. 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_t * | co_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_t * | co_sub_prev (const co_sub_t *sub) |
Finds the previous sub-object in a CANopen object. More... | |
co_sub_t * | co_sub_next (const co_sub_t *sub) |
Finds the next sub-object in a CANopen object. More... | |
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. | |
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 the 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 the 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... | |
co_unsigned32_t | co_sub_default_dn_ind (co_sub_t *sub, struct co_sdo_req *req, void *data) |
The default download indication function. More... | |
co_unsigned32_t | co_sub_default_up_ind (const co_sub_t *sub, struct co_sdo_req *req, void *data) |
The default upload indication function. More... | |
This file is part of the CANopen library; it contains the implementation of the object dictionary.
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.c.
co_obj_t* co_obj_create | ( | co_unsigned16_t | idx | ) |
Creates a CANopen object.
idx | the object index. |
void co_obj_destroy | ( | co_obj_t * | obj | ) |
Destroys a CANopen object, including its sub-objects.
Finds the previous object in the object dictionary of a CANopen device.
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.
obj | a pointer to a CANopen object. |
maxsubidx | the maximum number of sub-indices to return. |
subidx | an array of at least maxsubidx indices (can be NULL). On success, *idx contains the sub-indices. |
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.
obj | a pointer to a CANopen object. |
sub | a pointer to the sub-object to be inserted. |
Removes a sub-object from a CANopen object.
obj | a pointer to a CANopen object. |
sub | a pointer to the sub-object to be removed. |
Finds a sub-object in a CANopen object.
obj | a pointer to a CANopen object. |
subidx | the object sub-index. |
Finds the first sub-object (with the lowest sub-index) in a CANopen object.
Finds the last sub-object (with the highest sub-index) in a CANopen object.
const char* co_obj_get_name | ( | const co_obj_t * | obj | ) |
Returns the name of a CANopen object.
int co_obj_set_name | ( | co_obj_t * | obj, |
const char * | name | ||
) |
Sets the name of a CANopen object.
co_unsigned8_t co_obj_get_code | ( | const co_obj_t * | obj | ) |
Returns the object code of a CANopen object.
int co_obj_set_code | ( | co_obj_t * | obj, |
co_unsigned8_t | code | ||
) |
Sets the code (type) of a CANopen object.
obj | a pointer to a CANopen object. |
code | the 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). |
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.
size_t co_obj_sizeof_val | ( | const co_obj_t * | obj | ) |
Returns size (in bytes) of the value of a CANopen object.
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.
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.
obj | a pointer to a CANopen object. |
subidx | the object sub-index. |
ptr | a pointer to the bytes to be copied. In case of strings or domains, ptr MUST point to the first byte in the array. |
n | the number of bytes at ptr. In case of strings, n SHOULD exclude the terminating null byte(s). |
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.
obj | a pointer to a CANopen object. |
ind | a pointer to the indication function. If ind is NULL, the default indication function will be used. |
data | a pointer to user-specified data (can be NULL). data is passed as the last parameter to func. |
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.
obj | a pointer to a CANopen object. |
ind | a pointer to the indication function. If ind is NULL, the default indication function will be used. |
data | a pointer to user-specified data (can be NULL). data is passed as the last parameter to func. |
co_sub_t* co_sub_create | ( | co_unsigned8_t | subidx, |
co_unsigned16_t | type | ||
) |
Creates a CANopen sub-object.
subidx | the object sub-index. |
type | the 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. |
void co_sub_destroy | ( | co_sub_t * | sub | ) |
Finds the previous sub-object in a CANopen object.
Finds the next sub-object in a CANopen object.
const char* co_sub_get_name | ( | const co_sub_t * | sub | ) |
Returns the name 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.
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.
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.
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.
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.
sub | a pointer to a CANopen sub-object. |
ptr | a pointer to the bytes to be copied. In case of strings or domains, ptr MUST point to the first byte in the array. |
n | the number of bytes at ptr. In case of strings, n SHOULD exclude the terminating null byte(s). |
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.
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.
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.
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.
sub | a pointer to a CANopen sub-object. |
ptr | a pointer to the bytes to be copied. In case of strings or domains, ptr MUST point to the first byte in the array. |
n | the number of bytes at ptr. In case of strings, n SHOULD exclude the terminating null byte(s). |
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.
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.
In the case of strings or domains, this is the number of bytes in the array.
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.
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.
sub | a pointer to a CANopen sub-object. |
ptr | a pointer to the bytes to be copied. In case of strings or domains, ptr MUST point to the first byte in the array. |
n | the number of bytes at ptr. In case of strings, n SHOULD exclude the terminating null byte(s). |
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.
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.
In the case of strings or domains, this is the number of bytes in the array.
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.
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.
sub | a pointer to a CANopen sub-object. |
ptr | a pointer to the bytes to be copied. In case of strings or domains, ptr MUST point to the first byte in the array. |
n | the number of bytes at ptr. In case of strings, n SHOULD exclude the terminating null byte(s). |
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.
sub | a pointer to a CANopen sub-object. |
type | the data type (in the range [1..27]). This MUST be the object index of one of the static data types. |
val | a pointer to the value to be checked. In the case of strings or domains, this MUST be the address of pointer. |
unsigned int co_sub_get_access | ( | const co_sub_t * | sub | ) |
Returns the access type of a CANopen sub-object.
int co_sub_set_access | ( | co_sub_t * | sub, |
unsigned int | access | ||
) |
Sets the access type of a CANopen sub-object.
sub | a pointer to a CANopen sub-object. |
access | the access type (one of CO_ACCESS_RO, CO_ACCESS_WO, CO_ACCESS_RW or CO_ACCESS_CONST). |
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.
void co_sub_set_pdo_mapping | ( | co_sub_t * | sub, |
int | pdo_mapping | ||
) |
Enables or disables PDO mapping a CANopen sub-object.
unsigned int co_sub_get_flags | ( | const co_sub_t * | sub | ) |
Returns the object flags of a CANopen sub-object.
void co_sub_set_flags | ( | co_sub_t * | sub, |
unsigned int | flags | ||
) |
Sets the object flags of a CANopen sub-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, or NULL if the attribute does not exist.
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.
sub | a pointer to a CANopen sub-object. |
filename | a pointer to the null-terminated string to be copied to the UploadFile attribute. |
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.
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.
sub | a pointer to a CANopen sub-object. |
filename | a pointer to the null-terminated string to be copied to the DownloadFile attribute. |
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.
sub | a pointer to a CANopen sub-object. |
pind | the address at which to store a pointer to the indication function (can be NULL). |
pdata | the address at which to store a pointer to user-specified data (can be NULL). |
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().
sub | a pointer to a CANopen sub-object. |
ind | a pointer to the indication function. If ind is NULL, the default indication function will be used (which invokes co_sub_on_dn()). |
data | a pointer to user-specified data (can be NULL). data is passed as the last parameter to func. |
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().
sub | a pointer to a CANopen sub-object. |
req | a pointer to a CANopen SDO download request. |
pac | the address of a value which, on error, contains the SDO abort code (can be NULL). |
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.
sub | a pointer to a CANopen sub-object. |
req | a 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. |
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.
sub | a pointer to a CANopen sub-object. |
type | the 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(). |
val | the address of the value to be written. In case of string or domains, this MUST be the address of pointer. |
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.
sub | a pointer to a CANopen sub-object. |
val | a 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). |
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.
sub | a pointer to a CANopen sub-object. |
pind | the address at which to store a pointer to the indication function (can be NULL). |
pdata | the address at which to store a pointer to user-specified data (can be NULL). |
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().
sub | a pointer to a CANopen sub-object. |
ind | a pointer to the indication function. If ind is NULL, the default indication function will be used (which invokes co_sub_on_up()). |
data | a pointer to user-specified data (can be NULL). data is passed as the last parameter to func. |
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().
sub | a pointer to a CANopen sub-object. |
req | a pointer to a CANopen SDO upload request. |
pac | the address of a value which, on error, contains the SDO abort code (can be NULL). |
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.
sub | a pointer to a CANopen sub-object. |
req | a 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. |
co_unsigned32_t co_sub_default_dn_ind | ( | co_sub_t * | sub, |
struct co_sdo_req * | req, | ||
void * | data | ||
) |
The default download indication function.
co_unsigned32_t co_sub_default_up_ind | ( | const co_sub_t * | sub, |
struct co_sdo_req * | req, | ||
void * | data | ||
) |
The default upload indication function.