Paparazzi UAS  v5.8.2_stable-0-g6260b7c
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 "gps_nmea.h"
30 #include "subsystems/gps.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 void nmea_parse_perdcrv(void);
59 
60 #define GpsLinkDevice (&(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  if (GpsLinkDevice->check_free_space(GpsLinkDevice->periph, len + 6)) {
75  crc = nmea_calc_crc(gps_furuno_settings[i], len);
76  sprintf(buf, "$%s*%02X\r\n", gps_furuno_settings[i], crc);
77  for (j = 0; j < len + 6; j++) {
78  GpsLinkDevice->put_byte(GpsLinkDevice->periph, buf[j]);
79  }
81  } else {
82  // Not done yet...
83  return;
84  }
85  }
87 }
88 
90 {
91  furuno_cfg_cnt = 0;
92 }
93 
94 
96 {
97  if (gps_nmea.msg_len > 5 && !strncmp(gps_nmea.msg_buf , "PERDCRV", 7)) {
99  }
100 }
101 
103 {
104  int i = 8;
105 
106  // Ignore reserved
107  nmea_read_until(&i);
108 
109  // Ignore reserved
110  nmea_read_until(&i);
111 
112  //EAST VEL
113  double east_vel = strtod(&gps_nmea.msg_buf[i], NULL);
114  gps.ned_vel.y = east_vel * 100; // in cm/s
115 
116  // Ignore reserved
117  nmea_read_until(&i);
118 
119  // NORTH VEL
120  double north_vel = strtod(&gps_nmea.msg_buf[i], NULL);
121  gps.ned_vel.x = north_vel * 100; // in cm/s
122 
123  //Convert velocity to ecef
124  struct LtpDef_i ltp;
127 }
struct GpsNmea gps_nmea
Definition: gps_nmea.c:62
definition of the local (flat earth) coordinate system
static const char * gps_furuno_settings[GPS_FURUNO_SETTINGS_NB]
Definition: gps_furuno.c:35
char msg_buf[NMEA_MAXLEN]
buffer for storing one nmea-line
Definition: gps_nmea.h:45
void nmea_parse_prop_msg(void)
Definition: gps_furuno.c:95
static void nmea_read_until(int *i)
Read until a certain character, placed here for proprietary includes.
Definition: gps_nmea.h:85
void nmea_configure(void)
Configure furuno GPS.
Definition: gps_furuno.c:66
int32_t y
East.
#define TRUE
Definition: std.h:4
static void nmea_parse_perdcrv(void)
Definition: gps_furuno.c:102
Device independent GPS code (interface)
int32_t x
North.
struct EcefCoor_i ecef_pos
position in ECEF in cm
Definition: gps.h:68
bool_t is_configured
flag set to TRUE if configuration is finished
Definition: gps_nmea.h:42
#define GPS_FURUNO_SETTINGS_NB
Definition: gps_furuno.c:34
NMEA protocol specific code.
void nmea_parse_prop_init(void)
Definition: gps_furuno.c:89
struct adc_buf * buf
Definition: adc_arch.c:587
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:225
int msg_len
Definition: gps_nmea.h:46
struct EcefCoor_i ecef_vel
speed ECEF in cm/s
Definition: gps.h:72
struct NedCoor_i ned_vel
speed NED in cm/s
Definition: gps.h:73
struct GpsState gps
global GPS state
Definition: gps.c:41
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