aboutsummaryrefslogtreecommitdiff
path: root/apps/sm-serial-read.cpp
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-03-14 17:33:43 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2015-03-14 17:33:43 +0100
commitefa1825dd6d16e7901e9620c31796b27b6c84ee9 (patch)
tree7ce8e6b4728dfaa853bb9d67f53c1a50eafb2231 /apps/sm-serial-read.cpp
parent46cd1838255712cc599a30a81098121aa26d80f5 (diff)
downloadble-toys-efa1825dd6d16e7901e9620c31796b27b6c84ee9.tar.gz
ble-toys-efa1825dd6d16e7901e9620c31796b27b6c84ee9.tar.bz2
ble-toys-efa1825dd6d16e7901e9620c31796b27b6c84ee9.tar.xz
ble-toys-efa1825dd6d16e7901e9620c31796b27b6c84ee9.zip
o Creating a tool to calculate an absolute timestamp from a relative timestamp.
o Using git submodules instead of CMake's external project.
Diffstat (limited to 'apps/sm-serial-read.cpp')
-rw-r--r--apps/sm-serial-read.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/apps/sm-serial-read.cpp b/apps/sm-serial-read.cpp
index fee1a8c..04a718d 100644
--- a/apps/sm-serial-read.cpp
+++ b/apps/sm-serial-read.cpp
@@ -59,7 +59,7 @@ string hostname = get_hostname();
class port_handler {
public:
- port_handler(string device, serial_port &serial_port, shared_ptr<CsvParser> input) :
+ port_handler(string device, serial_port &serial_port, shared_ptr<CsvSampleParser> input) :
device(device), port(serial_port), input(input) {
}
@@ -84,7 +84,7 @@ private:
uint8_t data[size];
mutable_buffers_1 buffer = boost::asio::buffer(data, size);
- shared_ptr<CsvParser> input;
+ shared_ptr<CsvSampleParser> input;
};
class sm_serial_read : public app {
@@ -120,20 +120,21 @@ public:
cerr << "port is not open" << endl;
}
- shared_ptr <SampleOutputStream> output;
+ shared_ptr<SampleOutputStream> output;
+ unique_ptr<ostream> outputStream = unique_ptr<ostream>(&cout);
if (format == Format::JSON) {
- output = make_shared<JsonSampleOutputStream>(cout);
+ output = make_shared<JsonSampleOutputStream>(std::move(outputStream));
} else if (format == Format::SQL) {
- output = make_shared<SqlSampleOutputStream>(cout, "raw");
+ output = make_shared<SqlSampleOutputStream>(std::move(outputStream), "raw");
} else if (format == Format::PLAIN) {
- output = make_shared<CsvSampleOutputStream>(cout);
+ output = make_shared<CsvSampleOutputStream>(std::move(outputStream));
} else {
cerr << "Unsupported format: " << boost::lexical_cast<string>(format) << endl;
return EXIT_FAILURE;
}
- shared_ptr <CsvParser> input = make_shared<CsvParser>(output);
+ shared_ptr<CsvSampleParser> input = make_shared<CsvSampleParser>(output);
port_handler(port_name, port, input).run();