数据接收
This commit is contained in:
21
main.cpp
21
main.cpp
@@ -24,7 +24,8 @@ using namespace std;
|
|||||||
#define ARMOR_STATE 0
|
#define ARMOR_STATE 0
|
||||||
|
|
||||||
int state = ARMOR_STATE;
|
int state = ARMOR_STATE;
|
||||||
float yaw=0, pitch=0;
|
float curr_yaw=0, curr_pitch=0;
|
||||||
|
float mark_yaw=0, mark_pitch=0;
|
||||||
|
|
||||||
void uartReceive(Uart* uart);
|
void uartReceive(Uart* uart);
|
||||||
|
|
||||||
@@ -99,20 +100,22 @@ void uartReceive(Uart* uart){
|
|||||||
if(cnt >= 100){
|
if(cnt >= 100){
|
||||||
LOGE("data receive over flow!");
|
LOGE("data receive over flow!");
|
||||||
}
|
}
|
||||||
}buffer[cnt] = 0;
|
}
|
||||||
if(cnt == 9){
|
if(cnt == 10){
|
||||||
if(buffer[8] == 'e'){
|
if(buffer[8] == 'e'){
|
||||||
state = ENERGY_STATE;
|
state = ENERGY_STATE;
|
||||||
LOGM("Energy state");
|
LOGM("Energy state");
|
||||||
memcpy(&yaw, buffer, 4);
|
|
||||||
memcpy(&pitch, buffer+4, 4);
|
|
||||||
LOGM("Get yaw:%f pitch:%f", yaw, pitch);
|
|
||||||
}else if(buffer[8] == 'a'){
|
}else if(buffer[8] == 'a'){
|
||||||
state = ARMOR_STATE;
|
state = ARMOR_STATE;
|
||||||
LOGM("Armor state");
|
LOGM("Armor state");
|
||||||
memcpy(&yaw, buffer, 4);
|
}
|
||||||
memcpy(&pitch, buffer+4, 4);
|
memcpy(&curr_yaw, buffer, 4);
|
||||||
LOGM("Get yaw:%f pitch:%f", yaw, pitch);
|
memcpy(&curr_pitch, buffer+4, 4);
|
||||||
|
LOGM("Get yaw:%f pitch:%f", curr_yaw, curr_pitch);
|
||||||
|
if(buffer[9] == 1){
|
||||||
|
mark_yaw = curr_yaw;
|
||||||
|
mark_pitch = curr_pitch;
|
||||||
|
LOGM("Marked");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user