1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

'Slightly' more efficient binary packet handling.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2845 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
pip 2011-02-22 12:45:51 +00:00 committed by pip
parent 9da0fb47e2
commit f6370a035d

View File

@ -129,7 +129,7 @@ int GTOP_BIN_update_position(uint8_t b, volatile uint32_t *chksum_errors, volati
// add the new byte into the buffer
gps_rx_buffer[gps_rx_buffer_wr++] = b;
while (gps_rx_buffer_wr >= sizeof(t_gps_bin_packet))
while (gps_rx_buffer_wr > 0)
{
// scan for the start of a binary packet (the header bytes)
while (gps_rx_buffer_wr >= sizeof(rx_packet->header))
@ -143,13 +143,11 @@ int GTOP_BIN_update_position(uint8_t b, volatile uint32_t *chksum_errors, volati
}
if (gps_rx_buffer_wr < sizeof(t_gps_bin_packet))
{ // not yet enough bytes for a complete binary packet
break;
}
break; // not yet enough bytes for a complete binary packet
// we have enough bytes for a complete binary packet
// check to see if certain params are valid
// check to see if certain parameters in the binary packet are valid
if (rx_packet->header != 0x2404 ||
rx_packet->end_word != 0x0A0D ||
rx_packet->asterisk != 0x2A ||
@ -198,12 +196,12 @@ int GTOP_BIN_update_position(uint8_t b, volatile uint32_t *chksum_errors, volati
GPSTimeData GpsTime;
GPSTimeGet(&GpsTime);
uint32_t utc_time = rx_packet->data.utc_time / 1000;
GpsTime.Second = utc_time % 100; //
GpsTime.Minute = (utc_time / 100) % 100; //
GpsTime.Hour = utc_time / 10000; //
GpsTime.Day = rx_packet->data.day; //
GpsTime.Month = rx_packet->data.month; //
GpsTime.Year = rx_packet->data.year; //
GpsTime.Second = utc_time % 100; // seconds
GpsTime.Minute = (utc_time / 100) % 100; // minutes
GpsTime.Hour = utc_time / 10000; // hours
GpsTime.Day = rx_packet->data.day; // day
GpsTime.Month = rx_packet->data.month; // month
GpsTime.Year = rx_packet->data.year; // year
GPSTimeSet(&GpsTime);
// set the gps position object
@ -228,7 +226,7 @@ int GTOP_BIN_update_position(uint8_t b, volatile uint32_t *chksum_errors, volati
// GpsData.VDOP; // not available in binary mode
GPSPositionSet(&GpsData);
// remove the spent packet from the buffer
// remove the spent binary packet from the buffer
if (gps_rx_buffer_wr > sizeof(t_gps_bin_packet))
{
memmove(gps_rx_buffer, gps_rx_buffer + sizeof(t_gps_bin_packet), gps_rx_buffer_wr - sizeof(t_gps_bin_packet));