|
|
|
@ -308,30 +308,40 @@ bool frsky_parse_host(uint8_t * sbuf, int nbytes, struct adc_linkquality * v)
@@ -308,30 +308,40 @@ bool frsky_parse_host(uint8_t * sbuf, int nbytes, struct adc_linkquality * v)
|
|
|
|
|
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)
@@ -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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|