Added debug config

This commit is contained in:
Emanuele Trabattoni
2025-07-06 19:52:48 +02:00
parent f274970d63
commit 4b97e6535d
4 changed files with 43 additions and 63 deletions

View File

@@ -103,11 +103,12 @@ void setup()
void loop()
{
const uint8_t devAddress(0xAA);
const uint8_t tempBoardAddr(0xAA);
const uint8_t relayBoardAddr(0x01);
const uint8_t baseRegister(0x00);
LOG_INFO("Looop");
std::vector<uint16_t> results;
bool success = bus.readHoldingRegisters(devAddress, baseRegister, 8, results);
bool success = bus.readHoldingRegisters(tempBoardAddr, baseRegister, 8, results);
if (success)
{
for (auto i(0); i < results.size(); i++)
@@ -116,19 +117,19 @@ void loop()
}
results.clear();
}
delay(100);
for (auto i(0); i < 8; i++)
{
LOG_DEBUG("\nCHANNEL ", i);
LOG_DEBUG("\n\nCHANNEL ", i);
std::vector<bool> values;
bus.writeCoil(0x01, (uint8_t)i, true);
delay(500);
bus.readCoils(0x01,0x00,8, values);
for (auto v: values ) {
LOG_DEBUG("Coil", i, v ? "True" : "False");
bus.writeCoil(relayBoardAddr, (uint8_t)i, true);
bus.readCoils(relayBoardAddr,0x00,8, values);
for (auto j(0); j < values.size(); j++) {
LOG_DEBUG("Coil", j, values.at(j) ? "True" : "False");
}
bus.writeCoil(0x01, (uint8_t)i, false);
delay(500);
delay(1000);
bus.writeCoil(relayBoardAddr, (uint8_t)i, false);
delay(1000);
}
delay(5000);
}