Hello everyone!
Excuse me to post too many messages.

I have a RCM3900 is connected to a slave via RS485. I want to read the registry via the Modbus protocol. So I used the example modbus_serial_master. c that I adapted. But I can not play my records. I could see that in the example there modbus_serial_master.c different functions that are included in RS232.lib serXrdUsed like () or serCread ().

Should I replace them because I have a RS485 connection?
Help me please, thank you!

My program:

#define Mesure
#define MODBUS_DEBUG_PRINT 0 // define to 1 to print transactions
#define CINBUFSIZE 15
#define COUTBUFSIZE 15
#define _RS485 485
#use modbus_master.lib

void brdInit();
int MBM_Send_ADU ( char *Packet, int ByteCount );
int MBM_Rcv_Resp ( char * Packet );
void serInit ( void );
void ser485Tx( void ) ;
void ser485Rx( void );

main ()
{long i, RegsValue[50];
i = MBM_ReadRegs (005, &RegsValue[0], 4096, 2 ); // read reg 0
printf("%d, %d,
", RegsValue[0], i);

void serInit ( void )
serCopen (9600 ); // open the serial port
/* START FUNCTION DESCRIPTION ********************************************
END DESCRIPTION **********************************************************/

void brdInit()
{ WrPortI(PCFR, &PCFRShadow, PCFRShadow&0xEA); //clear bit 4,2,0 to normal function
//bits 5,3,1 normally inputs
WrPortI(PCDR, &PCDRShadow, PCDRShadow|0x15); //set bits 4,2,0 high
WrPortI(PDCR, &PDCRShadow, 0x00); //clear all bits to pclk/2
WrPortI(PDFR, &PDFRShadow, 0x00); //clear all bits to normal function
WrPortI(PDDCR, &PDDCRShadow, 0x00); //clear all bits to drive high and low
WrPortI(PDDR, &PDDRShadow, 0x0b); //set bits 3,1,0 high
WrPortI(PDDDR, &PDDDRShadow, 0x8b); //set bits 7,3,1,0 to output, rest inputs

void ser485Tx( void )
set 7,a ;set bit 7
ioi ld (PDDR),a ;set PD7 high

void ser485Rx( void )
res 7,a ;clear bit 7
ioi ld (PDDR),a ;set PF5 low

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

printf ( “Tx:” );
for ( i=0; i