<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-2022-jp">
<META content="MSHTML 6.00.2900.3199" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face="MS UI Gothic" size=2><FONT 
size=3>$B$$$D$b$*@$OC$K$J$C$F$$$^$9!#0KF#$H?=$7$^$9!#(B<BR>$B8=:_!"(BArmadillo210$B$rMQ$$$F(BCOM$B#4$+$i5!3#$N@)8f$r(B<BR>$B%7%j%"%kDL?.$G9T$*$&$H$7$F$$$k$N$G$9$,$&$^$/$$$-$^$;$s!#(B</FONT></FONT></DIV>
<DIV><FONT face="MS UI Gothic" size=2><FONT 
size=3>$B%O%$%Q!<%?!<%_%J%k$+$i8+$F$b!"(BCOM$B#4$K$O=P$F$$$^$;$s!#(B<BR>$B=iJbE*$J$3$H$G?=$7Lu$4$6$$$^$;$s$,!"$I$J$?$+$42sEz(B<BR>$B$$$?$@$1$^$9$h$&$*4j$$CW$7$^$9!#(B<BR> <BR> 
$B$J$*!"8=>u!":n6H$r$7$F$$$k%=!<%9$O0J2<$NDL$j$G$9!#(B<BR>#include<stdio.h><BR>#include<stdlib.h><BR>#include<strings.h><BR>#include<termios.h><BR>#include<unistd.h><BR>#include<fcntl.h><BR>#include 
<stdint.h><BR>#include <sys/signal.h><BR>#include 
<sys/types.h><BR>#include <signal.h><BR>#include 
<unistd.h><BR> <BR> #define BAUDRATE B38400<BR>#define MODEMDEVICE 
"/dev/ttyAM1"<BR>#define _POSIX_SOURCE 1 <BR> #define FALSE 0<BR>#define 
TRUE 1<BR> <BR>extern uint16_t StrwCalcCRC16( uint8_t * pbData, int 
iDataLen, int iOpt );<BR> <BR>volatile int STOP=FALSE; <BR> <BR> 
void signal_handler_IO (int status);   <BR> <BR> int 
wait_flag=TRUE;                    <BR> <BR> 
int main(int argc,char * argv[])<BR> {<BR>   $B!!!!(Bint fd, 
res;<BR> $B!!!!(B  struct termios oldtio,newtio;<BR>   $B!!!!(Bstruct 
sigaction 
saio;        <BR> <BR>  
 $B!!!!(Bchar 
buf[8];                 <BR> 
$B!!(B $B!!(B  char rtn[13];<BR>$B!!!!(B  fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY | 
O_NONBLOCK);<BR> $B!!!!(B if (fd <0)<BR>$B!!!!!!(B 
{$B!!(B<BR> $B!!!!!!!!!!!!!!(Bperror(MODEMDEVICE);<BR> $B!!!!!!!!(B        
exit(-1);<BR> $B!!!!!!(B  }<BR> <BR> $B!!!!!!(B  saio.sa_handler = 
signal_handler_IO;$B!!(B<BR> $B!!!!!!(B  //saio.sa_mask = 0;<BR> $B!!!!!!(B  
saio.sa_flags = 0;<BR>   $B!!!!!!(Bsaio.sa_restorer = 
NULL;<BR> $B!!!!!!(B  sigaction(SIGIO,&saio,NULL);<BR> $B!!!!!!(B  
fcntl(fd, F_SETOWN, getpid());<BR> $B!!!!!!(B  fcntl(fd, F_SETFL, 
FASYNC);<BR> $B!!!!!!(B  tcgetattr(fd,&oldtio); <BR>   
$B!!!!!!(Bnewtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;<BR>$B!!!!!!!!(B  
newtio.c_iflag = IGNPAR | ICRNL;<BR> $B!!!!!!(B  newtio.c_oflag = 
0;<BR> $B!!!!!!(B  newtio.c_lflag = ICANON;<BR> <BR>   
$B!!!!!!(Bnewtio.c_cc[VMIN]=1;<BR> $B!!!!!!(B  newtio.c_cc[VTIME]=0;<BR>   
$B!!!!!!(Btcflush(fd, TCIFLUSH);<BR> $B!!!!!!(B  
tcsetattr(fd,TCSANOW,&newtio);<BR> <BR> $B!!!!!!(B  
bzero(&buf,sizeof(buf));<BR>$B!!!!!!(B  
bzero(&rtn,sizeof(rtn));<BR> $B!!!!!!(B  
bzero(&buf2,sizeof(buf2));<BR> <BR> $B!!!!(B   buf[0] = 
0x05;<BR> $B!!!!(B   buf[1] = 0x54;<BR> $B!!!!(B   buf[2] = 
0x30;<BR> $B!!!!(B   buf[3] = 0x30;<BR> $B!!!!(B   buf[4] = 
StrwCalcCRC16(buf,4,0);<BR> $B!!!!(B   buf[6] = 
0x04;<BR>    $B!!!!(Bwhile (STOP==FALSE)<BR>     
$B!!(B{<BR>      $B!!!!!!(Bres = 
write(fd,buf,7);<BR>      
$B!!!!!!(Bprintf(".\n");<BR>      
$B!!!!!!(Busleep(100000);<BR>   $B!!!!!!!!(Bif 
(wait_flag==FALSE)<BR>      
$B!!!!!!(B{ <BR>         $B!!!!!!!!(Bres = 
read(fd,rtn,12);<BR>         
$B!!!!!!!!(Bbuf[res]=0;<BR> $B!!(B      $B!!!!!!!!(Bprintf(":%s:%d\n", 
buf, res);$B!!(B<BR> $B!!!!!!!!!!(B     if 
(res==1)<BR>    $B!!!!!!!!!!!!!!(BSTOP=TRUE; <BR> 
$B!!!!!!!!!!(B     wait_flag = TRUE; <BR>    $B!!!!!!(B 
}<BR>  $B!!!!(B }<BR> $B!!!!(B close(fd);  <BR>   
$B!!!!(Breturn(0);<BR>  }<BR> <BR> void signal_handler_IO (int 
status)<BR> {<BR>   printf("received SIGIO 
signal.\n");<BR>   wait_flag = 
FALSE;<BR> }</FONT><BR></DIV></FONT></BODY></HTML>