mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
auto-formatting
This commit is contained in:
@@ -2091,7 +2091,7 @@ int EMSdevice::modbus_value_to_json(uint8_t tag, const std::string & shortname,
|
||||
}
|
||||
|
||||
uint32_t value = 0;
|
||||
for(auto i = 0; i < modbus_data.size(); i++) {
|
||||
for (auto i = 0; i < modbus_data.size(); i++) {
|
||||
value += (uint32_t)modbus_data[modbus_data.size() - i - 1] << (i * 8);
|
||||
}
|
||||
|
||||
|
||||
@@ -508,10 +508,14 @@ int Modbus::getRegisterCount(const DeviceValue & dv) {
|
||||
uint32_t num_values = std::max(dv.max, (uint32_t)abs(dv.min));
|
||||
int num_registers = 0;
|
||||
|
||||
if (num_values <= (1L << 8)) num_registers = 1;
|
||||
else if(num_values <= (1L << 16)) num_registers = 2;
|
||||
else if(num_values <= (1L << 32)) num_registers = 4;
|
||||
else LOG_ERROR("num_registers is too big to be encoded with modbus registers");
|
||||
if (num_values <= (1L << 8))
|
||||
num_registers = 1;
|
||||
else if (num_values <= (1L << 16))
|
||||
num_registers = 2;
|
||||
else if (num_values <= (1L << 32))
|
||||
num_registers = 4;
|
||||
else
|
||||
LOG_ERROR("num_registers is too big to be encoded with modbus registers");
|
||||
|
||||
LOG_DEBUG("Value for CMD '%s' can take on %ld values and is encoded in %d registers", dv.short_name, num_values, num_registers);
|
||||
|
||||
|
||||
@@ -2076,7 +2076,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
||||
shell.printfln("Testing modbus->handleWrite() for thermostat:");
|
||||
|
||||
uint16_t reg = Modbus::REGISTER_BLOCK_SIZE * DeviceValueTAG::TAG_HC1 + 41; // remotetemp
|
||||
ModbusMessage request({thermostat_dev->device_type(), 0x06, static_cast<unsigned char>(reg >> 8), static_cast<unsigned char>(reg & 0xff), 0, 1, 2, 0, 45});
|
||||
ModbusMessage request(
|
||||
{thermostat_dev->device_type(), 0x06, static_cast<unsigned char>(reg >> 8), static_cast<unsigned char>(reg & 0xff), 0, 1, 2, 0, 45});
|
||||
auto response = EMSESP::modbus_->handleWrite(request);
|
||||
|
||||
if (response.getError() == SUCCESS) {
|
||||
|
||||
Reference in New Issue
Block a user