OpenCPN Partial API docs
Loading...
Searching...
No Matches
comm_drv_n2k_socketcan.cpp
1/***************************************************************************
2 *
3 * Project: OpenCPN
4 * Purpose: Implement comm_drv_socketcan.h -- socketcan driver.
5 * Author: David Register, Alec Leamas
6 *
7 ***************************************************************************
8 * Copyright (C) 2022 by David Register, Alec Leamas *
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
24 **************************************************************************/
25
26#if !defined(__linux__) || defined(__ANDROID__)
27#error "This file can only be compiled on Linux"
28#endif
29
30#include <algorithm>
31#include <atomic>
32#include <chrono>
33#include <mutex>
34#include <thread>
35#include <vector>
36#include <future>
37
38#include "config.h"
39
40#include <net/if.h>
41#include <serial/serial.h>
42#include <sys/ioctl.h>
43#include <sys/socket.h>
44#include <sys/time.h>
45
46#include <wx/log.h>
47#include <wx/string.h>
48#include <wx/utils.h>
49#include <wx/thread.h>
50
51#include "model/comm_can_util.h"
52#include "model/comm_drv_n2k_socketcan.h"
55#include "model/config_vars.h"
56
57#define DEFAULT_N2K_SOURCE_ADDRESS 72
58
59wxDEFINE_EVENT(EVT_N2K_59904, ObservedEvt);
60
61static const int kNotFound = -1;
62
64static const int kSocketTimeoutSeconds = 2;
65
66typedef struct can_frame CanFrame;
67
69using namespace std::literals::chrono_literals;
70
95class Worker {
96public:
97 Worker(CommDriverN2KSocketCAN* parent, const wxString& PortName);
98
99 bool StartThread();
100 void StopThread();
101 int GetSocket() { return m_socket; }
102
103private:
104 void Entry();
105
106 void ThreadMessage(const std::string& msg, wxLogLevel l = wxLOG_Message);
107
108 int InitSocket(const std::string port_name);
109 void SocketMessage(const std::string& msg, const std::string& device);
110 void HandleInput(CanFrame frame);
111 void ProcessRxMessages(std::shared_ptr<const Nmea2000Msg> n2k_msg);
112
113 std::vector<unsigned char> PushCompleteMsg(const CanHeader header,
114 int position,
115 const CanFrame frame);
116 std::vector<unsigned char> PushFastMsgFragment(const CanHeader& header,
117 int position);
118
119 CommDriverN2KSocketCanImpl* const m_parent_driver;
120 const wxString m_port_name;
121 std::atomic<int> m_run_flag;
122 FastMessageMap fast_messages;
123 int m_socket;
124};
125
128 friend class Worker;
129
130public:
133 m_worker(this, p->socketCAN_port),
134 m_source_address(-1),
135 m_last_TX_sequence(0) {
136 SetN2K_Name();
137 Open();
138 }
139
140 ~CommDriverN2KSocketCanImpl() { Close(); }
141
142 bool Open();
143 void Close();
144 void SetN2K_Name();
145
146 bool SendMessage(std::shared_ptr<const NavMsg> msg,
147 std::shared_ptr<const NavAddr> addr);
148
149 int DoAddressClaim();
150 bool SendAddressClaim(int proposed_source_address);
151 bool SendProductInfo();
152
153 Worker& GetWorker() { return m_worker; }
154 void UpdateAttrCanAddress();
155
156private:
157 N2kName node_name;
158 Worker m_worker;
159 int m_source_address;
160 int m_last_TX_sequence;
161 std::future<int> m_AddressClaimFuture;
162 wxMutex m_TX_mutex;
163 int m_unique_number;
164
165 ObservableListener listener_N2K_59904;
166 bool HandleN2K_59904(std::shared_ptr<const Nmea2000Msg> n2k_msg);
167};
168
169// Static CommDriverN2KSocketCAN factory implementation.
170
171std::unique_ptr<CommDriverN2KSocketCAN> CommDriverN2KSocketCAN::Create(
172 const ConnectionParams* params, DriverListener& listener) {
173 return std::unique_ptr<CommDriverN2KSocketCAN>(
174 new CommDriverN2KSocketCanImpl(params, listener));
175}
176
177// CommDriverN2KSocketCanImpl implementation
178
179void CommDriverN2KSocketCanImpl::SetN2K_Name() {
180 // We choose some "benign" values for OCPN socketCan interface
181 node_name.value.Name = 0;
182
183 m_unique_number = 1;
184 // Build a simple 16 bit hash of g_hostname, to use as unique "serial number"
185 int hash = 0;
186 std::string str(g_hostname.mb_str());
187 int len = str.size();
188 const char* ch = str.data();
189 for (int i = 0; i < len; i++)
190 hash = hash + ((hash) << 5) + *(ch + i) + ((*(ch + i)) << 7);
191 m_unique_number = ((hash) ^ (hash >> 16)) & 0xffff;
192
193 node_name.SetManufacturerCode(2046);
194 node_name.SetUniqueNumber(m_unique_number);
195 node_name.SetDeviceFunction(130); // Display
196 node_name.SetDeviceClass(120); // Display
197 node_name.SetIndustryGroup(4); // Marine
198 node_name.SetSystemInstance(0);
199}
200
201void CommDriverN2KSocketCanImpl::UpdateAttrCanAddress() {
202 this->attributes["canAddress"] = std::to_string(m_source_address);
203}
204
205bool CommDriverN2KSocketCanImpl::Open() {
206 // Start the RX worker thread
207 bool bws = m_worker.StartThread();
208 return bws;
209}
210
211void CommDriverN2KSocketCanImpl::Close() {
212 wxLogMessage("Closing N2K socketCAN: %s", m_params.socketCAN_port.c_str());
213 m_worker.StopThread();
214
215 // We cannot use shared_from_this() since we might be in the destructor.
216 auto& registry = CommDriverRegistry::GetInstance();
217 auto& me = FindDriver(registry.GetDrivers(), iface, bus);
218 registry.Deactivate(me);
219}
220
221bool CommDriverN2KSocketCanImpl::SendAddressClaim(int proposed_source_address) {
222 wxMutexLocker lock(m_TX_mutex);
223
224 int socket = GetWorker().GetSocket();
225
226 if (socket < 0) return false;
227
228 CanFrame frame;
229 memset(&frame, 0, sizeof(frame));
230
231 uint64_t _pgn = 60928;
232 unsigned long canId = BuildCanID(6, proposed_source_address, 255, _pgn);
233 frame.can_id = canId | CAN_EFF_FLAG;
234
235 // Load the data
236 uint32_t b32_0 = node_name.value.UnicNumberAndManCode;
237 memcpy(&frame.data, &b32_0, 4);
238
239 unsigned char b81 = node_name.value.DeviceInstance;
240 memcpy(&frame.data[4], &b81, 1);
241
242 b81 = node_name.value.DeviceFunction;
243 memcpy(&frame.data[5], &b81, 1);
244
245 b81 = (node_name.value.DeviceClass);
246 memcpy(&frame.data[6], &b81, 1);
247
248 b81 = node_name.value.IndustryGroupAndSystemInstance;
249 memcpy(&frame.data[7], &b81, 1);
250
251 frame.can_dlc = 8; // data length
252
253 int sentbytes = write(socket, &frame, sizeof(frame));
254
255 return (sentbytes == 16);
256}
257
258void AddStr(std::vector<uint8_t>& vec, std::string str, size_t max_len) {
259 size_t i;
260 for (i = 0; i < str.size(); i++) {
261 vec.push_back(str[i]);
262 ;
263 }
264 for (; i < max_len; i++) {
265 vec.push_back(0);
266 }
267}
268
269bool CommDriverN2KSocketCanImpl::SendProductInfo() {
270 // Create the payload
271 std::vector<uint8_t> payload;
272
273 payload.push_back(2100 & 0xFF); // N2KVersion
274 payload.push_back(2100 >> 8);
275 payload.push_back(0xEC); // Product Code, 1772
276 payload.push_back(0x06);
277
278 std::string ModelID("OpenCPN"); // Model ID
279 AddStr(payload, ModelID, 32);
280
281 std::string ModelSWCode(PACKAGE_VERSION); // SwCode
282 AddStr(payload, ModelSWCode, 32);
283
284 std::string ModelVersion(PACKAGE_VERSION); // Model Version
285 AddStr(payload, ModelVersion, 32);
286
287 std::string ModelSerialCode(
288 std::to_string(m_unique_number)); // Model Serial Code
289 AddStr(payload, ModelSerialCode, 32);
290
291 payload.push_back(0); // CertificationLevel
292 payload.push_back(0); // LoadEquivalency
293
294 auto dest_addr = std::make_shared<const NavAddr2000>(iface, 255);
295 uint64_t _PGN;
296 _PGN = 126996;
297
298 auto msg = std::make_shared<const Nmea2000Msg>(_PGN, payload, dest_addr);
299 SendMessage(msg, dest_addr);
300
301 return true;
302}
303
304bool CommDriverN2KSocketCanImpl::SendMessage(
305 std::shared_ptr<const NavMsg> msg, std::shared_ptr<const NavAddr> addr) {
306 wxMutexLocker lock(m_TX_mutex);
307
308 // Verify claimed address is useable
309 if (m_source_address < 0) return false;
310
311 if (m_source_address > 253) // Could not claim...
312 return false;
313
314 int socket = GetWorker().GetSocket();
315
316 if (socket < 0) return false;
317
318 CanFrame frame;
319 memset(&frame, 0, sizeof(frame));
320
321 auto msg_n2k = std::dynamic_pointer_cast<const Nmea2000Msg>(msg);
322 std::vector<uint8_t> load = msg_n2k->payload;
323
324 uint64_t _pgn = msg_n2k->PGN.pgn;
325 auto destination_address = std::static_pointer_cast<const NavAddr2000>(addr);
326
327 unsigned long canId = BuildCanID(msg_n2k->priority, m_source_address,
328 destination_address->address, _pgn);
329
330 frame.can_id = canId | CAN_EFF_FLAG;
331
332 int sentbytes = 0;
333
334 if (load.size() <= 8) {
335 frame.can_dlc = load.size();
336 if (load.size() > 0) memcpy(&frame.data, load.data(), load.size());
337
338 sentbytes += write(socket, &frame, sizeof(frame));
339 } else { // Fast Packet
340 int sequence = (m_last_TX_sequence + 0x20) & 0xE0;
341 m_last_TX_sequence = sequence;
342 unsigned char* data_ptr = load.data();
343 int n_remaining = load.size();
344
345 // First packet
346 frame.can_dlc = 8;
347 frame.data[0] = sequence;
348 frame.data[1] = load.size();
349 int data_len_0 = wxMin(load.size(), 6);
350 memcpy(&frame.data[2], load.data(), data_len_0);
351
352 sentbytes += write(socket, &frame, sizeof(frame));
353
354 data_ptr += data_len_0;
355 n_remaining -= data_len_0;
356 sequence++;
357
358 // The rest of the bytes
359 while (n_remaining > 0) {
360 wxMilliSleep(10);
361 frame.data[0] = sequence;
362 int data_len_n = wxMin(n_remaining, 7);
363 memcpy(&frame.data[1], data_ptr, data_len_n);
364
365 sentbytes += write(socket, &frame, sizeof(frame));
366
367 data_ptr += data_len_n;
368 n_remaining -= data_len_n;
369 sequence++;
370 }
371 }
372
373 DriverStats stats = GetDriverStats();
374 stats.tx_count += sentbytes;
375 SetDriverStats(stats);
376
377 return true;
378}
379
380// CommDriverN2KSocketCAN implementation
381
382CommDriverN2KSocketCAN::CommDriverN2KSocketCAN(const ConnectionParams* params,
383 DriverListener& listener)
384 : CommDriverN2K(params->GetStrippedDSPort()),
385 m_params(*params),
386 m_listener(listener),
387 m_ok(false),
388 m_portstring(params->GetDSPort()),
389 m_baudrate(wxString::Format("%i", params->Baudrate)),
390 m_stats_timer(*this, 2s) {
391 this->attributes["canPort"] = params->socketCAN_port.ToStdString();
392 this->attributes["canAddress"] = std::to_string(DEFAULT_N2K_SOURCE_ADDRESS);
393 this->attributes["userComment"] = params->UserComment.ToStdString();
394 this->attributes["ioDirection"] = std::string("IN/OUT");
395
396 m_driver_stats.driver_bus = NavAddr::Bus::N2000;
397 m_driver_stats.driver_iface = params->GetStrippedDSPort();
398}
399
400CommDriverN2KSocketCAN::~CommDriverN2KSocketCAN() {}
401
402// Worker implementation
403
404Worker::Worker(CommDriverN2KSocketCAN* parent, const wxString& port_name)
405 : m_parent_driver(dynamic_cast<CommDriverN2KSocketCanImpl*>(parent)),
406 m_port_name(port_name.Clone()),
407 m_run_flag(-1),
408 m_socket(-1) {
409 assert(m_parent_driver != 0);
410}
411
412std::vector<unsigned char> Worker::PushCompleteMsg(const CanHeader header,
413 int position,
414 const CanFrame frame) {
415 std::vector<unsigned char> data;
416 data.push_back(0x93);
417 data.push_back(0x13);
418 data.push_back(header.priority);
419 data.push_back(header.pgn & 0xFF);
420 data.push_back((header.pgn >> 8) & 0xFF);
421 data.push_back((header.pgn >> 16) & 0xFF);
422 data.push_back(header.destination);
423 data.push_back(header.source);
424 data.push_back(0xFF); // FIXME (dave) generate the time fields
425 data.push_back(0xFF);
426 data.push_back(0xFF);
427 data.push_back(0xFF);
428 data.push_back(CAN_MAX_DLEN); // nominally 8
429 for (size_t n = 0; n < CAN_MAX_DLEN; n++) data.push_back(frame.data[n]);
430 data.push_back(0x55); // CRC dummy, not checked
431 return data;
432}
433
434std::vector<unsigned char> Worker::PushFastMsgFragment(const CanHeader& header,
435 int position) {
436 std::vector<unsigned char> data;
437 data.push_back(0x93);
438 data.push_back(fast_messages[position].expected_length + 11);
439 data.push_back(header.priority);
440 data.push_back(header.pgn & 0xFF);
441 data.push_back((header.pgn >> 8) & 0xFF);
442 data.push_back((header.pgn >> 16) & 0xFF);
443 data.push_back(header.destination);
444 data.push_back(header.source);
445 data.push_back(0xFF); // FIXME (dave) Could generate the time fields
446 data.push_back(0xFF);
447 data.push_back(0xFF);
448 data.push_back(0xFF);
449 data.push_back(fast_messages[position].expected_length);
450 for (size_t n = 0; n < fast_messages[position].expected_length; n++)
451 data.push_back(fast_messages[position].data[n]);
452 data.push_back(0x55); // CRC dummy
453 fast_messages.Remove(position);
454 return data;
455}
456
457void Worker::ThreadMessage(const std::string& msg, wxLogLevel level) {
458 wxLogGeneric(level, wxString(msg.c_str()));
459 auto s = std::string("CommDriverN2KSocketCAN: ") + msg;
460 CommDriverRegistry::GetInstance().evt_driver_msg.Notify(level, s);
461}
462
463void Worker::SocketMessage(const std::string& msg, const std::string& device) {
464 std::stringstream ss;
465 ss << msg << device << ": " << strerror(errno);
466 ThreadMessage(ss.str());
467}
468
475int Worker::InitSocket(const std::string port_name) {
476 int sock = socket(PF_CAN, SOCK_RAW, CAN_RAW);
477 if (sock < 0) {
478 SocketMessage("SocketCAN socket create failed: ", port_name);
479 return -1;
480 }
481
482 // Get the interface index
483 struct ifreq if_request;
484 strcpy(if_request.ifr_name, port_name.c_str());
485 if (ioctl(sock, SIOCGIFINDEX, &if_request) < 0) {
486 SocketMessage("SocketCAN ioctl (SIOCGIFINDEX) failed: ", port_name);
487 return -1;
488 }
489
490 // Check if interface is UP
491 struct sockaddr_can can_address;
492 can_address.can_family = AF_CAN;
493 can_address.can_ifindex = if_request.ifr_ifindex;
494 if (ioctl(sock, SIOCGIFFLAGS, &if_request) < 0) {
495 SocketMessage("SocketCAN socket IOCTL (SIOCGIFFLAGS) failed: ", port_name);
496 return -1;
497 }
498 if (if_request.ifr_flags & IFF_UP) {
499 ThreadMessage("socketCan interface is UP");
500 } else {
501 ThreadMessage("socketCan interface is NOT UP");
502 return -1;
503 }
504
505 // Set timeout and bind
506 struct timeval tv;
507 tv.tv_sec = kSocketTimeoutSeconds;
508 tv.tv_usec = 0;
509 int r =
510 setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof tv);
511 if (r < 0) {
512 SocketMessage("SocketCAN setsockopt SO_RCVTIMEO failed on device: ",
513 port_name);
514 return -1;
515 }
516 r = bind(sock, (struct sockaddr*)&can_address, sizeof(can_address));
517 if (r < 0) {
518 SocketMessage("SocketCAN socket bind() failed: ", port_name);
519 return -1;
520 }
521 DriverStats stats = m_parent_driver->GetDriverStats();
522 stats.available = true;
523 m_parent_driver->SetDriverStats(stats);
524
525 return sock;
526}
527
534void Worker::HandleInput(CanFrame frame) {
535 int position = -1;
536 bool ready = true;
537
538 CanHeader header(frame);
539 if (header.IsFastMessage()) {
540 position = fast_messages.FindMatchingEntry(header, frame.data[0]);
541 if (position == kNotFound) {
542 // Not an existing fast message: create new entry and insert first frame
543 position = fast_messages.AddNewEntry();
544 ready = fast_messages.InsertEntry(header, frame.data, position);
545 } else {
546 // An existing fast message entry is present, append the frame
547 ready = fast_messages.AppendEntry(header, frame.data, position);
548 }
549 }
550 if (ready) {
551 std::vector<unsigned char> vec;
552 if (position >= 0) {
553 // Re-assembled fast message
554 vec = PushFastMsgFragment(header, position);
555 } else {
556 // Single frame message
557 vec = PushCompleteMsg(header, position, frame);
558 }
559 // auto name = N2kName(static_cast<uint64_t>(header.pgn));
560 auto src_addr = m_parent_driver->GetAddress(m_parent_driver->node_name);
561 auto msg = std::make_shared<const Nmea2000Msg>(header.pgn, vec, src_addr);
562 auto msg_all = std::make_shared<const Nmea2000Msg>(1, vec, src_addr);
563
564 ProcessRxMessages(msg);
565 m_parent_driver->m_listener.Notify(std::move(msg));
566 m_parent_driver->m_listener.Notify(std::move(msg_all));
567
568 DriverStats stats = m_parent_driver->GetDriverStats();
569 stats.rx_count += vec.size();
570 m_parent_driver->SetDriverStats(stats);
571 }
572}
573
575void Worker::ProcessRxMessages(std::shared_ptr<const Nmea2000Msg> n2k_msg) {
576 if (n2k_msg->PGN.pgn == 59904) {
577 unsigned long RequestedPGN = 0;
578 RequestedPGN = n2k_msg->payload.at(15) << 16;
579 RequestedPGN += n2k_msg->payload.at(14) << 8;
580 RequestedPGN += n2k_msg->payload.at(13);
581
582 switch (RequestedPGN) {
583 case 60928:
584 m_parent_driver->SendAddressClaim(m_parent_driver->m_source_address);
585 break;
586 case 126996:
587 m_parent_driver->SendProductInfo();
588 break;
589 default:
590 break;
591 }
592 }
593
594 else if (n2k_msg->PGN.pgn == 60928) {
595 // Watch for conflicting source address
596 if (n2k_msg->payload.at(7) == m_parent_driver->m_source_address) {
597 // My name
598 uint64_t my_name = m_parent_driver->node_name.GetName();
599
600 // His name
601 uint64_t his_name = 0;
602 unsigned char* p = (unsigned char*)&his_name;
603 for (unsigned int i = 0; i < 8; i++) *p++ = n2k_msg->payload.at(13 + i);
604
605 // Compare literally the NAME values
606 if (his_name < my_name) {
607 // I lose, so select a new address
608 m_parent_driver->m_source_address++;
609 if (m_parent_driver->m_source_address > 253)
610 // Could not claim an address
611 m_parent_driver->m_source_address = 254;
612 m_parent_driver->UpdateAttrCanAddress();
613 }
614
615 // Claim the existing or modified address
616 m_parent_driver->SendAddressClaim(m_parent_driver->m_source_address);
617 }
618 }
619}
620
622void Worker::Entry() {
623 int recvbytes;
624 int socket;
625 CanFrame frame;
626
627 socket = InitSocket(m_port_name.ToStdString());
628 if (socket < 0) {
629 std::string msg("SocketCAN socket create failed: ");
630 ThreadMessage(msg + m_port_name.ToStdString());
631 m_run_flag = -1;
632 return;
633 }
634 m_socket = socket;
635
636 // Claim our default address
637 if (m_parent_driver->SendAddressClaim(DEFAULT_N2K_SOURCE_ADDRESS)) {
638 m_parent_driver->m_source_address = DEFAULT_N2K_SOURCE_ADDRESS;
639 m_parent_driver->UpdateAttrCanAddress();
640 }
641
642 // The main loop
643 while (m_run_flag > 0) {
644 recvbytes = read(socket, &frame, sizeof(frame));
645 if (recvbytes == -1) {
646 if (errno == EAGAIN || errno == EWOULDBLOCK) continue; // timeout
647
648 wxLogWarning("can socket %s: fatal error %s", m_port_name.c_str(),
649 strerror(errno));
650 break;
651 }
652 if (recvbytes != 16) {
653 wxLogWarning("can socket %s: bad frame size: %d (ignored)",
654 m_port_name.c_str(), recvbytes);
655 sleep(1);
656 continue;
657 }
658 HandleInput(frame);
659 }
660 m_run_flag = -1;
661 return;
662}
663
664bool Worker::StartThread() {
665 m_run_flag = 1;
666 std::thread t(&Worker::Entry, this);
667 t.detach();
668 return true;
669}
670
671void Worker::StopThread() {
672 if (m_run_flag < 0) {
673 wxLogMessage("Attempt to stop already dead thread (ignored).");
674 return;
675 }
676 wxLogMessage("Stopping Worker Thread");
677
678 m_run_flag = 0;
679 int tsec = 10;
680 while ((m_run_flag >= 0) && (tsec--)) wxSleep(1);
681
682 if (m_run_flag < 0)
683 wxLogMessage("StopThread: Stopped in %d sec.", 10 - tsec);
684 else
685 wxLogWarning("StopThread: Not Stopped after 10 sec.");
686}
const std::string iface
Physical device for 0183, else a unique string.
Definition comm_driver.h:88
CAN v2.0 29 bit header as used by NMEA 2000.
bool IsFastMessage() const
Return true if header reflects a multipart fast message.
Local driver implementation, not visible outside this file.
EventVar evt_driver_msg
Notified for messages from drivers.
Interface implemented by transport layer and possible other parties like test code which should handl...
Definition comm_driver.h:48
virtual void Notify(std::shared_ptr< const NavMsg > message)=0
Handle a received message.
const void Notify()
Notify all listeners, no data supplied.
Track fast message fragments eventually forming complete messages.
int AddNewEntry(void)
Allocate a new, fresh entry and return index to it.
void Remove(int pos)
Remove entry at pos.
bool AppendEntry(const CanHeader hdr, const unsigned char *data, int index)
Append fragment to existing multipart message.
int FindMatchingEntry(const CanHeader header, const unsigned char sid)
Setter.
bool InsertEntry(const CanHeader header, const unsigned char *data, int index)
Insert a new entry, first part of a multipart message.
Keeps listening over it's lifespan, removes itself on destruction.
Definition observable.h:131
Custom event class for OpenCPN's notification system.
Manages reading the N2K data stream provided by some N2K gateways from the declared serial port.
DriverPtr & FindDriver(const std::vector< DriverPtr > &drivers, const std::string &iface, const NavAddr::Bus _bus)
Search list of drivers for a driver with given interface string.
Driver registration container, a singleton.
Raw messages layer, supports sending and recieving navmsg messages.
Driver statistics report.
unsigned tx_count
Number of bytes sent since program start.
unsigned rx_count
Number of bytes received since program start.
N2k uses CAN which defines the basic properties of messages.
Definition comm_navmsg.h:70