ICP DAS USA LinPAC-22 Series User Manual page 12

Xv-board api functions
Table of Contents

Advertisement

ICP DAS
Example:
int RetValue, comport=COM1, count=4;
int addr=0;
char szBuf[80];
DWORD baudrate=115200;
/* Open the device file */
RetValue=Open_Com(comport, baudrate, Data8Bit, NonParity, OneStopBit);
if (RetValue > 0) {
printf("open COM%d failed!\n",comport);
return FAILURE;
}
memset(szBuf, 0, sizeof(szBuf));
RetValue=getXVBitBack(comport, addr, count, szBuf, sizeof(szBuf));
Close_Com(comport);
if (RetValue==0) {
if(count<=8) {
printf("%d", szBuf[0]);
} else if (count<=16){
dwValue=(szBuf[1]<<8)|szBuf[0];
printf("%u", dwValue);
} else {
dwValue=(szBuf[3]<<24)|(szBuf[2]<<16)|(szBuf[1]<<8)|szBuf[0];
printf("%lu", dwValue);
}
}
Remarks:
[1] This is the input value reference address mapping (Modbus register table) for the 'wAddr'
parameter. More information regarding address mapping can be found at:
http://ftp.icpdas.com.tw/pub/cd/linpac/napdos/lp-5000/lp-52xx/lp-5231/user_manual/xv-boar
d_user_manual_v1.0.3.pdf
/* Refer to [Remark 1] */
LinPAC-52xx Series XV-Board API User Manual
12

Advertisement

Table of Contents
loading

Table of Contents