~thomas-voss/location-service/enable-kml-reporting

« back to all changes in this revision

Viewing changes to src/location/providers/ubx/_8/serial_port_receiver.cpp

  • Committer: Thomas Voß
  • Date: 2017-03-08 11:58:46 UTC
  • mfrom: (289.2.5 spike-on-gdbus)
  • Revision ID: thomas.voss@canonical.com-20170308115846-bx6e266x3e5mk6v6
Merge lp:~thomas-voss/location-service/rework-dbus-bits.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
void ubx::_8::SerialPortReceiver::start()
23
23
{
24
 
    LOG(INFO) << __PRETTY_FUNCTION__ << std::endl;
25
24
    auto flush_rc = ::tcflush(sp.lowest_layer().native_handle(), TCIOFLUSH);
26
25
    start_read();
27
26
    if (flush_rc) throw std::system_error(errno, std::system_category());
28
27
}
29
28
 
30
29
void ubx::_8::SerialPortReceiver::stop() {
31
 
    LOG(INFO) << __PRETTY_FUNCTION__ << std::endl;
32
30
    sp.cancel();
33
31
}
34
32
 
35
33
void ubx::_8::SerialPortReceiver::start_read()
36
34
{
37
 
    LOG(INFO) << __PRETTY_FUNCTION__ << std::endl;
38
35
    auto thiz = shared_from_this();
39
36
    boost::asio::async_read(sp, boost::asio::buffer(&buffer.front(), buffer.size()),
40
37
                            [thiz, this](const boost::system::error_code& ec, std::size_t transferred) {
52
49
                                    }
53
50
                                    catch(...)
54
51
                                    {
55
 
                                        LOG(WARNING) << "Error processing NMEA chunk";
 
52
                                        LOG(WARNING) << "Error processing NMEA chunk.";
56
53
                                    }
57
54
 
58
55
                                    start_read();