Merge lp:~thomas-voss/location-service/add-sirf-support into lp:location-service

Proposed by Thomas Voß
Status: Merged
Approved by: Thomas Voß
Approved revision: 305
Merged at revision: 304
Proposed branch: lp:~thomas-voss/location-service/add-sirf-support
Merge into: lp:location-service
Diff against target: 3976 lines (+2602/-453)
58 files modified
src/location/CMakeLists.txt (+7/-1)
src/location/cmds/monitor.cpp (+72/-4)
src/location/cmds/monitor.h (+7/-0)
src/location/nmea/cardinal_direction.h (+3/-12)
src/location/nmea/date.h (+3/-12)
src/location/nmea/fusion_adapt.h (+61/-61)
src/location/nmea/generator.h (+12/-21)
src/location/nmea/gga.h (+15/-22)
src/location/nmea/gll.h (+11/-19)
src/location/nmea/gps/fix_mode.h (+9/-16)
src/location/nmea/grammar.h (+7/-17)
src/location/nmea/gsa.h (+10/-19)
src/location/nmea/gsv.h (+9/-16)
src/location/nmea/latitude.h (+8/-15)
src/location/nmea/longitude.h (+8/-15)
src/location/nmea/mode.h (+8/-15)
src/location/nmea/rmc.h (+16/-23)
src/location/nmea/scanner.cpp (+2/-2)
src/location/nmea/scanner.h (+8/-15)
src/location/nmea/sentence.cpp (+3/-3)
src/location/nmea/sentence.h (+14/-22)
src/location/nmea/status.h (+8/-15)
src/location/nmea/talker.h (+8/-15)
src/location/nmea/txt.h (+9/-16)
src/location/nmea/utc.h (+8/-15)
src/location/nmea/vtg.h (+10/-17)
src/location/providers/CMakeLists.txt (+1/-0)
src/location/providers/config.cpp (+7/-0)
src/location/providers/sirf/CMakeLists.txt (+33/-0)
src/location/providers/sirf/bits.h (+49/-0)
src/location/providers/sirf/checksum.cpp (+28/-0)
src/location/providers/sirf/checksum.h (+42/-0)
src/location/providers/sirf/codec.h (+81/-0)
src/location/providers/sirf/dop.h (+64/-0)
src/location/providers/sirf/geodetic_navigation_data.h (+213/-0)
src/location/providers/sirf/initialize_data_source.h (+93/-0)
src/location/providers/sirf/magic.h (+43/-0)
src/location/providers/sirf/message.h (+53/-0)
src/location/providers/sirf/provider.cpp (+353/-0)
src/location/providers/sirf/provider.h (+143/-0)
src/location/providers/sirf/reader.cpp (+87/-0)
src/location/providers/sirf/reader.h (+52/-0)
src/location/providers/sirf/receiver.cpp (+80/-0)
src/location/providers/sirf/receiver.h (+92/-0)
src/location/providers/sirf/scanner.cpp (+161/-0)
src/location/providers/sirf/scanner.h (+76/-0)
src/location/providers/sirf/serial_port_receiver.cpp (+80/-0)
src/location/providers/sirf/serial_port_receiver.h (+79/-0)
src/location/providers/sirf/set_protocol.h (+73/-0)
src/location/providers/sirf/writer.cpp (+94/-0)
src/location/providers/sirf/writer.h (+54/-0)
src/location/providers/ubx/CMakeLists.txt (+5/-2)
src/location/providers/ubx/_8/receiver.cpp (+1/-1)
src/location/providers/ubx/_8/receiver.h (+4/-4)
src/location/providers/ubx/_8/scanner.cpp (+1/-1)
src/location/providers/ubx/provider.cpp (+28/-28)
src/location/providers/ubx/provider.h (+9/-9)
src/location/runtime_tests.cpp (+87/-0)
To merge this branch: bzr merge lp:~thomas-voss/location-service/add-sirf-support
Reviewer Review Type Date Requested Status
Simon Fels (community) Approve
Thomas Voß Pending
Review via email: mp+323629@code.launchpad.net

Commit message

Add support for SiRF providers.

Description of the change

Add support for SiRF providers.

To post a comment you must log in.
305. By Thomas Voß

Adjust formatting of output for locationd.monitor.

Revision history for this message
Simon Fels (morphis) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/location/CMakeLists.txt'
--- src/location/CMakeLists.txt 2017-04-26 19:58:19 +0000
+++ src/location/CMakeLists.txt 2017-05-05 09:37:41 +0000
@@ -35,6 +35,12 @@
35 COMMAND ${GDBUS_CODEGEN_EXECUTABLE} --generate-c-code "${CMAKE_CURRENT_BINARY_DIR}/connectivity/w11t_gen" "${CMAKE_CURRENT_SOURCE_DIR}/connectivity/w11t.xml")35 COMMAND ${GDBUS_CODEGEN_EXECUTABLE} --generate-c-code "${CMAKE_CURRENT_BINARY_DIR}/connectivity/w11t_gen" "${CMAKE_CURRENT_SOURCE_DIR}/connectivity/w11t.xml")
3636
37add_library(37add_library(
38 nmea
39
40 nmea/scanner.cpp
41 nmea/sentence.cpp)
42
43add_library(
38 ubuntu-location-service SHARED44 ubuntu-location-service SHARED
3945
40 ${UBUNTU_LOCATION_SERVICE_PUBLIC_HEADERS}46 ${UBUNTU_LOCATION_SERVICE_PUBLIC_HEADERS}
@@ -88,7 +94,7 @@
88 cmds/status.cpp94 cmds/status.cpp
89 cmds/test.h95 cmds/test.h
90 cmds/test.cpp96 cmds/test.cpp
9197
92 util/benchmark.h98 util/benchmark.h
93 util/benchmark.cpp99 util/benchmark.cpp
94 util/cli.h100 util/cli.h
95101
=== modified file 'src/location/cmds/monitor.cpp'
--- src/location/cmds/monitor.cpp 2017-04-26 19:58:19 +0000
+++ src/location/cmds/monitor.cpp 2017-05-05 09:37:41 +0000
@@ -20,6 +20,7 @@
20#include <location/cmds/monitor.h>20#include <location/cmds/monitor.h>
2121
22#include <location/criteria.h>22#include <location/criteria.h>
23#include <location/logging.h>
23#include <location/dbus/stub/service.h>24#include <location/dbus/stub/service.h>
24#include <location/glib/runtime.h>25#include <location/glib/runtime.h>
25#include <location/runtime.h>26#include <location/runtime.h>
@@ -34,17 +35,84 @@
3435
35void location::cmds::Monitor::PrintingDelegate::on_new_position(const Update<Position>& pos)36void location::cmds::Monitor::PrintingDelegate::on_new_position(const Update<Position>& pos)
36{37{
37 out << pos << std::endl;38 last_position_update = pos;
39 print_row();
38}40}
3941
40void location::cmds::Monitor::PrintingDelegate::on_new_heading(const Update<units::Degrees>& heading)42void location::cmds::Monitor::PrintingDelegate::on_new_heading(const Update<units::Degrees>& heading)
41{43{
42 out << heading << std::endl;44 last_heading_update = heading;
45 print_row();
43}46}
4447
45void location::cmds::Monitor::PrintingDelegate::on_new_velocity(const Update<units::MetersPerSecond>& velocity)48void location::cmds::Monitor::PrintingDelegate::on_new_velocity(const Update<units::MetersPerSecond>& velocity)
46{49{
47 out << velocity << std::endl;50 last_velocity_update = velocity;
51 print_row();
52}
53
54void location::cmds::Monitor::PrintingDelegate::print_header()
55{
56 out << std::left << std::setw(15) << std::setfill(' ') << "lat.[deg]"
57 << std::left << std::setw(15) << std::setfill(' ') << "lon.[deg]"
58 << std::left << std::setw(15) << std::setfill(' ') << "hor.acc.[m]"
59 << std::left << std::setw(15) << std::setfill(' ') << "alt.[m]"
60 << std::left << std::setw(15) << std::setfill(' ') << "ver.acc.[m]"
61 << std::left << std::setw(15) << std::setfill(' ') << "heading[deg]"
62 << std::left << std::setw(15) << std::setfill(' ') << "vel.[m/s]" << std::endl;
63}
64
65void location::cmds::Monitor::PrintingDelegate::print_row()
66{
67 if (last_position_update)
68 {
69 out << std::left << std::setw(15) << std::setfill(' ') << std::fixed << std::setprecision(5) << last_position_update->value.latitude().value();
70 out << std::left << std::setw(15) << std::setfill(' ') << std::fixed << std::setprecision(5) << last_position_update->value.longitude().value();
71
72 if (last_position_update->value.accuracy().horizontal())
73 out << std::left << std::setw(15) << std::setfill(' ') << std::fixed << std::setprecision(2) << last_position_update->value.accuracy().horizontal()->value() ;
74 else
75 out << std::left << std::setw(15) << std::setfill(' ') << "n/a" ;
76
77 if (last_position_update->value.altitude())
78 out << std::left << std::setw(15) << std::setfill(' ') << std::fixed << std::setprecision(2) << last_position_update->value.altitude()->value() ;
79 else
80 out << std::left << std::setw(15) << std::setfill(' ') << "n/a" ;
81
82 if (last_position_update->value.accuracy().vertical())
83 out << std::left << std::setw(15) << std::setfill(' ') << std::fixed << std::setprecision(2) << last_position_update->value.accuracy().vertical()->value() ;
84 else
85 out << std::left << std::setw(15) << std::setfill(' ') << "n/a" ;
86 }
87 else
88 {
89 out << std::left << std::setw(15) << std::setfill(' ') << "n/a" // latitude
90 << std::left << std::setw(15) << std::setfill(' ') << "n/a" // longitude
91 << std::left << std::setw(15) << std::setfill(' ') << "n/a" // horizontal accuracy
92 << std::left << std::setw(15) << std::setfill(' ') << "n/a" // altitude
93 << std::left << std::setw(15) << std::setfill(' ') << "n/a" ; // vertical accuracy
94 }
95
96 if (last_heading_update)
97 {
98 out << std::left << std::setw(15) << std::setfill(' ') << last_heading_update->value.value() ;
99 }
100 else
101 {
102 out << std::left << std::setw(15) << std::setfill(' ') << "n/a" ;
103 }
104
105 if (last_velocity_update)
106 {
107 out << std::left << std::setw(15) << std::setfill(' ') << last_velocity_update->value.value();
108 }
109 else
110 {
111 out << std::left << std::setw(15) << std::setfill(' ') << "n/a";
112 }
113
114 out << std::endl;
115
48}116}
49117
50location::cmds::Monitor::Monitor(const std::shared_ptr<Delegate>& delegate)118location::cmds::Monitor::Monitor(const std::shared_ptr<Delegate>& delegate)
@@ -96,7 +164,7 @@
96 session->updates().heading_status = location::Service::Session::Updates::Status::enabled;164 session->updates().heading_status = location::Service::Session::Updates::Status::enabled;
97 session->updates().velocity_status = location::Service::Session::Updates::Status::enabled;165 session->updates().velocity_status = location::Service::Session::Updates::Status::enabled;
98166
99 ctxt.cout << "Enabled position/heading/velocity updates..." << std::endl;167 LOG(INFO) << "Enabled position/heading/velocity updates..." << std::endl;
100 });168 });
101 });169 });
102170
103171
=== modified file 'src/location/cmds/monitor.h'
--- src/location/cmds/monitor.h 2017-03-07 10:01:34 +0000
+++ src/location/cmds/monitor.h 2017-05-05 09:37:41 +0000
@@ -61,8 +61,15 @@
61 void on_new_position(const Update<Position>& pos) override;61 void on_new_position(const Update<Position>& pos) override;
62 void on_new_heading(const Update<units::Degrees>& heading) override;62 void on_new_heading(const Update<units::Degrees>& heading) override;
63 void on_new_velocity(const Update<units::MetersPerSecond>& velocity) override;63 void on_new_velocity(const Update<units::MetersPerSecond>& velocity) override;
64
64 private:65 private:
66 void print_header();
67 void print_row();
68
65 std::ostream& out;69 std::ostream& out;
70 Optional<Update<Position>> last_position_update;
71 Optional<Update<units::Degrees>> last_heading_update;
72 Optional<Update<units::MetersPerSecond>> last_velocity_update;
66 };73 };
6774
68 // Monitor initializes a new instance.75 // Monitor initializes a new instance.
6976
=== renamed directory 'src/location/providers/ubx/_8/nmea' => 'src/location/nmea'
=== modified file 'src/location/nmea/cardinal_direction.h'
--- src/location/providers/ubx/_8/nmea/cardinal_direction.h 2016-10-10 09:15:40 +0000
+++ src/location/nmea/cardinal_direction.h 2017-05-05 09:37:41 +0000
@@ -12,17 +12,11 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_CARDINAL_DIRECTION_H_15#ifndef LOCATION_NMEA_CARDINAL_DIRECTION_H_
16#define UBX_8_NMEA_CARDINAL_DIRECTION_H_16#define LOCATION_NMEA_CARDINAL_DIRECTION_H_
1717
18namespace location18namespace location
19{19{
20namespace providers
21{
22namespace ubx
23{
24namespace _8
25{
26namespace nmea20namespace nmea
27{21{
28/// @brief CardinalDirection enumerates the main cardinal direction22/// @brief CardinalDirection enumerates the main cardinal direction
@@ -36,8 +30,5 @@
36};30};
37}31}
38}32}
39}
40}
41}
4233
43#endif // UBX_8_NMEA_CARDINAL_DIRECTION_H_34#endif // LOCATION_NMEA_CARDINAL_DIRECTION_H_
4435
=== modified file 'src/location/nmea/date.h'
--- src/location/providers/ubx/_8/nmea/date.h 2016-10-10 09:15:40 +0000
+++ src/location/nmea/date.h 2017-05-05 09:37:41 +0000
@@ -12,19 +12,13 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_DATE_H_15#ifndef LOCATION_NMEA_DATE_H_
16#define UBX_8_NMEA_DATE_H_16#define LOCATION_NMEA_DATE_H_
1717
18#include <cstdint>18#include <cstdint>
1919
20namespace location20namespace location
21{21{
22namespace providers
23{
24namespace ubx
25{
26namespace _8
27{
28namespace nmea22namespace nmea
29{23{
30/// @brief Date models a specific calendar day (Gregorian calendar).24/// @brief Date models a specific calendar day (Gregorian calendar).
@@ -36,8 +30,5 @@
36};30};
37}31}
38}32}
39}
40}
41}
4233
43#endif // UBX_8_NMEA_DATE_H_34#endif // LOCATION_NMEA_DATE_H_
4435
=== modified file 'src/location/nmea/fusion_adapt.h'
--- src/location/providers/ubx/_8/nmea/fusion_adapt.h 2016-10-10 09:15:40 +0000
+++ src/location/nmea/fusion_adapt.h 2017-05-05 09:37:41 +0000
@@ -12,123 +12,123 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_FUSION_ADAPT_H_15#ifndef LOCATION_NMEA_FUSION_ADAPT_H_
16#define UBX_8_NMEA_FUSION_ADAPT_H_16#define LOCATION_NMEA_FUSION_ADAPT_H_
1717
18#define BOOST_SPIRIT_DEBUG18#define BOOST_SPIRIT_DEBUG
19#define FUSION_MAX_VECTOR_SIZE 1519#define FUSION_MAX_VECTOR_SIZE 15
2020
21#include <location/providers/ubx/_8/nmea/sentence.h>21#include <location/nmea/sentence.h>
2222
23#include <boost/fusion/adapted/struct.hpp>23#include <boost/fusion/adapted/struct.hpp>
2424
25// clang-format off25// clang-format off
26BOOST_FUSION_ADAPT_STRUCT(26BOOST_FUSION_ADAPT_STRUCT(
27 location::providers::ubx::_8::nmea::Latitude,27 location::nmea::Latitude,
28 (uint32_t, degrees)28 (uint32_t, degrees)
29 (double, minutes))29 (double, minutes))
3030
31BOOST_FUSION_ADAPT_STRUCT(31BOOST_FUSION_ADAPT_STRUCT(
32 location::providers::ubx::_8::nmea::Longitude,32 location::nmea::Longitude,
33 (uint32_t, degrees)33 (uint32_t, degrees)
34 (double, minutes))34 (double, minutes))
3535
36BOOST_FUSION_ADAPT_STRUCT(36BOOST_FUSION_ADAPT_STRUCT(
37 location::providers::ubx::_8::nmea::Date,37 location::nmea::Date,
38 (std::uint8_t, day)38 (std::uint8_t, day)
39 (std::uint8_t, month)39 (std::uint8_t, month)
40 (std::uint8_t, year))40 (std::uint8_t, year))
4141
42BOOST_FUSION_ADAPT_STRUCT(42BOOST_FUSION_ADAPT_STRUCT(
43 location::providers::ubx::_8::nmea::Utc,43 location::nmea::Utc,
44 (std::uint8_t, hours)44 (std::uint8_t, hours)
45 (std::uint8_t, minutes)45 (std::uint8_t, minutes)
46 (double, seconds))46 (double, seconds))
4747
48BOOST_FUSION_ADAPT_STRUCT(48BOOST_FUSION_ADAPT_STRUCT(
49 location::providers::ubx::_8::nmea::Gsa,49 location::nmea::Gsa,
50 (location::providers::ubx::_8::nmea::Talker, talker)50 (location::nmea::Talker, talker)
51 (boost::optional<location::providers::ubx::_8::nmea::Gsa::OperationMode>, operation_mode)51 (boost::optional<location::nmea::Gsa::OperationMode>, operation_mode)
52 (boost::optional<location::providers::ubx::_8::nmea::Gsa::FixMode>, fix_mode)52 (boost::optional<location::nmea::Gsa::FixMode>, fix_mode)
53 (std::vector<boost::optional<std::uint8_t>>, satellite_ids)53 (std::vector<boost::optional<std::uint8_t>>, satellite_ids)
54 (boost::optional<location::providers::ubx::Dop<location::providers::ubx::tag::Positional>>, pdop)54 (boost::optional<float>, pdop)
55 (boost::optional<location::providers::ubx::Dop<location::providers::ubx::tag::Horizontal>>, hdop)55 (boost::optional<float>, hdop)
56 (boost::optional<location::providers::ubx::Dop<location::providers::ubx::tag::Vertical>>, vdop))56 (boost::optional<float>, vdop))
5757
58BOOST_FUSION_ADAPT_STRUCT(58BOOST_FUSION_ADAPT_STRUCT(
59 location::providers::ubx::_8::nmea::Gga,59 location::nmea::Gga,
60 (location::providers::ubx::_8::nmea::Talker, talker)60 (location::nmea::Talker, talker)
61 (boost::optional<location::providers::ubx::_8::nmea::Utc>, utc)61 (boost::optional<location::nmea::Utc>, utc)
62 (boost::optional<location::providers::ubx::_8::nmea::Latitude>, latitude)62 (boost::optional<location::nmea::Latitude>, latitude)
63 (boost::optional<location::providers::ubx::_8::nmea::CardinalDirection>, latitude_direction)63 (boost::optional<location::nmea::CardinalDirection>, latitude_direction)
64 (boost::optional<location::providers::ubx::_8::nmea::Longitude>, longitude)64 (boost::optional<location::nmea::Longitude>, longitude)
65 (boost::optional<location::providers::ubx::_8::nmea::CardinalDirection>, longitude_direction)65 (boost::optional<location::nmea::CardinalDirection>, longitude_direction)
66 (boost::optional<location::providers::ubx::_8::nmea::gps::FixMode>, fix_mode)66 (boost::optional<location::nmea::gps::FixMode>, fix_mode)
67 (boost::optional<std::uint8_t>, satellites_in_use)67 (boost::optional<std::uint8_t>, satellites_in_use)
68 (boost::optional<location::providers::ubx::Dop<location::providers::ubx::tag::Horizontal>>, hdop)68 (boost::optional<float>, hdop)
69 (boost::optional<float>, altitude)69 (boost::optional<float>, altitude)
70 (boost::optional<float>, geoidal_separation)70 (boost::optional<float>, geoidal_separation)
71 (boost::optional<float>, age)71 (boost::optional<float>, age)
72 (boost::optional<std::uint16_t>, differential_reference_station))72 (boost::optional<std::uint16_t>, differential_reference_station))
7373
74BOOST_FUSION_ADAPT_STRUCT(74BOOST_FUSION_ADAPT_STRUCT(
75 location::providers::ubx::_8::nmea::Gll,75 location::nmea::Gll,
76 (location::providers::ubx::_8::nmea::Talker, talker)76 (location::nmea::Talker, talker)
77 (boost::optional<location::providers::ubx::_8::nmea::Latitude>, latitude)77 (boost::optional<location::nmea::Latitude>, latitude)
78 (boost::optional<location::providers::ubx::_8::nmea::CardinalDirection>, latitude_direction)78 (boost::optional<location::nmea::CardinalDirection>, latitude_direction)
79 (boost::optional<location::providers::ubx::_8::nmea::Longitude>, longitude)79 (boost::optional<location::nmea::Longitude>, longitude)
80 (boost::optional<location::providers::ubx::_8::nmea::CardinalDirection>, longitude_direction)80 (boost::optional<location::nmea::CardinalDirection>, longitude_direction)
81 (boost::optional<location::providers::ubx::_8::nmea::Utc>, utc)81 (boost::optional<location::nmea::Utc>, utc)
82 (boost::optional<location::providers::ubx::_8::nmea::Status>, status)82 (boost::optional<location::nmea::Status>, status)
83 (boost::optional<location::providers::ubx::_8::nmea::Mode>, mode))83 (boost::optional<location::nmea::Mode>, mode))
8484
85BOOST_FUSION_ADAPT_STRUCT(85BOOST_FUSION_ADAPT_STRUCT(
86 location::providers::ubx::_8::nmea::Gsv::Info,86 location::nmea::Gsv::Info,
87 (boost::optional<std::uint8_t>, satellite_id)87 (boost::optional<std::uint8_t>, satellite_id)
88 (boost::optional<std::uint8_t>, elevation)88 (boost::optional<std::uint8_t>, elevation)
89 (boost::optional<std::uint16_t>, azimuth)89 (boost::optional<std::uint16_t>, azimuth)
90 (boost::optional<std::uint8_t>, snr))90 (boost::optional<std::uint8_t>, snr))
9191
92BOOST_FUSION_ADAPT_STRUCT(92BOOST_FUSION_ADAPT_STRUCT(
93 location::providers::ubx::_8::nmea::Gsv,93 location::nmea::Gsv,
94 (location::providers::ubx::_8::nmea::Talker, talker)94 (location::nmea::Talker, talker)
95 (boost::optional<std::uint8_t>, sentence_count)95 (boost::optional<std::uint8_t>, sentence_count)
96 (boost::optional<std::uint8_t>, sentence_number)96 (boost::optional<std::uint8_t>, sentence_number)
97 (boost::optional<std::uint8_t>, satellites_count)97 (boost::optional<std::uint8_t>, satellites_count)
98 (std::vector<location::providers::ubx::_8::nmea::Gsv::Info>, satellites_info))98 (std::vector<location::nmea::Gsv::Info>, satellites_info))
9999
100BOOST_FUSION_ADAPT_STRUCT(100BOOST_FUSION_ADAPT_STRUCT(
101 location::providers::ubx::_8::nmea::Rmc,101 location::nmea::Rmc,
102 (location::providers::ubx::_8::nmea::Talker, talker)102 (location::nmea::Talker, talker)
103 (boost::optional<location::providers::ubx::_8::nmea::Utc>, utc)103 (boost::optional<location::nmea::Utc>, utc)
104 (boost::optional<location::providers::ubx::_8::nmea::Status>, status)104 (boost::optional<location::nmea::Status>, status)
105 (boost::optional<location::providers::ubx::_8::nmea::Latitude>, latitude)105 (boost::optional<location::nmea::Latitude>, latitude)
106 (boost::optional<location::providers::ubx::_8::nmea::CardinalDirection>, latitude_direction)106 (boost::optional<location::nmea::CardinalDirection>, latitude_direction)
107 (boost::optional<location::providers::ubx::_8::nmea::Longitude>, longitude)107 (boost::optional<location::nmea::Longitude>, longitude)
108 (boost::optional<location::providers::ubx::_8::nmea::CardinalDirection>, longitude_direction)108 (boost::optional<location::nmea::CardinalDirection>, longitude_direction)
109 (boost::optional<float>, speed_over_ground)(boost::optional<float>, course_over_ground)109 (boost::optional<float>, speed_over_ground)(boost::optional<float>, course_over_ground)
110 (boost::optional<location::providers::ubx::_8::nmea::Date>, date)110 (boost::optional<location::nmea::Date>, date)
111 (boost::optional<float>, magnetic_variation)111 (boost::optional<float>, magnetic_variation)
112 (boost::optional<location::providers::ubx::_8::nmea::CardinalDirection>, cardinal_direction)112 (boost::optional<location::nmea::CardinalDirection>, cardinal_direction)
113 (boost::optional<location::providers::ubx::_8::nmea::Mode>, mode))113 (boost::optional<location::nmea::Mode>, mode))
114114
115BOOST_FUSION_ADAPT_STRUCT(115BOOST_FUSION_ADAPT_STRUCT(
116 location::providers::ubx::_8::nmea::Txt,116 location::nmea::Txt,
117 (location::providers::ubx::_8::nmea::Talker, talker)117 (location::nmea::Talker, talker)
118 (boost::optional<std::uint8_t>, total_number_of_sentences)118 (boost::optional<std::uint8_t>, total_number_of_sentences)
119 (boost::optional<std::uint8_t>, sentence_number)119 (boost::optional<std::uint8_t>, sentence_number)
120 (boost::optional<std::uint8_t>, identifier)120 (boost::optional<std::uint8_t>, identifier)
121 (boost::optional<std::string>, message))121 (boost::optional<std::string>, message))
122122
123BOOST_FUSION_ADAPT_STRUCT(123BOOST_FUSION_ADAPT_STRUCT(
124 location::providers::ubx::_8::nmea::Vtg,124 location::nmea::Vtg,
125 (location::providers::ubx::_8::nmea::Talker, talker)125 (location::nmea::Talker, talker)
126 (boost::optional<float>, cog_true)126 (boost::optional<float>, cog_true)
127 (boost::optional<float>, cog_magnetic)127 (boost::optional<float>, cog_magnetic)
128 (boost::optional<float>, sog_knots)128 (boost::optional<float>, sog_knots)
129 (boost::optional<float>, sog_kmh)129 (boost::optional<float>, sog_kmh)
130 (boost::optional<location::providers::ubx::_8::nmea::Mode>, mode))130 (boost::optional<location::nmea::Mode>, mode))
131131
132// clang-format on132// clang-format on
133133
134#endif // UBX_8_NMEA_FUSION_ADAPT_H_134#endif // LOCATION_NMEA_FUSION_ADAPT_H_
135135
=== modified file 'src/location/nmea/generator.h'
--- src/location/providers/ubx/_8/nmea/generator.h 2017-03-09 09:42:25 +0000
+++ src/location/nmea/generator.h 2017-05-05 09:37:41 +0000
@@ -12,15 +12,14 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_GENERATOR_H_15#ifndef LOCATION_NMEA_GENERATOR_H_
16#define UBX_8_NMEA_GENERATOR_H_16#define LOCATION_NMEA_GENERATOR_H_
1717
18#define BOOST_SPIRIT_DEBUG
19#define FUSION_MAX_VECTOR_SIZE 1518#define FUSION_MAX_VECTOR_SIZE 15
2019
21#include <location/providers/ubx/_8/nmea/sentence.h>20#include <location/nmea/sentence.h>
2221
23#include <location/providers/ubx/_8/nmea/fusion_adapt.h>22#include <location/nmea/fusion_adapt.h>
2423
25#include <boost/spirit/include/classic.hpp>24#include <boost/spirit/include/classic.hpp>
26#include <boost/spirit/include/karma.hpp>25#include <boost/spirit/include/karma.hpp>
@@ -31,12 +30,6 @@
3130
32namespace location31namespace location
33{32{
34namespace providers
35{
36namespace ubx
37{
38namespace _8
39{
40namespace nmea33namespace nmea
41{34{
4235
@@ -209,9 +202,9 @@
209 boost::spirit::karma::rule<Iterator, Longitude()> longitude;202 boost::spirit::karma::rule<Iterator, Longitude()> longitude;
210 boost::spirit::karma::rule<Iterator, Date()> date;203 boost::spirit::karma::rule<Iterator, Date()> date;
211 boost::spirit::karma::rule<Iterator, Utc()> utc;204 boost::spirit::karma::rule<Iterator, Utc()> utc;
212 boost::spirit::karma::rule<Iterator, Dop<tag::Positional>()> pdop;205 boost::spirit::karma::rule<Iterator, float()> pdop;
213 boost::spirit::karma::rule<Iterator, Dop<tag::Horizontal>()> hdop;206 boost::spirit::karma::rule<Iterator, float()> hdop;
214 boost::spirit::karma::rule<Iterator, Dop<tag::Vertical>()> vdop;207 boost::spirit::karma::rule<Iterator, float()> vdop;
215208
216 boost::spirit::karma::rule<Iterator, Gsa()> gsa;209 boost::spirit::karma::rule<Iterator, Gsa()> gsa;
217 boost::spirit::karma::rule<Iterator, Gga()> gga;210 boost::spirit::karma::rule<Iterator, Gga()> gga;
@@ -246,10 +239,8 @@
246 boost::spirit::karma::symbols<Gsa::FixMode, char> fix_mode;239 boost::spirit::karma::symbols<Gsa::FixMode, char> fix_mode;
247 } for_gsa;240 } for_gsa;
248};241};
249}242
250}243}
251}244}
252}245
253}246#endif // LOCATION_NMEA_GENERATOR_H_
254
255#endif // UBX_8_NMEA_GENERATOR_H_
256247
=== modified file 'src/location/nmea/gga.h'
--- src/location/providers/ubx/_8/nmea/gga.h 2016-10-10 09:15:40 +0000
+++ src/location/nmea/gga.h 2017-05-05 09:37:41 +0000
@@ -12,18 +12,18 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_GGA_H_15#ifndef LOCATION_NMEA_GGA_H_
16#define UBX_8_NMEA_GGA_H_16#define LOCATION_NMEA_GGA_H_
1717
18#include <location/providers/ubx/dop.h>18#include <location/providers/ubx/dop.h>
1919
20#include <location/providers/ubx/_8/nmea/cardinal_direction.h>20#include <location/nmea/cardinal_direction.h>
21#include <location/providers/ubx/_8/nmea/latitude.h>21#include <location/nmea/latitude.h>
22#include <location/providers/ubx/_8/nmea/longitude.h>22#include <location/nmea/longitude.h>
23#include <location/providers/ubx/_8/nmea/talker.h>23#include <location/nmea/talker.h>
24#include <location/providers/ubx/_8/nmea/utc.h>24#include <location/nmea/utc.h>
2525
26#include <location/providers/ubx/_8/nmea/gps/fix_mode.h>26#include <location/nmea/gps/fix_mode.h>
2727
28#include <boost/optional.hpp>28#include <boost/optional.hpp>
2929
@@ -31,14 +31,9 @@
3131
32namespace location32namespace location
33{33{
34namespace providers
35{
36namespace ubx
37{
38namespace _8
39{
40namespace nmea34namespace nmea
41{35{
36
42/// @brief Global positioning system fix data.37/// @brief Global positioning system fix data.
43///38///
44/// Time and position, together with GPS fixing related data (number of39/// Time and position, together with GPS fixing related data (number of
@@ -54,16 +49,14 @@
54 boost::optional<CardinalDirection> longitude_direction;49 boost::optional<CardinalDirection> longitude_direction;
55 boost::optional<gps::FixMode> fix_mode;50 boost::optional<gps::FixMode> fix_mode;
56 boost::optional<std::uint8_t> satellites_in_use;51 boost::optional<std::uint8_t> satellites_in_use;
57 boost::optional<Dop<tag::Horizontal>> hdop;52 boost::optional<float> hdop;
58 boost::optional<float> altitude;53 boost::optional<float> altitude;
59 boost::optional<float> geoidal_separation;54 boost::optional<float> geoidal_separation;
60 boost::optional<float> age; // [s]55 boost::optional<float> age; // [s]
61 boost::optional<std::uint16_t> differential_reference_station;56 boost::optional<std::uint16_t> differential_reference_station;
62};57};
63}58
64}59}
65}60}
66}61
67}62#endif // LOCATION_NMEA_GGA_H_
68
69#endif // UBX_8_NMEA_GGA_H_
7063
=== modified file 'src/location/nmea/gll.h'
--- src/location/providers/ubx/_8/nmea/gll.h 2016-10-10 09:15:40 +0000
+++ src/location/nmea/gll.h 2017-05-05 09:37:41 +0000
@@ -12,29 +12,24 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_GLL_H_15#ifndef LOCATION_NMEA_GLL_H_
16#define UBX_8_NMEA_GLL_H_16#define LOCATION_NMEA_GLL_H_
1717
18#include <location/providers/ubx/_8/nmea/cardinal_direction.h>18#include <location/nmea/cardinal_direction.h>
19#include <location/providers/ubx/_8/nmea/latitude.h>19#include <location/nmea/latitude.h>
20#include <location/providers/ubx/_8/nmea/longitude.h>20#include <location/nmea/longitude.h>
21#include <location/providers/ubx/_8/nmea/mode.h>21#include <location/nmea/mode.h>
22#include <location/providers/ubx/_8/nmea/status.h>22#include <location/nmea/status.h>
23#include <location/providers/ubx/_8/nmea/talker.h>23#include <location/nmea/talker.h>
24#include <location/providers/ubx/_8/nmea/utc.h>24#include <location/nmea/utc.h>
2525
26#include <boost/optional.hpp>26#include <boost/optional.hpp>
2727
28namespace location28namespace location
29{29{
30namespace providers
31{
32namespace ubx
33{
34namespace _8
35{
36namespace nmea30namespace nmea
37{31{
32
38/// @brief Latitude and longitude, with time of position fix and status33/// @brief Latitude and longitude, with time of position fix and status
39struct Gll34struct Gll
40{35{
@@ -49,8 +44,5 @@
49};44};
50}45}
51}46}
52}
53}
54}
5547
56#endif // UBX_8_NMEA_GLL_H_48#endif // LOCATION_NMEA_GLL_H_
5749
=== modified file 'src/location/nmea/gps/fix_mode.h'
--- src/location/providers/ubx/_8/nmea/gps/fix_mode.h 2016-10-10 09:15:40 +0000
+++ src/location/nmea/gps/fix_mode.h 2017-05-05 09:37:41 +0000
@@ -12,21 +12,16 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_GPS_FIX_MODE_H_15#ifndef LOCATION_NMEA_GPS_FIX_MODE_H_
16#define UBX_8_NMEA_GPS_FIX_MODE_H_16#define LOCATION_NMEA_GPS_FIX_MODE_H_
1717
18namespace location18namespace location
19{19{
20namespace providers
21{
22namespace ubx
23{
24namespace _8
25{
26namespace nmea20namespace nmea
27{21{
28namespace gps22namespace gps
29{23{
24
30/// @brief FixMode enumerates all known, gps-specific fix modes.25/// @brief FixMode enumerates all known, gps-specific fix modes.
31enum class FixMode26enum class FixMode
32{27{
@@ -40,11 +35,9 @@
40 manual_input = 7,35 manual_input = 7,
41 simulator = 836 simulator = 8
42};37};
43}38
44}39}
45}40}
46}41}
47}42
48}43#endif // LOCATION_NMEA_GPS_FIX_MODE_H_
49
50#endif // UBX_8_NMEA_GPS_FIX_MODE_H_
5144
=== modified file 'src/location/nmea/grammar.h'
--- src/location/providers/ubx/_8/nmea/grammar.h 2017-03-09 09:42:25 +0000
+++ src/location/nmea/grammar.h 2017-05-05 09:37:41 +0000
@@ -12,13 +12,12 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_GRAMMAR_H_15#ifndef LOCATION_NMEA_GRAMMAR_H_
16#define UBX_8_NMEA_GRAMMAR_H_16#define LOCATION_NMEA_GRAMMAR_H_
1717
18#define BOOST_SPIRIT_DEBUG
19#define FUSION_MAX_VECTOR_SIZE 1518#define FUSION_MAX_VECTOR_SIZE 15
2019
21#include <location/providers/ubx/_8/nmea/fusion_adapt.h>20#include <location/nmea/fusion_adapt.h>
2221
23#include <boost/spirit/include/classic.hpp>22#include <boost/spirit/include/classic.hpp>
24#include <boost/spirit/include/qi.hpp>23#include <boost/spirit/include/qi.hpp>
@@ -29,12 +28,6 @@
2928
30namespace location29namespace location
31{30{
32namespace providers
33{
34namespace ubx
35{
36namespace _8
37{
38namespace nmea31namespace nmea
39{32{
4033
@@ -206,9 +199,9 @@
206 boost::spirit::qi::rule<Iterator, Longitude()> longitude;199 boost::spirit::qi::rule<Iterator, Longitude()> longitude;
207 boost::spirit::qi::rule<Iterator, Date()> date;200 boost::spirit::qi::rule<Iterator, Date()> date;
208 boost::spirit::qi::rule<Iterator, Utc()> utc;201 boost::spirit::qi::rule<Iterator, Utc()> utc;
209 boost::spirit::qi::rule<Iterator, Dop<tag::Positional>()> pdop;202 boost::spirit::qi::rule<Iterator, float()> pdop;
210 boost::spirit::qi::rule<Iterator, Dop<tag::Horizontal>()> hdop;203 boost::spirit::qi::rule<Iterator, float()> hdop;
211 boost::spirit::qi::rule<Iterator, Dop<tag::Vertical>()> vdop;204 boost::spirit::qi::rule<Iterator, float()> vdop;
212205
213 boost::spirit::qi::rule<Iterator, Gsa()> gsa;206 boost::spirit::qi::rule<Iterator, Gsa()> gsa;
214 boost::spirit::qi::rule<Iterator, Gga()> gga;207 boost::spirit::qi::rule<Iterator, Gga()> gga;
@@ -245,8 +238,5 @@
245};238};
246}239}
247}240}
248}
249}
250}
251241
252#endif // UBX_8_NMEA_GRAMMAR_H_242#endif // LOCATION_NMEA_GRAMMAR_H_
253243
=== modified file 'src/location/nmea/gsa.h'
--- src/location/providers/ubx/_8/nmea/gsa.h 2016-10-10 09:15:40 +0000
+++ src/location/nmea/gsa.h 2017-05-05 09:37:41 +0000
@@ -12,16 +12,16 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_GSA_H_15#ifndef LOCATION_NMEA_GSA_H_
16#define UBX_8_NMEA_GSA_H_16#define LOCATION_NMEA_GSA_H_
1717
18#include <location/providers/ubx/dop.h>18#include <location/providers/ubx/dop.h>
1919
20#include <location/providers/ubx/_8/nmea/latitude.h>20#include <location/nmea/latitude.h>
21#include <location/providers/ubx/_8/nmea/longitude.h>21#include <location/nmea/longitude.h>
22#include <location/providers/ubx/_8/nmea/talker.h>22#include <location/nmea/talker.h>
2323
24#include <location/providers/ubx/_8/nmea/gps/fix_mode.h>24#include <location/nmea/gps/fix_mode.h>
2525
26#include <boost/optional.hpp>26#include <boost/optional.hpp>
2727
@@ -30,12 +30,6 @@
3030
31namespace location31namespace location
32{32{
33namespace providers
34{
35namespace ubx
36{
37namespace _8
38{
39namespace nmea33namespace nmea
40{34{
41/// @brief GNSS DOP and Active Satellites.35/// @brief GNSS DOP and Active Satellites.
@@ -71,14 +65,11 @@
71 boost::optional<OperationMode> operation_mode;65 boost::optional<OperationMode> operation_mode;
72 boost::optional<FixMode> fix_mode;66 boost::optional<FixMode> fix_mode;
73 std::vector<boost::optional<std::uint8_t>> satellite_ids;67 std::vector<boost::optional<std::uint8_t>> satellite_ids;
74 boost::optional<Dop<tag::Positional>> pdop;68 boost::optional<float> pdop;
75 boost::optional<Dop<tag::Horizontal>> hdop;69 boost::optional<float> hdop;
76 boost::optional<Dop<tag::Vertical>> vdop;70 boost::optional<float> vdop;
77};71};
78}72}
79}73}
80}
81}
82}
8374
84#endif // UBX_8_NMEA_GSA_H_75#endif // LOCATION_NMEA_GSA_H_
8576
=== modified file 'src/location/nmea/gsv.h'
--- src/location/providers/ubx/_8/nmea/gsv.h 2016-10-10 09:15:40 +0000
+++ src/location/nmea/gsv.h 2017-05-05 09:37:41 +0000
@@ -12,10 +12,10 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_GSV_H_15#ifndef LOCATION_NMEA_GSV_H_
16#define UBX_8_NMEA_GSV_H_16#define LOCATION_NMEA_GSV_H_
1717
18#include <location/providers/ubx/_8/nmea/talker.h>18#include <location/nmea/talker.h>
1919
20#include <boost/optional.hpp>20#include <boost/optional.hpp>
2121
@@ -25,14 +25,9 @@
2525
26namespace location26namespace location
27{27{
28namespace providers
29{
30namespace ubx
31{
32namespace _8
33{
34namespace nmea28namespace nmea
35{29{
30
36/// @brief GNSS Satellites in View.31/// @brief GNSS Satellites in View.
37///32///
38/// The number of satellites in view, together with each SV ID, elevation33/// The number of satellites in view, together with each SV ID, elevation
@@ -57,10 +52,8 @@
57 boost::optional<std::uint8_t> satellites_count;52 boost::optional<std::uint8_t> satellites_count;
58 std::vector<Info> satellites_info;53 std::vector<Info> satellites_info;
59};54};
60}55
61}56}
62}57}
63}58
64}59#endif // LOCATION_NMEA_GSV_H_
65
66#endif // UBX_8_NMEA_GSV_H_
6760
=== modified file 'src/location/nmea/latitude.h'
--- src/location/providers/ubx/_8/nmea/latitude.h 2016-10-10 09:15:40 +0000
+++ src/location/nmea/latitude.h 2017-05-05 09:37:41 +0000
@@ -12,31 +12,24 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_LATITUDE_H_15#ifndef LOCATION_NMEA_LATITUDE_H_
16#define UBX_8_NMEA_LATITUDE_H_16#define LOCATION_NMEA_LATITUDE_H_
1717
18#include <cstdint>18#include <cstdint>
1919
20namespace location20namespace location
21{21{
22namespace providers
23{
24namespace ubx
25{
26namespace _8
27{
28namespace nmea22namespace nmea
29{23{
24
30/// @brief Latitude as defined in wgs84.25/// @brief Latitude as defined in wgs84.
31struct Latitude26struct Latitude
32{27{
33 std::uint32_t degrees;28 std::uint32_t degrees;
34 double minutes;29 double minutes;
35};30};
36}31
37}32}
38}33}
39}34
40}35#endif // LOCATION_NMEA_LATITUDE_H_
41
42#endif // UBX_8_NMEA_LATITUDE_H_
4336
=== modified file 'src/location/nmea/longitude.h'
--- src/location/providers/ubx/_8/nmea/longitude.h 2016-10-10 09:15:40 +0000
+++ src/location/nmea/longitude.h 2017-05-05 09:37:41 +0000
@@ -12,31 +12,24 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_LONGITUDE_H_15#ifndef LOCATION_NMEA_LONGITUDE_H_
16#define UBX_8_NMEA_LONGITUDE_H_16#define LOCATION_NMEA_LONGITUDE_H_
1717
18#include <cstdint>18#include <cstdint>
1919
20namespace location20namespace location
21{21{
22namespace providers
23{
24namespace ubx
25{
26namespace _8
27{
28namespace nmea22namespace nmea
29{23{
24
30/// @brief Longitude as defined in wgs84.25/// @brief Longitude as defined in wgs84.
31struct Longitude26struct Longitude
32{27{
33 std::uint32_t degrees;28 std::uint32_t degrees;
34 double minutes;29 double minutes;
35};30};
36}31
37}32}
38}33}
39}34
40}35#endif // LOCATION_NMEA_LONGITUDE_H_
41
42#endif // UBX_8_NMEA_LONGITUDE_H_
4336
=== modified file 'src/location/nmea/mode.h'
--- src/location/providers/ubx/_8/nmea/mode.h 2016-10-10 09:15:40 +0000
+++ src/location/nmea/mode.h 2017-05-05 09:37:41 +0000
@@ -12,19 +12,14 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_MODE_H_15#ifndef LOCATION_NMEA_MODE_H_
16#define UBX_8_NMEA_MODE_H_16#define LOCATION_NMEA_MODE_H_
1717
18namespace location18namespace location
19{19{
20namespace providers
21{
22namespace ubx
23{
24namespace _8
25{
26namespace nmea20namespace nmea
27{21{
22
28/// @brief Mode enumerates all known NMEA positioning modes.23/// @brief Mode enumerates all known NMEA positioning modes.
29enum class Mode24enum class Mode
30{25{
@@ -35,10 +30,8 @@
35 simulator_mode = 'S',30 simulator_mode = 'S',
36 data_not_valid = 'N'31 data_not_valid = 'N'
37};32};
38}33
39}34}
40}35}
41}36
42}37#endif // LOCATION_NMEA_MODE_H_
43
44#endif // UBX_8_NMEA_MODE_H_
4538
=== modified file 'src/location/nmea/rmc.h'
--- src/location/providers/ubx/_8/nmea/rmc.h 2016-10-10 09:15:40 +0000
+++ src/location/nmea/rmc.h 2017-05-05 09:37:41 +0000
@@ -12,17 +12,17 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_RMC_H_15#ifndef LOCATION_NMEA_RMC_H_
16#define UBX_8_NMEA_RMC_H_16#define LOCATION_NMEA_RMC_H_
1717
18#include <location/providers/ubx/_8/nmea/cardinal_direction.h>18#include <location/nmea/cardinal_direction.h>
19#include <location/providers/ubx/_8/nmea/date.h>19#include <location/nmea/date.h>
20#include <location/providers/ubx/_8/nmea/latitude.h>20#include <location/nmea/latitude.h>
21#include <location/providers/ubx/_8/nmea/longitude.h>21#include <location/nmea/longitude.h>
22#include <location/providers/ubx/_8/nmea/mode.h>22#include <location/nmea/mode.h>
23#include <location/providers/ubx/_8/nmea/status.h>23#include <location/nmea/status.h>
24#include <location/providers/ubx/_8/nmea/talker.h>24#include <location/nmea/talker.h>
25#include <location/providers/ubx/_8/nmea/utc.h>25#include <location/nmea/utc.h>
2626
27#include <boost/optional.hpp>27#include <boost/optional.hpp>
2828
@@ -32,14 +32,9 @@
3232
33namespace location33namespace location
34{34{
35namespace providers
36{
37namespace ubx
38{
39namespace _8
40{
41namespace nmea35namespace nmea
42{36{
37
43/// @brief Recommended Minimum data.38/// @brief Recommended Minimum data.
44///39///
45/// The recommended minimum sentence defined by NMEA for GNSS system data.40/// The recommended minimum sentence defined by NMEA for GNSS system data.
@@ -59,10 +54,8 @@
59 boost::optional<CardinalDirection> cardinal_direction;54 boost::optional<CardinalDirection> cardinal_direction;
60 boost::optional<Mode> mode;55 boost::optional<Mode> mode;
61};56};
62}57
63}58}
64}59}
65}60
66}61#endif // LOCATION_NMEA_RMC_H_
67
68#endif // UBX_8_NMEA_RMC_H_
6962
=== modified file 'src/location/nmea/scanner.cpp'
--- src/location/providers/ubx/_8/nmea/scanner.cpp 2017-03-23 12:32:38 +0000
+++ src/location/nmea/scanner.cpp 2017-05-05 09:37:41 +0000
@@ -13,11 +13,11 @@
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
1515
16#include <location/providers/ubx/_8/nmea/scanner.h>16#include <location/nmea/scanner.h>
1717
18#include <stdexcept>18#include <stdexcept>
1919
20namespace nmea = location::providers::ubx::_8::nmea;20namespace nmea = location::nmea;
2121
22nmea::Scanner::Expect nmea::Scanner::update(char c) {22nmea::Scanner::Expect nmea::Scanner::update(char c) {
23 switch (state) {23 switch (state) {
2424
=== modified file 'src/location/nmea/scanner.h'
--- src/location/providers/ubx/_8/nmea/scanner.h 2016-10-10 09:15:40 +0000
+++ src/location/nmea/scanner.h 2017-05-05 09:37:41 +0000
@@ -12,22 +12,17 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_SCANNER_H_15#ifndef LOCATION_NMEA_SCANNER_H_
16#define UBX_8_NMEA_SCANNER_H_16#define LOCATION_NMEA_SCANNER_H_
1717
18#include <sstream>18#include <sstream>
19#include <string>19#include <string>
2020
21namespace location21namespace location
22{22{
23namespace providers
24{
25namespace ubx
26{
27namespace _8
28{
29namespace nmea23namespace nmea
30{24{
25
31/// @brief Scanner inspects incoming characters and tries to identify beginning26/// @brief Scanner inspects incoming characters and tries to identify beginning
32/// and end of27/// and end of
33/// NMEA messages.28/// NMEA messages.
@@ -58,10 +53,8 @@
58 Expect state{Expect::dollar}; ///< The state of the Scanner.53 Expect state{Expect::dollar}; ///< The state of the Scanner.
59 std::stringstream ss; ///< Buffer holding incomplete sentence data.54 std::stringstream ss; ///< Buffer holding incomplete sentence data.
60};55};
61}56
62}57}
63}58}
64}59
65}60#endif // LOCATION_NMEA_SCANNER_H_
66
67#endif // UBX_8_NMEA_SCANNER_H_
6861
=== modified file 'src/location/nmea/sentence.cpp'
--- src/location/providers/ubx/_8/nmea/sentence.cpp 2016-10-10 09:15:40 +0000
+++ src/location/nmea/sentence.cpp 2017-05-05 09:37:41 +0000
@@ -13,12 +13,12 @@
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
1515
16#include <location/providers/ubx/_8/nmea/generator.h>16#include <location/nmea/generator.h>
17#include <location/providers/ubx/_8/nmea/grammar.h>17#include <location/nmea/grammar.h>
1818
19#include <iterator>19#include <iterator>
2020
21namespace nmea = location::providers::ubx::_8::nmea;21namespace nmea = location::nmea;
2222
23namespace {23namespace {
24template <typename Iterator>24template <typename Iterator>
2525
=== modified file 'src/location/nmea/sentence.h'
--- src/location/providers/ubx/_8/nmea/sentence.h 2016-10-10 09:15:40 +0000
+++ src/location/nmea/sentence.h 2017-05-05 09:37:41 +0000
@@ -12,16 +12,16 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_SENTENCE_H_15#ifndef LOCATION_NMEA_SENTENCE_H_
16#define UBX_8_NMEA_SENTENCE_H_16#define LOCATION_NMEA_SENTENCE_H_
1717
18#include <location/providers/ubx/_8/nmea/gga.h>18#include <location/nmea/gga.h>
19#include <location/providers/ubx/_8/nmea/gll.h>19#include <location/nmea/gll.h>
20#include <location/providers/ubx/_8/nmea/gsa.h>20#include <location/nmea/gsa.h>
21#include <location/providers/ubx/_8/nmea/gsv.h>21#include <location/nmea/gsv.h>
22#include <location/providers/ubx/_8/nmea/rmc.h>22#include <location/nmea/rmc.h>
23#include <location/providers/ubx/_8/nmea/txt.h>23#include <location/nmea/txt.h>
24#include <location/providers/ubx/_8/nmea/vtg.h>24#include <location/nmea/vtg.h>
2525
26#include <boost/variant.hpp>26#include <boost/variant.hpp>
2727
@@ -29,12 +29,6 @@
2929
30namespace location30namespace location
31{31{
32namespace providers
33{
34namespace ubx
35{
36namespace _8
37{
38namespace nmea32namespace nmea
39{33{
4034
@@ -47,10 +41,8 @@
47std::string generate_sentence(const Sentence& sentence);41std::string generate_sentence(const Sentence& sentence);
48/// @brief operator<< inserts sentence into out.42/// @brief operator<< inserts sentence into out.
49std::ostream& operator<<(std::ostream& out, const Sentence& sentence);43std::ostream& operator<<(std::ostream& out, const Sentence& sentence);
50}44
51}45}
52}46}
53}47
54}48#endif // LOCATION_NMEA_SENTENCE_H_
55
56#endif // UBX_8_NMEA_SENTENCE_H_
5749
=== modified file 'src/location/nmea/status.h'
--- src/location/providers/ubx/_8/nmea/status.h 2016-10-10 09:15:40 +0000
+++ src/location/nmea/status.h 2017-05-05 09:37:41 +0000
@@ -12,29 +12,22 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_STATUS_H_15#ifndef LOCATION_NMEA_STATUS_H_
16#define UBX_8_NMEA_STATUS_H_16#define LOCATION_NMEA_STATUS_H_
1717
18namespace location18namespace location
19{19{
20namespace providers
21{
22namespace ubx
23{
24namespace _8
25{
26namespace nmea20namespace nmea
27{21{
22
28/// @brief Status enumerates all status codes known to NMEA messages.23/// @brief Status enumerates all status codes known to NMEA messages.
29enum class Status24enum class Status
30{25{
31 valid = 'A', ///< The referenced data is valid.26 valid = 'A', ///< The referenced data is valid.
32 not_valid = 'V' ///< The reference data is missing and thus not valid.27 not_valid = 'V' ///< The reference data is missing and thus not valid.
33};28};
34}29
35}30}
36}31}
37}32
38}33#endif // LOCATION_NMEA_STATUS_H_
39
40#endif // UBX_8_NMEA_STATUS_H_
4134
=== modified file 'src/location/nmea/talker.h'
--- src/location/providers/ubx/_8/nmea/talker.h 2017-03-09 09:42:25 +0000
+++ src/location/nmea/talker.h 2017-05-05 09:37:41 +0000
@@ -12,19 +12,14 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_TALKER_H_15#ifndef LOCATION_NMEA_TALKER_H_
16#define UBX_8_NMEA_TALKER_H_16#define LOCATION_NMEA_TALKER_H_
1717
18namespace location18namespace location
19{19{
20namespace providers
21{
22namespace ubx
23{
24namespace _8
25{
26namespace nmea20namespace nmea
27{21{
22
28/// @brief Talker enumerates well-known participants on an NMEA bus.23/// @brief Talker enumerates well-known participants on an NMEA bus.
29enum class Talker24enum class Talker
30{25{
@@ -33,10 +28,8 @@
33 gn, ///< Global Navigation Satellite System (GNSS)28 gn, ///< Global Navigation Satellite System (GNSS)
34 gp ///< Global Positioning System (GPS)29 gp ///< Global Positioning System (GPS)
35};30};
36}31
37}32}
38}33}
39}34
40}35#endif // LOCATION_NMEA_TALKER_H_
41
42#endif // UBX_8_NMEA_TALKER_H_
4336
=== modified file 'src/location/nmea/txt.h'
--- src/location/providers/ubx/_8/nmea/txt.h 2016-10-10 09:15:40 +0000
+++ src/location/nmea/txt.h 2017-05-05 09:37:41 +0000
@@ -12,10 +12,10 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_TXT_H_15#ifndef LOCATION_NMEA_TXT_H_
16#define UBX_8_NMEA_TXT_H_16#define LOCATION_NMEA_TXT_H_
1717
18#include <location/providers/ubx/_8/nmea/talker.h>18#include <location/nmea/talker.h>
1919
20#include <boost/optional.hpp>20#include <boost/optional.hpp>
2121
@@ -25,14 +25,9 @@
2525
26namespace location26namespace location
27{27{
28namespace providers
29{
30namespace ubx
31{
32namespace _8
33{
34namespace nmea28namespace nmea
35{29{
30
36/// @brief Text Transmission.31/// @brief Text Transmission.
37///32///
38/// This message outputs various information on the receiver, such as power-up33/// This message outputs various information on the receiver, such as power-up
@@ -46,10 +41,8 @@
46 boost::optional<std::uint8_t> identifier;41 boost::optional<std::uint8_t> identifier;
47 boost::optional<std::string> message;42 boost::optional<std::string> message;
48};43};
49}44
50}45}
51}46}
52}47
53}48#endif // LOCATION_NMEA_TXT_H_
54
55#endif // UBX_8_NMEA_TXT_H_
5649
=== modified file 'src/location/nmea/utc.h'
--- src/location/providers/ubx/_8/nmea/utc.h 2016-10-10 09:15:40 +0000
+++ src/location/nmea/utc.h 2017-05-05 09:37:41 +0000
@@ -12,21 +12,16 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_UTC_H_15#ifndef LOCATION_NMEA_UTC_H_
16#define UBX_8_NMEA_UTC_H_16#define LOCATION_NMEA_UTC_H_
1717
18#include <cstdint>18#include <cstdint>
1919
20namespace location20namespace location
21{21{
22namespace providers
23{
24namespace ubx
25{
26namespace _8
27{
28namespace nmea22namespace nmea
29{23{
24
30/// @brief Time in UTC.25/// @brief Time in UTC.
31struct Utc26struct Utc
32{27{
@@ -34,10 +29,8 @@
34 std::uint8_t minutes;29 std::uint8_t minutes;
35 double seconds;30 double seconds;
36};31};
37}32
38}33}
39}34}
40}35
41}36#endif // LOCATION_NMEA_UTC_H_
42
43#endif // UBX_8_NMEA_UTC_H_
4437
=== modified file 'src/location/nmea/vtg.h'
--- src/location/providers/ubx/_8/nmea/vtg.h 2016-10-10 09:15:40 +0000
+++ src/location/nmea/vtg.h 2017-05-05 09:37:41 +0000
@@ -12,11 +12,11 @@
12//12//
13// You should have received a copy of the GNU Lesser General Public License13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef UBX_8_NMEA_VTG_H_15#ifndef LOCATION_NMEA_VTG_H_
16#define UBX_8_NMEA_VTG_H_16#define LOCATION_NMEA_VTG_H_
1717
18#include <location/providers/ubx/_8/nmea/mode.h>18#include <location/nmea/mode.h>
19#include <location/providers/ubx/_8/nmea/talker.h>19#include <location/nmea/talker.h>
2020
21#include <boost/optional.hpp>21#include <boost/optional.hpp>
2222
@@ -24,14 +24,9 @@
2424
25namespace location25namespace location
26{26{
27namespace providers
28{
29namespace ubx
30{
31namespace _8
32{
33namespace nmea27namespace nmea
34{28{
29
35/// @brief Course over ground and Ground speed.30/// @brief Course over ground and Ground speed.
36///31///
37/// Velocity is given as Course over Ground (COG) and Speed over Ground (SOG).32/// Velocity is given as Course over Ground (COG) and Speed over Ground (SOG).
@@ -44,10 +39,8 @@
44 boost::optional<float> sog_kmh;39 boost::optional<float> sog_kmh;
45 boost::optional<Mode> mode;40 boost::optional<Mode> mode;
46};41};
47}42
48}43}
49}44}
50}45
51}46#endif // LOCATION_NMEA_VTG_H_
52
53#endif // UBX_8_NMEA_VTG_H_
5447
=== modified file 'src/location/providers/CMakeLists.txt'
--- src/location/providers/CMakeLists.txt 2017-03-04 21:43:23 +0000
+++ src/location/providers/CMakeLists.txt 2017-05-05 09:37:41 +0000
@@ -3,6 +3,7 @@
3add_subdirectory(mls)3add_subdirectory(mls)
4# add_subdirectory(remote)4# add_subdirectory(remote)
5add_subdirectory(gps)5add_subdirectory(gps)
6add_subdirectory(sirf)
6add_subdirectory(ubx)7add_subdirectory(ubx)
78
8set(9set(
910
=== modified file 'src/location/providers/config.cpp'
--- src/location/providers/config.cpp 2016-10-10 09:15:40 +0000
+++ src/location/providers/config.cpp 2017-05-05 09:37:41 +0000
@@ -20,6 +20,7 @@
2020
21#include "dummy/provider.h"21#include "dummy/provider.h"
22#include "mls/provider.h"22#include "mls/provider.h"
23#include "sirf/provider.h"
23#include "ubx/provider.h"24#include "ubx/provider.h"
2425
25#include <map>26#include <map>
@@ -47,6 +48,12 @@
47 location::providers::mls::Provider::create_instance48 location::providers::mls::Provider::create_instance
48};49};
4950
51static FactoryInjector sirf_injector
52{
53 "sirf::Provider",
54 location::providers::sirf::Provider::create_instance
55};
56
50static FactoryInjector ubx_injector57static FactoryInjector ubx_injector
51{58{
52 "ubx::Provider",59 "ubx::Provider",
5360
=== added directory 'src/location/providers/sirf'
=== added file 'src/location/providers/sirf/CMakeLists.txt'
--- src/location/providers/sirf/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/CMakeLists.txt 2017-05-05 09:37:41 +0000
@@ -0,0 +1,33 @@
1file(GLOB_RECURSE SIRF_HEADERS*.h)
2
3add_library(
4 sirf
5
6 ${SIRF_HEADERS}
7
8 bits.h
9
10 checksum.h
11 checksum.cpp
12 reader.h
13 reader.cpp
14 receiver.h
15 receiver.cpp
16 scanner.h
17 scanner.cpp
18 serial_port_receiver.h
19 serial_port_receiver.cpp
20 writer.h
21 writer.cpp
22
23 provider.h provider.cpp)
24
25target_link_libraries(
26 sirf
27
28 nmea)
29
30set(
31 ENABLED_PROVIDER_TARGETS
32 ${ENABLED_PROVIDER_TARGETS} sirf
33 PARENT_SCOPE)
034
=== added file 'src/location/providers/sirf/bits.h'
--- src/location/providers/sirf/bits.h 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/bits.h 2017-05-05 09:37:41 +0000
@@ -0,0 +1,49 @@
1// Copyright (C) 2017 Thomas Voss <thomas.voss.bochum@gmail.com>
2//
3// This library is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Lesser General Public License as published
5// by the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16#ifndef LOCATION_PROVIDERS_SIRF_BITS_H_
17#define LOCATION_PROVIDERS_SIRF_BITS_H_
18
19#include <cstdint>
20
21namespace location
22{
23namespace providers
24{
25namespace sirf
26{
27namespace bits
28{
29
30template<std::size_t begin, std::size_t end, typename T, typename U>
31void set(T& bitfield, U value)
32{
33 static_assert(begin < end, "begin >= end");
34 bitfield |= ((value & ((1 << (end - begin))-1)) << begin);
35}
36
37template<std::size_t begin, std::size_t end, typename T, typename U = T>
38U get(const T& bitfield)
39{
40 static_assert(begin < end, "begin >= end");
41 return (bitfield >> begin) & ((1 << (end - begin)) - 1);
42}
43
44} // namespace bits
45} // namespace sirf
46} // namespace providers
47} // namespace location
48
49#endif // LOCATION_PROVIDERS_SIRF_BITS_H_
050
=== added file 'src/location/providers/sirf/checksum.cpp'
--- src/location/providers/sirf/checksum.cpp 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/checksum.cpp 2017-05-05 09:37:41 +0000
@@ -0,0 +1,28 @@
1// Copyright (C) 2017 Thomas Voss <thomas.voss.bochum@gmail.com>
2//
3// This library is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Lesser General Public License as published
5// by the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16#include <location/providers/sirf/checksum.h>
17
18namespace sirf = location::providers::sirf;
19
20void sirf::Checksum::operator()(std::uint8_t byte)
21{
22 checksum += byte;
23}
24
25std::uint16_t sirf::Checksum::operator()() const
26{
27 return checksum;
28}
029
=== added file 'src/location/providers/sirf/checksum.h'
--- src/location/providers/sirf/checksum.h 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/checksum.h 2017-05-05 09:37:41 +0000
@@ -0,0 +1,42 @@
1// Copyright (C) 2017 Thomas Voss <thomas.voss.bochum@gmail.com>
2//
3// This library is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Lesser General Public License as published
5// by the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16#ifndef LOCATION_PROVIDERS_SIRF_CHECKSUM_H_
17#define LOCATION_PROVIDERS_SIRF_CHECKSUM_H_
18
19#include <cstdint>
20
21namespace location
22{
23namespace providers
24{
25namespace sirf
26{
27
28class Checksum
29{
30public:
31 void operator()(std::uint8_t byte);
32 std::uint16_t operator()() const;
33
34private:
35 std::uint16_t checksum{0};
36};
37
38} // namespace sirf
39} // namespace providers
40} // namepsace location
41
42#endif // LOCATION_PROVIDERS_SIRF_CHECKSUM_H_
043
=== added file 'src/location/providers/sirf/codec.h'
--- src/location/providers/sirf/codec.h 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/codec.h 2017-05-05 09:37:41 +0000
@@ -0,0 +1,81 @@
1// Copyright (C) 2016 Thomas Voss <thomas.voss.bochum@gmail.com>
2//
3// This library is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Lesser General Public License as published
5// by the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16#ifndef LOCATION_PROVIDERS_SIRF_CODEC_H_
17#define LOCATION_PROVIDERS_SIRF_CODEC_H_
18
19#include <location/providers/sirf/checksum.h>
20#include <location/providers/sirf/magic.h>
21#include <location/providers/sirf/reader.h>
22#include <location/providers/sirf/writer.h>
23
24#include <algorithm>
25#include <cstdint>
26#include <iostream>
27#include <vector>
28
29namespace location
30{
31namespace providers
32{
33namespace sirf
34{
35
36template<typename T>
37inline T decode_message(const std::vector<std::uint8_t>& payload)
38{
39 T result;
40 Reader reader{payload.begin(), payload.end()};
41 result.read(reader);
42
43 return result;
44}
45
46template<typename T>
47inline std::vector<std::uint8_t> encode_message(const T& message)
48{
49 auto msg_size = message.size();
50
51 std::uint16_t size =
52 sizeof(std::uint8_t) + sizeof(std::uint8_t) +
53 sizeof(std::uint16_t) +
54 msg_size +
55 sizeof(std::uint16_t) +
56 sizeof(std::uint8_t) + sizeof(std::uint8_t);
57
58 std::vector<std::uint8_t> result(size, 0);
59
60 Writer writer{result.begin(), result.end()};
61 writer.write_unsigned_char(begin::sync_char_1);
62 writer.write_unsigned_char(begin::sync_char_2);
63 writer.write_unsigned_short(msg_size);
64
65 Writer payload = writer.slice(msg_size);
66 message.write(payload);
67
68 auto checksum = std::for_each(result.begin() + 4, result.end() - 4, Checksum{});
69
70 writer.write_unsigned_short(checksum());
71 writer.write_unsigned_char(end::sync_char_1);
72 writer.write_unsigned_char(end::sync_char_2);
73
74 return result;
75}
76
77} // namespace sirf
78} // namespace providers
79} // namespace location
80
81#endif // LOCATION_PROVIDERS_SIRF_CODEC_H_
082
=== added file 'src/location/providers/sirf/dop.h'
--- src/location/providers/sirf/dop.h 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/dop.h 2017-05-05 09:37:41 +0000
@@ -0,0 +1,64 @@
1// Copyright (C) 2016 Thomas Voss <thomas.voss.bochum@gmail.com>
2//
3// This library is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Lesser General Public License as published
5// by the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef LOCATION_PROVIDERS_SIRF_DOP_H_
16#define LOCATION_PROVIDERS_SIRF_DOP_H_
17
18namespace location
19{
20namespace providers
21{
22namespace sirf
23{
24namespace tag
25{
26
27struct Horizontal
28{
29};
30struct Positional
31{
32};
33struct Vertical
34{
35};
36
37} // namespace tag
38
39template <typename T>
40struct DillusionOfPrecision
41{
42 explicit DillusionOfPrecision(float value = -1) : value{value} {}
43
44 DillusionOfPrecision(const DillusionOfPrecision<T>& rhs) : value{rhs.value} {}
45
46 DillusionOfPrecision& operator=(const DillusionOfPrecision<T>& rhs)
47 {
48 value = rhs.value;
49 return *this;
50 }
51
52 operator float() const { return value; }
53
54 float value;
55};
56
57template <typename T>
58using Dop = DillusionOfPrecision<T>;
59
60} // namespace sirf
61} // namespace providers
62} // namespace location
63
64#endif // LOCATION_PROVIDERS_SIRF_DOP_H_
065
=== added file 'src/location/providers/sirf/geodetic_navigation_data.h'
--- src/location/providers/sirf/geodetic_navigation_data.h 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/geodetic_navigation_data.h 2017-05-05 09:37:41 +0000
@@ -0,0 +1,213 @@
1// Copyright (C) 2017 Thomas Voss <thomas.voss@canonical.com>
2//
3// This library is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Lesser General Public License as published
5// by the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16#ifndef LOCATION_PROVIDERS_SIRF_GEODETIC_NAVIGATION_DATA_H_
17#define LOCATION_PROVIDERS_SIRF_GEODETIC_NAVIGATION_DATA_H_
18
19#include <location/providers/sirf/reader.h>
20
21#include <cstdint>
22#include <iostream>
23
24namespace location
25{
26namespace providers
27{
28namespace sirf
29{
30
31struct GeodeticNavigationData
32{
33 enum NavValid
34 {
35 valid_navigation = 0,
36 solution_not_overdetermined = 1 << 0,
37 invalid_dr_sensor_data = 1 << 3,
38 invalid_dr_calibration = 1 << 4,
39 unavailable_dr_gps_calibration = 1 << 5,
40 invalid_dr_position_fix = 1 << 6,
41 invalid_heading = 1 << 7,
42 no_tracker_data_available = 1 << 15
43 };
44
45 enum NavType
46 {
47 no_navigation_fix = 0,
48 one_sv_kf_solution = 1,
49 two_sv_kf_solution = 2,
50 three_sv_kf_solution = 3,
51 four_sv_kf_solution = 4,
52 two_dim_least_squares_solution = 5,
53 three_dim_least_squares_solution = 6,
54 dr_solution = 7,
55 trickle_power_in_use = 1 << 3,
56 altitude_hold_off = 0,
57 altitude_hold_kf = 1,
58 altitude_hold_user_input = 2,
59 altitude_hold_user_input_always = 3,
60 dop_limits_exceeded = 1 << 6,
61 dgps_corrections_applied = 1 << 7,
62 dr_solution_type_sensor = 1,
63 dr_solution_type_velocity = 0,
64 navigation_solution_overdetermined = 1 << 9,
65 velocity_dr_timeout_exceeded = 1 << 10,
66 fix_edited_by_mi_functions = 1 << 11,
67 invalid_velocity = 1 << 12,
68 altitude_hold_disabled = 1 << 13,
69
70 };
71
72 static constexpr std::uint8_t id{0x29};
73
74 std::size_t size() const
75 {
76 return 91;
77 }
78
79 void read(Reader& reader)
80 {
81 nav_valid = reader.read_unsigned_short();
82 nav_type = reader.read_unsigned_short();
83 extended_week_number = reader.read_unsigned_short();
84 time_of_week = reader.read_unsigned_long();
85 utc.year = reader.read_unsigned_short();
86 utc.month = reader.read_unsigned_char();
87 utc.day = reader.read_unsigned_char();
88 utc.hour = reader.read_unsigned_char();
89 utc.minute = reader.read_unsigned_char();
90 utc.seconds = reader.read_unsigned_short();
91 satellite_id_list = reader.read_unsigned_long();
92 latitude = reader.read_signed_long() * 1e-7;
93 longitude = reader.read_signed_long() * 1e-7;
94 altitude.above_ellipsoid = reader.read_signed_long() * 1e-2;
95 altitude.above_mean_sea_level = reader.read_signed_long() * 1e-2;
96 map_datum = reader.read_signed_char();
97 over_ground.speed = reader.read_unsigned_short() * 1e-2;
98 over_ground.course = reader.read_unsigned_short() * 1e-2;
99 magnetic_variation = reader.read_signed_short();
100 climb_rate = reader.read_signed_short() * 1e-2;
101 heading_rate = reader.read_signed_short() * 1e-2;
102 error.horizontal_position = reader.read_unsigned_long() * 1e-2;
103 error.vertical_position = reader.read_unsigned_long() * 1e-2;
104 error.time = reader.read_unsigned_long() * 1e-2;
105 error.horizontal_velocity = reader.read_unsigned_short() * 1e-2;
106 clock.bias = reader.read_signed_long() * 1e-2;
107 clock.bias_error = reader.read_unsigned_long() * 1e-2;
108 clock.drift = reader.read_signed_long() * 1e-2;
109 clock.drift_error = reader.read_unsigned_long() * 1e-2;
110 distance_traveled = reader.read_unsigned_long();
111 distance_traveled_error = reader.read_unsigned_short();
112 error.heading = reader.read_unsigned_short() * 1e-2;
113 svs_in_fix = reader.read_unsigned_char();
114 hdop = reader.read_unsigned_char() / 5.f;
115 mode_info = reader.read_unsigned_char();
116 }
117
118 std::uint16_t nav_valid;
119 std::uint16_t nav_type;
120 std::uint16_t extended_week_number;
121 std::uint32_t time_of_week;
122 struct
123 {
124 std::uint16_t year;
125 std::uint8_t month;
126 std::uint8_t day;
127 std::uint8_t hour;
128 std::uint8_t minute;
129 std::uint16_t seconds;
130 } utc;
131 std::uint32_t satellite_id_list;
132 float latitude;
133 float longitude;
134 struct
135 {
136 float above_ellipsoid;
137 float above_mean_sea_level;
138 } altitude;
139 std::int8_t map_datum;
140 struct
141 {
142 std::uint16_t speed;
143 std::uint16_t course;
144 } over_ground;
145 std::int16_t magnetic_variation;
146 float climb_rate;
147 float heading_rate;
148 struct
149 {
150 float horizontal_position;
151 float vertical_position;
152 float time;
153 float horizontal_velocity;
154 float heading;
155 } error;
156 struct
157 {
158 float bias;
159 float bias_error;
160 float drift;
161 float drift_error;
162 } clock;
163 std::uint32_t distance_traveled;
164 std::uint32_t distance_traveled_error;
165 std::uint8_t svs_in_fix;
166 std::uint8_t hdop;
167 std::uint8_t mode_info;
168};
169
170inline std::ostream& operator<<(std::ostream& out, const GeodeticNavigationData& gnd)
171{
172 return out << "GeodeticNavigationData:" << std::endl
173 << " nav-valid: " << gnd.nav_valid << std::endl
174 << " nav-type: " << gnd.nav_type << std::endl
175 << " extended-week-number: " << gnd.extended_week_number << std::endl
176 << " time-of-week: " << gnd.time_of_week << std::endl
177 << " utc.year: " << gnd.utc.year << std::endl
178 << " utc.month: " << std::uint32_t(gnd.utc.month) << std::endl
179 << " utc.day: " << std::uint32_t(gnd.utc.day) << std::endl
180 << " utc.hour: " << std::uint32_t(gnd.utc.hour) << std::endl
181 << " utc.minute: " << std::uint32_t(gnd.utc.minute) << std::endl
182 << " utc.seconds: " << gnd.utc.seconds << std::endl
183 << " satellite-id-list: " << gnd.satellite_id_list << std::endl
184 << " latitude: " << gnd.latitude << std::endl
185 << " longitude: " << gnd.longitude << std::endl
186 << " altitude.above-ellipsoid: " << gnd.altitude.above_ellipsoid << std::endl
187 << " altitude.above-msl: " << gnd.altitude.above_mean_sea_level << std::endl
188 << " map-datum: " << std::int32_t(gnd.map_datum) << std::endl
189 << " over-ground.speed: " << gnd.over_ground.speed << std::endl
190 << " over-ground.course: " << gnd.over_ground.course << std::endl
191 << " climb-rate: " << gnd.climb_rate << std::endl
192 << " heading-rate: " << gnd.heading_rate << std::endl
193 << " error.horizontal-position: " << gnd.error.horizontal_position << std::endl
194 << " error.vertical-position: " << gnd.error.vertical_position << std::endl
195 << " error.time: " << gnd.error.time << std::endl
196 << " error.horizontal-velocity: " << gnd.error.horizontal_velocity << std::endl
197 << " error.heading: " << gnd.error.heading << std::endl
198 << " clock.bias: " << gnd.clock.bias << std::endl
199 << " clock.bias-error: " << gnd.clock.bias_error << std::endl
200 << " clock.drift: " << gnd.clock.drift << std::endl
201 << " clock.drift-error: " << gnd.clock.drift_error << std::endl
202 << " distance-traveled: " << gnd.distance_traveled << std::endl
203 << " distance-traveled-error: " << gnd.distance_traveled_error << std::endl
204 << " svs-in-fix: " << std::uint32_t(gnd.svs_in_fix) << std::endl
205 << " hdop: " << std::uint32_t(gnd.hdop) << std::endl
206 << " mode-info: " << std::uint32_t(gnd.mode_info);
207}
208
209} // namespace sirf
210} // namespace providers
211} // namespace location
212
213#endif // LOCATION_PROVIDERS_SIRF_GEODETIC_NAVIGATION_DATA_H_
0214
=== added file 'src/location/providers/sirf/initialize_data_source.h'
--- src/location/providers/sirf/initialize_data_source.h 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/initialize_data_source.h 2017-05-05 09:37:41 +0000
@@ -0,0 +1,93 @@
1// Copyright (C) 2017 Thomas Voss <thomas.voss@canonical.com>
2//
3// This library is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Lesser General Public License as published
5// by the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16#ifndef LOCATION_PROVIDERS_SIRF_INITIALIZE_DATA_SOURCE_H_
17#define LOCATION_PROVIDERS_SIRF_INITIALIZE_DATA_SOURCE_H_
18
19#include <location/providers/sirf/writer.h>
20
21#include <cstdint>
22#include <iostream>
23
24namespace location
25{
26namespace providers
27{
28namespace sirf
29{
30
31struct InitializeDataSource
32{
33 enum ResetConfiguration
34 {
35 data_valid = 1 << 0,
36 clear_ephemeris_data = 1 << 1,
37 clear_all_history = 1 << 2,
38 factory_reset = 1 << 3,
39 enable_nav_lib_data = 1 << 4,
40 enable_debug_data = 1 << 5,
41 rtc_is_not_precise = 1 << 6,
42 reset = 1 << 7
43 };
44
45 static constexpr std::uint8_t id{128};
46 static constexpr std::uint8_t max_number_channels{12};
47
48 std::size_t size() const
49 {
50 return 25;
51 }
52
53 void write(Writer& writer) const
54 {
55 writer.write_unsigned_char(id);
56 writer.write_signed_long(ecef_x);
57 writer.write_signed_long(ecef_y);
58 writer.write_signed_long(ecef_z);
59 writer.write_signed_long(clock_drift);
60 writer.write_unsigned_long(ecef_x);
61 writer.write_unsigned_short(week_number);
62 writer.write_unsigned_char(channels);
63 writer.write_unsigned_char(reset_configuration);
64 }
65
66 std::int32_t ecef_x;
67 std::int32_t ecef_y;
68 std::int32_t ecef_z;
69 std::int32_t clock_drift;
70 std::uint32_t time_of_week;
71 std::uint16_t week_number;
72 std::uint8_t channels;
73 std::uint8_t reset_configuration;
74};
75
76inline std::ostream& operator<<(std::ostream& out, const InitializeDataSource& ids)
77{
78 return out << "InitializeDataSource:" << std::endl
79 << " ecef-x: " << ids.ecef_x << std::endl
80 << " ecef-y: " << ids.ecef_y << std::endl
81 << " ecef-z: " << ids.ecef_z << std::endl
82 << " clock-drift: " << ids.clock_drift << std::endl
83 << " time-of-week: " << ids.time_of_week << std::endl
84 << " week_number: " << ids.week_number << std::endl
85 << " channels: " << std::uint32_t(ids.channels) << std::endl
86 << " reset-config: " << std::uint32_t(ids.reset_configuration) << std::endl;
87}
88
89} // namespace sirf
90} // namespace providers
91} // namespace location
92
93#endif // LOCATION_PROVIDERS_SIRF_INITIALIZE_DATA_SOURCE_H_
094
=== added file 'src/location/providers/sirf/magic.h'
--- src/location/providers/sirf/magic.h 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/magic.h 2017-05-05 09:37:41 +0000
@@ -0,0 +1,43 @@
1// Copyright (C) 2016 Thomas Voss <thomas.voss.bochum@gmail.com>
2//
3// This library is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Lesser General Public License as published
5// by the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16#ifndef LOCATION_PROVIDERS_SIRF_MAGIC_H_
17#define LOCATION_PROVIDERS_SIRF_MAGIC_H_
18
19namespace location
20{
21namespace providers
22{
23namespace sirf
24{
25namespace begin
26{
27
28constexpr const std::uint8_t sync_char_1{0xa0};
29constexpr const std::uint8_t sync_char_2{0xa2};
30
31} // namespace begin
32namespace end
33{
34
35constexpr const std::uint8_t sync_char_1{0xb0};
36constexpr const std::uint8_t sync_char_2{0xb3};
37
38} // namespace end
39} // namespace sirf
40} // namespace providers
41} // namespace location
42
43#endif // LOCATION_PROVIDERS_SIRF_MAGIC_H_
044
=== added file 'src/location/providers/sirf/message.h'
--- src/location/providers/sirf/message.h 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/message.h 2017-05-05 09:37:41 +0000
@@ -0,0 +1,53 @@
1// Copyright (C) 2016 Thomas Voss <thomas.voss.bochum@gmail.com>
2//
3// This library is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Lesser General Public License as published
5// by the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16#ifndef LOCATION_PROVIDERS_SIRF_MESSAGE_H_
17#define LOCATION_PROVIDERS_SIRF_MESSAGE_H_
18
19#include <location/providers/sirf/geodetic_navigation_data.h>
20#include <location/providers/sirf/initialize_data_source.h>
21#include <location/providers/sirf/set_protocol.h>
22
23#include <boost/variant.hpp>
24
25#include <iostream>
26
27namespace location
28{
29namespace providers
30{
31namespace sirf
32{
33
34struct Null {};
35
36using Message = boost::variant<
37 Null,
38 InitializeDataSource,
39 GeodeticNavigationData,
40 SetProtocol
41>;
42
43inline std::ostream& operator<<(std::ostream& out, const Null&)
44{
45 return out << "Uninterpreted sirf message";
46}
47
48
49} // namespace sirf
50} // namespace providers
51} // namespace location
52
53#endif // LOCATION_PROVIDERS_SIRF_MESSAGE_H_
054
=== added file 'src/location/providers/sirf/provider.cpp'
--- src/location/providers/sirf/provider.cpp 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/provider.cpp 2017-05-05 09:37:41 +0000
@@ -0,0 +1,353 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18
19#include <location/providers/sirf/provider.h>
20
21#include <location/logging.h>
22#include <location/runtime.h>
23#include <location/events/reference_position_updated.h>
24#include <location/glib/runtime.h>
25
26#include <core/net/http/client.h>
27#include <core/posix/this_process.h>
28
29#include <boost/lexical_cast.hpp>
30
31#include <fstream>
32#include <iostream>
33#include <iterator>
34#include <thread>
35
36namespace env = core::posix::this_process::env;
37namespace sirf = location::providers::sirf;
38
39namespace
40{
41
42struct SettingsHelper
43{
44 template<typename T>
45 static T get_value(std::string key, T&& default_value)
46 {
47 static const std::string snap_path = env::get("SNAP_DATA");
48
49 boost::filesystem::path path{snap_path};
50 std::replace(key.begin(), key.end(), '.', '/');
51 path /= key;
52
53 LOG(INFO) << "Reading setting from " << path.string();
54
55 std::ifstream in{path.string().c_str()};
56 T value{default_value}; in >> value;
57
58 return value;
59 }
60};
61
62}
63
64std::string sirf::Provider::class_name()
65{
66 return "sirf::Provider";
67}
68
69void sirf::Provider::Monitor::on_new_sirf_message(const Message& message)
70{
71 VLOG(1) << message;
72 if (auto sp = provider.lock())
73 if (sp->configuration.protocol == Provider::Protocol::sirf)
74 boost::apply_visitor(*this, message);
75}
76
77
78void sirf::Provider::Monitor::on_new_nmea_sentence(const nmea::Sentence& sentence)
79{
80 VLOG(1) << sentence;
81 if (auto sp = provider.lock())
82 if (sp->configuration.protocol == Provider::Protocol::nmea)
83 boost::apply_visitor(*this, sentence);
84}
85
86void sirf::Provider::Monitor::operator()(const sirf::GeodeticNavigationData& gnd)
87{
88 auto thiz = shared_from_this();
89 std::weak_ptr<sirf::Provider::Monitor> wp{thiz};
90
91 glib::Runtime::instance()->dispatch([gnd, wp]()
92 {
93 if (auto sp = wp.lock())
94 {
95 if (auto spp = sp->provider.lock())
96 {
97 if (gnd.nav_valid == GeodeticNavigationData::valid_navigation)
98 {
99 Position position
100 {
101 gnd.latitude * units::degrees,
102 gnd.longitude * units::degrees
103 };
104 position.accuracy().horizontal(gnd.error.horizontal_position * units::meters);
105
106 position.altitude(gnd.altitude.above_mean_sea_level * units::meters);
107 position.accuracy().vertical(gnd.error.vertical_position * units::meters);
108
109 spp->updates.position(location::Update<location::Position>{position});
110 if (!(gnd.nav_type & GeodeticNavigationData::invalid_heading))
111 spp->updates.heading(location::Update<units::Degrees>{gnd.over_ground.course * units::degrees});
112 if (!(gnd.nav_type & GeodeticNavigationData::invalid_velocity))
113 spp->updates.velocity(location::Update<units::MetersPerSecond>{gnd.over_ground.speed * units::meters_per_second});
114 }
115 }
116 }
117 });
118}
119
120void sirf::Provider::Monitor::operator()(const nmea::Gga& gga)
121{
122 if (gga.latitude && gga.longitude)
123 {
124 auto lat = gga.latitude.get();
125 auto lon = gga.longitude.get();
126
127 Position position
128 {
129 (lat.degrees + lat.minutes / 60.f) * units::degrees,
130 (lon.degrees + lon.minutes / 60.f) * units::degrees
131 };
132
133 if (gga.altitude)
134 position.altitude(units::Meters::from_value(*gga.altitude));
135
136 // TODO(tvoss): Maximum accuracy should be reported by the receiver
137 // implementation rather than hardcoding 3 [m] here.
138 if (gga.hdop)
139 position.accuracy().horizontal(gga.hdop.get() * 3. * units::meters);
140
141 auto thiz = shared_from_this();
142 std::weak_ptr<sirf::Provider::Monitor> wp{thiz};
143
144 glib::Runtime::instance()->dispatch([position, wp]()
145 {
146 if (auto sp = wp.lock())
147 if (auto spp = sp->provider.lock())
148 spp->updates.position(location::Update<location::Position>{position});
149 });
150 }
151}
152
153void sirf::Provider::Monitor::operator()(const nmea::Gsa&)
154{
155 // Empty on purpose
156}
157
158void sirf::Provider::Monitor::operator()(const nmea::Gll&)
159{
160 // Empty on purpose
161}
162
163void sirf::Provider::Monitor::operator()(const nmea::Gsv&)
164{
165 // Empty on purpose
166}
167
168void sirf::Provider::Monitor::operator()(const nmea::Rmc&)
169{
170 // Empty on purpose
171}
172
173void sirf::Provider::Monitor::operator()(const nmea::Txt&)
174{
175 // Empty on purpose
176}
177
178void sirf::Provider::Monitor::operator()(const nmea::Vtg& vtg)
179{
180 auto thiz = shared_from_this();
181 std::weak_ptr<sirf::Provider::Monitor> wp{thiz};
182
183 glib::Runtime::instance()->dispatch([vtg, wp]()
184 {
185 if (auto sp = wp.lock())
186 {
187 if (vtg.cog_true)
188 if (auto spp = sp->provider.lock())
189 spp->updates.heading(
190 Update<units::Degrees>(
191 vtg.cog_true.get() * units::degrees));
192 if (vtg.sog_kmh)
193 if (auto spp = sp->provider.lock())
194 spp->updates.velocity(
195 Update<units::MetersPerSecond>(
196 vtg.sog_kmh.get() * 1000./3600. * units::meters_per_second));
197 }
198 });
199}
200
201location::Provider::Ptr sirf::Provider::create_instance(const location::ProviderFactory::Configuration& config)
202{
203 Configuration configuration
204 {
205 SettingsHelper::get_value<Protocol>(
206 "sirf.provider.protocol",
207 Protocol::sirf),
208 config.get<std::string>(
209 "device", SettingsHelper::get_value<std::string>(
210 "sirf.provider.path",
211 "/dev/ttyUSB1"
212 )
213 )
214 };
215
216 return sirf::Provider::create(configuration);
217}
218
219// Create a new instance with configuration.
220std::shared_ptr<sirf::Provider> sirf::Provider::create(const Configuration& configuration)
221{
222 auto sp = std::shared_ptr<Provider>{new Provider{configuration}};
223 return sp->finalize_construction();
224}
225
226
227sirf::Provider::Provider(const Configuration& configuration)
228 : configuration{configuration},
229 runtime{location::Runtime::create(1)},
230 monitor{std::make_shared<Monitor>()},
231 receiver{SerialPortReceiver::create(runtime->service(), configuration.device, monitor)}
232{
233 runtime->start();
234 configure_protocol();
235}
236
237sirf::Provider::~Provider() noexcept
238{
239 deactivate();
240 runtime->stop();
241}
242
243void sirf::Provider::reset()
244{
245 InitializeDataSource ids;
246 ids.channels = InitializeDataSource::max_number_channels;
247 ids.reset_configuration = InitializeDataSource::clear_ephemeris_data | InitializeDataSource::clear_all_history;
248 receiver->send_message(Message{ids});
249}
250
251void sirf::Provider::on_new_event(const Event&)
252{
253 // TODO(tvoss): Use incoming reference position updates
254 // to query assistance data.
255}
256
257location::Provider::Requirements sirf::Provider::requirements() const
258{
259 return Requirements::none;
260}
261
262bool sirf::Provider::satisfies(const location::Criteria&)
263{
264 return true;
265}
266
267void sirf::Provider::enable()
268{
269}
270
271void sirf::Provider::disable()
272{
273}
274
275void sirf::Provider::activate()
276{
277 receiver->start();
278}
279
280void sirf::Provider::deactivate()
281{
282 receiver->stop();
283}
284
285const core::Signal<location::Update<location::Position>>& sirf::Provider::position_updates() const
286{
287 return updates.position;
288}
289
290const core::Signal<location::Update<location::units::Degrees>>& sirf::Provider::heading_updates() const
291{
292 return updates.heading;
293}
294
295const core::Signal<location::Update<location::units::MetersPerSecond>>& sirf::Provider::velocity_updates() const
296{
297 return updates.velocity;
298}
299
300std::shared_ptr<sirf::Provider> sirf::Provider::finalize_construction()
301{
302 auto thiz = shared_from_this();
303 std::weak_ptr<sirf::Provider> wp{thiz};
304
305 monitor->provider = wp;
306 return thiz;
307}
308
309void sirf::Provider::configure_protocol()
310{
311 switch(configuration.protocol)
312 {
313 case Protocol::sirf:
314 {
315 static const std::string set_serial_port{"$PSRF100,0,4800,8,1,0*0F\r\n"};
316 receiver->send_encoded_message(std::vector<std::uint8_t>{set_serial_port.begin(), set_serial_port.end()});
317 break;
318 }
319 case Protocol::nmea:
320 receiver->send_message(Message{SetProtocol{SetProtocol::nmea}});
321 break;
322 default:
323 break;
324 }
325}
326
327std::istream& sirf::operator>>(std::istream& in, Provider::Protocol& protocol)
328{
329 std::string value;
330 in >> value;
331
332 if (value == "sirf")
333 protocol = Provider::Protocol::sirf;
334 if (value == "nmea")
335 protocol = Provider::Protocol::nmea;
336
337 return in;
338}
339
340std::ostream& sirf::operator<<(std::ostream& out, Provider::Protocol protocol)
341{
342 switch (protocol)
343 {
344 case Provider::Protocol::sirf:
345 out << "sirf";
346 break;
347 case Provider::Protocol::nmea:
348 out << "nmea";
349 break;
350 }
351
352 return out;
353}
0354
=== added file 'src/location/providers/sirf/provider.h'
--- src/location/providers/sirf/provider.h 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/provider.h 2017-05-05 09:37:41 +0000
@@ -0,0 +1,143 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18#ifndef LOCATION_PROVIDERS_SIRF_PROVIDER_H_
19#define LOCATION_PROVIDERS_SIRF_PROVIDER_H_
20
21#include <location/provider.h>
22#include <location/provider_factory.h>
23#include <location/runtime.h>
24#include <location/nmea/sentence.h>
25#include <location/providers/sirf/serial_port_receiver.h>
26
27#include <boost/filesystem.hpp>
28
29#include <iosfwd>
30#include <thread>
31
32namespace location
33{
34namespace providers
35{
36namespace sirf
37{
38// sirf::Provider integrates GNSS receivers relying on
39// ublox chipsets with locationd.
40//
41// In this version, only receivers connected to a serial port
42// are supported. More to this, this version only reads NMEA sentences
43// and does not support the proprietary ublox protocol.
44//
45// Configuration parameters:
46// - device[=/dev/ttyUSB1] serial device connecting to the receiver.
47class Provider : public location::Provider, public std::enable_shared_from_this<Provider>
48{
49public:
50 enum class Protocol
51 {
52 sirf, // Rely on sirf.
53 nmea // Rely on nmea.
54 };
55
56 // Configuration bundles all construction time parameters.
57 struct Configuration
58 {
59 Protocol protocol; // The protocol used for communicating with the receiver.
60 boost::filesystem::path device; // Serial device used for communicating with the receiver.
61 };
62
63 // For integration with the Provider factory.
64 static std::string class_name();
65 // Instantiates a new provider instance, populating the configuration object
66 // from the provided property bundle. Please see dummy::Configuration::Keys
67 // for the list of known options.
68 static Provider::Ptr create_instance(const ProviderFactory::Configuration&);
69
70 // Create a new instance with configuration.
71 static std::shared_ptr<Provider> create(const Configuration& configuration);
72
73 // Cleans up all resources and stops the updates.
74 ~Provider() noexcept;
75
76 // Resets the chipset and drops all cached data.
77 // The next positioning request will be a cold start.
78 void reset();
79
80 // From Provider
81 void on_new_event(const Event& event) override;
82
83 void enable() override;
84 void disable() override;
85 void activate() override;
86 void deactivate() override;
87
88 Requirements requirements() const override;
89 bool satisfies(const Criteria& criteria) override;
90 const core::Signal<Update<Position>>& position_updates() const override;
91 const core::Signal<Update<units::Degrees>>& heading_updates() const override;
92 const core::Signal<Update<units::MetersPerSecond>>& velocity_updates() const override;
93
94private:
95 // Relays incoming sentences to a provider instance.
96 struct Monitor : public std::enable_shared_from_this<sirf::Provider::Monitor>, public sirf::Receiver::Monitor, public boost::static_visitor<>
97 {
98 // From Receiver::Monitor
99 void on_new_sirf_message(const Message& message) override;
100 void on_new_nmea_sentence(const nmea::Sentence& sentence) override;
101
102 template<typename T>
103 void operator()(const T&) const {}
104
105 void operator()(const GeodeticNavigationData& gnd);
106
107 void operator()(const nmea::Gga& gga);
108 void operator()(const nmea::Gsa& gsa);
109 void operator()(const nmea::Gll& gll);
110 void operator()(const nmea::Gsv& gsv);
111 void operator()(const nmea::Rmc& rmc);
112 void operator()(const nmea::Txt& txt);
113 void operator()(const nmea::Vtg& vtg);
114
115 std::weak_ptr<Provider> provider;
116 };
117
118 // Creates a new provider instance talking via device to the ubx chipset.
119 Provider(const Configuration& configuration);
120
121 std::shared_ptr<Provider> finalize_construction();
122 void configure_protocol();
123
124 Configuration configuration;
125 std::shared_ptr<location::Runtime> runtime;
126 std::shared_ptr<Monitor> monitor;
127 std::shared_ptr<SerialPortReceiver> receiver;
128 struct
129 {
130 core::Signal<Update<Position>> position;
131 core::Signal<Update<units::Degrees>> heading;
132 core::Signal<Update<units::MetersPerSecond>> velocity;
133 } updates;
134};
135
136std::istream& operator>>(std::istream&, Provider::Protocol&);
137std::ostream& operator<<(std::ostream&, Provider::Protocol);
138
139} // namespace sirf
140} // namespace providers
141} // namespace location
142
143#endif // LOCATION_PROVIDERS_SIRF_PROVIDER_H_
0144
=== added file 'src/location/providers/sirf/reader.cpp'
--- src/location/providers/sirf/reader.cpp 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/reader.cpp 2017-05-05 09:37:41 +0000
@@ -0,0 +1,87 @@
1// Copyright (C) 2016 Thomas Voss <thomas.voss.bochum@gmail.com>
2//
3// This library is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Lesser General Public License as published
5// by the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16#include <location/providers/sirf/reader.h>
17
18#include <arpa/inet.h>
19
20#include <cstring>
21#include <stdexcept>
22
23namespace sirf = location::providers::sirf;
24
25sirf::Reader::Reader(std::vector<std::uint8_t>::const_iterator begin,
26 std::vector<std::uint8_t>::const_iterator end)
27 : begin{begin}, current{begin}, end{end} {}
28
29std::uint8_t sirf::Reader::read_unsigned_char()
30{
31 if (current + sizeof(std::uint8_t) > end)
32 throw std::out_of_range{"Read buffer exhausted"};
33
34 auto result = *current;
35 ++current;
36 return result;
37}
38
39std::int8_t sirf::Reader::read_signed_char()
40{
41 if (current + sizeof(std::int8_t) > end)
42 throw std::out_of_range{"Read buffer exhausted"};
43
44 auto result = reinterpret_cast<const std::int8_t*>(&(*current));
45 current += sizeof(std::int8_t);
46 return *result;
47}
48
49std::uint16_t sirf::Reader::read_unsigned_short()
50{
51 if (current + sizeof(std::uint16_t) > end)
52 throw std::out_of_range{"Read buffer exhausted"};
53
54 auto result = reinterpret_cast<const std::uint16_t*>(&(*current));
55 current += sizeof(std::uint16_t);
56 return ::htons(*result);
57}
58
59std::int16_t sirf::Reader::read_signed_short()
60{
61 if (current + sizeof(std::int16_t) > end)
62 throw std::out_of_range{"Read buffer exhausted"};
63
64 auto result = reinterpret_cast<const std::int16_t*>(&(*current));
65 current += sizeof(std::int16_t);
66 return ::htons(*result);
67}
68
69std::uint32_t sirf::Reader::read_unsigned_long()
70{
71 if (current + sizeof(std::uint32_t) > end)
72 throw std::out_of_range{"Read buffer exhausted"};
73
74 auto result = reinterpret_cast<const std::uint32_t*>(&(*current));
75 current += sizeof(std::uint32_t);
76 return ::htonl(*result);
77}
78
79std::int32_t sirf::Reader::read_signed_long()
80{
81 if (current + sizeof(std::int32_t) > end)
82 throw std::out_of_range{"Read buffer exhausted"};
83
84 auto result = reinterpret_cast<const std::int32_t*>(&(*current));
85 current += sizeof(std::int32_t);
86 return ::htonl(*result);
87}
088
=== added file 'src/location/providers/sirf/reader.h'
--- src/location/providers/sirf/reader.h 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/reader.h 2017-05-05 09:37:41 +0000
@@ -0,0 +1,52 @@
1// Copyright (C) 2016 Thomas Voss <thomas.voss.bochum@gmail.com>
2//
3// This library is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Lesser General Public License as published
5// by the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16#ifndef LOCATION_PROVIDERS_SIRF_READER_H_
17#define LOCATION_PROVIDERS_SIRF_READER_H_
18
19#include <cstdint>
20#include <vector>
21
22namespace location
23{
24namespace providers
25{
26namespace sirf
27{
28
29class Reader
30{
31public:
32 explicit Reader(std::vector<std::uint8_t>::const_iterator begin,
33 std::vector<std::uint8_t>::const_iterator end);
34
35 std::uint8_t read_unsigned_char();
36 std::int8_t read_signed_char();
37 std::uint16_t read_unsigned_short();
38 std::int16_t read_signed_short();
39 std::uint32_t read_unsigned_long();
40 std::int32_t read_signed_long();
41
42private:
43 std::vector<std::uint8_t>::const_iterator begin;
44 std::vector<std::uint8_t>::const_iterator current;
45 std::vector<std::uint8_t>::const_iterator end;
46};
47
48} // namespace sirf
49} // namespace providers
50} // namespace location
51
52#endif // LOCATION_PROVIDERS_SIRF_READER_H_
053
=== added file 'src/location/providers/sirf/receiver.cpp'
--- src/location/providers/sirf/receiver.cpp 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/receiver.cpp 2017-05-05 09:37:41 +0000
@@ -0,0 +1,80 @@
1#include <location/providers/sirf/receiver.h>
2
3#include <location/nmea/sentence.h>
4#include <location/providers/sirf/message.h>
5
6#include <iostream>
7
8namespace sirf = location::providers::sirf;
9
10namespace
11{
12
13struct EncodingVisitor : public boost::static_visitor<std::vector<std::uint8_t>>
14{
15 template<typename T>
16 std::vector<std::uint8_t> operator()(const T&) const
17 {
18 throw std::logic_error{"Encoding not supported"};
19 }
20
21 std::vector<std::uint8_t> operator()(const sirf::InitializeDataSource& ids) const
22 {
23 return sirf::encode_message(ids);
24 }
25
26 std::vector<std::uint8_t> operator()(const sirf::SetProtocol& sp) const
27 {
28 return sirf::encode_message(sp);
29 }
30};
31
32} // namespace
33
34sirf::Receiver::Receiver(const std::shared_ptr<Monitor>& monitor) : monitor{monitor} {}
35
36void sirf::Receiver::send_message(const Message& message)
37{
38 send_encoded_message(boost::apply_visitor(EncodingVisitor{}, message));
39}
40
41void sirf::Receiver::process_chunk(Buffer::iterator it, Buffer::iterator itE)
42{
43 while (it != itE)
44 {
45 auto result = sirf_scanner.update(*it);
46
47 if (std::get<0>(result) == Scanner::Expect::nothing_more)
48 {
49 try
50 {
51 monitor->on_new_sirf_message(sirf_scanner.finalize());
52 }
53 catch (...)
54 {
55 // Dropping the exception as there is hardly any reasonable measure
56 // we can take. Both scanners are designed to recover from issues, and we
57 // we just trap the exception here to guarantee that we keep on consuming the
58 // entire buffer.
59 }
60 }
61 else if (!std::get<1>(result))
62 {
63 if (nmea::Scanner::Expect::nothing_more == nmea_scanner.update(*it))
64 {
65 try
66 {
67 monitor->on_new_nmea_sentence(nmea::parse_sentence(nmea_scanner.finalize()));
68 }
69 catch (...)
70 {
71 // Dropping the exception as there is hardly any reasonable measure
72 // we can take. Both scanners are designed to recover from issues, and we
73 // we just trap the exception here to guarantee that we keep on consuming the
74 // entire buffer.
75 }
76 }
77 }
78 ++it;
79 }
80}
081
=== added file 'src/location/providers/sirf/receiver.h'
--- src/location/providers/sirf/receiver.h 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/receiver.h 2017-05-05 09:37:41 +0000
@@ -0,0 +1,92 @@
1// Copyright (C) 2016 Thomas Voss <thomas.voss.bochum@gmail.com>
2//
3// This library is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Lesser General Public License as published
5// by the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16#ifndef LOCATION_PROVIDERS_SIRF_RECEIVER_H_
17#define LOCATION_PROVIDERS_SIRF_RECEIVER_H_
18
19#include <location/providers/sirf/codec.h>
20#include <location/providers/sirf/message.h>
21#include <location/providers/sirf/scanner.h>
22
23#include <location/nmea/scanner.h>
24#include <location/nmea/sentence.h>
25
26#include <memory>
27
28namespace location
29{
30namespace providers
31{
32namespace sirf
33{
34
35/// @brief Receiver connects to a ublox 8 GNSS receiver.
36class Receiver
37{
38public:
39 using Buffer = std::array<std::uint8_t, 4096>;
40
41 /// @brief Monitor provides calling code with means for monitoring
42 /// receiver operation.
43 class Monitor
44 {
45 public:
46 /// @cond
47 Monitor() = default;
48 Monitor(const Monitor&) = delete;
49 Monitor(Monitor&&) = delete;
50 virtual ~Monitor() = default;
51 Monitor& operator=(const Monitor&) = delete;
52 Monitor& operator=(Monitor&&) = delete;
53 /// @endcond
54
55 /// @brief on_new_ubx_message is invoked for every complete and parsed
56 /// ubx message.
57 virtual void on_new_sirf_message(const sirf::Message& message) = 0;
58
59 /// @brief on_new_nmea_sentence is invoked for every complete and parsed
60 /// nmea sentence.
61 virtual void on_new_nmea_sentence(const nmea::Sentence& sentence) = 0;
62 };
63
64 /// @brief send_message encodes and sends 'message' to the receiver.
65 void send_message(const Message& message);
66
67 /// @brief send_encoded_message sends out data to the receiver.
68 virtual void send_encoded_message(const std::vector<std::uint8_t> &data) = 0;
69
70protected:
71 /// @brief Receiver initializes a new instance with monitor
72 ///
73 /// Throws in case of issues.
74 Receiver(const std::shared_ptr<Monitor>& monitor);
75
76 /// @brief process_chunk iterates over the given range, updating scanners and
77 /// parsers.
78 ///
79 /// Calls out to a configured monitor instance for announcing results.
80 void process_chunk(Buffer::iterator it, Buffer::iterator itE);
81
82private:
83 std::shared_ptr<Monitor> monitor;
84 nmea::Scanner nmea_scanner;
85 sirf::Scanner sirf_scanner;
86};
87
88} // namespace sirf
89} // namespace providers
90} // namespace location
91
92#endif // LOCATION_PROVIDERS_SIRF_RECEIVER_H_
093
=== added file 'src/location/providers/sirf/scanner.cpp'
--- src/location/providers/sirf/scanner.cpp 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/scanner.cpp 2017-05-05 09:37:41 +0000
@@ -0,0 +1,161 @@
1// Copyright (C) 2016 Thomas Voss <thomas.voss.bochum@gmail.com>
2//
3// This library is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Lesser General Public License as published
5// by the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16#include <location/providers/sirf/scanner.h>
17
18#include <location/providers/sirf/codec.h>
19#include <location/providers/sirf/magic.h>
20#include <location/providers/sirf/message.h>
21
22#include <cstdint>
23#include <functional>
24#include <iomanip>
25#include <iostream>
26#include <map>
27#include <stdexcept>
28#include <tuple>
29#include <vector>
30
31namespace sirf = location::providers::sirf;
32
33sirf::Scanner::Scanner()
34 : next{Expect::sync_char_begin_1},
35 expected_size{0},
36 message_id{0},
37 payload_iterator{payload.end()},
38 checksum_1{0},
39 checksum_2{0}
40{
41}
42
43std::tuple<sirf::Scanner::Expect, bool> sirf::Scanner::update(std::uint8_t c)
44{
45 bool consumed = false;
46
47 switch (next)
48 {
49 case Expect::sync_char_begin_1:
50 if (c == begin::sync_char_1)
51 {
52 reset();
53 next = Expect::sync_char_begin_2;
54 consumed = true;
55 }
56 break;
57 case Expect::sync_char_begin_2:
58 if (c == begin::sync_char_2)
59 {
60 next = Expect::length_1;
61 consumed = true;
62 }
63 break;
64 case Expect::length_1:
65 expected_size |= (c << 8);
66 next = Expect::length_2;
67 consumed = true;
68 break;
69 case Expect::length_2:
70 expected_size |= c;
71 if (expected_size > 0)
72 expected_size -= 1;
73 payload.resize(expected_size);
74 payload_iterator = payload.begin();
75 next = Expect::message_id;
76 consumed = true;
77 break;
78 case Expect::message_id:
79 checksum(c);
80 message_id = c;
81 next = expected_size > 0 ? Expect::payload : Expect::checksum_1;
82 consumed = true;
83 break;
84 case Expect::payload:
85 checksum(c);
86 *payload_iterator = c;
87 ++payload_iterator;
88 next = payload_iterator == payload.end()
89 ? Expect::checksum_1
90 : next;
91 consumed = true;
92 break;
93 case Expect::checksum_1:
94 checksum_1 = c;
95 next = Expect::checksum_2;
96 consumed = true;
97 break;
98 case Expect::checksum_2:
99 checksum_2 = c;
100 next = Expect::sync_char_end_1;
101 consumed = true;
102 break;
103 case Expect::sync_char_end_1:
104 if (c == end::sync_char_1)
105 {
106 next = Expect::sync_char_end_2;
107 consumed = true;
108 }
109 break;
110 case Expect::sync_char_end_2:
111 if (c == end::sync_char_2)
112 {
113 next = Expect::nothing_more;
114 consumed = true;
115 }
116 break;
117 default:
118 consumed = false;
119 break;
120 }
121
122 return std::make_tuple(next, consumed);
123}
124
125sirf::Message sirf::Scanner::finalize()
126{
127 if (next != Expect::nothing_more)
128 throw std::logic_error{"Not ready for extraction."};
129
130 struct Scope
131 {
132 Scope(Scanner& scanner) : scanner{scanner} {}
133 ~Scope() { scanner.reset(); }
134
135 Scanner& scanner;
136 } scope{*this};
137
138 if (checksum() != ((checksum_1 << 8) | checksum_2))
139 throw std::runtime_error("Failed to verify sirf protocol message integrity.");
140
141 switch (message_id)
142 {
143 case GeodeticNavigationData::id:
144 return decode_message<GeodeticNavigationData>(payload);
145 default:
146 break;
147 }
148
149 return Message{Null{}};
150}
151
152void sirf::Scanner::reset()
153{
154 checksum = Checksum{};
155 next = Expect::sync_char_begin_1;
156 expected_size = 0;
157 message_id = 0;
158 payload.clear();
159 payload_iterator = payload.end();
160 checksum_1 = checksum_2 = 0;
161}
0162
=== added file 'src/location/providers/sirf/scanner.h'
--- src/location/providers/sirf/scanner.h 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/scanner.h 2017-05-05 09:37:41 +0000
@@ -0,0 +1,76 @@
1// Copyright (C) 2016 Thomas Voss <thomas.voss.bochum@gmail.com>
2//
3// This library is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Lesser General Public License as published
5// by the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16#ifndef LOCATION_PROVIDERS_SIRF_SCANNER_H_
17#define LOCATION_PROVIDERS_SIRF_SCANNER_H_
18
19#include <location/providers/sirf/checksum.h>
20#include <location/providers/sirf/message.h>
21
22#include <cstdint>
23#include <tuple>
24#include <vector>
25
26namespace location
27{
28namespace providers
29{
30namespace sirf
31{
32
33class Scanner
34{
35public:
36 /// @brief Expect enumerates the different states of the scanner/parser.
37 enum class Expect
38 {
39 sync_char_begin_1,
40 sync_char_begin_2,
41 length_1,
42 length_2,
43 message_id,
44 payload,
45 checksum_1,
46 checksum_2,
47 sync_char_end_1,
48 sync_char_end_2,
49 nothing_more
50 };
51
52 Scanner();
53
54 std::tuple<Expect, bool> update(std::uint8_t c);
55
56 Message finalize();
57
58private:
59
60 void reset();
61
62 Expect next;
63 Checksum checksum;
64 std::uint16_t expected_size;
65 std::uint8_t message_id;
66 std::vector<uint8_t> payload;
67 std::vector<uint8_t>::iterator payload_iterator;
68 std::uint8_t checksum_1;
69 std::uint8_t checksum_2;
70};
71
72}
73}
74}
75
76#endif // LOCATION_PROVIDERS_SIRF_SCANNER_H_
077
=== added file 'src/location/providers/sirf/serial_port_receiver.cpp'
--- src/location/providers/sirf/serial_port_receiver.cpp 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/serial_port_receiver.cpp 2017-05-05 09:37:41 +0000
@@ -0,0 +1,80 @@
1#include <location/providers/sirf/serial_port_receiver.h>
2
3#include <location/logging.h>
4
5#include <iostream>
6#include <system_error>
7
8namespace sirf = location::providers::sirf;
9
10std::shared_ptr<sirf::SerialPortReceiver> sirf::SerialPortReceiver::create(
11 boost::asio::io_service& ios, const boost::filesystem::path& dev, const std::shared_ptr<Monitor>& monitor)
12{
13 return std::shared_ptr<SerialPortReceiver>{new SerialPortReceiver{ios, dev, monitor}};
14}
15
16sirf::SerialPortReceiver::SerialPortReceiver(boost::asio::io_service& ios, const boost::filesystem::path& dev,
17 const std::shared_ptr<Monitor>& monitor)
18 : Receiver{monitor}, ios{ios}, serial_port{ios, dev.string().c_str()}
19{
20 serial_port.set_option(boost::asio::serial_port::baud_rate(4800));
21 serial_port.set_option(boost::asio::serial_port::stop_bits(boost::asio::serial_port::stop_bits::one));
22 serial_port.set_option(boost::asio::serial_port::parity(boost::asio::serial_port::parity::none));
23 serial_port.set_option(boost::asio::serial_port::flow_control(boost::asio::serial_port::flow_control::none));
24}
25
26void sirf::SerialPortReceiver::send_encoded_message(const std::vector<std::uint8_t>& data)
27{
28 auto thiz = shared_from_this();
29 std::weak_ptr<SerialPortReceiver> wp{thiz};
30
31 ios.dispatch([this, wp, data]()
32 {
33 if (auto sp = wp.lock())
34 boost::asio::write(serial_port, boost::asio::buffer(data), boost::asio::transfer_all());
35 });
36}
37
38void sirf::SerialPortReceiver::start()
39{
40 ::tcflush(serial_port.lowest_layer().native_handle(), TCIFLUSH);
41 start_read();
42}
43
44void sirf::SerialPortReceiver::stop()
45{
46 serial_port.cancel();
47}
48
49void sirf::SerialPortReceiver::start_read()
50{
51 auto thiz = shared_from_this();
52 std::weak_ptr<SerialPortReceiver> wp{thiz};
53
54 boost::asio::async_read(serial_port, boost::asio::buffer(&buffer.front(), buffer.size()),
55 [this, wp](const boost::system::error_code& ec, std::size_t transferred) {
56 if (ec == boost::asio::error::operation_aborted)
57 return;
58
59 if (auto sp = wp.lock())
60 {
61 if (not ec)
62 {
63 try
64 {
65 process_chunk(buffer.begin(), buffer.begin() + transferred);
66 }
67 catch(const std::exception& e)
68 {
69 LOG(WARNING) << "Error processing data chunk: " << e.what();
70 }
71 catch(...)
72 {
73 LOG(WARNING) << "Error processing data chunk.";
74 }
75
76 start_read();
77 }
78 }
79 });
80}
081
=== added file 'src/location/providers/sirf/serial_port_receiver.h'
--- src/location/providers/sirf/serial_port_receiver.h 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/serial_port_receiver.h 2017-05-05 09:37:41 +0000
@@ -0,0 +1,79 @@
1// Copyright (C) 2016 Thomas Voss <thomas.voss.bochum@gmail.com>
2//
3// This library is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Lesser General Public License as published
5// by the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15#ifndef LOCATION_PROVIDERS_SIRF_SERIAL_PORT_RECEIVER_H_
16#define LOCATION_PROVIDERS_SIRF_SERIAL_PORT_RECEIVER_H_
17
18#include <location/providers/sirf/receiver.h>
19
20#include <boost/asio.hpp>
21#include <boost/filesystem.hpp>
22
23#include <array>
24#include <atomic>
25
26namespace location
27{
28namespace providers
29{
30namespace sirf
31{
32
33/// @brief SerialPortReceiver connects to a ublox 8 GNSS receiver over a serial
34/// port.
35class SerialPortReceiver : public Receiver, public std::enable_shared_from_this<SerialPortReceiver>
36{
37public:
38 /// @brief create returns a new Receiver instance connected to the
39 /// serial port reachable under dev.
40 static std::shared_ptr<SerialPortReceiver> create(boost::asio::io_service& ios, const boost::filesystem::path& dev,
41 const std::shared_ptr<Receiver::Monitor>& monitor);
42
43 void start();
44 void stop();
45
46 void send_encoded_message(const std::vector<std::uint8_t>& data) override;
47
48private:
49 enum class State
50 {
51 running,
52 stopped
53 };
54
55 /// @brief Receiver initializes a new instance opening the serial port
56 /// located at path.
57 ///
58 /// Throws in case of issues.
59 SerialPortReceiver(boost::asio::io_service& ios, const boost::filesystem::path& dev,
60 const std::shared_ptr<Receiver::Monitor>& monitor);
61
62 /// @brief finalize returns a finalized reader instance reading from
63 /// the serial port.
64 std::shared_ptr<SerialPortReceiver> finalize();
65
66 /// @brief start_read starts an async read operation from the configured
67 /// serial port.
68 void start_read();
69
70 Receiver::Buffer buffer;
71 boost::asio::io_service& ios;
72 boost::asio::serial_port serial_port;
73};
74
75}
76}
77}
78
79#endif // LOCATION_PROVIDERS_SIRF_SERIAL_PORT_RECEIVER_H_
080
=== added file 'src/location/providers/sirf/set_protocol.h'
--- src/location/providers/sirf/set_protocol.h 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/set_protocol.h 2017-05-05 09:37:41 +0000
@@ -0,0 +1,73 @@
1// Copyright (C) 2017 Thomas Voss <thomas.voss@canonical.com>
2//
3// This library is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Lesser General Public License as published
5// by the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16#ifndef LOCATION_PROVIDERS_SIRF_SET_PROTOCOL_H_
17#define LOCATION_PROVIDERS_SIRF_SET_PROTOCOL_H_
18
19#include <location/providers/sirf/writer.h>
20
21#include <cstdint>
22#include <iostream>
23
24namespace location
25{
26namespace providers
27{
28namespace sirf
29{
30
31// Switches the protocol to another protocol. For most software,
32// the default protocol is SiRF binary.
33struct SetProtocol
34{
35 enum
36 {
37 null = 0,
38 sirf_binary = 1,
39 nmea = 2,
40 ascii = 3,
41 rtcm = 4,
42 user1 = 5,
43 sirf_loc = 6,
44 statistic = 7
45 };
46
47 static constexpr std::uint8_t id{0x87};
48
49 std::size_t size() const
50 {
51 return sizeof(std::uint8_t) + sizeof(std::uint8_t);
52 }
53
54 void write(Writer& writer) const
55 {
56 writer.write_unsigned_char(id);
57 writer.write_unsigned_char(protocol);
58 }
59
60 std::uint8_t protocol;
61};
62
63inline std::ostream& operator<<(std::ostream& out, const SetProtocol& sp)
64{
65 return out << "SetProtocol:" << std::endl
66 << " protocol: " << sp.protocol;
67}
68
69} // namespace sirf
70} // namespace providers
71} // namespace location
72
73#endif // LOCATION_PROVIDERS_SIRF_SET_PROTOCOL_H_
074
=== added file 'src/location/providers/sirf/writer.cpp'
--- src/location/providers/sirf/writer.cpp 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/writer.cpp 2017-05-05 09:37:41 +0000
@@ -0,0 +1,94 @@
1// Copyright (C) 2016 Thomas Voss <thomas.voss.bochum@gmail.com>
2//
3// This library is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Lesser General Public License as published
5// by the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16#include <location/providers/sirf/writer.h>
17
18#include <arpa/inet.h>
19
20#include <cstring>
21#include <stdexcept>
22
23namespace sirf = location::providers::sirf;
24
25sirf::Writer::Writer(std::vector<std::uint8_t>::iterator begin,
26 std::vector<std::uint8_t>::iterator end)
27 : begin{begin}, current{begin}, end{end} {}
28
29void sirf::Writer::write_unsigned_char(std::uint8_t value)
30{
31 if (current + sizeof(value) > end)
32 throw std::out_of_range{"Write buffer exhausted"};
33
34 *reinterpret_cast<std::uint8_t*>(&(*current)) = value;
35 current += sizeof(value);
36
37}
38
39void sirf::Writer::write_signed_char(std::int8_t value)
40{
41 if (current + sizeof(value) > end)
42 throw std::out_of_range{"Write buffer exhausted"};
43
44 *reinterpret_cast<std::int8_t*>(&(*current)) = value;
45 current += sizeof(value);
46
47}
48
49void sirf::Writer::write_unsigned_short(std::uint16_t value)
50{
51 if (current + sizeof(value) > end)
52 throw std::out_of_range{"Write buffer exhausted"};
53
54 *reinterpret_cast<std::uint16_t*>(&(*current)) = ::ntohs(value);
55 current += sizeof(value);
56}
57
58void sirf::Writer::write_signed_short(std::int16_t value)
59{
60 if (current + sizeof(value) > end)
61 throw std::out_of_range{"Write buffer exhausted"};
62
63 *reinterpret_cast<std::int16_t*>(&(*current)) = ::ntohs(value);
64 current += sizeof(value);
65}
66
67void sirf::Writer::write_unsigned_long(std::uint32_t value)
68{
69 if (current + sizeof(value) > end)
70 throw std::out_of_range{"Write buffer exhausted"};
71
72 *reinterpret_cast<std::uint32_t*>(&(*current)) = ::ntohl(value);
73 current += sizeof(value);
74}
75
76void sirf::Writer::write_signed_long(std::int32_t value)
77{
78 if (current + sizeof(value) > end)
79 throw std::out_of_range{"Write buffer exhausted"};
80
81 *reinterpret_cast<std::int32_t*>(&(*current)) = ::ntohl(value);
82 current += sizeof(value);
83}
84
85sirf::Writer sirf::Writer::slice(std::size_t size)
86{
87 if (current + size > end)
88 throw std::out_of_range{"Write buffer exhausted"};
89
90 Writer result{current, current + size};
91 current += size;
92
93 return result;
94}
095
=== added file 'src/location/providers/sirf/writer.h'
--- src/location/providers/sirf/writer.h 1970-01-01 00:00:00 +0000
+++ src/location/providers/sirf/writer.h 2017-05-05 09:37:41 +0000
@@ -0,0 +1,54 @@
1// Copyright (C) 2016 Thomas Voss <thomas.voss.bochum@gmail.com>
2//
3// This library is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Lesser General Public License as published
5// by the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16#ifndef LOCATION_PROVIDERS_SIRF_WRITER_H_
17#define LOCATION_PROVIDERS_SIRF_WRITER_H_
18
19#include <cstdint>
20#include <vector>
21
22namespace location
23{
24namespace providers
25{
26namespace sirf
27{
28
29class Writer
30{
31public:
32 explicit Writer(std::vector<std::uint8_t>::iterator begin,
33 std::vector<std::uint8_t>::iterator end);
34
35 void write_unsigned_char(std::uint8_t value);
36 void write_signed_char(std::int8_t value);
37 void write_unsigned_short(std::uint16_t value);
38 void write_signed_short(std::int16_t value);
39 void write_unsigned_long(std::uint32_t value);
40 void write_signed_long(std::int32_t value);
41
42 Writer slice(std::size_t size);
43
44private:
45 std::vector<std::uint8_t>::iterator begin;
46 std::vector<std::uint8_t>::iterator current;
47 std::vector<std::uint8_t>::iterator end;
48};
49
50} // namespace sirf
51} // namespace providers
52} // namespace location
53
54#endif // LOCATION_PROVIDERS_SIRF_WRITER_H_
055
=== modified file 'src/location/providers/ubx/CMakeLists.txt'
--- src/location/providers/ubx/CMakeLists.txt 2017-03-23 12:32:38 +0000
+++ src/location/providers/ubx/CMakeLists.txt 2017-05-05 09:37:41 +0000
@@ -37,11 +37,14 @@
37 _8/nav/pvt.cpp37 _8/nav/pvt.cpp
38 _8/nav/sat.h38 _8/nav/sat.h
39 _8/nav/sat.cpp39 _8/nav/sat.cpp
40 _8/nmea/scanner.cpp
41 _8/nmea/sentence.cpp
4240
43 provider.h provider.cpp)41 provider.h provider.cpp)
4442
43target_link_libraries(
44 ubx
45
46 nmea)
47
45set(48set(
46 ENABLED_PROVIDER_TARGETS49 ENABLED_PROVIDER_TARGETS
47 ${ENABLED_PROVIDER_TARGETS} ubx50 ${ENABLED_PROVIDER_TARGETS} ubx
4851
=== modified file 'src/location/providers/ubx/_8/receiver.cpp'
--- src/location/providers/ubx/_8/receiver.cpp 2017-03-23 15:47:38 +0000
+++ src/location/providers/ubx/_8/receiver.cpp 2017-05-05 09:37:41 +0000
@@ -1,6 +1,6 @@
1#include <location/providers/ubx/_8/receiver.h>1#include <location/providers/ubx/_8/receiver.h>
22
3#include <location/providers/ubx/_8/nmea/sentence.h>3#include <location/nmea/sentence.h>
44
5#include <iostream>5#include <iostream>
66
77
=== modified file 'src/location/providers/ubx/_8/receiver.h'
--- src/location/providers/ubx/_8/receiver.h 2017-03-24 21:13:53 +0000
+++ src/location/providers/ubx/_8/receiver.h 2017-05-05 09:37:41 +0000
@@ -20,8 +20,8 @@
20#include <location/providers/ubx/_8/message.h>20#include <location/providers/ubx/_8/message.h>
21#include <location/providers/ubx/_8/scanner.h>21#include <location/providers/ubx/_8/scanner.h>
2222
23#include <location/providers/ubx/_8/nmea/scanner.h>23#include <location/nmea/scanner.h>
24#include <location/providers/ubx/_8/nmea/sentence.h>24#include <location/nmea/sentence.h>
2525
26#include <memory>26#include <memory>
2727
@@ -60,7 +60,7 @@
6060
61 /// @brief on_new_nmea_sentence is invoked for every complete and parsed61 /// @brief on_new_nmea_sentence is invoked for every complete and parsed
62 /// nmea sentence.62 /// nmea sentence.
63 virtual void on_new_nmea_sentence(const ubx::_8::nmea::Sentence& sentence) = 0;63 virtual void on_new_nmea_sentence(const nmea::Sentence& sentence) = 0;
64 };64 };
6565
66 /// @brief send_message encodes and sends 'message' to the receiver.66 /// @brief send_message encodes and sends 'message' to the receiver.
@@ -83,7 +83,7 @@
8383
84private:84private:
85 std::shared_ptr<Monitor> monitor;85 std::shared_ptr<Monitor> monitor;
86 ubx::_8::nmea::Scanner nmea_scanner;86 nmea::Scanner nmea_scanner;
87 ubx::_8::Scanner ubx_scanner;87 ubx::_8::Scanner ubx_scanner;
88};88};
8989
9090
=== modified file 'src/location/providers/ubx/_8/scanner.cpp'
--- src/location/providers/ubx/_8/scanner.cpp 2017-03-23 12:32:38 +0000
+++ src/location/providers/ubx/_8/scanner.cpp 2017-05-05 09:37:41 +0000
@@ -105,7 +105,7 @@
105 expected_size |= (c << 8);105 expected_size |= (c << 8);
106 payload.resize(expected_size);106 payload.resize(expected_size);
107 payload_iterator = payload.begin();107 payload_iterator = payload.begin();
108 next = Expect::payload;108 next = expected_size > 0 ? Expect::payload : Expect::ck_a;
109 consumed = true;109 consumed = true;
110 break;110 break;
111 case Expect::payload:111 case Expect::payload:
112112
=== modified file 'src/location/providers/ubx/provider.cpp'
--- src/location/providers/ubx/provider.cpp 2017-04-21 07:16:45 +0000
+++ src/location/providers/ubx/provider.cpp 2017-05-05 09:37:41 +0000
@@ -80,7 +80,7 @@
80}80}
8181
8282
83void ubx::Provider::Monitor::on_new_nmea_sentence(const _8::nmea::Sentence& sentence)83void ubx::Provider::Monitor::on_new_nmea_sentence(const nmea::Sentence& sentence)
84{84{
85 VLOG(1) << sentence;85 VLOG(1) << sentence;
86 if (auto sp = provider.lock())86 if (auto sp = provider.lock())
@@ -88,7 +88,7 @@
88 boost::apply_visitor(*this, sentence);88 boost::apply_visitor(*this, sentence);
89}89}
9090
91void ubx::Provider::Monitor::operator()(const _8::nmea::Gga& gga)91void ubx::Provider::Monitor::operator()(const nmea::Gga& gga)
92{ 92{
93 if (gga.latitude && gga.longitude)93 if (gga.latitude && gga.longitude)
94 {94 {
@@ -159,32 +159,32 @@
159 });159 });
160}160}
161161
162void ubx::Provider::Monitor::operator()(const _8::nmea::Gsa&)162void ubx::Provider::Monitor::operator()(const nmea::Gsa&)
163{163{
164 // Empty on purpose164 // Empty on purpose
165}165}
166166
167void ubx::Provider::Monitor::operator()(const _8::nmea::Gll&)167void ubx::Provider::Monitor::operator()(const nmea::Gll&)
168{168{
169 // Empty on purpose169 // Empty on purpose
170}170}
171171
172void ubx::Provider::Monitor::operator()(const _8::nmea::Gsv&)172void ubx::Provider::Monitor::operator()(const nmea::Gsv&)
173{173{
174 // Empty on purpose174 // Empty on purpose
175}175}
176176
177void ubx::Provider::Monitor::operator()(const _8::nmea::Rmc&)177void ubx::Provider::Monitor::operator()(const nmea::Rmc&)
178{178{
179 // Empty on purpose179 // Empty on purpose
180}180}
181181
182void ubx::Provider::Monitor::operator()(const _8::nmea::Txt&)182void ubx::Provider::Monitor::operator()(const nmea::Txt&)
183{183{
184 // Empty on purpose184 // Empty on purpose
185}185}
186186
187void ubx::Provider::Monitor::operator()(const _8::nmea::Vtg& vtg)187void ubx::Provider::Monitor::operator()(const nmea::Vtg& vtg)
188{188{
189 auto thiz = shared_from_this();189 auto thiz = shared_from_this();
190 std::weak_ptr<ubx::Provider::Monitor> wp{thiz};190 std::weak_ptr<ubx::Provider::Monitor> wp{thiz};
191191
=== modified file 'src/location/providers/ubx/provider.h'
--- src/location/providers/ubx/provider.h 2017-04-21 07:16:45 +0000
+++ src/location/providers/ubx/provider.h 2017-05-05 09:37:41 +0000
@@ -21,7 +21,7 @@
21#include <location/provider.h>21#include <location/provider.h>
22#include <location/provider_factory.h>22#include <location/provider_factory.h>
23#include <location/runtime.h>23#include <location/runtime.h>
2424#include <location/nmea/sentence.h>
25#include <location/providers/ubx/_8/assist_now_online_client.h>25#include <location/providers/ubx/_8/assist_now_online_client.h>
26#include <location/providers/ubx/_8/serial_port_receiver.h>26#include <location/providers/ubx/_8/serial_port_receiver.h>
2727
@@ -104,20 +104,20 @@
104 {104 {
105 // From Receiver::Monitor105 // From Receiver::Monitor
106 void on_new_ubx_message(const _8::Message& message) override;106 void on_new_ubx_message(const _8::Message& message) override;
107 void on_new_nmea_sentence(const _8::nmea::Sentence& sentence) override;107 void on_new_nmea_sentence(const nmea::Sentence& sentence) override;
108108
109 template<typename T>109 template<typename T>
110 void operator()(const T&) const {}110 void operator()(const T&) const {}
111111
112 void operator()(const _8::nav::Pvt& pvt);112 void operator()(const _8::nav::Pvt& pvt);
113113
114 void operator()(const _8::nmea::Gga& gga);114 void operator()(const nmea::Gga& gga);
115 void operator()(const _8::nmea::Gsa& gsa);115 void operator()(const nmea::Gsa& gsa);
116 void operator()(const _8::nmea::Gll& gll);116 void operator()(const nmea::Gll& gll);
117 void operator()(const _8::nmea::Gsv& gsv);117 void operator()(const nmea::Gsv& gsv);
118 void operator()(const _8::nmea::Rmc& rmc);118 void operator()(const nmea::Rmc& rmc);
119 void operator()(const _8::nmea::Txt& txt);119 void operator()(const nmea::Txt& txt);
120 void operator()(const _8::nmea::Vtg& vtg);120 void operator()(const nmea::Vtg& vtg);
121121
122 std::weak_ptr<Provider> provider;122 std::weak_ptr<Provider> provider;
123 };123 };
124124
=== modified file 'src/location/runtime_tests.cpp'
--- src/location/runtime_tests.cpp 2017-04-03 07:32:40 +0000
+++ src/location/runtime_tests.cpp 2017-05-05 09:37:41 +0000
@@ -22,6 +22,7 @@
22#include <location/clock.h>22#include <location/clock.h>
23#include <location/glib/runtime.h>23#include <location/glib/runtime.h>
24#include <location/providers/gps/hardware_abstraction_layer.h>24#include <location/providers/gps/hardware_abstraction_layer.h>
25#include <location/providers/sirf/provider.h>
25#include <location/providers/ubx/provider.h>26#include <location/providers/ubx/provider.h>
26#include <location/util/benchmark.h>27#include <location/util/benchmark.h>
27#include <location/util/cli.h>28#include <location/util/cli.h>
@@ -251,12 +252,98 @@
251 return 0;252 return 0;
252}253}
253254
255int sirf(std::ostream& cout, std::ostream&)
256{
257 location::util::Benchmark benchmark{boost::lexical_cast<unsigned int>(env::get("SIRF_PROVIDER_TEST_TRIALS", "15")), "ttff in [µs]"};
258
259 auto test_device = env::get_or_throw("SIRF_PROVIDER_TEST_DEVICE");
260
261 location::providers::sirf::Provider::Configuration configuration
262 {
263 location::providers::sirf::Provider::Protocol::sirf, test_device
264 };
265
266 auto provider = location::providers::sirf::Provider::create(configuration);
267
268 struct State
269 {
270 State() : worker{[this]() { runtime.run(); }}, fix_received(false)
271 {
272 }
273
274 ~State()
275 {
276 runtime.stop();
277 if (worker.joinable())
278 worker.join();
279 }
280
281 bool wait_for_fix_for(const std::chrono::seconds& seconds)
282 {
283 std::unique_lock<std::mutex> ul(guard);
284 return wait_condition.wait_for(
285 ul,
286 seconds,
287 [this]() {return fix_received == true;});
288 }
289
290 void on_position_updated(const location::Position&)
291 {
292 fix_received = true;
293 wait_condition.notify_all();
294 }
295
296 void reset()
297 {
298 fix_received = false;
299 }
300
301 location::glib::Runtime runtime{location::glib::Runtime::WithOwnMainLoop{}};
302 std::thread worker;
303 std::mutex guard;
304 std::condition_variable wait_condition;
305 bool fix_received;
306 } state;
307
308 provider->position_updates().connect([&state](const location::Update<location::Position>& update)
309 {
310 state.on_position_updated(update.value);
311 });
312
313 {
314 cli::ProgressBar pb(cout, "sirf runtime test: ", 30);
315
316 benchmark.run(
317 [&](std::size_t)
318 {
319 provider->reset(); state.reset();
320 },
321 [&](std::size_t trial)
322 {
323 pb.update(trial / static_cast<double>(benchmark.trials()));
324
325 provider->activate();
326 // We expect a maximum cold start time of 15 minutes. The theoretical
327 // limit is 12.5 minutes, and we add up some grace period to make the
328 // test more robust (see http://en.wikipedia.org/wiki/Time_to_first_fix).
329 expect<true, std::runtime_error>(state.wait_for_fix_for(std::chrono::seconds{15 * 60}), "Wait for fix timed out.");
330 provider->deactivate();
331 });
332 }
333
334 cout << benchmark << std::endl;
335
336 return 0;
337}
338
254} // namespace339} // namespace
255340
256int location::execute_runtime_tests(const std::string& test_suite, std::ostream& cout, std::ostream& cerr)341int location::execute_runtime_tests(const std::string& test_suite, std::ostream& cout, std::ostream& cerr)
257{342{
258 if (test_suite == "android-gps")343 if (test_suite == "android-gps")
259 return snr_and_ttff(cout, cerr);344 return snr_and_ttff(cout, cerr);
345 else if (test_suite == "sirf")
346 return sirf(cout, cerr);
260 else if (test_suite == "ubx")347 else if (test_suite == "ubx")
261 return ubx(cout, cerr);348 return ubx(cout, cerr);
262 return 0;349 return 0;

Subscribers

People subscribed via source and target branches

to all changes: