OpenCPN Partial API docs
All Classes Namespaces Functions Variables Pages
comm_drv_n0183_serial.h
1/***************************************************************************
2 *
3 * Project: OpenCPN
4 * Purpose:
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#ifndef _COMMDRIVERN0183SERIAL_H
27#define _COMMDRIVERN0183SERIAL_H
28
29#include <string>
30
31#include <wx/event.h>
32
33#include "comm_drv_n0183.h"
34#include "conn_params.h"
35
38
41
43class CommDriverN0183Serial : public CommDriverN0183, public wxEvtHandler {
44public:
46
47 virtual ~CommDriverN0183Serial();
48
50 void Activate() override;
51
52 bool Open();
53 void Close();
54
55 // Secondary thread life toggle
56 // Used to inform launching object (this) to determine if the thread can
57 // be safely called or polled, e.g. wxThread->Destroy();
58 void SetSecThreadActive(void) { m_bsec_thread_active = true; }
59 void SetSecThreadInActive(void) { m_bsec_thread_active = false; }
60 bool IsSecThreadActive() const { return m_bsec_thread_active; }
61
62 void SetSecondaryThread(CommDriverN0183SerialThread* secondary_Thread) {
63 m_pSecondary_Thread = secondary_Thread;
64 }
65 CommDriverN0183SerialThread* GetSecondaryThread() {
66 return m_pSecondary_Thread;
67 }
68 void SetThreadRunFlag(int run) { m_Thread_run_flag = run; }
69
70 int m_Thread_run_flag;
71
72 ConnectionParams GetParams() const { return m_params; }
73
74 bool SendMessage(std::shared_ptr<const NavMsg> msg,
75 std::shared_ptr<const NavAddr> addr) override;
76
77private:
78 bool m_bok;
79 std::string m_portstring;
80 std::string m_BaudRate;
81 int m_handshake;
82
83 CommDriverN0183SerialThread* m_pSecondary_Thread;
84 bool m_bsec_thread_active;
85
86 ConnectionParams m_params;
87 DriverListener& m_listener;
88 void handle_N0183_MSG(CommDriverN0183SerialEvent& event);
89};
90
91#endif // guard
Internal event worker thread -> driver main code.
Driver for NMEA0183 over serial connections.
void Activate() override
Register driver and possibly do other post-ctor steps.
Abstract NMEA0183 drivers common parts.
Interface implemented by transport layer and possible other parties like test code which should handl...
Definition: comm_driver.h:47