Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading 8 Ists & Coils and writing multiple register bug fix #35

Open
umarsaid opened this issue Mar 8, 2018 · 6 comments
Open

Reading 8 Ists & Coils and writing multiple register bug fix #35

umarsaid opened this issue Mar 8, 2018 · 6 comments

Comments

@umarsaid
Copy link

umarsaid commented Mar 8, 2018

I found some bugs in the library. You reading Ists and Coils for 8 registers, the 8th register will always be 0. Also, when we write multiple holding registers, the last value will be lost.

I have fix the bug in my local copy. I want to submit the bug but I do not know how.

@masrodjie
Copy link

you can fork the repo, commit your changes and pull request. or you can attach your update here, i'll try to make pull request to make this library better

@janchower
Copy link

I am also seeing this same issue - every 8th coil is not working.
Umarsaid, is there any way at all for you to post or forward me the updated library you mention that you fixed? My programming skills are still improving and I'm having trouble reading through the library to identify where the issue is. Thank you very much in advance for your help!!!!

@petersoltys
Copy link

Please would you change these lines 329 and 380 in modbus.cpp
from
while (numregs--) { i = (totregs - numregs) / 8;
to
while (numregs) { i = (totregs - numregs) / 8; numregs--;
by my findings only this decrement order need to be changed.

@janchower
Copy link

Peter - THANK YOU - I tried this and it looks like it works! I am very grateful for your help. This is definitely something very important to my projects. I really appreciate this!

@raf59
Copy link

raf59 commented Jul 17, 2019

Thank you Peter !!
I met the same issue with the writeMultipleCoils function.
I did the same change at line 499 with numoutputs and it works now.

while (numoutputs) { i = (totoutputs - numoutputs) / 8; numoutputs--;

@HGQ21102
Copy link

Thank you Peter !!
I met the same issue with the writeMultipleCoils function.
I did the same change at line 499 with numoutputs and it works now.

while (numoutputs) { i = (totoutputs - numoutputs) / 8; numoutputs--;

Thank you, you are the best

Please would you change these lines 329 and 380 in modbus.cpp
from
while (numregs--) { i = (totregs - numregs) / 8;
to
while (numregs) { i = (totregs - numregs) / 8; numregs--;
by my findings only this decrement order need to be changed.

Thank you, you are the best

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants