emelianov / modbus-esp8266

Most complete Modbus library for Arduino. A library that allows your Arduino board to communicate via Modbus protocol, acting as a master, slave or both. Supports network transport (Modbus TCP) and Serial line/RS-485 (Modbus RTU). Supports Modbus TCP Security for ESP8266/ESP32.
Other
534 stars 188 forks source link

Write single register issue with function code #247

Closed simogaspa84 closed 2 years ago

simogaspa84 commented 2 years ago

Hello @emelianov ,

just a question..

Why if i run these commands

mb.writeHreg(SLAVE_ID, ADDRESS_SINGLE_REGISTER, 0, 1, nullptr, MODBUSIP_UNIT); mb.writeHreg(SLAVE_ID, ADDRESS_SINGLE_REGISTER, 0, 1, nullptr);

The function code for the modbus is 10

10 1 22 0 1 2 0 0

instead of

image

emelianov commented 2 years ago
mb.writeHreg(SLAVE_ID, ADDRESS_SINGLE_REGISTER, 0, nullptr, MODBUSIP_UNIT);
mb.writeHreg(SLAVE_ID, ADDRESS_SINGLE_REGISTER, 0, nullptr);
simogaspa84 commented 2 years ago

Just a question @emelianov

if i run this

6 1 16 FF FF

and I got this error from slave Request result: 0x2

This means that the address of that register is not known ?

It is correct ?

emelianov commented 2 years ago

Exactly. Communications are Okay but reg 0x16 doesn't exists on server/slave.