mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 11:46:31 +00:00
Fixed FC16
https://github.com/arendst/Tasmota/issues/9586#issuecomment-1226120239
This commit is contained in:
parent
d333948816
commit
ffcdce6041
@ -634,11 +634,12 @@ void ModbusTCPHandle(void)
|
|||||||
if (mbfunctioncode <= 4)
|
if (mbfunctioncode <= 4)
|
||||||
{
|
{
|
||||||
modbusBridge.dataCount = (uint16_t)((((uint16_t)modbusBridgeTCP.tcp_buf[10]) << 8) | ((uint16_t)modbusBridgeTCP.tcp_buf[11]));
|
modbusBridge.dataCount = (uint16_t)((((uint16_t)modbusBridgeTCP.tcp_buf[10]) << 8) | ((uint16_t)modbusBridgeTCP.tcp_buf[11]));
|
||||||
|
dataSendCount = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// For functioncode 15 & 16 ignore bytecount, tasmotaModbus does calculate this
|
// 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;
|
modbusBridge.dataCount = 1;
|
||||||
dataSendCount = (buf_len - dataStartByte) / 2;
|
dataSendCount = (buf_len - dataStartByte) / 2;
|
||||||
writeData = (uint16_t *)malloc(dataSendCount);
|
writeData = (uint16_t *)malloc(dataSendCount);
|
||||||
@ -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"),
|
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);
|
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);
|
free(writeData);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user