From 17ba4eb8d3d55e08605bbbc7e387254a4fdd75df Mon Sep 17 00:00:00 2001 From: Olivier Matz Date: Tue, 9 Sep 2014 19:07:54 +0200 Subject: [PATCH] gps: fix global position --- imuboard/gps_venus.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/imuboard/gps_venus.c b/imuboard/gps_venus.c index 82f6525..860a0b9 100644 --- a/imuboard/gps_venus.c +++ b/imuboard/gps_venus.c @@ -426,27 +426,28 @@ static int decode_gps_pos(uint8_t *buf, uint16_t len) if (len != sizeof(*pos)) return -1; - if (pos->msg_id != 0xA8) /* XXX not tested */ + if (pos->msg_id != 0xA8) return -1; - gps_pos.gps_week = ntohs(pos->gps_week); - gps_pos.tow = ntohl(pos->tow); + /* fix endianness inside the frame */ + pos->gps_week = ntohs(pos->gps_week); + pos->tow = ntohl(pos->tow); - gps_pos.latitude = ntohl(pos->latitude); - gps_pos.longitude = ntohl(pos->longitude); - gps_pos.altitude = ntohl(pos->altitude); + pos->latitude = ntohl(pos->latitude); + pos->longitude = ntohl(pos->longitude); + pos->altitude = ntohl(pos->altitude); - gps_pos.sea_altitude = ntohl(pos->sea_altitude); + pos->sea_altitude = ntohl(pos->sea_altitude); - gps_pos.gdop = ntohs(pos->gdop); - gps_pos.pdop = ntohs(pos->pdop); - gps_pos.hdop = ntohs(pos->hdop); - gps_pos.vdop = ntohs(pos->vdop); - gps_pos.tdop = ntohs(pos->tdop); + pos->gdop = ntohs(pos->gdop); + pos->pdop = ntohs(pos->pdop); + pos->hdop = ntohs(pos->hdop); + pos->vdop = ntohs(pos->vdop); + pos->tdop = ntohs(pos->tdop); - gps_pos.ecef_vx = ntohl(pos->ecef_vx); - gps_pos.ecef_vy = ntohl(pos->ecef_vy); - gps_pos.ecef_vz = ntohl(pos->ecef_vz); + pos->ecef_vx = ntohl(pos->ecef_vx); + pos->ecef_vy = ntohl(pos->ecef_vy); + pos->ecef_vz = ntohl(pos->ecef_vz); /* update global structure */ IRQ_LOCK(irq_flags); -- 2.39.5