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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Write single register issue with function code

simogaspa84 opened this issue · comments

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

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

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 ?

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