JS8Call-Improved master
Loading...
Searching...
No Matches
HamlibTransceiver.h
1#ifndef HAMLIB_TRANSCEIVER_HPP_
2#define HAMLIB_TRANSCEIVER_HPP_
3
4#include "PollingTransceiver.h"
5#include "TransceiverFactory.h"
6#include <hamlib/rig.h>
7
8#include <QString>
9
10#include <tuple>
11
12extern "C" {
13#ifdef JS8_USE_HAMLIB_THREE
14typedef struct rig RIG;
15#else
16typedef struct s_rig RIG;
17#endif
18struct rig_caps;
19#ifdef JS8_USE_HAMLIB_THREE
20typedef int vfo_t;
21#else
22typedef unsigned int vfo_t;
23#endif
24}
25
26// hamlib transceiver and PTT mostly delegated directly to hamlib Rig class
27class HamlibTransceiver final : public PollingTransceiver {
28 Q_OBJECT; // for translation context
29
30 public:
31 static void register_transceivers(TransceiverFactory::Transceivers *);
32 static void unregister_transceivers();
33
34 explicit HamlibTransceiver(int model_number,
36 QObject *parent = nullptr);
37 explicit HamlibTransceiver(TransceiverFactory::PTTMethod ptt_type,
38 QString const &ptt_port,
39 QObject *parent = nullptr);
40
41 protected:
44 virtual void hamlib_bug_bandaid(TransceiverState const &s) override;
45
46 private:
47 int do_start() override;
48 void do_stop() override;
49 void do_frequency(Frequency, MODE, bool no_ignore) override;
50 void do_tx_frequency(Frequency, MODE, bool no_ignore) override;
51 void do_mode(MODE) override;
52 void do_ptt(bool) override;
53
54 void poll() override;
55
56 void error_check(int ret_code, QString const &doing) const;
57 void set_conf(char const *item, char const *value);
58 QByteArray get_conf(char const *item);
59 Transceiver::MODE map_mode(rmode_t) const;
60 rmode_t map_mode(Transceiver::MODE mode) const;
61 std::tuple<vfo_t, vfo_t> get_vfos(bool for_split) const;
62
63 struct RIGDeleter {
64 static void cleanup(RIG *);
65 };
66 QScopedPointer<RIG, RIGDeleter> rig_;
67
68 bool back_ptt_port_;
69 bool one_VFO_;
70 bool is_dummy_;
71
72 // these are saved on destruction so we can start new instances
73 // where the last one left off
74 static freq_t dummy_frequency_;
75 static rmode_t dummy_mode_;
76
77 bool mutable reversed_;
78
79 bool freq_query_works_;
80 bool mode_query_works_;
81 bool split_query_works_;
82 bool tickle_hamlib_; // Hamlib requires a
83 // rig_set_split_vfo() call to
84 // establish the Tx VFO
85 bool get_vfo_works_; // Net rigctl promises what it can't deliver
86 bool set_vfo_works_; // More rigctl promises which it can't deliver
87};
88
89#endif
virtual void hamlib_bug_bandaid(TransceiverState const &s) override
Definition HamlibTransceiver.cpp:769
Definition Transceiver.h:83
Definition TransceiverFactory.h:105