mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-31 03:57:45 +08:00
[gps] Add Furuno NMEA based GPS
This commit is contained in:
@@ -0,0 +1,32 @@
|
|||||||
|
# Hey Emacs, this is a -*- makefile -*-
|
||||||
|
|
||||||
|
# Furuno NMEA GPS unit
|
||||||
|
|
||||||
|
GPS_LED ?= none
|
||||||
|
|
||||||
|
ap.CFLAGS += -DUSE_GPS -DGPS_USE_LATLONG
|
||||||
|
ap.CFLAGS += -DGPS_LINK=$(GPS_PORT)
|
||||||
|
ap.CFLAGS += -DUSE_$(GPS_PORT)
|
||||||
|
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
|
||||||
|
ap.CFLAGS += -DNMEA_PARSE_PROP
|
||||||
|
|
||||||
|
ifneq ($(GPS_LED),none)
|
||||||
|
ap.CFLAGS += -DGPS_LED=$(GPS_LED)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_nmea.h\"
|
||||||
|
ap.srcs += $(SRC_SUBSYSTEMS)/gps/gps_nmea.c $(SRC_SUBSYSTEMS)/gps/gps_furuno.c
|
||||||
|
|
||||||
|
$(TARGET).srcs += $(SRC_SUBSYSTEMS)/gps.c
|
||||||
|
|
||||||
|
sim.CFLAGS += -DUSE_GPS -DGPS_USE_LATLONG
|
||||||
|
sim.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_sim.h\"
|
||||||
|
sim.srcs += $(SRC_SUBSYSTEMS)/gps/gps_sim.c
|
||||||
|
|
||||||
|
jsbsim.CFLAGS += -DUSE_GPS -DGPS_TYPE_H=\"subsystems/gps/gps_sim.h\"
|
||||||
|
jsbsim.srcs += $(SRC_SUBSYSTEMS)/gps/gps_sim.c
|
||||||
|
|
||||||
|
nps.CFLAGS += -DUSE_GPS -DGPS_USE_LATLONG
|
||||||
|
nps.srcs += $(SRC_SUBSYSTEMS)/gps.c
|
||||||
|
nps.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_sim_nps.h\"
|
||||||
|
nps.srcs += $(SRC_SUBSYSTEMS)/gps/gps_sim_nps.c
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Hey Emacs, this is a -*- makefile -*-
|
||||||
|
|
||||||
|
# Furuno NMEA GPS unit
|
||||||
|
|
||||||
|
|
||||||
|
ap.CFLAGS += -DUSE_GPS
|
||||||
|
ap.CFLAGS += -DGPS_LINK=$(GPS_PORT)
|
||||||
|
ap.CFLAGS += -DUSE_$(GPS_PORT)
|
||||||
|
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
|
||||||
|
ap.CFLAGS += -DNMEA_PARSE_PROP
|
||||||
|
|
||||||
|
ifneq ($(GPS_LED),none)
|
||||||
|
ap.CFLAGS += -DGPS_LED=$(GPS_LED)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_nmea.h\"
|
||||||
|
ap.srcs += $(SRC_SUBSYSTEMS)/gps/gps_nmea.c $(SRC_SUBSYSTEMS)/gps/gps_furuno.c
|
||||||
|
|
||||||
|
$(TARGET).srcs += $(SRC_SUBSYSTEMS)/gps.c
|
||||||
|
|
||||||
|
nps.CFLAGS += -DUSE_GPS
|
||||||
|
nps.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_sim.h\"
|
||||||
|
nps.srcs += $(SRC_SUBSYSTEMS)/gps/gps_sim_nps.c
|
||||||
|
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
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 (GpsLink(CheckFreeSpace(len + 6))) {
|
||||||
|
for (j = 0; j < len + 6; j++) {
|
||||||
|
GpsLink(Transmit(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);
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2004-2011 The Paparazzi Team
|
* Copyright (C) 2004-2011 The Paparazzi Team
|
||||||
|
* 2014 Freek van Tienen <freek.v.tienen@gmail.com>
|
||||||
*
|
*
|
||||||
* This file is part of paparazzi.
|
* This file is part of paparazzi.
|
||||||
*
|
*
|
||||||
@@ -31,11 +32,7 @@
|
|||||||
|
|
||||||
#include "mcu_periph/uart.h"
|
#include "mcu_periph/uart.h"
|
||||||
|
|
||||||
#define GPS_NB_CHANNELS 16
|
#ifndef DEBUG_NMEA
|
||||||
|
|
||||||
#ifdef DEBUG_NMEA
|
|
||||||
#define NMEA_PRINT(...) { UsbSPrintString( __VA_ARGS__);};
|
|
||||||
#else
|
|
||||||
#define NMEA_PRINT(...) {};
|
#define NMEA_PRINT(...) {};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -62,6 +59,7 @@ extern struct GpsNmea gps_nmea;
|
|||||||
#define GpsBuffer() GpsLink(ChAvailable())
|
#define GpsBuffer() GpsLink(ChAvailable())
|
||||||
|
|
||||||
#define GpsEvent(_sol_available_callback) { \
|
#define GpsEvent(_sol_available_callback) { \
|
||||||
|
nmea_parse_prop_init(); \
|
||||||
if (GpsBuffer()) { \
|
if (GpsBuffer()) { \
|
||||||
ReadGpsBuffer(); \
|
ReadGpsBuffer(); \
|
||||||
} \
|
} \
|
||||||
@@ -80,19 +78,27 @@ extern struct GpsNmea gps_nmea;
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ReadGpsBuffer() { \
|
#define ReadGpsBuffer() { \
|
||||||
while (GpsLink(ChAvailable())&&!gps_nmea.msg_available) \
|
while (GpsLink(ChAvailable())&&!gps_nmea.msg_available) \
|
||||||
nmea_parse_char(GpsLink(Getch())); \
|
nmea_parse_char(GpsLink(Getch())); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** The function to be called when a characted friom the device is available */
|
/** The function to be called when a characted friom the device is available */
|
||||||
extern void nmea_parse_char(uint8_t c);
|
extern void nmea_parse_char(uint8_t c);
|
||||||
|
|
||||||
extern void nmea_parse_msg(void);
|
extern void nmea_parse_msg(void);
|
||||||
|
extern uint8_t nmea_calc_crc(const char *buff, int buff_sz);
|
||||||
|
void nmea_parse_prop_init(void);
|
||||||
|
void nmea_parse_prop_msg(void);
|
||||||
|
|
||||||
|
/** Read until a certain character, placed here for proprietary includes */
|
||||||
#define gps_nmea_Reset(_val) { }
|
static inline void nmea_read_until(int *i)
|
||||||
|
{
|
||||||
|
while (gps_nmea.msg_buf[*i++] != ',') {
|
||||||
|
if (*i >= gps_nmea.msg_len) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* GPS_NMEA_H */
|
#endif /* GPS_NMEA_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user