-
Notifications
You must be signed in to change notification settings - Fork 1
/
cat.h
112 lines (94 loc) · 3.61 KB
/
cat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Peaberry CW - Transceiver for Peaberry SDR
// Copyright (C) 2015 David Turnbull AE9RB
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CAT_H
#define CAT_H
#include <string>
#include <cstdint>
#include "libusb-1.0/libusb.h"
#include "Config.h"
#define USBDEV_SHARED_VENDOR 0x16C0 // VOTI VID
#define USBDEV_SHARED_PRODUCT 0x05DC // OBDEV PID
#define VENDOR_NAME_OBDEV "www.obdev.at"
#define IAMBIC_MODE_B (1 << 0)
#define IAMBIC_SKEY (1 << 1)
#define IAMBIC_AUTOSPACE (1 << 2)
#define IAMBIC_RST_N (1 << 7)
enum class CatCommandID : uint16_t {
// Set local oscillator frequency in Hz.
// int64_t frequency
SetFreq,
// Set the CW TX frequency in Hz.
// int64_t frequency
SetCWTxFreq,
// Set the CW keyer speed in Words per Minute.
// Limited to <5, 45>
// uint8_t
SetCWKeyerSpeed,
// KeyerMode mode
// uint8_t
SetKeyerMode,
// Delay of the dit sent after dit played, to avoid hot switching of the AMP relay, in microseconds. Maximum time is 15ms.
// Relay hang after the last dit, in microseconds. Maximum time is 10 seconds.
// bool enabled, uint32_t delay, uint32_t hang
SetAMPControl,
// CW phase & amplitude balance and output power.
// double phase_balance_deg, double amplitude_balance, double power
SetIQBalanceAndPower,
};
class Cat {
public:
Cat() {}
~Cat() {}
bool init(libusb_device_handle *handle);
const std::string get_error() const { return error; }
std::string error;
std::string serialNumber;
// Set local oscillator frequency in Hz.
bool set_freq(int64_t frequency);
// Set the CW TX frequency in Hz.
bool set_cw_tx_freq(int64_t frequency);
// Set the CW keyer speed in Words per Minute.
// Limited to <5, 45>
bool set_cw_keyer_speed(int wpm);
bool set_cw_keyer_mode(KeyerMode mode);
// Delay of the dit sent after dit played, to avoid hot switching of the AMP relay, in microseconds. Maximum time is 15ms.
// Relay hang after the last dit, in microseconds. Maximum time is 10 seconds.
bool set_amp_control(bool enabled, int delay, int hang);
bool setIQBalanceAndPower(double phase_balance_deg, double amplitude_balance, double power);
private:
// int findPeaberryDevice();
std::string readUsbString(struct usb_dev_handle *udh, uint8_t iDesc);
libusb_context *m_libusb_context = nullptr;
libusb_device *m_libusb_device = nullptr;
libusb_device_handle *m_libusb_device_handle = nullptr;
int64_t freqChangeMark = 0;
int64_t currentFreq = 0;
int64_t requestedFreq = 0;
int64_t freq = 0;
int64_t xit = 0;
int64_t rit = 0;
bool transmitOK = false;
void start();
void stop();
void setFreq(int64_t f) { freq = f; requestedFreq = f + rit; approveTransmit(); }
void setXit(int64_t f) { xit = f; approveTransmit(); }
void setRit(int64_t f) { rit = f; requestedFreq = f + freq; }
private:
void doWork();
void approveTransmit();
};
extern Cat g_Cat;
#endif // CAT_H