void USART2_IRQHandler(void)
{
u8 Res=0;
if(USART_GetITStatus(USART2,USART_IT_RXNE) != RESET)
{
Res = USART_ReceiveData(USART2);
Uart2_Buf[First_Int] = Res; //½«½óêÕμ½μÄ×Ö·û′®′æμ½»o′æÖD
First_Int++; //»o′æÖ¸ÕëÏòoóòƶˉ
if(First_Int > Buf2_Max) //èç1û»o′æÂú,½«»o′æÖ¸ÕëÖ¸Ïò»o′æμÄê×μØÖ·
{
First_Int = 0;
}
void judge_ser_data() //判断是否是服务器发来的数据
{
printf("t1");
printf("%s",Uart2_Buf);
// printf("------");
if(Find("sd:"))
{ char *t1;
printf("d1");
t1=strstr(Uart2_Buf,"sd:");
CLR_Buf();
ser_data_process(t1);
}
else{}
}
void ser_data_process(char temp_rec[50])
{
u8 i=0;
u8 j=0;
char wei[5];
char type;
temp_rec=strstr(Uart2_Buf,"sd:");
while(temp_rec[i++]!=':'){};
type=temp_rec[i];
i=i+2;
while(temp_rec[i]!='!')
{
wei[j++]=temp_rec[i++];
}
wei[j]=' ';
//wei=weight;
rice_info.weight=atoi(wei);
printf("type:%d,weight:%d",rice_info.type,rice_info.weight);
}
while(1)
{
judge_ser_data();
}
经常检测不到sd:,是怎么回事啊
一周热门 更多>