forked from JanuszBedkowski/mandeye_controller
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgnss.h
More file actions
68 lines (52 loc) · 1.74 KB
/
gnss.h
File metadata and controls
68 lines (52 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#pragma once
#include <deque>
#include <json.hpp>
#include <mutex>
#include <SerialPort.h>
#include <SerialStream.h>
#include "thread"
#include "utils/TimeStampReceiver.h"
#include "minmea.h"
#include <atomic>
namespace mandeye
{
class GNSSClient : public mandeye_utils::TimeStampReceiver
{
public:
nlohmann::json produceStatus();
//! Spins up a thread that reads from the serial port
bool startListener(const std::string& portName, LibSerial::BaudRate baudRate);
bool startListener();
//! Start logging into the buffers
void startLog();
//! Stop logging into the buffers
void stopLog();
//! Retrieve all data from the buffer, in form of CSV lines
std::deque<std::string> retrieveData();
//! Retrieve all data from the buffer, in form of CSV lines
std::deque<std::string> retrieveRawData();
//! Addcallback on data received
void setDataCallback(const std::function<void(const minmea_sentence_gga& gga)>& callback);
private:
std::mutex m_bufferMutex;
std::deque<std::string> m_buffer;
std::deque<std::string> m_rawbuffer;
std::string m_lastLine;
bool m_isLogging{false};
minmea_sentence_gga lastGGA;
LibSerial::SerialPort m_serialPort;
LibSerial::SerialStream m_serialPortStream;
std::thread m_serialPortThread;
std::string m_portName;
int m_baudRate {0};
void worker();
bool init_succes{false};
//! Convert a minmea_sentence_gga to a CSV line
std::string GgaToCsvLine(const minmea_sentence_gga& gga, double laserTimestamp);
//! Convert a raw entry to a CSV line
std::string RawEntryToLine(const std::string& line, double laserTimestamp);
//! Callbacks to call when new data is received
std::function<void(const minmea_sentence_gga& gga)> m_dataCallback;
std::atomic<unsigned uint32_t> m_messageCount{0};
};
} // namespace mandeye