From 9525469a680894d8693c409dfaffc93934d48bb0 Mon Sep 17 00:00:00 2001 From: Andreas Karlsson Date: Mon, 5 Feb 2024 09:33:54 +0100 Subject: [PATCH] Fix padding of index 0 for object type variable If object of type Variable return true bitsize of subindex 0. fixes #166 --- soes/esc_coe.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/soes/esc_coe.c b/soes/esc_coe.c index 361c67d..12866a8 100644 --- a/soes/esc_coe.c +++ b/soes/esc_coe.c @@ -556,8 +556,11 @@ static uint32_t complete_access_subindex_loop(const _objd *objd, } } - /* Subindex 0 is padded to 16 bit */ - size += (nsub == 0) ? 16 : bitlen; + /* Subindex 0 is padded to 16 bit if not object type VARIABLE. + * For VARIABLE use true bitsize. + */ + size += + ((nsub == 0) && (SDOobjects[nidx].objtype != OTYPE_VAR)) ? 16 : bitlen; nsub++; if ((max_bytes > 0) && (BITS2BYTES(size) >= max_bytes))