andresarmento / modbus-arduino

A library that allows your Arduino to communicate via Modbus protocol, acting as a slave (master in development). Supports serial (RS-232, RS-485) and IP via Ethernet (Modbus IP).
BSD 3-Clause "New" or "Revised" License
455 stars 267 forks source link

fix writeMultipleRegisters and writeMultipleCoils #1

Closed skefer closed 8 years ago

skefer commented 9 years ago

Tested the writMultipleRegisters and writeMultipleCoils function on my arduino mega2560 and pro mini, and found that they were uncorrect. So I fixed it.

andresarmento commented 8 years ago

Thanks skefer for fix. But I would like to fix without pass the frame in function. I dont have much time now but I need to know why these functions dont work with global frame buffer.

skefer commented 8 years ago

Let's use writeMultipleRegisters for example. The global frame buffer were freed,on line 265 in Modbus.cpp. However, on line 282, we need write the frame data to Hreg.So we need a local variable to save those data before _frame freed. That's what i thought.