Solved endian on uint16

This commit is contained in:
JeroenSt 2022-08-27 09:11:36 +02:00
parent 1ac5b6fd7f
commit a19edd4983
1 changed files with 2 additions and 2 deletions

View File

@ -383,7 +383,6 @@ void ModbusBridgeHandle(void)
else if ((buffer[1] > 0) && (buffer[1] < 7)) // Read Registers
{
uint8_t dataOffset = 3;
if (buffer[1] == 6) dataOffset = 4;
Response_P(PSTR("{\"" D_JSON_MODBUS_RECEIVED "\":{"));
ResponseAppend_P(PSTR("\"" D_JSON_MODBUS_DEVICE_ADDRESS "\":%d,"), buffer[0]);
ResponseAppend_P(PSTR("\"" D_JSON_MODBUS_FUNCTION_CODE "\":%d,"), buffer[1]);
@ -906,7 +905,8 @@ void CmndModbusBridgeSend(void)
break;
case ModbusBridgeType::mb_uint16:
writeData[jsonDataArrayPointer] = (uint16_t)swap_endian16(jsonDataArray[jsonDataArrayPointer].getUInt(0));
writeData[jsonDataArrayPointer] = bitMode ? swap_endian16(jsonDataArray[jsonDataArrayPointer].getUInt(0))
: (int16_t)jsonDataArray[jsonDataArrayPointer].getUInt(0);
break;
case ModbusBridgeType::mb_int32: