CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PICC modbus app layer issue

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
TimothyCarter



Joined: 08 Aug 2016
Posts: 22

View user's profile Send private message

PICC modbus app layer issue
PostPosted: Thu Jul 30, 2020 9:49 am     Reply with quote

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

View user's profile Send private message

Solved? Maybe :confused:
PostPosted: Thu Jul 30, 2020 1:42 pm     Reply with quote

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: 19535

View user's profile Send private message

PostPosted: Fri Jul 31, 2020 2:15 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group