Skip to content

Commit 5c9f968

Browse files
committed
Fix configuration CC sing value
1 parent 815dd8c commit 5c9f968

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

hardware/arduino/zunoG2/cores/ZWSupport/ZWCCConfiguration.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,23 @@ static const ZunoCFGParameter_t *zunoCFGParameterProxy(size_t param){
234234

235235
static void _zunoSaveCFGParam(uint8_t param, ssize_t value, bool bUser);
236236

237+
static uint32_t __get_value(const uint8_t *const data, const uint8_t size, const ZunoCFGParameter_t *const cfg)
238+
{
239+
const uint32_t value = _zunoSetterValue2Cortex(data, size);
240+
if (cfg->format != ZUNO_CFG_PARAMETER_FORMAT_SIGNED)
241+
{
242+
return value;
243+
}
244+
switch (size)
245+
{
246+
case 2:
247+
return (int16_t)value;
248+
case 1:
249+
return (int8_t)value;
250+
}
251+
return value;
252+
}
253+
237254
uint8_t checkConfigurationParameterSVSet(uint8_t * cmd){
238255
const ZunoCFGParameter_t *cfg;
239256

@@ -247,7 +264,7 @@ uint8_t checkConfigurationParameterSVSet(uint8_t * cmd){
247264
return PARAM_SV_UNKNOWN_PARAM;
248265

249266
if((options & CONFIGURATION_SET_LEVEL_DEFAULT_BIT_MASK) == 0){
250-
uint32_t new_value = _zunoSetterValue2Cortex(cmd+4, size);
267+
uint32_t new_value = __get_value(cmd+4, size, cfg);
251268
if(cfg->size != size)
252269
return PARAM_SV_WRONG_PARAM_SIZE;
253270
if (cfg->format == ZUNO_CFG_PARAMETER_FORMAT_SIGNED) {
@@ -423,7 +440,7 @@ static int _configuration_set(const ZUNOCommandCmd_t *cmd) {
423440
level = (level & CONFIGURATION_SET_LEVEL_SIZE_MASK);
424441
if (level != cfg->size)
425442
return (ZUNO_COMMAND_BLOCKED_FAIL);
426-
value = _zunoSetterValue2Cortex(&lp->byte4.configurationValue1, level);
443+
value = __get_value(&lp->byte4.configurationValue1, level, cfg);
427444
if (cfg->format == ZUNO_CFG_PARAMETER_FORMAT_SIGNED) {
428445
if ((ssize_t)value < cfg->minValue || (ssize_t)value > cfg->maxValue)
429446
return (ZUNO_COMMAND_BLOCKED_FAIL);

hardware/arduino/zunoG2/cores/ZWSupport/ZWSupport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,7 @@ void zunoSendZWPacketAdd(ZUNOCommandPacketReport_t *frame) {
16011601
zunoSendZWPacket(&frame->info);
16021602
}
16031603

1604-
uint32_t _zunoSetterValue2Cortex(uint8_t * packet, uint8_t sz){
1604+
uint32_t _zunoSetterValue2Cortex(const uint8_t * packet, uint8_t sz){
16051605
uint32_t res = 0;
16061606
while(sz){
16071607
res <<= 8;

hardware/arduino/zunoG2/cores/ZWSupport/ZWSupport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ void _zunoMarkSystemClassRequested(uint8_t systembit);
462462
#define QUEUE_CHANNEL_LLREPORT 0x02
463463

464464
extern ZUNOZWConfiguation_t g_zuno_zw_cfg;
465-
uint32_t _zunoSetterValue2Cortex(uint8_t * packet, uint8_t sz);
465+
uint32_t _zunoSetterValue2Cortex(const uint8_t * packet, uint8_t sz);
466466
uint8_t *zuno_AddCommonClassMinimal(uint8_t *b);
467467
uint8_t *zuno_AddCommonClass(uint8_t *b);
468468
int _zunoTransposeSecurityLevel(uint8_t sec);

0 commit comments

Comments
 (0)