mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 03:49:13 +03:00
fix EctoControl
This commit is contained in:
@@ -130,8 +130,9 @@ public:
|
|||||||
if (_addr > 0)
|
if (_addr > 0)
|
||||||
{
|
{
|
||||||
uint16_t type;
|
uint16_t type;
|
||||||
readFunctionModBus(0x0000, type);
|
readFunctionModBus(0x0003, type);
|
||||||
if (0x14 != (uint8_t)type || 0x15 != (uint8_t)type || 0x16 != (uint8_t)type)
|
type = type >> 8;
|
||||||
|
if (0x14 != type && 0x15 != type && 0x16 != type)
|
||||||
{
|
{
|
||||||
SerialPrint("E", "EctoControlAdapter", "Не подходящее устройство, type: " + String(type, HEX));
|
SerialPrint("E", "EctoControlAdapter", "Не подходящее устройство, type: " + String(type, HEX));
|
||||||
}
|
}
|
||||||
@@ -331,12 +332,13 @@ public:
|
|||||||
// set word 0 of TX buffer to least-significant word of counter (bits 15..0)
|
// set word 0 of TX buffer to least-significant word of counter (bits 15..0)
|
||||||
//node.setTransmitBuffer(1, lowWord(data));
|
//node.setTransmitBuffer(1, lowWord(data));
|
||||||
// set word 1 of TX buffer to most-significant word of counter (bits 31..16)
|
// set word 1 of TX buffer to most-significant word of counter (bits 31..16)
|
||||||
//node.setTransmitBuffer(0, highWord(data));
|
node.setTransmitBuffer(0, data);
|
||||||
// slave: write TX buffer to (2) 16-bit registers starting at register 0
|
// slave: write TX buffer to (2) 16-bit registers starting at register 0
|
||||||
uint8_t result = node.writeSingleRegister(reg, data);
|
uint8_t result = node.writeMultipleRegisters(reg, 1);
|
||||||
|
node.clearTransmitBuffer();
|
||||||
if (_debug > 2)
|
if (_debug > 2)
|
||||||
{
|
{
|
||||||
SerialPrint("I", "EctoControlAdapter", "writeSingleRegister, addr: " + String((uint8_t)_addr, HEX) + ", reg: " + String(reg, HEX) + ", state: " + String(data) + " = result: " + String(result, HEX));
|
SerialPrint("I", "EctoControlAdapter", "writeSingleRegister, addr: " + String((uint8_t)_addr, HEX) + ", reg: 0x" + String(reg, HEX) + ", state: " + String(data) + " = result: " + String(result, HEX));
|
||||||
}
|
}
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
return true;
|
return true;
|
||||||
@@ -360,7 +362,7 @@ public:
|
|||||||
else
|
else
|
||||||
result = node.readHoldingRegisters(reg, 1);
|
result = node.readHoldingRegisters(reg, 1);
|
||||||
if (_debug > 2)
|
if (_debug > 2)
|
||||||
SerialPrint("I", "EctoControlAdapter", "readHoldingRegisters, addr: " + String(_addr, HEX) + ", reg: " + String(reg, HEX) + " = result: " + String(result, HEX));
|
SerialPrint("I", "EctoControlAdapter", "readHoldingRegisters, addr: " + String(_addr, HEX) + ", reg: 0x" + String(reg, HEX) + " = result: " + String(result, HEX));
|
||||||
// break;
|
// break;
|
||||||
if (result == node.ku8MBSuccess)
|
if (result == node.ku8MBSuccess)
|
||||||
{
|
{
|
||||||
@@ -396,9 +398,10 @@ public:
|
|||||||
bool getModelVersion()
|
bool getModelVersion()
|
||||||
{
|
{
|
||||||
uint16_t reqData;
|
uint16_t reqData;
|
||||||
info.boilerMemberCode = readFunctionModBus(ReadDataEctoControl::ecR_MemberCode, info.boilerMemberCode);
|
bool ret;
|
||||||
info.boilerModelCode = readFunctionModBus(ReadDataEctoControl::ecR_ModelCode, info.boilerModelCode);
|
ret = readFunctionModBus(ReadDataEctoControl::ecR_MemberCode, info.boilerMemberCode);
|
||||||
bool ret = readFunctionModBus(ReadDataEctoControl::ecR_AdaperVersion, reqData);
|
ret = readFunctionModBus(ReadDataEctoControl::ecR_ModelCode, info.boilerModelCode);
|
||||||
|
ret = readFunctionModBus(ReadDataEctoControl::ecR_AdaperVersion, reqData);
|
||||||
info.adapterHardVer = highByte(reqData);
|
info.adapterHardVer = highByte(reqData);
|
||||||
info.adapterSoftVer = lowByte(reqData);
|
info.adapterSoftVer = lowByte(reqData);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -440,8 +443,8 @@ public:
|
|||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
publishData("codeError", String(code));
|
publishData("codeError", String(code));
|
||||||
if (codeExt)
|
if (code)
|
||||||
sendTelegramm("EctoControlAdapter: код ошибки: " + String((int)codeExt));
|
sendTelegramm("EctoControlAdapter: код ошибки: " + String((int)code));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ private:
|
|||||||
// высылается ведущим устройством единственному устройству на шине с неизвестным адресом
|
// высылается ведущим устройством единственному устройству на шине с неизвестным адресом
|
||||||
|
|
||||||
// Modbus timeout [milliseconds]
|
// Modbus timeout [milliseconds]
|
||||||
static const uint16_t ku16MBResponseTimeout = 2000; ///< Modbus timeout [milliseconds]
|
static const uint16_t ku16MBResponseTimeout = 500; ///< Modbus timeout [milliseconds]
|
||||||
|
|
||||||
// master function that conducts Modbus transactions
|
// master function that conducts Modbus transactions
|
||||||
uint8_t ModbusMasterTransaction(uint8_t u8MBFunction);
|
uint8_t ModbusMasterTransaction(uint8_t u8MBFunction);
|
||||||
|
|||||||
Reference in New Issue
Block a user