Fix for problems with reboots by using GPS modul
This commit is contained in:
parent
8b49db33f2
commit
e269034073
|
@ -0,0 +1,54 @@
|
||||||
|
#pragma once
|
||||||
|
#include "NMEA0183.h"
|
||||||
|
#include "GwNmea0183Msg.h"
|
||||||
|
|
||||||
|
class ObpNmea0183 : public tNMEA0183
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool GetMessageCor(SNMEA0183Msg &NMEA0183Msg)
|
||||||
|
{
|
||||||
|
if (!IsOpen())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
while (port->available() > 0 && !result)
|
||||||
|
{
|
||||||
|
int NewByte = port->read();
|
||||||
|
if (NewByte == '$' || NewByte == '!')
|
||||||
|
{ // Message start
|
||||||
|
MsgInStarted = true;
|
||||||
|
MsgInPos = 0;
|
||||||
|
MsgInBuf[MsgInPos] = NewByte;
|
||||||
|
MsgInPos++;
|
||||||
|
}
|
||||||
|
else if (MsgInStarted)
|
||||||
|
{
|
||||||
|
MsgInBuf[MsgInPos] = NewByte;
|
||||||
|
if (NewByte == '*')
|
||||||
|
MsgCheckSumStartPos = MsgInPos;
|
||||||
|
MsgInPos++;
|
||||||
|
if (MsgCheckSumStartPos != SIZE_MAX and MsgCheckSumStartPos + 3 == MsgInPos)
|
||||||
|
{ // We have full checksum and so full message
|
||||||
|
MsgInBuf[MsgInPos] = 0; // add null termination
|
||||||
|
if (NMEA0183Msg.SetMessageCor(MsgInBuf))
|
||||||
|
{
|
||||||
|
NMEA0183Msg.SourceID = SourceID;
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
MsgInStarted = false;
|
||||||
|
MsgInPos = 0;
|
||||||
|
MsgCheckSumStartPos = SIZE_MAX;
|
||||||
|
}
|
||||||
|
if (MsgInPos >= MAX_NMEA0183_MSG_BUF_LEN)
|
||||||
|
{ // Too may chars in message. Start from beginning
|
||||||
|
MsgInStarted = false;
|
||||||
|
MsgInPos = 0;
|
||||||
|
MsgCheckSumStartPos = SIZE_MAX;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
|
@ -28,8 +28,12 @@
|
||||||
#include "Logo_OBP_400x300_sw.h" // OBP Logo
|
#include "Logo_OBP_400x300_sw.h" // OBP Logo
|
||||||
#include "OBP60QRWiFi.h" // Functions lib for WiFi QR code
|
#include "OBP60QRWiFi.h" // Functions lib for WiFi QR code
|
||||||
|
|
||||||
|
#include "ObpNmea0183.h"
|
||||||
|
#include "GwNmea0183Msg.h"
|
||||||
|
|
||||||
tNMEA0183Msg NMEA0183Msg;
|
tNMEA0183Msg NMEA0183Msg;
|
||||||
tNMEA0183 NMEA0183;
|
ObpNmea0183 NMEA0183; // Fixed Lib for NMEA0183
|
||||||
|
// tNMEA0183 NMEA0183; // Old lib with problems for NMEA0183
|
||||||
|
|
||||||
Adafruit_BME280 bme280; // Evironment sensor BME280
|
Adafruit_BME280 bme280; // Evironment sensor BME280
|
||||||
Adafruit_BMP280 bmp280; // Evironment sensor BMEP280
|
Adafruit_BMP280 bmp280; // Evironment sensor BMEP280
|
||||||
|
@ -520,6 +524,7 @@ void OBP60Task(GwApi *api){
|
||||||
long starttime6 = millis(); // Environment sensor update all 1s
|
long starttime6 = millis(); // Environment sensor update all 1s
|
||||||
|
|
||||||
while (true){
|
while (true){
|
||||||
|
delay(10); // Fixed the problem with NMEA0183 and GPS sentences
|
||||||
Timer1.update(); // Update for Timer1
|
Timer1.update(); // Update for Timer1
|
||||||
Timer2.update(); // Update for Timer2
|
Timer2.update(); // Update for Timer2
|
||||||
if(millis() > starttime0 + 100){
|
if(millis() > starttime0 + 100){
|
||||||
|
|
Loading…
Reference in New Issue