Skip to content

Commit

Permalink
Fixed FC16
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenSt committed Aug 24, 2022
1 parent c788e80 commit 54d747e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tasmota/tasmota_xdrv_driver/xdrv_63_modbus_bridge.ino
Original file line number Diff line number Diff line change
Expand Up @@ -634,11 +634,12 @@ void ModbusTCPHandle(void)
if (mbfunctioncode <= 4)
{
modbusBridge.dataCount = (uint16_t)((((uint16_t)modbusBridgeTCP.tcp_buf[10]) << 8) | ((uint16_t)modbusBridgeTCP.tcp_buf[11]));
dataSendCount = 1;
}
else
{
// For functioncode 15 & 16 ignore bytecount, tasmotaModbus does calculate this
uint8_t dataStartByte = mbfunctioncode <= 6 ? 10 : 11;
uint8_t dataStartByte = mbfunctioncode <= 6 ? 10 : 13;
modbusBridge.dataCount = 1;
dataSendCount = (buf_len - dataStartByte) / 2;
writeData = (uint16_t *)malloc(dataSendCount);
Expand All @@ -653,7 +654,7 @@ void ModbusTCPHandle(void)
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("MBS: MBRTCP to Modbus Transactionid:%d, deviceAddress:%d, functionCode:%d, startAddress:%d, sendCount:%d, recvCount:%d"),
modbusBridgeTCP.tcp_transaction_id, mbdeviceaddress, mbfunctioncode, mbstartaddress, dataSendCount, modbusBridge.dataCount);

tasmotaModbus->Send(mbdeviceaddress, mbfunctioncode, mbstartaddress, dataSendCount, writeData);
tasmotaModbus->Send(mbdeviceaddress, mbfunctioncode, mbstartaddress, dataSendCount, writeData, modbusBridge.dataCount);

free(writeData);
}
Expand Down

0 comments on commit 54d747e

Please sign in to comment.