MCPcopy Create free account
hub / github.com/CANopenNode/CANopenNode / OD_write_1016

Function OD_write_1016

301/CO_HBconsumer.c:76–101  ·  view source on GitHub ↗

* Custom function for writing OD object "Consumer heartbeat time" * * For more information see file CO_ODinterface.h, OD_IO_t. */

Source from the content-addressed store, hash-verified

74 * For more information see file CO_ODinterface.h, OD_IO_t.
75 */
76static ODR_t
77OD_write_1016(OD_stream_t* stream, const void* buf, OD_size_t count, OD_size_t* countWritten) {
78 CO_HBconsumer_t* HBcons;
79
80 if (stream == NULL) {
81 return ODR_DEV_INCOMPAT;
82 }
83 HBcons = stream->object;
84
85 if ((buf == NULL) || (stream->subIndex < 1U)
86 || (stream->subIndex > HBcons->numberOfMonitoredNodes) || (count != sizeof(uint32_t))
87 || (countWritten == NULL)) {
88 return ODR_DEV_INCOMPAT;
89 }
90
91 uint32_t val = CO_getUint32(buf);
92 uint8_t nodeId = (uint8_t)((val >> 16) & 0xFFU);
93 uint16_t consumer_time = (uint16_t)(val & 0xFFFFU);
94 CO_ReturnError_t ret = CO_HBconsumer_initEntry(HBcons, stream->subIndex - 1U, nodeId, consumer_time);
95 if (ret != CO_ERROR_NO) {
96 return ODR_PAR_INCOMPAT;
97 }
98
99 /* write value to the original location in the Object Dictionary */
100 return OD_writeOriginal(stream, buf, count, countWritten);
101}
102#endif
103
104CO_ReturnError_t

Callers

nothing calls this directly

Calls 3

CO_getUint32Function · 0.85
CO_HBconsumer_initEntryFunction · 0.85
OD_writeOriginalFunction · 0.85

Tested by

no test coverage detected