A SERVICE OF

logo

iVIEW-100 Series user’s Manual, 2006, v2.0 ----- 88
InstallCom(port,115200L,8,0,1); //install COM port 2, baud rate:115200
ClearCom(port); //clear Com before read or send to Com
SendCmdTo7000(port, "@0100",0); //send Do all off command
ClearCom(port);
SendCmdTo7000(port, "@01",0); //send Di read command
//show Di
while(!quit)
{
while (IsCom(port) ) //while COM has any data, begin to decode
{
tt=ReadCom(port);
if(tt == '>' || diR[0] =='>' ) //the first data of available respond is ‘>’
{
if(tt=='>') j=0;
diR[j]=tt;
j++;
if (tt == 0x0D && j==6) //the last data of respond is 0x0D
{
n=ascii_to_hex(diR[4]);
for(i=0;i<4;i++)
{
check=n & DiCT[i];
if (check==0) color=0;
else color=1;
lamp(7+i,3,color);
}//end Di lamp draw
ClearCom(port);
SendCmdTo7000(port, "@01",0); //send read Di command
}//end if 0xd
}//end if Di right
else
{
ClearCom(port);
Print("Di wrong rspns '%c' or too long(%d rspns)\r\n",tt,j);
Print("Do you want to quit");
Getch();
quit=1;
If data is available respond, store them
to diR[j]
The 4
th
data of respond is about light
ON/OFF, transfer it to hex. Please refer
to I-7000 DIO user’s manual for detail.
Analyse Di respond, set the ON/OFF
situation to LCD screen.
If Com port respond wrong data, print
wrong msg, and quit program.