From 6eedcb7cdf8379938c58bdbf55f999d7264cd740 Mon Sep 17 00:00:00 2001 From: Lars Danielsson Date: Fri, 7 Aug 2020 10:17:06 +0200 Subject: [PATCH] Use callback also when data is NULL Change-Id: Id75f52772dfb80fc6802a7a9e252e9f3fc2f33f0 --- soes/esc_coe.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/soes/esc_coe.c b/soes/esc_coe.c index 5de339e..3e23b3c 100644 --- a/soes/esc_coe.c +++ b/soes/esc_coe.c @@ -296,26 +296,28 @@ void SDO_upload (void) /* expedited response i.e. length<=4 bytes */ coeres->command = COE_COMMAND_UPLOADRESPONSE + COE_SIZE_INDICATOR + COE_EXPEDITED_INDICATOR + dss; - if ((objd + nsub)->data == NULL) + /* convert bits to bytes */ + size = BITS2BYTES(size); + void *dataptr = ((objd + nsub)->data) ? + (objd + nsub)->data : (void *)&((objd + nsub)->value); + abort = ESC_upload_pre_objecthandler (index, subindex, + dataptr, size, (objd + nsub)->flags); + if (abort == 0) { - /* use constant value */ - coeres->size = htoel ((objd + nsub)->value); - } - else - { - /* convert bits to bytes */ - size = BITS2BYTES(size); - abort = ESC_upload_pre_objecthandler (index, subindex, - (objd + nsub)->data, size, (objd + nsub)->flags); - if (abort == 0) + if ((objd + nsub)->data == NULL) + { + /* use constant value */ + coeres->size = htoel ((objd + nsub)->value); + } + else { /* use dynamic data */ copy2mbx ((objd + nsub)->data, &(coeres->size), size); } - else - { - SDO_abort (index, subindex, abort); - } + } + else + { + SDO_abort (index, subindex, abort); } } else