@@ -359,7 +359,7 @@ uint32_t co_od_load (co_net_t * net, co_store_t store)
359359 if (net -> open == NULL || net -> read == NULL || net -> close == NULL )
360360 return CO_SDO_ABORT_GENERAL ;
361361
362- arg = net -> open (store );
362+ arg = net -> open (store , CO_MODE_READ );
363363 if (arg == NULL )
364364 return CO_SDO_ABORT_GENERAL ;
365365
@@ -384,19 +384,19 @@ uint32_t co_od_load (co_net_t * net, co_store_t store)
384384 if (net -> read (arg , & subindex , sizeof (subindex )) < 0 )
385385 goto error ;
386386
387- if (net -> read (arg , & size , sizeof (size )) < 0 )
387+ if (net -> read (arg , & size , sizeof (size )) < 0 || size == 0 )
388388 goto error ;
389389
390390 /* Attempt to set value. Errors are ignored to support firmware
391391 update of dictionary */
392392
393393 obj = co_obj_find (net , index );
394394 if (obj == NULL )
395- continue ;
395+ goto skip ;
396396
397397 entry = co_entry_find (net , obj , subindex );
398- if (entry == NULL || !(entry -> flags & OD_WRITE ))
399- continue ;
398+ if (entry == NULL || !(entry -> flags & OD_WRITE ) || ( entry -> flags & OD_TRANSIENT ) )
399+ goto skip ; /* Not storable in this OD */
400400
401401 if (size <= sizeof (value ))
402402 {
@@ -418,16 +418,20 @@ uint32_t co_od_load (co_net_t * net, co_store_t store)
418418 else
419419 {
420420 /* Stored size does not match object size. Discard data. */
421- while (size > sizeof (value ))
422- {
423- if (net -> read (arg , & value , sizeof (value )) < 0 )
424- goto error ;
425- size -= sizeof (value );
426- }
421+ goto skip ;
422+ }
427423
428- if (net -> read (arg , & value , size ) < 0 )
424+ continue ;
425+ skip :
426+ while (size > sizeof (value ))
427+ {
428+ if (net -> read (arg , & value , sizeof (value )) < 0 )
429429 goto error ;
430+ size -= sizeof (value );
430431 }
432+
433+ if (net -> read (arg , & value , size ) < 0 )
434+ goto error ;
431435 }
432436
433437 /* Ignore any error on close */
@@ -457,7 +461,7 @@ uint32_t co_od_store (co_net_t * net, co_store_t store, uint16_t min, uint16_t m
457461 if (net -> open == NULL || net -> write == NULL || net -> close == NULL )
458462 return CO_SDO_ABORT_HW_ERROR ;
459463
460- arg = net -> open (store );
464+ arg = net -> open (store , CO_MODE_WRITE );
461465 if (arg == NULL )
462466 return CO_SDO_ABORT_HW_ERROR ;
463467
@@ -555,7 +559,7 @@ uint32_t co_od_restore (co_net_t * net, co_store_t store)
555559 if (net -> open == NULL || net -> write == NULL || net -> close == NULL )
556560 return CO_SDO_ABORT_HW_ERROR ;
557561
558- arg = net -> open (store );
562+ arg = net -> open (store , CO_MODE_WRITE );
559563 if (arg == NULL )
560564 return CO_SDO_ABORT_HW_ERROR ;
561565
0 commit comments