mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-28 00:24:08 +08:00
fix format
This commit is contained in:
parent
de39b63402
commit
e25b26e2a8
@ -289,7 +289,7 @@ void frsky_send_frame3(int uart)
|
||||
}
|
||||
|
||||
/* parse 11 byte frames */
|
||||
bool frsky_parse_host(uint8_t * sbuf, int nbytes, struct adc_linkquality * v)
|
||||
bool frsky_parse_host(uint8_t *sbuf, int nbytes, struct adc_linkquality *v)
|
||||
{
|
||||
bool data_ready = false;
|
||||
static int dcount = 0;
|
||||
@ -302,36 +302,46 @@ bool frsky_parse_host(uint8_t * sbuf, int nbytes, struct adc_linkquality * v)
|
||||
TRAILER
|
||||
} state = HEADER;
|
||||
|
||||
for (int i=0; i<nbytes; i++) {
|
||||
for (int i = 0; i < nbytes; i++) {
|
||||
switch (state) {
|
||||
case HEADER:
|
||||
if (sbuf[i] == 0x7E) {
|
||||
state = TYPE;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case TYPE:
|
||||
if (sbuf[i] != 0x7E) {
|
||||
state = DATA;
|
||||
type = sbuf[i];
|
||||
dcount = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case DATA:
|
||||
|
||||
/* read 8 data bytes */
|
||||
if (dcount < 7) {
|
||||
data[dcount++] = sbuf[i];
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
/* received all data bytes */
|
||||
state = TRAILER;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case TRAILER:
|
||||
state = HEADER;
|
||||
|
||||
if (sbuf[i] != 0x7E) {
|
||||
warnx("host packet error: %x", sbuf[i]);
|
||||
|
||||
} else {
|
||||
data_ready = true;
|
||||
|
||||
if (type == 0xFE) {
|
||||
/* this is an adc_linkquality packet */
|
||||
v->ad1 = data[0];
|
||||
@ -339,9 +349,11 @@ bool frsky_parse_host(uint8_t * sbuf, int nbytes, struct adc_linkquality * v)
|
||||
v->linkq = data[2];
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return data_ready;
|
||||
}
|
||||
|
||||
|
||||
@ -55,6 +55,6 @@ struct adc_linkquality {
|
||||
uint8_t ad2;
|
||||
uint8_t linkq;
|
||||
};
|
||||
bool frsky_parse_host(uint8_t * sbuf, int nbytes, struct adc_linkquality * v);
|
||||
bool frsky_parse_host(uint8_t *sbuf, int nbytes, struct adc_linkquality *v);
|
||||
|
||||
#endif /* _FRSKY_TELEMETRY_H */
|
||||
|
||||
@ -344,9 +344,10 @@ static int frsky_telemetry_thread_main(int argc, char *argv[])
|
||||
/* parse incoming data */
|
||||
int nbytes = read(uart, &dbuf[0], sizeof(dbuf));
|
||||
bool new_input = frsky_parse_host(&dbuf[0], nbytes, &host_frame);
|
||||
|
||||
if (new_input) {
|
||||
warnx("host frame: ad1:%u, ad2: %u, rssi: %u",
|
||||
host_frame.ad1, host_frame.ad2, host_frame.linkq);
|
||||
host_frame.ad1, host_frame.ad2, host_frame.linkq);
|
||||
}
|
||||
|
||||
/* Send frame 1 (every 200ms): acceleration values, altitude (vario), temperatures, current & voltages, RPM */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user