中断串口接收方法

来源:互联网 发布:淘宝c店全屏装修 编辑:程序博客网 时间:2024/06/06 06:17

此方法是在知道数据包的包头和数据长度的基础上实现,没有校验过程。

        extern uint8 cmd[12+1+1];         static uint8 cnt = 0;

 uint8 in;if(RxUart(&in,1)){   if(cnt == 0)   {       if(in == 头地址)       {           cmd[cnt] = in;           cnt = 1;       }   }   else   {       cmd[cnt] = in;       cnt++;       if(cnt == 13)       {           if ( cmd[cnt]  == 包尾)           {           }           cnt = 0;       }    }}
0 0
原创粉丝点击