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

Function OD_write_SRDO_mappingParam

304/CO_SRDO.c:250–299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

248}
249
250static ODR_t
251OD_write_SRDO_mappingParam(OD_stream_t* stream, const void* buf, OD_size_t count, OD_size_t* countWritten) {
252 if ((stream == NULL) || (buf == NULL) || (countWritten == NULL)
253 || (stream->subIndex > CO_SRDO_MAX_MAPPED_ENTRIES)) {
254 return ODR_DEV_INCOMPAT;
255 }
256
257#ifdef CO_CONFORMANCE_TEST_TOOL_ADAPTATION
258 if (OD_not_write_same_value(stream, buf, count)) {
259 return ODR_OK;
260 }
261#endif
262
263 CO_SRDO_t* SRDO = stream->object;
264 CO_SRDOGuard_t* SRDOGuard = SRDO->SRDOGuard;
265
266 /* Writing Object Dictionary variable */
267 if (SRDOGuard->NMTisOperational) {
268 /* Data cannot be transferred or stored to the application because of the present device state. */
269 return ODR_DATA_DEV_STATE;
270 }
271
272 /* SRDO must be disabled */
273 if (SRDO->informationDirection != 0U) {
274 return ODR_UNSUPP_ACCESS; /* Unsupported access to an object. */
275 }
276
277 /* numberOfMappedObjects */
278 if (stream->subIndex == 0U) {
279 uint8_t value = CO_getUint8(buf);
280 /* only odd numbers are allowed */
281 if ((value > CO_SRDO_MAX_MAPPED_ENTRIES) || ((value & 1U) != 0U)) {
282 return ODR_MAP_LEN; /* Number and length of object to be mapped exceeds SRDO length. */
283 }
284 SRDO->mappedObjectsCount = value;
285 }
286 /* mapping objects */
287 else {
288 if (SRDO->mappedObjectsCount != 0U) {
289 return ODR_UNSUPP_ACCESS;
290 }
291 /* No other checking is implemented here. Values are validated in the configuration function. */
292 }
293
294 /* set OD object 13FE:00 to CO_SRDO_INVALID */
295 configurationValidUnset(SRDOGuard);
296
297 /* write value to the original location in the Object Dictionary */
298 return OD_writeOriginal(stream, buf, count, countWritten);
299}
300
301static ODR_t
302OD_write_13FE(OD_stream_t* stream, const void* buf, OD_size_t count, OD_size_t* countWritten) {

Callers

nothing calls this directly

Calls 4

OD_not_write_same_valueFunction · 0.85
CO_getUint8Function · 0.85
configurationValidUnsetFunction · 0.85
OD_writeOriginalFunction · 0.85

Tested by

no test coverage detected