# READ MODBUS

**URL:** <https://forums.digi.com/t/read-modbus/9444>\
**Category:** Rabbit\
**Created:** [April 28, 2011, 2:00pm UTC](https://forums.digi.com/t/read-modbus/9444 "2011-04-28T14:00:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Termi](https://avatars.discourse-cdn.com/v4/letter/t/ed655f/32.png) [@Termi](https://forums.digi.com/u/Termi)\
**Post date:** [April 28, 2011, 2:00pm UTC](https://forums.digi.com/t/read-modbus/9444/1 "2011-04-28T14:00:45Z")

</div>

Hello everyone.  
I have big problem and I need your help …  
I have an RCM 3900 and I connect via an RS485 logger: Slave address 7, Baud Rate: 9600, Data Length: 8, Stop Bit = 1, Parity = No Parity

I’d like to read this register through the library MODBUS\_MASTER.lib (MBM\_ReadRegs). After I wrote this program but it does not work. Can someone help me, please?

#define Mesure  
#define MODBUS\_DEBUG\_PRINT 0 // define to 1 to print transactions  
#define CINBUFSIZE 15  
#define COUTBUFSIZE 15  
#define MODBUS\_PORT C

#define \_RS485 485  
#define SERIAL\_PORT\_MODE \_RS485  
#use modbus\_master.lib  
#use “rcm39xx.lib”

int MBM\_Send\_ADU ( char \*Packet, int ByteCount );  
int MBM\_Rcv\_Resp ( char \* Packet );  
void serInit ( void );

main ()  
{ int i,a, RegsValue[50];  
serInit();  
i = MBM\_ReadRegs ( 7, &RegsValue[0], 0xC55E, 4 ); // read reg 0  
a =MB\_SUCCESS;  
if (a==0)  
printf(“Connexion NON OK”);  
else printf(“Connexion OK”);  
printf("%d, %d,  
", RegsValue[1], RegsValue[2]);  
while (1);  
}

void serInit ( void )  
{ serCopen (9600 ); // open the serial port  
}

/\* START FUNCTION DESCRIPTION \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
MBM\_Send\_ADU  
END DESCRIPTION \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

int MBM\_Send\_ADU ( char \*Packet, int ByteCount )  
{ auto unsigned CRCvalue;  
auto unsigned long Endtime;  
int i;

// insert CRC  
CRCvalue = MODBUS\_CRC ( Packet, ByteCount );  
Packet[ByteCount+1] = CRCvalue; // store low byte  
Packet[ByteCount] = CRCvalue\>\>8; // store high byte  
ByteCount+=2; // adjust for CRC

#ifdef MODBUS\_DEBUG\_PRINT & 1  
printf ( “Tx:” );  
for ( i=0; i
