anle82 发表于 2007-8-6 20:28

[求助]用2个红外手持器发送字符串和接收字符串并返回发送状态

<P>大家好!我写了个收发字符但不能实现字符串发送该如何在这个程序里修改:?<BR><BR>#include &lt;stdlib.h&gt;<BR>#include &lt;string.h&gt;<BR>#include &lt;conio.h&gt;<BR>#include &lt;dos.h&gt;<BR>#include &lt;time.h&gt;<BR>#include &lt;io.h&gt;<BR>#include &lt;fcntl.h&gt;<BR>#include &lt;process.h&gt;<BR>#include &lt;stdio.h&gt; <BR>#include &lt;infrared.h&gt;<BR>#include &lt;htlcd.h&gt;<BR>#include &lt;htxlcd.h&gt;<BR>#include &lt;commplus.h&gt;<BR>#include &lt;htproces.h&gt;<BR>#include &lt;barcode.h&gt;<BR>#include &lt;htosex.h&gt;</P>
<P>  main()<BR>  {<BR>   unsigned char ascch, auxb, auxstat,workmode,commport,send,akey,str[7];</P>
<P>   unsigned int  baudrate,inRx,i;</P>
<P>   <BR>  <BR> </P>
<P>   printf("打开红外电源:\r\n");<BR>   IRPowerCtrl(_IRPowON);                                 //红外电源控制  122<BR>   SetIRMFreq(38000);                                     //设制红外调制频率 38k    122<BR>   getch();<BR>   printf("打开红外输出:\r\n");<BR>   SetIROutput(0);<BR> <BR>   do {<BR>   } while (!kbhit());                                   //kbhit()用来检测键盘是否有按键,有则返回-1,没有则返回0<BR>   printf("设置红外输出:\r\n");<BR>   SetIROutput(2);<BR>   do {<BR>   } while (!kbhit()); <BR>     getch();                                                <BR>   <BR>   GetCommMode(&amp;workmode, &amp;commport, &amp;baudrate);          //取当前通讯串口、通讯方式和波特率    107<BR>   SetCommMode(3, 1, 1200);                               //设置通讯串口、通讯方式和波特率     107<BR>   EnableRx(0);    </P>
<P>                            </P>
<P>   printf("请输入一些字符串并发送: \r\n");<BR>    <BR>   send = 0;<BR>  </P>
<P>   do {<BR>       if (kbhit()) <BR>        { <BR>         akey=getch();      <BR>          if (akey !=auxb){<BR>          if (!send)<BR>          send = 1; <BR>            <BR>           PutAuxByte(akey);<BR>           printf("%c\r\n",akey);<BR>           <BR>          } <BR>         }<BR>       if (ExistAuxBGot(&amp;auxb,&amp;auxstat))<BR>        { if (send)<BR>          printf("\r\n");<BR>          send = 0;<BR>          printf("%c\n",auxb);<BR>     <BR>        }<BR>       <BR>       } while (akey !=27);<BR>   IRPowerCtrl(_IRPowOFF);                                //红外电源控制  122<BR>   SetIRMFreq(0);                                         //设制红外调制频率 0   122<BR>   DisableRx();                                           //禁止串行口接收任何数据<BR>   SetCommMode(workmode, commport, baudrate);  <BR>   return 0;<BR>}</P>
<P>这段代码怎么改?</P>


页: [1]

编程论坛