gps
This commit is contained in:
parent
553c35a154
commit
961950dbcc
|
@ -1,7 +1,6 @@
|
|||
#define ts_show_hip9011 false
|
||||
#define ts_show_cj125 false
|
||||
|
||||
#define ts_show_gps false
|
||||
#define ts_show_software_knock true
|
||||
|
||||
#define show_test_presets true
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#define ts_show_hip9011 false
|
||||
#define ts_show_cj125 false
|
||||
|
||||
#define ts_show_gps false
|
||||
#define ts_show_software_knock true
|
||||
|
||||
#define show_test_presets true
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#define ts_show_hip9011 false
|
||||
#define ts_show_cj125 false
|
||||
|
||||
#define ts_show_gps false
|
||||
#define ts_show_software_knock true
|
||||
|
||||
#define show_test_presets true
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#define ts_show_hip9011 false
|
||||
#define ts_show_cj125 false
|
||||
|
||||
#define ts_show_gps false
|
||||
#define ts_show_software_knock true
|
||||
|
||||
#define show_test_presets true
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#define ts_show_hip9011 false
|
||||
#define ts_show_cj125 false
|
||||
|
||||
#define ts_show_gps false
|
||||
#define ts_show_software_knock true
|
||||
|
||||
#define show_test_presets true
|
||||
|
|
|
@ -87,9 +87,6 @@ void setBoardDefaultConfiguration() {
|
|||
engineConfiguration->hip9011SpiDevice = SPI_DEVICE_2;
|
||||
engineConfiguration->cj125SpiDevice = SPI_DEVICE_2;
|
||||
|
||||
// engineConfiguration->gps_rx_pin = Gpio::B7;
|
||||
// engineConfiguration->gps_tx_pin = Gpio::B6;
|
||||
|
||||
engineConfiguration->triggerSimulatorPins[0] = Gpio::D1;
|
||||
engineConfiguration->triggerSimulatorPins[1] = Gpio::D2;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
|
||||
#define ts_show_egt false
|
||||
#define ts_show_gps false
|
||||
#define ts_show_etb_pins false
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi true
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
|
||||
#define ts_show_egt false
|
||||
#define ts_show_gps false
|
||||
#define ts_show_etb_pins false
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi true
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
|
||||
#define ts_show_egt false
|
||||
#define ts_show_gps false
|
||||
#define ts_show_etb_pins false
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi true
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
|
||||
#define ts_show_egt false
|
||||
#define ts_show_gps false
|
||||
#define ts_show_etb_pins false
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi true
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
|
||||
#define ts_show_egt false
|
||||
#define ts_show_gps false
|
||||
#define ts_show_etb_pins false
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi true
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
|
||||
#define ts_show_egt false
|
||||
#define ts_show_gps false
|
||||
#define ts_show_etb_pins false
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi true
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
|
||||
#define ts_show_egt false
|
||||
#define ts_show_gps false
|
||||
#define ts_show_etb_pins false
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi true
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
|
||||
#define ts_show_egt false
|
||||
#define ts_show_gps false
|
||||
#define ts_show_etb_pins false
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi true
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
|
||||
#define ts_show_egt false
|
||||
#define ts_show_gps false
|
||||
#define ts_show_etb_pins false
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi true
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
|
||||
#define ts_show_egt false
|
||||
#define ts_show_gps false
|
||||
#define ts_show_etb_pins false
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi true
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
|
||||
#define ts_show_egt false
|
||||
#define ts_show_gps false
|
||||
#define ts_show_etb_pins false
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi true
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
|
||||
#define ts_show_egt false
|
||||
#define ts_show_gps false
|
||||
#define ts_show_etb_pins false
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi true
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
|
||||
#define ts_show_egt false
|
||||
#define ts_show_gps false
|
||||
#define ts_show_etb_pins false
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi true
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
|
||||
#define ts_show_egt false
|
||||
#define ts_show_gps false
|
||||
#define ts_show_etb_pins false
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi true
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
|
||||
#define ts_show_egt false
|
||||
#define ts_show_gps false
|
||||
#define ts_show_etb_pins false
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi true
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
|
||||
#define ts_show_egt false
|
||||
#define ts_show_gps false
|
||||
#define ts_show_etb_pins false
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi true
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
|
||||
#define ts_show_egt false
|
||||
#define ts_show_gps false
|
||||
#define ts_show_etb_pins false
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi true
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
! https://rusefi.com/forum/viewtopic.php?p=43270#p43270
|
||||
#define ts_show_egt true
|
||||
|
||||
#define ts_show_gps false
|
||||
#define ts_show_etb_pins false
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi true
|
||||
|
|
|
@ -27,9 +27,6 @@
|
|||
|
||||
#define TS_PRIMARY_UxART_PORT UARTD4
|
||||
|
||||
#undef EFI_UART_GPS
|
||||
#define EFI_UART_GPS FALSE
|
||||
|
||||
#undef EFI_BLUETOOTH_SETUP
|
||||
#define EFI_BLUETOOTH_SETUP TRUE
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#define ts_show_cj125 false
|
||||
#define ts_show_full_pinout false
|
||||
#define ts_show_egt false
|
||||
#define ts_show_gps false
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi false
|
||||
#define ts_show_sd_card true
|
||||
|
|
|
@ -73,9 +73,6 @@
|
|||
|
||||
#define ADC_CHANNEL_VREF ADC_CHANNEL_IN14
|
||||
|
||||
#undef EFI_UART_GPS
|
||||
#define EFI_UART_GPS FALSE
|
||||
|
||||
#undef EFI_BLUETOOTH_SETUP
|
||||
#define EFI_BLUETOOTH_SETUP FALSE
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#define ts_show_hip9011 true
|
||||
#define ts_show_cj125 false
|
||||
#define ts_show_egt false
|
||||
#define ts_show_gps false
|
||||
#define ts_show_etb_pins true
|
||||
#define ts_show_analog_divider false
|
||||
#define ts_show_spi true
|
||||
|
|
|
@ -314,11 +314,6 @@
|
|||
#define DL_OUTPUT_BUFFER 8000
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Do we need GPS logic?
|
||||
*/
|
||||
#define EFI_UART_GPS FALSE
|
||||
|
||||
#define EFI_ELECTRONIC_THROTTLE_BODY TRUE
|
||||
//#define EFI_ELECTRONIC_THROTTLE_BODY FALSE
|
||||
|
||||
|
@ -408,11 +403,6 @@
|
|||
#define LED_ERROR_BRAIN_PIN_MODE DEFAULT_OUTPUT
|
||||
#endif
|
||||
|
||||
// USART1 -> check defined STM32_SERIAL_USE_USART1
|
||||
// For GPS we have USART1. We can start with PB7 USART1_RX and PB6 USART1_TX
|
||||
#define GPS_SERIAL_DEVICE &SD1
|
||||
#define GPS_SERIAL_SPEED 38400
|
||||
|
||||
#ifndef CONFIG_RESET_SWITCH_PORT
|
||||
// looks like this feature is not extremely popular, we can try living without it now :)
|
||||
//#define CONFIG_RESET_SWITCH_PORT GPIOD
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#undef EFI_POTENTIOMETER
|
||||
#define EFI_POTENTIOMETER FALSE
|
||||
|
||||
#undef EFI_MAX_31855
|
||||
#define EFI_MAX_31855 FALSE
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ CONTROLLERS_ALGO_SRC_CPP = $(PROJECT_DIR)/controllers/algo/advance_map.cpp \
|
|||
$(PROJECT_DIR)/controllers/algo/fuel/fuel_computer.cpp \
|
||||
$(PROJECT_DIR)/controllers/algo/fuel/injector_model.cpp \
|
||||
$(PROJECT_DIR)/controllers/algo/fuel/dfco.cpp \
|
||||
$(PROJECT_DIR)/controllers/algo/nmea.cpp \
|
||||
$(PROJECT_DIR)/controllers/algo/odometer.cpp \
|
||||
$(PROJECT_DIR)/controllers/algo/defaults/default_base_engine.cpp \
|
||||
$(PROJECT_DIR)/controllers/algo/defaults/default_cranking.cpp \
|
||||
|
|
|
@ -579,9 +579,6 @@ static void setDefaultEngineConfiguration() {
|
|||
// todo: start using this for custom MAP
|
||||
engineConfiguration->mapHighValueVoltage = 5;
|
||||
|
||||
engineConfiguration->HD44780width = 20;
|
||||
engineConfiguration->HD44780height = 4;
|
||||
|
||||
engineConfiguration->cylinderBore = 87.5;
|
||||
|
||||
setBoschHDEV_5_injectors();
|
||||
|
|
|
@ -1,311 +0,0 @@
|
|||
/**
|
||||
* @date Dec 20, 2013
|
||||
*
|
||||
* @author Andrey Belomutskiy, (c) 2012-2020
|
||||
* @author Kot_dnz
|
||||
*
|
||||
* This file is part of rusEfi - see http://rusefi.com
|
||||
*
|
||||
* rusEfi 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 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* rusEfi 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 this program.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* see #testGpsParser
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "nmea.h"
|
||||
#include "rtc_helper.h"
|
||||
|
||||
static long hex2int(const char * a, const int len) {
|
||||
int i;
|
||||
long val = 0;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
if (a[i] <= 57)
|
||||
val += (a[i] - 48) * (1 << (4 * (len - 1 - i))); // it's decimal number
|
||||
else
|
||||
val += (a[i] - 87) * (1 << (4 * (len - 1 - i))); // it's a-f -> work only with low case hex
|
||||
return val;
|
||||
}
|
||||
|
||||
static float gps_deg_dec(float deg_point) {
|
||||
float ddeg;
|
||||
float sec = modff(deg_point, &ddeg) * 60;
|
||||
int deg = (int) (ddeg / 100);
|
||||
int min = (int) (deg_point - (deg * 100));
|
||||
|
||||
float absdlat = round(deg * 1000000.);
|
||||
float absmlat = round(min * 1000000.);
|
||||
float absslat = round(sec * 1000000.);
|
||||
|
||||
return round(absdlat + (absmlat / 60) + (absslat / 3600)) / 1000000;
|
||||
}
|
||||
|
||||
// Convert lat e lon to decimals (from deg)
|
||||
static void gps_convert_deg_to_dec(float *latitude, char ns, float *longitude, char we) {
|
||||
float lat = (ns == 'N') ? *latitude : -1 * (*latitude);
|
||||
float lon = (we == 'E') ? *longitude : -1 * (*longitude);
|
||||
|
||||
*latitude = gps_deg_dec(lat);
|
||||
*longitude = gps_deg_dec(lon);
|
||||
}
|
||||
|
||||
// in string collect all char till comma and convert to float
|
||||
static int str_till_comma(const char * const a, char * const dStr) {
|
||||
|
||||
int i = 0, sLen = strlen(a);
|
||||
if (sLen > GPS_MAX_STRING)
|
||||
sLen = GPS_MAX_STRING;
|
||||
|
||||
while (a[i] != 44 && i < sLen) { // while not comma or end
|
||||
dStr[i] = a[i];
|
||||
i++;
|
||||
}
|
||||
dStr[i] = '\0';
|
||||
return i;
|
||||
}
|
||||
|
||||
/*
|
||||
GxGGA - name code
|
||||
Parameter Value Unit Description
|
||||
UTC hhmmss.sss Universal time coordinated
|
||||
Lat ddmm.mmmm Latitude
|
||||
Northing Indicator N=North, S=South
|
||||
Lon dddmm.mmmm Longitude
|
||||
Easting Indicator E=East, W=West
|
||||
Status 0 0=Invalid, 1=2D/3D, 2=DGPS, 6=Dead Reckoning
|
||||
SVs Used 00 Number of SVs used for Navigation
|
||||
HDOP 99.99 Horizontal Dilution of Precision
|
||||
Alt (MSL) m Altitude (above means sea level)
|
||||
Unit M=Meters
|
||||
Geoid Sep. m Geoid Separation = Alt(HAE) - Alt(MSL)
|
||||
Unit M=Meters
|
||||
Age of DGPS Corr s Age of Differential Corrections
|
||||
DGPS Ref Station ID of DGPS Reference Station
|
||||
*/
|
||||
void nmea_parse_gpgga(char const * const nmea, loc_t *loc) {
|
||||
char const * p = (char *)nmea;
|
||||
char dStr[GPS_MAX_STRING];
|
||||
|
||||
p = strchr(p, ',') + 1; //skip time - we read date&time if Valid in GxRMC
|
||||
|
||||
p = strchr(p, ',') + 1; // in p string started with searching address
|
||||
str_till_comma(p, dStr); // str to float till comma saved modified string
|
||||
if (strlen(p) == 0) {
|
||||
return; // if no data in field - empty data - we return
|
||||
}
|
||||
|
||||
loc->latitude = atoff(dStr); // fulfil data
|
||||
|
||||
p = strchr(p, ',') + 1; // see above
|
||||
switch (p[0]) {
|
||||
case 'N':
|
||||
loc->lat = 'N';
|
||||
break;
|
||||
case 'S':
|
||||
loc->lat = 'S';
|
||||
break;
|
||||
case ',':
|
||||
loc->lat = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
p = strchr(p, ',') + 1;
|
||||
str_till_comma(p, dStr); // str to float till comma saved modified string
|
||||
loc->longitude = atoff(dStr);
|
||||
|
||||
p = strchr(p, ',') + 1;
|
||||
switch (p[0]) {
|
||||
case 'W':
|
||||
loc->lon = 'W';
|
||||
break;
|
||||
case 'E':
|
||||
loc->lon = 'E';
|
||||
break;
|
||||
case ',':
|
||||
loc->lon = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
p = strchr(p, ',') + 1;
|
||||
str_till_comma(p, dStr); // str to float till comma saved modified string
|
||||
loc->quality = atoi(dStr);
|
||||
|
||||
p = strchr(p, ',') + 1;
|
||||
str_till_comma(p, dStr); // str to float till comma saved modified string
|
||||
loc->satellites = atoi(dStr);
|
||||
|
||||
p = strchr(p, ',') + 1;
|
||||
|
||||
p = strchr(p, ',') + 1;
|
||||
str_till_comma(p, dStr); // str to float till comma saved modified string
|
||||
loc->altitude = atoff(dStr);
|
||||
}
|
||||
|
||||
/*
|
||||
GxRMC - nmea code
|
||||
Parameter Value Unit Description
|
||||
UTC hhmmss.sss Universal time coordinated
|
||||
Status V A=Valid, V=Invalid
|
||||
Lat ddmm.mmmm Latitude
|
||||
Northing Indicator N=North, S=South
|
||||
Lon dddmm.mmmm Longitude
|
||||
Easting Indicator E=East, W=West
|
||||
SOG nots Speed Over Ground
|
||||
COG (true) ° Course Over Ground (true)
|
||||
Date ddmmyy Universal time coordinated
|
||||
Magnetic Variation ° Magnetic Variation
|
||||
Magnetic Variation E=East,W=West
|
||||
Mode Indicator N A=Autonomous, D=Differential, E=Dead Reckoning, N=None
|
||||
Navigational Status S=Safe C=Caution U=Unsafe V=Not valid
|
||||
*/
|
||||
|
||||
void nmea_parse_gprmc(char const * const nmea, loc_t *loc) {
|
||||
char const * p = (char *)nmea;
|
||||
char dStr[GPS_MAX_STRING];
|
||||
efidatetime_t dt;
|
||||
|
||||
p = strchr(p, ',') + 1; // read time
|
||||
str_till_comma(p, dStr);
|
||||
if (strlen(dStr) > 5) {
|
||||
dt.hour = str2int(dStr, 2);
|
||||
dt.minute = str2int(dStr + 2, 2);
|
||||
dt.second = str2int(dStr + 4, 2);
|
||||
}
|
||||
|
||||
p = strchr(p, ',') + 1; // read field Valid status
|
||||
str_till_comma(p, dStr);
|
||||
|
||||
if (dStr[0] == 'V') { // if field is invalid
|
||||
loc->quality = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
loc->quality = 4; // this is declaration that last receive field VALID
|
||||
|
||||
p = strchr(p, ',') + 1; // latitude
|
||||
str_till_comma(p, dStr); // str to float till comma saved modified string
|
||||
loc->latitude = atoff(dStr);
|
||||
|
||||
p = strchr(p, ',') + 1;
|
||||
switch (p[0]) {
|
||||
case 'N':
|
||||
loc->lat = 'N';
|
||||
break;
|
||||
case 'S':
|
||||
loc->lat = 'S';
|
||||
break;
|
||||
case ',':
|
||||
loc->lat = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
p = strchr(p, ',') + 1; // longitude
|
||||
str_till_comma(p, dStr); // str to float till comma saved modified string
|
||||
loc->longitude = atoff(dStr);
|
||||
|
||||
p = strchr(p, ',') + 1;
|
||||
switch (p[0]) {
|
||||
case 'W':
|
||||
loc->lon = 'W';
|
||||
break;
|
||||
case 'E':
|
||||
loc->lon = 'E';
|
||||
break;
|
||||
case ',':
|
||||
loc->lon = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
p = strchr(p, ',') + 1;
|
||||
str_till_comma(p, dStr); // str to float till comma saved modified string
|
||||
loc->speed = atoff(dStr);
|
||||
|
||||
p = strchr(p, ',') + 1;
|
||||
str_till_comma(p, dStr); // str to float till comma saved modified string
|
||||
loc->course = atoff(dStr);
|
||||
|
||||
p = strchr(p, ',') + 1; // read date
|
||||
str_till_comma(p, dStr);
|
||||
if (strlen(dStr) > 5) {
|
||||
dt.day = str2int(dStr, 2);
|
||||
dt.month = str2int(dStr + 2, 2);
|
||||
dt.year = 100 + // we receive -200, but standard wait -1900 = add correction
|
||||
str2int(dStr + 4, 2);
|
||||
}
|
||||
|
||||
if (dt.year > 0 ) { // check if date field is valid
|
||||
memcpy(&loc->time, &dt, sizeof(dt));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message type (GPGGA, GPRMC, etc..)
|
||||
*
|
||||
* This function filters out also wrong packages (invalid checksum)
|
||||
*
|
||||
* @param message The NMEA message
|
||||
* @return The type of message if it is valid
|
||||
*/
|
||||
nmea_message_type nmea_get_message_type(const char *message) {
|
||||
int checksum = nmea_valid_checksum(message);
|
||||
if (checksum != _EMPTY) {
|
||||
return static_cast<nmea_message_type>(checksum);
|
||||
}
|
||||
|
||||
if (strstr(message, NMEA_GPGGA_STR) != NULL) {
|
||||
return NMEA_GPGGA;
|
||||
}
|
||||
|
||||
if (strstr(message, NMEA_GPRMC_STR) != NULL) {
|
||||
return NMEA_GPRMC;
|
||||
}
|
||||
|
||||
return NMEA_UNKNOWN;
|
||||
}
|
||||
|
||||
int nmea_valid_checksum(char const * message) {
|
||||
char p;
|
||||
int sum = 0;
|
||||
const char* starPtr = strrchr(message, '*');
|
||||
if (!starPtr) {
|
||||
return NMEA_CHECKSUM_ERR;
|
||||
}
|
||||
const char* int_message = starPtr + 1;
|
||||
long checksum = hex2int(int_message, 2);
|
||||
|
||||
++message;
|
||||
while ((p = *message++) != '*') {
|
||||
sum ^= p;
|
||||
}
|
||||
|
||||
if (sum != checksum) {
|
||||
return NMEA_CHECKSUM_ERR;
|
||||
}
|
||||
return _EMPTY;
|
||||
}
|
||||
|
||||
// Compute the GPS location using decimal scale
|
||||
void gps_location(loc_t *coord, char const * const buffer) {
|
||||
coord->type = nmea_get_message_type(buffer);
|
||||
|
||||
switch (coord->type) {
|
||||
case NMEA_GPGGA:
|
||||
nmea_parse_gpgga(buffer, coord);
|
||||
gps_convert_deg_to_dec(&(coord->latitude), coord->lat, &(coord->longitude), coord->lon);
|
||||
break;
|
||||
case NMEA_GPRMC:
|
||||
nmea_parse_gprmc(buffer, coord);
|
||||
break;
|
||||
case NMEA_UNKNOWN:
|
||||
// unknown message type
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* https://github.com/wdalmut/libgps/tree/develop/src
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "rusefi_types.h"
|
||||
|
||||
#define GPS_MAX_STRING 256
|
||||
|
||||
typedef enum {
|
||||
NMEA_UNKNOWN = 0x00,
|
||||
NMEA_GPRMC = 0x01,
|
||||
NMEA_GPGGA = 0x02
|
||||
} nmea_message_type;
|
||||
|
||||
#define _EMPTY 0x00
|
||||
#define NMEA_GPRMC_STR "$GPRMC"
|
||||
#define NMEA_GPGGA_STR "$GPGGA"
|
||||
#define _COMPLETED 0x03
|
||||
|
||||
#define NMEA_CHECKSUM_ERR 0x80
|
||||
#define NMEA_MESSAGE_ERR 0xC0
|
||||
|
||||
struct GPSlocation {
|
||||
float latitude;
|
||||
float longitude;
|
||||
float speed;
|
||||
float altitude;
|
||||
float course;
|
||||
efidatetime_t time;
|
||||
nmea_message_type type;
|
||||
int quality;
|
||||
int satellites;
|
||||
char lat; // Northing Indicator N=North, S=South
|
||||
char lon; // Easting Indicator E=East, W=West
|
||||
};
|
||||
typedef struct GPSlocation loc_t;
|
||||
|
||||
nmea_message_type nmea_get_message_type(const char *);
|
||||
int nmea_valid_checksum(const char *);
|
||||
void nmea_parse_gpgga(char const * const, loc_t *);
|
||||
void nmea_parse_gprmc(char const * const, loc_t *);
|
||||
void gps_location(loc_t *, char const * const);
|
||||
|
||||
static int str2int(const char * a, const int len) {
|
||||
int i = 0, k = 0;
|
||||
while (i < len) {
|
||||
k = (k << 3) + (k << 1) + (*a) - '0';
|
||||
a++;
|
||||
i++;
|
||||
}
|
||||
return k;
|
||||
}
|
|
@ -39,7 +39,6 @@
|
|||
#include "mcp3208.h"
|
||||
#include "hip9011.h"
|
||||
#include "histogram.h"
|
||||
#include "gps_uart.h"
|
||||
#include "sent.h"
|
||||
#include "cdm_ion_sense.h"
|
||||
#include "trigger_central.h"
|
||||
|
@ -554,10 +553,6 @@ void initHardware() {
|
|||
initBoschYawRateSensor();
|
||||
#endif /* EFI_BOSCH_YAW */
|
||||
|
||||
#if EFI_UART_GPS
|
||||
initGps();
|
||||
#endif
|
||||
|
||||
#if EFI_AUX_SERIAL
|
||||
initAuxSerial();
|
||||
#endif /* EFI_AUX_SERIAL */
|
||||
|
|
|
@ -1,118 +0,0 @@
|
|||
/**
|
||||
* @file gps_uart.cpp
|
||||
* @brief GPS receiver hardware UART driver
|
||||
*
|
||||
* Tested and developed for NEO-6M
|
||||
* http://www.u-blox.com/en/gps-modules/pvt-modules/previous-generations/neo-6-family.html
|
||||
* Technically any UART GPS should work with this driver since NMEA protocol is pretty common anyway
|
||||
*
|
||||
* @date Dec 28, 2013
|
||||
* @author Andrey Belomutskiy, (c) 2012-2020
|
||||
* Kot_dnz 2014
|
||||
*/
|
||||
|
||||
#if EFI_UART_GPS
|
||||
#include "pch.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "rusefi_types.h"
|
||||
#include "console_io.h"
|
||||
#include "eficonsole.h"
|
||||
#include "nmea.h"
|
||||
#include "gps_uart.h"
|
||||
#include "rtc_helper.h"
|
||||
|
||||
static SerialConfig GPSserialConfig = { GPS_SERIAL_SPEED, 0, USART_CR2_STOP1_BITS | USART_CR2_LINEN, 0 };
|
||||
static THD_WORKING_AREA(gpsThreadStack, UTILITY_THREAD_STACK_SIZE);
|
||||
|
||||
// this field holds our current state
|
||||
static loc_t GPSdata;
|
||||
static efidatetime_t lastDateTime;
|
||||
|
||||
static int gpsMessageCount = 0;
|
||||
static int uartErrors = 0;
|
||||
|
||||
// TODO: some data structure for coordinates location
|
||||
|
||||
float getCurrentSpeed(void) {
|
||||
// TODO: ???
|
||||
return GPSdata.speed;
|
||||
}
|
||||
|
||||
static void printGpsInfo() {
|
||||
efiPrintf("GPS RX %s", hwPortname(engineConfiguration->gps_rx_pin));
|
||||
efiPrintf("GPS TX %s", hwPortname(engineConfiguration->gps_tx_pin));
|
||||
|
||||
efiPrintf("m=%d,e=%d: vehicle speed = %.2f", gpsMessageCount, uartErrors, getCurrentSpeed());
|
||||
|
||||
float sec = getTimeNowMs() / 1000.0;
|
||||
efiPrintf("communication speed: %.2f", gpsMessageCount / sec);
|
||||
|
||||
efiPrintf("GPS latitude = %.2f\r\n", GPSdata.latitude);
|
||||
efiPrintf("GPS longitude = %.2f\r\n", GPSdata.longitude);
|
||||
}
|
||||
|
||||
static void onGpsMessage(const char * const buffer) {
|
||||
gps_location(&GPSdata, buffer);
|
||||
|
||||
if (GPSdata.quality == 4 && GPSdata.time.year > 0) {
|
||||
getRtcDateTime(&lastDateTime);
|
||||
if (GPSdata.time.second != dateTime.second) {
|
||||
// quality =4 (valid GxRMC), year > 0, and difference more than second
|
||||
setRtcDateTime(GPSdata.time);
|
||||
}
|
||||
}
|
||||
|
||||
gpsMessageCount++;
|
||||
}
|
||||
|
||||
// we do not want this on stack, right?
|
||||
static char gps_str[GPS_MAX_STRING];
|
||||
|
||||
static THD_FUNCTION(GpsThreadEntryPoint, arg) {
|
||||
(void) arg;
|
||||
chRegSetThreadName("GPS thread");
|
||||
|
||||
int count = 0;
|
||||
|
||||
while (true) {
|
||||
msg_t charbuf = streamGet(GPS_SERIAL_DEVICE);
|
||||
if (charbuf == 10 || count == GPS_MAX_STRING) { // if 0xD,0xA or limit
|
||||
if (count >= 1)
|
||||
gps_str[--count] = '\0'; // delete 0xD
|
||||
|
||||
// scheduleMsg(&logger, "got GPS [%s]", gps_str);
|
||||
|
||||
// 'gps_str' string completed
|
||||
onGpsMessage(gps_str);
|
||||
memset(&gps_str, '\0', GPS_MAX_STRING); // clear buffer
|
||||
count = 0;
|
||||
} else {
|
||||
gps_str[count++] = charbuf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool isGpsEnabled() {
|
||||
return (isBrainPinValid(engineConfiguration->gps_rx_pin) &&
|
||||
isBrainPinValid(engineConfiguration->gps_tx_pin));
|
||||
}
|
||||
|
||||
void initGps(void) {
|
||||
if (!isGpsEnabled())
|
||||
return;
|
||||
|
||||
|
||||
sdStart(GPS_SERIAL_DEVICE, &GPSserialConfig);
|
||||
// GPS we have USART1: PB7 -> USART1_RX and PB6 -> USART1_TX
|
||||
efiSetPadMode("GPS tx", engineConfiguration->gps_tx_pin, PAL_MODE_ALTERNATE(7));
|
||||
efiSetPadMode("GPS rx", engineConfiguration->gps_rx_pin, PAL_MODE_ALTERNATE(7));
|
||||
|
||||
// todo: add a thread which would save location. If the GPS 5Hz - we should save the location each 200 ms
|
||||
chThdCreateStatic(gpsThreadStack, sizeof(gpsThreadStack), LOWPRIO, (tfunc_t)(void*) GpsThreadEntryPoint, NULL);
|
||||
|
||||
addConsoleAction("gpsinfo", &printGpsInfo);
|
||||
}
|
||||
|
||||
#endif // EFI_UART_GPS
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* @file gps_uart.h
|
||||
*
|
||||
*
|
||||
* @date Dec 30, 2013
|
||||
* @author Kot_dnz
|
||||
* @author Andrey Belomutskiy, (c) 2012-2020
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void initGps(void);
|
||||
float getCurrentSpeed(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
|
@ -9,4 +9,3 @@ HW_SENSORS_CPP = \
|
|||
$(HW_SENSORS_DIR)/accelerometer.cpp \
|
||||
$(HW_SENSORS_DIR)/lps25.cpp \
|
||||
$(HW_SENSORS_DIR)/max31855.cpp \
|
||||
$(HW_SENSORS_DIR)/gps_uart.cpp
|
||||
|
|
|
@ -2144,7 +2144,6 @@ end_struct
|
|||
#define ts_show_critical_led false
|
||||
#define ts_show_joystick true
|
||||
#define ts_show_egt true
|
||||
#define ts_show_gps true
|
||||
#define ts_show_analog_divider true
|
||||
#define ts_show_spi true
|
||||
#define ts_show_sd_card true
|
||||
|
|
|
@ -2774,8 +2774,6 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_
|
|||
field = "Aux ADC #6", auxAnalogInputs6
|
||||
field = "Aux ADC #7", auxAnalogInputs7
|
||||
field = "Aux ADC #8", auxAnalogInputs8
|
||||
field = "GPS RX", gps_rx_pin @@if_ts_show_gps
|
||||
field = "GPS TX", gps_tx_pin @@if_ts_show_gps
|
||||
field = "CAN RX pin", canRxPin @@if_ts_show_can_pins
|
||||
field = "CAN TX pin", canTxPin @@if_ts_show_can_pins
|
||||
field = "SPI1 MOSI", spi1mosiPin, { spi1mosiPin != 0 || is_enabled_spi_1 == 1} @@if_ts_show_spi
|
||||
|
@ -3588,10 +3586,6 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_
|
|||
field = "SD logger rate", sdCardLogFrequency
|
||||
field = "SD logger mode", sdTriggerLog
|
||||
|
||||
dialog = gpsReceiver, "GPS Receiver"
|
||||
field = "gps RX", gps_rx_pin
|
||||
field = "gps TX", gps_tx_pin
|
||||
|
||||
dialog = tle8888, "TLE8888", yAxis
|
||||
field = "TLE8888 Chip Select", tle8888_cs @@if_ts_show_spi
|
||||
field = "TLE8888 SPI", tle8888spiDevice @@if_ts_show_spi
|
||||
|
@ -3605,8 +3599,6 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_
|
|||
panel = tsPort @@if_ts_show_tunerstudio_port
|
||||
field = "uartConsoleSerialSpeed", uartConsoleSerialSpeed
|
||||
panel = auxSerial
|
||||
panel = gpsReceiver @@if_ts_show_gps
|
||||
|
||||
|
||||
dialog = monitoringSettings, "rusEFI Console Settings"
|
||||
field = "Sensor Sniffer", sensorChartMode
|
||||
|
|
|
@ -112,7 +112,6 @@
|
|||
#define HAL_TRIGGER_USE_ADC FALSE
|
||||
#endif /* HAL_TRIGGER_USE_ADC */
|
||||
|
||||
#define EFI_UART_GPS FALSE
|
||||
#define EFI_HAS_RESET FALSE
|
||||
#define EXTREME_TERM_LOGGING FALSE
|
||||
#define DEBUG_FUEL FALSE
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "malfunction_central.h"
|
||||
#include "cli_registry.h"
|
||||
|
||||
#include "nmea.h"
|
||||
#include "mmc_card.h"
|
||||
#include "fl_stack.h"
|
||||
|
||||
|
@ -248,59 +247,6 @@ static void testEchoFFF(float first, float second, float third) {
|
|||
|
||||
#define UNKNOWN_COMMAND "dfadasdasd"
|
||||
|
||||
static loc_t GPSdata;
|
||||
|
||||
static char nmeaMessage[1000];
|
||||
|
||||
TEST(misc, testGpsParser) {
|
||||
strcpy(nmeaMessage, "");
|
||||
gps_location(&GPSdata, nmeaMessage);
|
||||
|
||||
// we need to pass a mutable string, not a constant because the parser would be modifying the string
|
||||
strcpy(nmeaMessage, "$GPRMC,173843,A,3349.896,N,11808.521,W,000.0,360.0,230108,013.4,E*69");
|
||||
gps_location(&GPSdata, nmeaMessage);
|
||||
ASSERT_EQ( 4, GPSdata.quality) << "1 valid";
|
||||
assertEqualsM("1 latitude", 3349.896, GPSdata.latitude);
|
||||
assertEqualsM("1 longitude", 11808.521, GPSdata.longitude);
|
||||
ASSERT_EQ( 0, GPSdata.speed) << "1 speed";
|
||||
// ASSERT_EQ( 0, GPSdata.altitude) << "1 altitude"; // GPRMC not overwrite altitude
|
||||
ASSERT_EQ( 360, GPSdata.course) << "1 course";
|
||||
|
||||
strcpy(nmeaMessage, "$GPGGA,111609.14,5001.27,N,3613.06,E,3,08,0.0,10.2,M,0.0,M,0.0,0000*70");
|
||||
gps_location(&GPSdata, nmeaMessage);
|
||||
ASSERT_EQ( 3, GPSdata.quality) << "2 valid"; // see field details
|
||||
assertEqualsM("2 latitude", 50.0212, GPSdata.latitude);
|
||||
assertEqualsM("2 longitude", 36.2177, GPSdata.longitude);
|
||||
ASSERT_EQ( 0, GPSdata.speed) << "2 speed";
|
||||
assertEqualsM("2 altitude", 10.2, GPSdata.altitude);
|
||||
// ASSERT_EQ( 0, GPSdata.course) << "2 course"; // GPGGA not overwrite course
|
||||
|
||||
strcpy(nmeaMessage, "$GPRMC,111609.14,A,5001.27,N,3613.06,E,11.2,0.0,261206,0.0,E*50");
|
||||
gps_location(&GPSdata, nmeaMessage);
|
||||
ASSERT_EQ( 4, GPSdata.quality) << "3 valid";
|
||||
assertEqualsM("3 latitude", 5001.27, GPSdata.latitude);
|
||||
assertEqualsM("3 longitude", 3613.06, GPSdata.longitude);
|
||||
assertEqualsM("3 speed", 11.2, GPSdata.speed);
|
||||
// ASSERT_EQ( 0, GPSdata.altitude) << "3 altitude"; // GPRMC not overwrite altitude
|
||||
ASSERT_EQ( 0, GPSdata.course) << "3 course";
|
||||
ASSERT_EQ( 2006, GPSdata.time.year + 1900) << "3 GPS yy";
|
||||
ASSERT_EQ( 12, GPSdata.time.month) << "3 GPS mm";
|
||||
ASSERT_EQ( 26, GPSdata.time.day) << "3 GPS dd";
|
||||
ASSERT_EQ( 11, GPSdata.time.hour) << "3 GPS hh";
|
||||
ASSERT_EQ( 16, GPSdata.time.minute) << "3 GPS mm";
|
||||
ASSERT_EQ( 9, GPSdata.time.second) << "3 GPS ss";
|
||||
|
||||
// check again first one
|
||||
// we need to pass a mutable string, not a constant because the parser would be modifying the string
|
||||
strcpy(nmeaMessage, "$GPRMC,173843,A,3349.896,N,11808.521,W,000.0,360.0,230108,013.4,E*69");
|
||||
gps_location(&GPSdata, nmeaMessage);
|
||||
ASSERT_EQ( 4, GPSdata.quality) << "4 valid";
|
||||
assertEqualsM("4 latitude", 3349.896, GPSdata.latitude);
|
||||
assertEqualsM("4 longitude", 11808.521, GPSdata.longitude);
|
||||
ASSERT_EQ( 0, GPSdata.speed) << "4 speed";
|
||||
ASSERT_EQ( 360, GPSdata.course) << "4 course";
|
||||
}
|
||||
|
||||
// this buffer is needed because on Unix you would not be able to change static char constants
|
||||
static char buffer[300];
|
||||
|
||||
|
@ -376,8 +322,6 @@ TEST(misc, testConsoleLogic) {
|
|||
ASSERT_EQ(1.0, fFirst);
|
||||
ASSERT_EQ(2.0, fSecond);
|
||||
ASSERT_EQ(3.0, fThird);
|
||||
|
||||
//addConsoleActionSSS("GPS", testGpsParser);
|
||||
}
|
||||
|
||||
TEST(misc, testFLStack) {
|
||||
|
|
Loading…
Reference in New Issue