View previous topic :: View next topic |
Author |
Message |
greenbridge
Joined: 14 May 2018 Posts: 19
|
|
Posted: Thu Aug 08, 2019 7:51 am |
|
|
I have up to date compiler 5.087
Code: | //////////////////////////////////////////////////////////////////////////////////////////
//// modbus_phy_layer.h ////
//// ////
//// Physical layer of the MODBUS protocol driver for serial communications. ////
//// ////
//// Refer to documentation at http://www.modbus.org for more information on MODBUS. ////
//// ////
//////////////////////////////////////////////////////////////////////////////////////////
//// ////
//// Revision history: ////
//// July 20, 2011 Seperated Physical Layer functions definitions into this ////
//// file from modbus.c ////
//// ////
//////////////////////////////////////////////////////////////////////////////////////////
//// (C) Copyright 1996, 2013 Custom Computer Services ////
//// This source code may only be used by licensed users of the CCS ////
//// C compiler. This source code may only be distributed to other ////
//// licensed users of the CCS C compiler. No other use, ////
//// reproduction or distribution is permitted without written ////
//// permission. Derivative programs created using this software ////
//// in object code form are not restricted in any way. ////
//////////////////////////////////////////////////////////////////////////////////////////
...
/********************************************************************
Our receive struct. This is used when receiving data as a master or
slave. Once a message is sent to you with your address, you should
begin processing that message. Refer to ex_modbus_slave.c to see
how to properly use this structure.
********************************************************************/
struct
{
unsigned int8 address;
unsigned int8 len; //number of bytes in the message received
function func; //the function of the message received
exception error; //error recieved, if any
unsigned int8 data[MODBUS_SERIAL_RX_BUFFER_SIZE]; //data of the message received
} modbus_rx;
...
|
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19245
|
|
Posted: Thu Aug 08, 2019 8:03 am |
|
|
As written, the CCS slave example, only uses the low byte of the register
number. So max register allowed is 256. To support 300, you will have to take
modbus.rx_data[4]*256+modbus.rx_data[3] as the register address number. |
|
|
greenbridge
Joined: 14 May 2018 Posts: 19
|
|
Posted: Fri Aug 09, 2019 7:44 am |
|
|
It worked fine. Thanks a lot! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19245
|
|
Posted: Fri Aug 09, 2019 7:50 am |
|
|
Well done. Nice to see movement forwards!. |
|
|
|