yaacov / ArduinoModbusSlave

Modbus slave library for Arduino
ISC License
205 stars 75 forks source link

Put data in a specific address #80

Closed kotioko closed 3 years ago

kotioko commented 3 years ago

Hi, First thank you for great work. I did test various libraries and this is the one library that work here. I have a question: Is possible change the start address or set a especific address using function 04? I need put data in address 4121 becouse i have one app that read data in this address and i cant change this.

Thank you one more time.

EDIT: I dont use analog in. I get one value per modbus function 03 from a equipment. I thought to do: uint8_t [4200] analog_pins; and: slave.writeRegister Buffer (4121, 1234);

Would be the solution, but it didn't work.

kotioko commented 3 years ago

Analyzing better the functioning of the library, I saw that the function "uint8_t readAnalogIn(uint8_t fc, uint16_t address, uint16_t length)" receives the address requested by the program and so I just needed to monitor the address that I need to send data. I put a condition for when address=4121, i send the data with "slave.writeRegisterToBuffer(1, data))". That way I managed to solve my problem. Thanks!