-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
gps_furuno.c
111 lines (94 loc) · 3.03 KB
/
gps_furuno.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
*
* Copyright (C) 2014 Freek van Tienen <freek.v.tienen@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
/**
* @file subsystems/gps/gps_furuno.c
* GPS furuno based NMEA parser
*/
#include "gps_nmea.h"
#include "subsystems/gps.h"
#include <stdio.h>
#include <string.h>
#define GPS_FURUNO_SETTINGS_NB 10
static const char *gps_furuno_settings[GPS_FURUNO_SETTINGS_NB] = {
"PERDAPI,FIXPERSEC,5", // Receive position every 5 Hz
"PERDAPI,CROUT,ALLOFF", // Disable all propriarty output
"PERDCFG,NMEAOUT,GGA,1", // Enable GGA every fix
"PERDCFG,NMEAOUT,RMC,1", // Enable RMC every fix
"PERDCFG,NMEAOUT,GSA,1", // Enable GSA every fix
"PERDCFG,NMEAOUT,GNS,0", // Disable GSA
"PERDCFG,NMEAOUT,ZDA,0", // Disable ZDA
"PERDCFG,NMEAOUT,GSV,0", // Disable GSV
"PERDCFG,NMEAOUT,GST,0", // Disable ZDA
"PERDAPI,CROUT,V" // Enable raw velocity
};
static void nmea_parse_perdcrv(void);
#define GpsLinkDevice (&(GPS_LINK).device)
void nmea_parse_prop_init(void)
{
static uint8_t i = 0;
uint8_t j, len, crc;
char buf[128];
// Return when doen
if (i == GPS_FURUNO_SETTINGS_NB) {
return;
}
for (; i < GPS_FURUNO_SETTINGS_NB; i++) {
len = strlen(gps_furuno_settings[i]);
crc = nmea_calc_crc(gps_furuno_settings[i], len);
sprintf(buf, "$%s*%02X\r\n", gps_furuno_settings[i], crc);
// Check if there is enough space to send the config msg
if (GpsLinkDevice->check_free_space(GpsLinkDevice->periph, len + 6)) {
for (j = 0; j < len + 6; j++) {
GpsLinkDevice->put_byte(GpsLinkDevice->periph, buf[j]);
}
} else {
break;
}
}
}
void nmea_parse_prop_msg(void)
{
if (gps_nmea.msg_len > 5 && !strncmp(gps_nmea.msg_buf , "PERDCRV", 7)) {
nmea_parse_perdcrv();
}
}
void nmea_parse_perdcrv(void)
{
int i = 8;
// Ignore reserved
nmea_read_until(&i);
// Ignore reserved
nmea_read_until(&i);
//EAST VEL
double east_vel = strtod(&gps_nmea.msg_buf[i], NULL);
gps.ned_vel.y = east_vel * 100; // in cm/s
// Ignore reserved
nmea_read_until(&i);
// NORTH VEL
double north_vel = strtod(&gps_nmea.msg_buf[i], NULL);
gps.ned_vel.x = north_vel * 100; // in cm/s
//Convert velocity to ecef
struct LtpDef_i ltp;
ltp_def_from_ecef_i(<p, &gps.ecef_pos);
ecef_of_ned_vect_i(&gps.ecef_vel, <p, &gps.ned_vel);
}