CANopenNode
CANopen protocol stack
|
Structure for input / output on the OD variable. More...
#include <CO_ODinterface.h>
Data Fields | |
OD_stream_t | stream |
Object Dictionary stream object, passed to read or write. | |
ODR_t(* | read )(OD_stream_t *stream, void *buf, OD_size_t count, OD_size_t *countRead) |
Function pointer for reading value from specified variable from Object Dictionary. | |
ODR_t(* | write )(OD_stream_t *stream, const void *buf, OD_size_t count, OD_size_t *countWritten) |
Function pointer for writing value into specified variable inside Object Dictionary. | |
Structure for input / output on the OD variable.
It is initialized with OD_getSub() function. Access principle to OD variable is via read/write functions operating on stream, similar as standard read/write.
ODR_t(* OD_IO_t::read) (OD_stream_t *stream, void *buf, OD_size_t count, OD_size_t *countRead) |
Function pointer for reading value from specified variable from Object Dictionary.
If OD variable is larger than buf, then this function must be called several times. After completed successful read function returns 'ODR_OK'. If read is partial, it returns 'ODR_PARTIAL'. In case of errors function returns code similar to SDO abort code.
Read can be restarted with OD_rwRestart() function.
At the moment, when Object Dictionary is initialized, every variable has assigned the same "read" function. This default function simply copies data from Object Dictionary variable. Application can bind its own "read" function for specific object. In that case application is able to calculate data for reading from own internal state at the moment of "read" function call. Own "read" function on OD object can be initialized with OD_extension_init() function.
"read" function must always copy all own data to buf, except if "buf" is not large enough. ("*returnCode" must not return 'ODR_PARTIAL', if there is still space in "buf".)
stream | Object Dictionary stream object. | |
buf | Pointer to external buffer, where to data will be copied. | |
count | Size of the external buffer in bytes. | |
[out] | countRead | If return value is "ODR_OK" or "ODR_PARTIAL", then number of bytes successfully read must be returned here. |
ODR_t(* OD_IO_t::write) (OD_stream_t *stream, const void *buf, OD_size_t count, OD_size_t *countWritten) |
Function pointer for writing value into specified variable inside Object Dictionary.
If OD variable is larger than buf, then this function must be called several times. After completed successful write function returns 'ODR_OK'. If write is partial, it returns 'ODR_PARTIAL'. In case of errors function returns code similar to SDO abort code.
Write can be restarted with OD_rwRestart() function.
At the moment, when Object Dictionary is initialized, every variable has assigned the same "write" function, which simply copies data to Object Dictionary variable. Application can bind its own "write" function, similar as it can bind "read" function.
"write" function must always copy all available data from buf. If OD variable expect more data, then "*returnCode" must return 'ODR_PARTIAL'.
stream | Object Dictionary stream object. | |
buf | Pointer to external buffer, from where data will be copied. | |
count | Size of the external buffer in bytes. | |
[out] | countWritten | If return value is "ODR_OK" or "ODR_PARTIAL", then number of bytes successfully written must be returned here. |