Home > Back-end >  A serial port data parsing
A serial port data parsing

Time:06-08

Void parse_serial (char * byte_buff, int byte_num)
{
Int I=0, num=1;
Char data=https://bbs.csdn.net/topics/0, data1=0;
Int buf [512].

for(i=0; i The data & gt;>=1;
Data |=0 x80;
If (8 (I + 1) %==0)//15 23 July 31 39
{
Buf [8] I/=data;
Data=https://bbs.csdn.net/topics/0;
}
//the begin
If (buf [I]==0 xa5) {
LOOP:
Data1 & gt;>=1;
Data1 |=0 x80;
If (32 (I + 1) %==0) {
Byte_buff [32] I/=data1;
//byte_buff [(I + 1) * 8 + 1];
Data1=0;
num++;
}
//Sleep (1000);
//end
If (buf [I]==0 x0d) {
Time: printf (" % d, 1 data: % d, 2 data: % d, 3 data: % d, 4 data: % d, 5 data: % d, 6 data: % d, temperature: % d \ n ", byte_buff [0], byte_buff [1],
Byte_buff byte_buff [2], [3], byte_buff [4], byte_buff [5], byte_buff [6], byte_buff [7]);
} else if (buf [I]!='\ 0') {
Goto LOOP;
} else {
break;
}

}
}
}

What is going wrong, please correct me big help
Background: receive a piece of data in the serial port, to parse him out
Void parse_serial (char * byte_buff, int byte_num) {
for (int i=0; i Printf (" % c ", byte_buff [I]);
}
printf("\n");
}
This print is the binary data 3 e 64 49 34 3 b 21 E1 06 BF 2 d CA 26 C1 3 a 3 b 88 F1 BA 7 c 7 f 3 c 5 f 2 E4 41 00 00 0 f d A5 27 73 17 45 57 6 b 1 e 3 e BE 50 BC C6 25 07 BF 7 d 1 b 73 D6 26 C1 3 a 3 b AC 96 CF 81, etc

CodePudding user response:


I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related