Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
gps_furuno.c
Go to the documentation of this file.
1/*
2 *
3 * Copyright (C) 2014 Freek van Tienen <freek.v.tienen@gmail.com>
4 *
5 * This file is part of paparazzi.
6 *
7 * paparazzi is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * paparazzi is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with paparazzi; see the file COPYING. If not, write to
19 * the Free Software Foundation, 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 *
22 */
23
29#include "modules/gps/gps.h"
30#include "gps_nmea.h"
31#include <stdio.h>
32#include <string.h>
33
34#define GPS_FURUNO_SETTINGS_NB 18
36 "PERDAPI,FIRSTFIXFILTER,STRONG",
37 "PERDAPI,FIXPERSEC,5", // Receive position every 5 Hz
38 "PERDAPI,FIXMASK,SENSITIVITY",
39 "PERDAPI,STATIC,0,0",
40 "PERDAPI,LATPROP,-1", // Disable latency position propagation
41 "PERDAPI,OUTPROP,0", // Disable position output propagation
42 "PERDAPI,PIN,OFF",
43 "PERDAPI,GNSS,AUTO,2,2,0,-1,-1",
44 "PERDSYS,ANTSEL,FORCE1L",
45 "PERDAPI,CROUT,ALLOFF", // Disable all propriarty output
46 "PERDAPI,CROUT,V", // Enable proprietary PERDCRV raw velocity message
47 "PERDCFG,NMEAOUT,GGA,1", // Enable GGA every fix
48 "PERDCFG,NMEAOUT,RMC,1", // Enable RMC every fix
49 "PERDCFG,NMEAOUT,GSA,1", // Enable GSA every fix
50 "PERDCFG,NMEAOUT,GNS,0", // Disable GNS
51 "PERDCFG,NMEAOUT,ZDA,0", // Disable ZDA
52 "PERDCFG,NMEAOUT,GSV,1", // Enable GSV
53 "PERDCFG,NMEAOUT,GST,0" // Disable GST
54};
55
57
58static bool nmea_parse_perdcrv(void);
59
60#define GpsLinkDevice (&(NMEA_GPS_LINK).device)
61
67{
68 uint8_t i, j, len, crc;
69 char buf[128];
70
71 for (i = furuno_cfg_cnt; i < GPS_FURUNO_SETTINGS_NB; i++) {
73 // Check if there is enough space to send the config msg
74 long fd = 0;
75 if (GpsLinkDevice->check_free_space(GpsLinkDevice->periph, &fd, len + 6)) {
77 sprintf(buf, "$%s*%02X\r\n", gps_furuno_settings[i], crc);
78 for (j = 0; j < len + 6; j++) {
79 GpsLinkDevice->put_byte(GpsLinkDevice->periph, fd, buf[j]);
80 }
82 } else {
83 // Not done yet...
84 return;
85 }
86 }
88}
89
91{
93}
94
95
97{
98 if (gps_nmea.msg_len > 5 && !strncmp(gps_nmea.msg_buf , "PERDCRV", 7)) {
99 return nmea_parse_perdcrv();
100 }
101 return false;
102}
103
105{
106 int i = 8;
107
108 // Ignore reserved
109 nmea_read_until(&i);
110
111 // Ignore reserved
112 nmea_read_until(&i);
113
114 //EAST VEL
115 double east_vel = strtod(&gps_nmea.msg_buf[i], NULL);
116 gps_nmea.state.ned_vel.y = east_vel * 100; // in cm/s
117
118 // Ignore reserved
119 nmea_read_until(&i);
120
121 // NORTH VEL
122 double north_vel = strtod(&gps_nmea.msg_buf[i], NULL);
123 gps_nmea.state.ned_vel.x = north_vel * 100; // in cm/s
124
125 //Convert velocity to ecef
126 struct LtpDef_i ltp;
129
130 /* indicate that msg was valid and gps_nmea.state updated */
131 return true;
132}
Device independent GPS code (interface)
struct EcefCoor_i ecef_pos
position in ECEF in cm
Definition gps.h:91
struct EcefCoor_i ecef_vel
speed ECEF in cm/s
Definition gps.h:95
struct NedCoor_i ned_vel
speed NED in cm/s
Definition gps.h:96
static uint8_t furuno_cfg_cnt
Definition gps_furuno.c:56
#define GPS_FURUNO_SETTINGS_NB
Definition gps_furuno.c:34
static bool nmea_parse_perdcrv(void)
Definition gps_furuno.c:104
bool nmea_parse_prop_msg(void)
Definition gps_furuno.c:96
void nmea_parse_prop_init(void)
Definition gps_furuno.c:90
#define GpsLinkDevice
Definition gps_furuno.c:60
static const char * gps_furuno_settings[GPS_FURUNO_SETTINGS_NB]
Definition gps_furuno.c:35
void nmea_configure(void)
Configure furuno GPS.
Definition gps_furuno.c:66
struct GpsNmea gps_nmea
Definition gps_nmea.c:59
uint8_t nmea_calc_crc(const char *buff, int buff_sz)
Calculate control sum of binary buffer.
Definition gps_nmea.c:243
NMEA protocol specific code.
int msg_len
Definition gps_nmea.h:49
static void nmea_read_until(int *i)
Read until a certain character, placed here for proprietary includes.
Definition gps_nmea.h:79
struct GpsState state
Definition gps_nmea.h:52
bool is_configured
flag set to TRUE if configuration is finished
Definition gps_nmea.h:45
char msg_buf[NMEA_MAXLEN]
buffer for storing one nmea-line
Definition gps_nmea.h:48
int32_t y
East.
int32_t x
North.
void ltp_def_from_ecef_i(struct LtpDef_i *def, struct EcefCoor_i *ecef)
void ecef_of_ned_vect_i(struct EcefCoor_i *ecef, struct LtpDef_i *def, struct NedCoor_i *ned)
Rotate a vector from NED to ECEF.
definition of the local (flat earth) coordinate system
uint16_t foo
Definition main_demo5.c:58
int fd
Definition serial.c:26
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.