ICP DAS USA LinPAC-22 Series User Manual page 9

Xv-board api functions
Table of Contents

Advertisement

ICP DAS
Example:
int RetValue, count=1;
int comport=COM1;
int function=1;
int addr=33;
char szBuf[80];
DWORD baudrate=115200;
WORD wValue;
switch(function) {
case FC05ForceSingleCoil:
case FC15ForceMultipleCoil:
szBuf[0]=wValue & 0xff;
break;
case FC06PresetSingleRegister:
case FC16PresetMultipleRegister:
szBuf[0]=(wValue >> 8) & 0xff;
szBuf[1]=wValue & 0xff;
break;
default:
return FAILURE;
}
/* Open the device file */
RetValue=Open_Com(comport, baudrate, Data8Bit, NonParity, OneStopBit);
if (RetValue >0) {
printf("open COM%d failed!\n",comport);
return FAILURE;
}
RetValue=modbusRequest(comport, netid, function, addr, count, szBuf, sizeof(szBuf),
timeout, &wT);
Close_Com(comport);
/* Refer to [Remark 1] */
/* Refer to [Remark 2] */
/* Refer to [Remark 3] */
LinPAC-52xx Series XV-Board API User Manual
9

Advertisement

Table of Contents
loading

Table of Contents