40std::string NavAddr::BusToString(NavAddr::Bus b) {
42 case NavAddr::Bus::N0183:
45 case NavAddr::Bus::N2000:
48 case NavAddr::Bus::Signalk:
51 case NavAddr::Bus::Onenet:
54 case NavAddr::Bus::Plugin:
57 case NavAddr::Bus::TestBus:
60 case NavAddr::Bus::AppMsg:
63 case NavAddr::Bus::Undef:
70NavAddr::Bus NavAddr::StringToBus(
const std::string& s) {
71 if (s ==
"nmea0183")
return NavAddr::Bus::N0183;
72 if (s ==
"nmea2000")
return NavAddr::Bus::N2000;
73 if (s ==
"SignalK")
return NavAddr::Bus::Signalk;
74 if (s ==
"Onenet")
return NavAddr::Bus::Onenet;
75 if (s ==
"Plugin")
return NavAddr::Bus::Plugin;
76 if (s ==
"TestBus")
return NavAddr::Bus::TestBus;
77 if (s ==
"AppMsg")
return NavAddr::Bus::AppMsg;
78 return NavAddr::Bus::Undef;
81static std::string CharToString(
unsigned char c) {
84 ss << setfill(
'0') << hex << setw(2) << (c & 0x00ff);
88static std::string CharToString(
char c) {
89 return CharToString(
static_cast<unsigned char>(c));
94 for (
auto c : payload) s.append(CharToString(c));
95 return PGN.to_string() +
" " + s;
100 for (
auto c : payload) s.append(CharToString(c) +
" ");
105 std::stringstream ss;
114 if (name ==
"position-fix")
return name +
":" +
ocpn::rtrim(message);
116 std::stringstream ss;
118 if (c >=
' ' && c <=
'~')
121 ss << CharToString(c);
123 return name +
": " + ss.str();
std::string key() const
Return unique key used by observable to notify/listen.
const std::string type
For example 'GGA'.
const std::string talker
For example 'GP'.
const std::string payload
Complete NMEA0183 sentence, also prefix.
std::string to_vdr() const override
Return message in unquoted format used by VDR plugin, see https://opencpn-manuals....
std::string to_string() const override
Return printable string for logging etc without trailing nl.
std::string to_string() const override
Print "bus key id payload".
std::string to_vdr() const override
Return message in unquoted format used by VDR plugin, see https://opencpn-manuals....
std::string to_string() const
Return printable string for logging etc without trailing nl.
Communication driver layer.
std::string printable(const std::string &str)
Return copy of str with non-printable chars replaced by hex like "<0D>".
std::string rtrim(const std::string &arg)
Strip possibly trailing space characters in s.
Miscellaneous utilities, many of which string related.