CANopenNode
CANopen protocol stack
Loading...
Searching...
No Matches
OD_IO_t Struct Reference

Structure for input / output on the OD variable. More...

#include <CO_ODinterface.h>

+ Collaboration diagram for OD_IO_t:

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.
 

Detailed Description

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.

Field Documentation

◆ read

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

Warning
Do not use CO_LOCK_OD() and CO_UNLOCK_OD() macros inside the read() function. See also Critical sections.
Parameters
streamObject Dictionary stream object.
bufPointer to external buffer, where to data will be copied.
countSize of the external buffer in bytes.
[out]countReadIf return value is "ODR_OK" or "ODR_PARTIAL", then number of bytes successfully read must be returned here.
Returns
Value from ODR_t, "ODR_OK" in case of success.

◆ write

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'.

Warning
Do not use CO_LOCK_OD() and CO_UNLOCK_OD() macros inside the write() function. See also Critical sections.
Parameters
streamObject Dictionary stream object.
bufPointer to external buffer, from where data will be copied.
countSize of the external buffer in bytes.
[out]countWrittenIf return value is "ODR_OK" or "ODR_PARTIAL", then number of bytes successfully written must be returned here.
Returns
Value from ODR_t, "ODR_OK" in case of success.

The documentation for this struct was generated from the following file: