AM335X-PAC Series User Manual version 2.0.1 Page: 114
Copyright © 2019 ICP DAS Co., Ltd. All Rights Reserved. E-mail: [email protected]
char i[10];
// Check Open_Com9 on the I-8114W
wRetVal =
Open_Com
(
COM9
,
115200
, Data8Bit, NonParity, OneStopBit);
if (wRetVal > 0) {
printf("Failed to open port. \n");
return (-1);
}
// ***** 7044 DO & DI Parameters *******
wBuf[0] =
9
;
// COM Port
wBuf[1] =
0x02
;
// Address
wBuf[2] =
0x7044
;
// ID
wBuf[3] = 0;
// Checksum disable
wBuf[4] = 100;
// Timeout, 100 milliseconds
wBuf[6] = 0;
// Debug string
// 7044 DO
while(j!=113) {
printf("Enter the DO value, or press 'q' to quit -> ");
scanf("%s",i);
if (i[0]=='q') {
wBuf[5] = 0; // All DO Channels OFF
wRetVal = DigitalOut(wBuf, fBuf, szSend, szReceive);
break;
}
j=atoi(i);
if (j>=0 & j<=255)
wBuf[5] = j; // DO Channels ON
else if (j>255)
wBuf[5] = 255;
wRetVal =
DigitalOut(wBuf, fBuf, szSend, szReceive)
;
if (wRetVal) //
There was an error with the Digital Output on the I-7044
printf("Digital Output of 7044 is error, Error Code=%d\n", wRetVal);
else
printf("The DO value of 7044 is: %u \n", wBuf[5]);