View previous topic :: View next topic |
Author |
Message |
TimothyCarter
Joined: 08 Aug 2016 Posts: 22
|
PICC modbus app layer issue |
Posted: Thu Jul 30, 2020 9:49 am |
|
|
I'm currently troubleshooting a controller with modbus and have come across an issue that may be a bug in the CCS "modbus_app_layer.c" file.
If you select "0" (40001) as your starting address when requesting "holding registers" from a modbus slave, everything works normally. However, if you select any other value for start address, the slave will respond with data starting at address 0 (40001).
Is this really a bug, or am I missing something?
{The for loop at line 636 of the above file, I believe is the issue: it starts with 0 regardless of a "start address" - which the referenced function doesn't have passed to it. _________________ “Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter.”
- Eric S. Raymond |
|
|
TimothyCarter
Joined: 08 Aug 2016 Posts: 22
|
Solved? Maybe :confused: |
Posted: Thu Jul 30, 2020 1:42 pm |
|
|
I think maybe I didn't understand the full use case for the holding register function; and was passing the full range of holding (& input) registers to the pointer in the function - when actually this should be a small subset (beginning at the entered "start address") of the holding registers. _________________ “Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter.”
- Eric S. Raymond |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Fri Jul 31, 2020 2:15 am |
|
|
Yes.
This is described in the modbus notes.
For example (simpler subset):
<http://www.simplymodbus.ca/FC03.htm>
If you read the Modbus Application Protocol document, you will find that
this is described for you.
The 'read_holding_registers' function, takes a 'holding register number',
not a full modbus address. So in the example on this page to access
the register at modbus address 40108, you ask for holding register number
107.
The same applies to the coil, input register & discrete input functions. They
all want a 'sub address' in the input range allocated to these devices. |
|
|
|