mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 02:36:37 +08:00
ST24: Fix parser return values, update docs
This commit is contained in:
+9
-7
@@ -103,16 +103,18 @@ uint8_t st24_common_crc8(uint8_t *ptr, uint8_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8_t st24_decode(uint8_t byte, uint8_t *rssi, uint8_t *rx_count, uint16_t *channel_count, uint16_t *channels,
|
int st24_decode(uint8_t byte, uint8_t *rssi, uint8_t *rx_count, uint16_t *channel_count, uint16_t *channels,
|
||||||
uint16_t max_chan_count)
|
uint16_t max_chan_count)
|
||||||
{
|
{
|
||||||
|
|
||||||
bool ret = false;
|
int ret = 1;
|
||||||
|
|
||||||
switch (_decode_state) {
|
switch (_decode_state) {
|
||||||
case ST24_DECODE_STATE_UNSYNCED:
|
case ST24_DECODE_STATE_UNSYNCED:
|
||||||
if (byte == ST24_STX1) {
|
if (byte == ST24_STX1) {
|
||||||
_decode_state = ST24_DECODE_STATE_GOT_STX1;
|
_decode_state = ST24_DECODE_STATE_GOT_STX1;
|
||||||
|
} else {
|
||||||
|
ret = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -163,7 +165,7 @@ uint8_t st24_decode(uint8_t byte, uint8_t *rssi, uint8_t *rx_count, uint16_t *ch
|
|||||||
|
|
||||||
if (st24_common_crc8((uint8_t *) & (_rxpacket.length), _rxlen) == _rxpacket.crc8) {
|
if (st24_common_crc8((uint8_t *) & (_rxpacket.length), _rxlen) == _rxpacket.crc8) {
|
||||||
|
|
||||||
ret = true;
|
ret = 0;
|
||||||
|
|
||||||
/* decode the actual packet */
|
/* decode the actual packet */
|
||||||
|
|
||||||
@@ -225,23 +227,23 @@ uint8_t st24_decode(uint8_t byte, uint8_t *rssi, uint8_t *rx_count, uint16_t *ch
|
|||||||
|
|
||||||
// ReceiverFcPacket* d = (ReceiverFcPacket*)&_rxpacket.st24_data;
|
// ReceiverFcPacket* d = (ReceiverFcPacket*)&_rxpacket.st24_data;
|
||||||
/* we silently ignore this data for now, as it is unused */
|
/* we silently ignore this data for now, as it is unused */
|
||||||
ret = false;
|
ret = 2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ret = false;
|
ret = 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* decoding failed */
|
/* decoding failed */
|
||||||
|
ret = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
_decode_state = ST24_DECODE_STATE_UNSYNCED;
|
_decode_state = ST24_DECODE_STATE_UNSYNCED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -155,9 +155,9 @@ uint8_t st24_common_crc8(uint8_t *ptr, uint8_t len);
|
|||||||
* @param rx_count pointer to a byte where the receive count of packets signce last wireless frame is written back to
|
* @param rx_count pointer to a byte where the receive count of packets signce last wireless frame is written back to
|
||||||
* @param channels pointer to a datastructure of size max_chan_count where channel values (12 bit) are written back to
|
* @param channels pointer to a datastructure of size max_chan_count where channel values (12 bit) are written back to
|
||||||
* @param max_chan_count maximum channels to decode - if more channels are decoded, the last n are skipped and success (0) is returned
|
* @param max_chan_count maximum channels to decode - if more channels are decoded, the last n are skipped and success (0) is returned
|
||||||
* @return 0 for success (a decoded packet), 1 for no packet yet (accumulating), 3 for out of sync, 4 for checksum error
|
* @return 0 for success (a decoded packet), 1 for no packet yet (accumulating), 2 for unknown packet, 3 for out of sync, 4 for checksum error
|
||||||
*/
|
*/
|
||||||
__EXPORT uint8_t st24_decode(uint8_t byte, uint8_t *rssi, uint8_t *rx_count, uint16_t *channel_count,
|
__EXPORT int st24_decode(uint8_t byte, uint8_t *rssi, uint8_t *rx_count, uint16_t *channel_count,
|
||||||
uint16_t *channels, uint16_t max_chan_count);
|
uint16_t *channels, uint16_t max_chan_count);
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|||||||
Reference in New Issue
Block a user