Merge lp:~thomas-voss/location-service/ubx-provider-configuration into lp:location-service

Proposed by Thomas Voß on 2017-01-06
Status: Merged
Approved by: Thomas Voß on 2017-01-06
Approved revision: 287
Merged at revision: 287
Proposed branch: lp:~thomas-voss/location-service/ubx-provider-configuration
Merge into: lp:location-service
Diff against target: 58 lines (+19/-1)
3 files modified
prebuilt/meta/hooks/configure (+6/-0)
snapcraft.yaml (+3/-0)
src/location/providers/ubx/provider.cpp (+10/-1)
To merge this branch: bzr merge lp:~thomas-voss/location-service/ubx-provider-configuration
Reviewer Review Type Date Requested Status
Thomas Voß Approve on 2017-03-30
Simon Fels (community) Approve on 2017-01-06
Review via email: mp+314209@code.launchpad.net

Commit message

Support configuration of ubx::Provider via snap set location ubx::provider::path=.

Description of the change

Support configuration of ubx::Provider via snap set location ubx::provider::path=.

To post a comment you must log in.
Simon Fels (morphis) wrote :

LGTM

review: Approve
Thomas Voß (thomas-voss) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'prebuilt'
2=== added directory 'prebuilt/meta'
3=== added directory 'prebuilt/meta/hooks'
4=== added file 'prebuilt/meta/hooks/configure'
5--- prebuilt/meta/hooks/configure 1970-01-01 00:00:00 +0000
6+++ prebuilt/meta/hooks/configure 2017-01-06 09:53:58 +0000
7@@ -0,0 +1,6 @@
8+#!/bin/sh
9+
10+if path=$(snapctl get ubx::provider::path); then
11+ mkdir -p $SNAP_DATA/ubx/provider
12+ echo "$path" > $SNAP_DATA/ubx/provider/path
13+fi
14
15=== modified file 'snapcraft.yaml'
16--- snapcraft.yaml 2016-12-09 10:49:29 +0000
17+++ snapcraft.yaml 2017-01-06 09:53:58 +0000
18@@ -42,6 +42,9 @@
19 interface: serial-port
20
21 parts:
22+ hooks:
23+ plugin: dump
24+ source: prebuilt
25 location-service:
26 plugin: cmake
27 configflags:
28
29=== modified file 'src/location/providers/ubx/provider.cpp'
30--- src/location/providers/ubx/provider.cpp 2016-12-12 13:01:34 +0000
31+++ src/location/providers/ubx/provider.cpp 2017-01-06 09:53:58 +0000
32@@ -21,8 +21,12 @@
33 #include <location/logging.h>
34 #include <location/runtime.h>
35
36+#include <core/posix/this_process.h>
37+
38+#include <fstream>
39 #include <thread>
40
41+namespace env = core::posix::this_process::env;
42 namespace ubx = location::providers::ubx;
43
44 std::string ubx::Provider::class_name()
45@@ -100,7 +104,12 @@
46
47 location::Provider::Ptr ubx::Provider::create_instance(const location::ProviderFactory::Configuration& config)
48 {
49- return location::Provider::Ptr{new ubx::Provider{config.get<std::string>("device", "/dev/ttyS4")}};
50+ std::string device_path;
51+ std::ifstream in(env::get("SNAP_DATA") + "/ubx/provider/path");
52+
53+ in >> device_path;
54+
55+ return location::Provider::Ptr{new ubx::Provider{config.get<std::string>("device", device_path.empty() ? "/dev/ttyS4" : device_path)}};
56 }
57
58 ubx::Provider::Provider(const boost::filesystem::path& device)

Subscribers

People subscribed via source and target branches

to all changes: