-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.cpp
41 lines (31 loc) · 1.12 KB
/
parser.cpp
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
#include "parser.h"
#include "cc_ublox/message/CfgPrtUart.h"
#include "cc_ublox/message/NavPvt.h"
#include "comms/units.h"
#include "comms/process.h"
Parser::Parser(Napi::Env* env, Napi::Object* obj) {
m_env = env;
m_obj = obj;
};
Parser::~Parser() = default;
void Parser::parse(std::vector<uint8_t> bytes)
{
if (bytes.empty()) {
return;
}
processAllWithDispatch(&bytes[0], bytes.size(), m_frame, *this);
}
void Parser::handle(InNavPvt& msg)
{
printf("UBX-NAV-PVT -> lon,lat: %f, %f\n", comms::units::getDegrees<double>(msg.field_lon()), comms::units::getDegrees<double>(msg.field_lat()));
m_obj->Set(Napi::String::New(*m_env, "lon"), Napi::Number::New(*m_env, comms::units::getDegrees<double>(msg.field_lon())));
m_obj->Set(Napi::String::New(*m_env, "lat"), Napi::Number::New(*m_env, comms::units::getDegrees<double>(msg.field_lat())));
}
void Parser::handle(InNavPosLlh& msg)
{
printf("UBX-NAV-POSLLH -> lon,lat: %f, %f\n", comms::units::getDegrees<double>(msg.field_lon()), comms::units::getDegrees<double>(msg.field_lat()));
}
void Parser::handle(InMessage& msg)
{
static_cast<void>(msg); // ignore
}