37#include "androidUTIL.h"
47 AndroidSerialIo(SendMsgFunc send_func,
const std::string& port,
unsigned baud)
49 m_driver_stats.driver_bus = NavAddr::Bus::N0183;
50 m_driver_stats.driver_iface =
"android";
57 if (msg.size() < 6 || (msg[0] !=
'$' && msg[0] !=
'!'))
return false;
58 wxString payload = msg;
59 if (!msg.EndsWith(
"\r\n")) payload +=
"\r\n";
60 wxString port(m_portname);
61 androidWriteSerial(port, payload);
62 m_driver_stats.
tx_count += m_portname.size();
67 if (m_portname.empty())
return;
68 wxString port(m_portname);
69 androidStartUSBSerial(port, std::to_string(m_baud), m_send_msg_func);
70 m_driver_stats.available =
true;
74 wxString port(m_portname);
75 androidStopUSBSerial(port);
78 m_driver_stats.available =
false;
86 const std::string& port,
88 return std::make_unique<AndroidSerialIo>(send_msg_func, port, baud);
Android SerialIo synchronous implementation based on the native Android serial interface as exposed i...
bool SetOutMsg(const wxString &msg) override
Send a message to remote peer.
DriverStats GetStats() const
Retrieve updated driver statistics.
void RequestStop() override
Request that thread stops operation.
void Start() override
Start IO operations including input, possibly in separate thread.
Nmea0183 serial communications wrapper, possibly running a thread.
static std::unique_ptr< SerialIo > Create(SendMsgFunc send_msg_func, const std::string &port, unsigned baud)
Factory.
void SignalExit()
Signal that thread has exited.
virtual void RequestStop()
Request that thread stops operation.
Communication statistics infrastructure.
Abstract N0183 serial communications interface.
std::function< void(const std::vector< unsigned char > &)> SendMsgFunc
Forwards data from driver to local receivers (main code, plugins, etc).
Driver statistics report.
unsigned tx_count
Number of bytes sent since program start.