Closed erikhaverkamp closed 4 years ago
I found the solution, there is an error in function ModbusParse:
Please change for Functioncode 3:
mb_buf_out[mb_buf_out_count++]=(st+nu)*2; // how many bytes we will send?
for(i=st;i<nu;i++)
To
mb_buf_out[mb_buf_out_count++]=(nu)*2; // how many bytes we will send?
for(i=st;i<(st+nu);i++)
For functioncode 16:
Change:
for(i=st;i<nu;i++)
{
mb_reg[i]=mb_buf_in[7+i*2]*256+mb_buf_in[8+i*2];
}
Into:
for(i=0;i<nu;i++)
{
mb_reg[st+i]=mb_buf_in[7+i*2]*256+mb_buf_in[8+i*2];
}
Oh , thanks for patch! Push fixes from you ;)
PS Sorry, i was little far away this repo ;)
I am using your code for a USART based project. It was very simple to implement, because of the well-documented code. However, I am facing this problem:
This works fine:
modpoll.exe -a 1 -r 1 -c 6 COM5
But any -r different from 1 fails:
Data seems to arrive well in STM32F4, also mb_buf_out seems ok, I don't really know where to go from here?
Thanks