Paparazzi UAS  v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 "subsystems/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 
58 static bool nmea_parse_perdcrv(void);
59 
60 #define GpsLinkDevice (&(NMEA_GPS_LINK).device)
61 
66 void nmea_configure(void)
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++) {
72  len = strlen(gps_furuno_settings[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)) {
76  crc = nmea_calc_crc(gps_furuno_settings[i], len);
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  }
87  gps_nmea.is_configured = true;
88 }
89 
91 {
92  furuno_cfg_cnt = 0;
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 }
struct GpsNmea gps_nmea
Definition: gps_nmea.c:59
definition of the local (flat earth) coordinate system
static const char * gps_furuno_settings[GPS_FURUNO_SETTINGS_NB]
Definition: gps_furuno.c:35
struct GpsState state
Definition: gps_nmea.h:52
char msg_buf[NMEA_MAXLEN]
buffer for storing one nmea-line
Definition: gps_nmea.h:48
static void nmea_read_until(int *i)
Read until a certain character, placed here for proprietary includes.
Definition: gps_nmea.h:79
static bool nmea_parse_perdcrv(void)
Definition: gps_furuno.c:104
void nmea_configure(void)
Configure furuno GPS.
Definition: gps_furuno.c:66
bool nmea_parse_prop_msg(void)
Definition: gps_furuno.c:96
int32_t y
East.
Device independent GPS code (interface)
int32_t x
North.
struct EcefCoor_i ecef_pos
position in ECEF in cm
Definition: gps.h:91
#define GPS_FURUNO_SETTINGS_NB
Definition: gps_furuno.c:34
NMEA protocol specific code.
void nmea_parse_prop_init(void)
Definition: gps_furuno.c:90
unsigned char uint8_t
Definition: types.h:14
uint8_t nmea_calc_crc(const char *buff, int buff_sz)
Calculate control sum of binary buffer.
Definition: gps_nmea.c:243
int fd
Definition: serial.c:26
bool is_configured
flag set to TRUE if configuration is finished
Definition: gps_nmea.h:45
int msg_len
Definition: gps_nmea.h:49
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
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.
#define GpsLinkDevice
Definition: gps_furuno.c:60