OpenCPN Partial API docs
Loading...
Searching...
No Matches
comm_drv_n2k_socketcan.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2022 by David Register *
3 * Copyright (C) 2022 Alec Leamas *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
17 **************************************************************************/
18
25#ifndef _COMMDRIVERN2KSOCKETCAN_H
26#define _COMMDRIVERN2KSOCKETCAN_H
27
28#include <chrono>
29#include <memory>
30#include <string>
31
32#include "model/comm_drv_n2k.h"
34#include "model/conn_params.h"
35
37 public DriverStatsProvider {
38public:
39 static std::unique_ptr<CommDriverN2KSocketCAN> Create(
40 const ConnectionParams* params, DriverListener& listener);
41
43
44 void SetListener(DriverListener& l) override { m_listener = l; }
45
46 bool SendMessage(std::shared_ptr<const NavMsg> msg,
47 std::shared_ptr<const NavAddr> addr) = 0; // override;
48
49 virtual bool Open() = 0;
50 virtual void Close() = 0;
51
52 void UpdateAttrCanAddress();
53 DriverStats GetDriverStats() const override { return m_driver_stats; }
54 void SetDriverStats(DriverStats _stats) { m_driver_stats = _stats; }
55
56protected:
58 DriverListener& listener);
59 ConnectionParams m_params;
60 DriverListener& m_listener;
61 StatsTimer m_stats_timer;
62
63private:
64 bool m_ok;
65 std::string m_portstring;
66 std::string m_baudrate;
67 DriverStats m_driver_stats;
68};
69
70#endif // guard
DriverStats GetDriverStats() const override
Get the Driver Statistics.
void SetListener(DriverListener &l) override
Set the entity which will receive incoming data.
Interface for handling incoming messages.
Definition comm_driver.h:50
Driver interface providing driver statistics.
Continuously report driver stats to CommDrvRegistry.evt_driver_stats.
Nmea2000 driver.
Communication statistics infrastructure.
Connection parameters.
Driver statistics report.