Replace the wxWidgets dependency with standard C++17 throughout the entire codebase, producing a clean, portable, thoroughly reviewed CLI daemon that builds on Linux, Windows, and macOS without any GUI toolkit. == Removed == - GUI application and config editor (DStarRepeaterFrame, DStarRepeaterConfig/) - GUI widget library (GUICommon/) - Windows USB drivers (WindowsUSB/) - Visual Studio solutions and project files (.sln, .vcxproj) - NSIS installer scripts, platform-specific makefiles - wxWidgets-specific files (LogEvent, LogRedirect, GMSKModemWinUSB) - Dead code: unused GUI constants, vestigial command methods, unused DTMF/queue constants in non-TRX thread variants == Core conversion (all source files) == - wxString -> std::string, wxArrayString -> std::vector<std::string> - wxFloat32 -> float, wxUint8/16/32 -> uint8_t/16_t/32_t - wxThread -> std::thread, wxMutex -> std::mutex - wxStopWatch -> std::chrono::steady_clock - wxRegEx -> std::regex, wxDynLib -> dlopen/dlsym - wxFFile -> FILE*, wxTextFile -> std::ifstream - WX_DECLARE_STRING_HASH_MAP -> std::unordered_map - volatile -> std::atomic for ring buffer and cross-thread flags - NULL -> nullptr throughout == INI config format (MMDVMHost compatible) == - [Section]/Key=Value INI format replaces flat key=value - Config file path is the single required command-line argument: dstarrepeaterd <config-file> - [Log] section: FilePath, FileLevel, DisplayLevel, MQTTLevel (levels 0-6 matching MMDVMHost convention) - [Paths] section: Data and Audio directories from config - [Whitelist]/[Blacklist]/[Greylist] file paths from config - All compile-time path defines (CONF_DIR, LOG_DIR) removed - Example config: Data/dstarrepeater.ini.example == Build system == - Plain g++ -std=c++17, no wx-config dependency - Defaults: release build, MQTT on, GPIO auto-detected - GPIO auto-detection checks uname -s (Linux only) and uname -m (arm/aarch64) to avoid false match on macOS Apple Silicon - Zero warnings with -Wall on GCC 13 - Verified on Ubuntu 24.04, Debian Trixie, and Alpine 3.21 == Install layout == - Binary: /usr/bin/dstarrepeaterd - AMBE voice data: /usr/share/dstarrepeater/ - Config directory: /etc/dstarrepeater/ (created on install) - Example config: /etc/dstarrepeater/dstarrepeater.ini.example == Cross-platform support == - EndianCompat.h: byte-swap functions for Linux, macOS, and Windows - Serial ports: Win32 CreateFile/ReadFile/WriteFile alongside POSIX - Sockets: Winsock2 with RAII WSAStartup alongside POSIX - Sound card: PortAudio for Windows/macOS, ALSA for Linux - All platform code is additive (#ifdef _WIN32), no Linux code changed == Standalone logger == - Thread-safe file logger with std::mutex and daily UTC rotation - Level-based filtering for file, display (stdout), and MQTT sinks - LogLevel enum matches MMDVMHost numbering (1=Debug through 6=Fatal) - Thread-safe gmtime via gmtime_r/gmtime_s - Atomic singleton for safe cross-thread access == Display-Driver MQTT compatibility == - All JSON messages match Display-Driver's expected format exactly - D-Star start/end/lost events with callsigns and source (rf/net) - BER updates during active RF - DVAP RSSI signal strength publishing - Slow-data text forwarding - MMDVM idle mode transitions - JSON escaping on all callsign/text fields from over-the-air data - JSON schema: schema.json with validated $defs structure == Security and safety fixes == - All cross-thread bool flags: std::atomic<bool> - MQTTConnection m_connected and DVAP m_signal/m_squelchOpen: atomic - RingBuffer: std::atomic<unsigned int> for ARM correctness - All sprintf -> snprintf to prevent buffer overflows - JSON escaping for all MQTT output from untrusted sources - DVTOOLFileWriter filename sanitization (path traversal prevention) - Thread-safe localtime_r/localtime_s in DVTOOLFileWriter - GatewayProtocolHandler: bounded string from network buffer - Integer underflow guards in protocol handler readData() - Buffer bounds checks in writePoll()/writeRegister() - MMDVM printDebug() minimum length guards - PID file: /var/run with O_NOFOLLOW, PID written for systemd - Exception-safe createThread() with full cleanup on failure - Deprecated gethostbyname() replaced with getaddrinfo() - CRLF stripping in callsign list loader - Infinite loop exits in DVAP resync() and serial getResponse() - Null guards in SoundCardReaderWriter::close() - RingBuffer::hasSpace() off-by-one fixed == Memory safety == - Delete protocol handler, modem, controller on open()/start() failure - Thread destructors clean up all owned objects with null-after-delete - Callsign lists properly deleted in TX/RX/TXRX thread no-op setters - BeaconUnit buffer allocation matched to actual write size (DV_FRAME) - Null dereference fix in endOfNetworkData() for network-first streams == Functional fixes == - Restored DTMF command execution (system() via checkControl()) - Fixed getControl() parameter order (commands 3-6 were swapped) - Fixed getStatus() argument order in idle branch (BER was at wrong position, causing MQTT to report garbage BER when idle) - Added missing GMSK interface type config parsing - Fixed IcomController uninitialized buffer and sync check order - Fixed SplitController format string vulnerability - Fixed DVAPController dumpPackets() dead loop - Inline const arrays in DStarDefines.h (ODR compliance) == Documentation == - Comprehensive comments added to all source files - README.md: quick start, dependency tables, usage guide - CONFIGURATION.md: complete INI format reference - MQTT.md: updated for INI config, Display-Driver integration - BUILD.md: per-platform instructions (Linux, Windows, macOS) - CHANGELOG.md: version history, newest first - schema.json: JSON schema for all MQTT messages Version bumped to 20260319.pull/17/head
parent
630ff49231
commit
c2406d9f11
@ -0,0 +1,133 @@
|
||||
# Building DStarRepeater
|
||||
|
||||
## Linux
|
||||
|
||||
### Dependencies
|
||||
|
||||
| Package | Ubuntu / Debian | Alpine | Purpose |
|
||||
|---------|-----------------|--------|---------|
|
||||
| C++17 compiler | `g++` (GCC 13+) | `g++` | Compilation |
|
||||
| GNU Make | `make` | `make` | Build system |
|
||||
| ALSA dev | `libasound2-dev` | `alsa-lib-dev` | Sound card modem |
|
||||
| libusb 1.0 dev | `libusb-1.0-0-dev` | `libusb-dev` | USB modem (GMSK) |
|
||||
| Mosquitto dev | `libmosquitto-dev` | `mosquitto-dev` | MQTT telemetry (on by default) |
|
||||
| Linux headers | — | `linux-headers` | Required on Alpine only |
|
||||
|
||||
**Raspberry Pi (additional):**
|
||||
|
||||
| Package | Install | Purpose |
|
||||
|---------|---------|---------|
|
||||
| wiringPi | `sudo apt-get install wiringpi` or [build from source](https://github.com/WiringPi/WiringPi) | GPIO controller (on by default on ARM) |
|
||||
|
||||
### Install (one-liner)
|
||||
|
||||
**Ubuntu / Debian:**
|
||||
```bash
|
||||
sudo apt-get install g++ make libasound2-dev libusb-1.0-0-dev libmosquitto-dev
|
||||
```
|
||||
|
||||
**Raspberry Pi:**
|
||||
```bash
|
||||
sudo apt-get install g++ make libasound2-dev libusb-1.0-0-dev libmosquitto-dev wiringpi
|
||||
```
|
||||
|
||||
**Alpine:**
|
||||
```bash
|
||||
apk add g++ make alsa-lib-dev libusb-dev linux-headers mosquitto-dev
|
||||
```
|
||||
|
||||
### Build
|
||||
|
||||
By default, `make` produces a release build with MQTT enabled and GPIO auto-detected (on for ARM).
|
||||
|
||||
```bash
|
||||
make # default: release, MQTT on, GPIO auto
|
||||
make MQTT=0 # without MQTT (no libmosquitto-dev needed)
|
||||
make GPIO=0 # without GPIO (no wiringPi needed)
|
||||
make BUILD=debug # debug build with symbols and assertions
|
||||
```
|
||||
|
||||
### Install
|
||||
|
||||
```bash
|
||||
sudo make install
|
||||
```
|
||||
|
||||
This installs:
|
||||
- `dstarrepeaterd` to `/usr/bin`
|
||||
- AMBE voice beacon data to `/usr/share/dstarrepeater/`
|
||||
- Example config to `/etc/dstarrepeater/dstarrepeater.ini.example`
|
||||
|
||||
---
|
||||
|
||||
## Windows
|
||||
|
||||
The source includes `#if defined(_WIN32)` blocks throughout. The provided `Makefile` targets Linux only — you will need a Visual Studio project or CMakeLists.txt.
|
||||
|
||||
### Compiler
|
||||
|
||||
| Option | Requirement |
|
||||
|--------|-------------|
|
||||
| Visual Studio 2019+ | Enable `/std:c++17` in project properties |
|
||||
| MinGW-w64 (MSYS2) | `g++ -std=c++17` |
|
||||
|
||||
### Libraries
|
||||
|
||||
| Library | Source | Required? |
|
||||
|---------|--------|-----------|
|
||||
| Windows SDK | Included with Visual Studio | Yes — provides Winsock2, serial port, and console APIs |
|
||||
| [libusb 1.0](https://libusb.info/) | Pre-built Windows binaries available | Yes — GMSK modem support |
|
||||
| [PortAudio](http://www.portaudio.com/) | Build from source or use vcpkg | Yes — sound card modem (replaces ALSA) |
|
||||
| [Eclipse Mosquitto](https://mosquitto.org/) | Installer or vcpkg | Optional — only for MQTT builds |
|
||||
|
||||
### Linker flags
|
||||
|
||||
```
|
||||
ws2_32.lib Winsock2 (sockets)
|
||||
portaudio.lib Sound card modem
|
||||
libusb-1.0.lib GMSK modem
|
||||
mosquitto.lib MQTT (optional)
|
||||
```
|
||||
|
||||
### Platform notes
|
||||
|
||||
- Serial ports use `CreateFile` / `ReadFile` / `WriteFile` (Win32 API)
|
||||
- Sockets use Winsock2 with automatic `WSAStartup` / `WSACleanup`
|
||||
- Signal handling uses `SetConsoleCtrlHandler` (Ctrl+C, close events)
|
||||
- Single-instance enforcement uses a named mutex (no PID file)
|
||||
- K8055 (Velleman) and URI USB controllers are stub-only on Windows — they require vendor DLLs that are not yet integrated
|
||||
|
||||
---
|
||||
|
||||
## macOS
|
||||
|
||||
The source includes macOS support for endian handling (`OSByteOrder.h`), serial ports (POSIX `termios`, same as Linux), and PortAudio audio. The `Makefile` currently targets Linux only.
|
||||
|
||||
### Dependencies (Homebrew)
|
||||
|
||||
```bash
|
||||
xcode-select --install
|
||||
brew install libusb portaudio
|
||||
```
|
||||
|
||||
For MQTT support:
|
||||
```bash
|
||||
brew install mosquitto
|
||||
```
|
||||
|
||||
### Building
|
||||
|
||||
The Makefile needs adjusted compiler flags and Homebrew library paths for macOS. A minimal approach:
|
||||
|
||||
```bash
|
||||
export CFLAGS="-std=c++17 -O2 -Wall -I$(brew --prefix)/include"
|
||||
export LDFLAGS="-L$(brew --prefix)/lib"
|
||||
# then adjust the Makefile or build manually
|
||||
```
|
||||
|
||||
### Platform notes
|
||||
|
||||
- Endian conversion uses `<libkern/OSByteOrder.h>` (via `EndianCompat.h`)
|
||||
- Sound card modem uses PortAudio (same as Windows)
|
||||
- Serial ports use POSIX `termios` (same as Linux)
|
||||
- ALSA is not available — sound card modem requires PortAudio
|
||||
@ -1,70 +0,0 @@
|
||||
Repeater - 20180710
|
||||
===================
|
||||
|
||||
Windows
|
||||
-------
|
||||
|
||||
To use the Repeater control software you will first need to build the latest
|
||||
version of wxWidgets (http://www.wxwidgets.org), the version I used was 3.0.4.
|
||||
I also installed it in the default location which is C:\wxWidgets-3.0.4.
|
||||
|
||||
You will also need a copy of PortAudio (http://www.portaudio.com), I used the
|
||||
latest stable version and it appears to be fine. I put that into the
|
||||
"Visual Studio 2017\Projects" folder alongside the source code for the
|
||||
Repeater itself.
|
||||
|
||||
For compiling I use Visual C++ 2017 Community Edition downloaded from Microsoft
|
||||
for free. I recommend that you use the same.
|
||||
|
||||
To build wxWidgets, you simply need to open Visual Studio 2017 using the File ->
|
||||
Open -> Projects/Solutions and load the wx_vc12.sln file to be found in
|
||||
wxWidgets-3.0.4\build\msw directory and then go into Batch Build and select the
|
||||
DLL Debug and DLL Release entries for every one, this take a little time! Then
|
||||
build them.
|
||||
|
||||
Unfortunately building the software under Windows also requires the downloading
|
||||
of a very large file from Microsoft, the WDK. There is no easy way around this
|
||||
but once installed it can be forgotten about.
|
||||
|
||||
The path names for things like wxWidgets and PortAudio are embedded within the
|
||||
Solution and Project preferences, and will need changing if anything other than
|
||||
these default locations are used. The first pass through the compiler will no
|
||||
doubt tell you all that you need to know if there are problems.
|
||||
|
||||
Once you have built the executables, you will need to copy the correct portaudio
|
||||
and wxWidgets files to the same location as the executables. For 32-bit systems
|
||||
these are portaudio_x86.dll, wxbase30u_vc_custom.dll, wxmsw30u_adv_vc_custom.dll,
|
||||
and wxmsw30u_core_vc_custom.dll. On 64-bit systems you'll need portaudio_x64.dll,
|
||||
wxbase30u_vc_x64_custom.dll, wxmsw30u_adv_vc_x64_custom.dll, and
|
||||
wxmsw30u_core_vc_x64_custom.dll
|
||||
|
||||
If you are running in debug mode then the required wxWidgets files have the names
|
||||
xxx30ud_xxxx instead. These can be found in the wxWidgets-3.0.4\lib\vc_dll
|
||||
directory.
|
||||
|
||||
It is also probable that you'll need to install a copy of the latest Visual C++
|
||||
run-time libraries from Microsoft, if you are not running the repeater software
|
||||
on the same machine as the development/compilation was done on. You can find the
|
||||
latest versions at https://support.microsoft.com/en-gb/help/2977003/the-latest-supported-visual-c-downloads
|
||||
|
||||
Linux
|
||||
-----
|
||||
|
||||
You need to ensure that wxGTK, ALSA and libusb-1.0 are already
|
||||
installed on your machine, under Ubuntu these are available from the standard
|
||||
repositories, the version of wxWidgets is adequate. However you should get the
|
||||
latest version of PortAudio from its home and build it from scratch.
|
||||
|
||||
To install them from scratch, you need to get wxGTK from
|
||||
<http://www.wxwidgets.org>, and libusb-1.0 from <http://www.libusb.org/wiki/libusb-1.0>.
|
||||
If you do a "make install" on all of them then they'll be installed in the
|
||||
right places and nothing more needs to be done.
|
||||
|
||||
On the Raspberry Pi you will need to build and install the wiringPi GPIO library
|
||||
which is available from <https://projects.drogon.net/raspberry-pi/wiringpi>.
|
||||
This will allow use the GPIO pins as controller pins for the different repeaters
|
||||
if needed.
|
||||
|
||||
To actually build the software, type "make" in the same directory as this file
|
||||
and all should build without errors, there may be a warning or two though. Once
|
||||
compiled log in as root or use the sudo command, and do "make install".
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,332 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AMBEFEC.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="AnnouncementUnit.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ArduinoController.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="BeaconUnit.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CallsignList.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CCITTChecksum.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CCITTChecksumReverse.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DStarGMSKDemodulator.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DStarGMSKModulator.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DStarRepeaterConfig.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DummyController.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DVAPController.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DVMegaController.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DVRPTRV1Controller.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DVRPTRV2Controller.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DVRPTRV3Controller.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DVTOOLFileReader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DVTOOLFileWriter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ExternalController.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FIRFilter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GatewayProtocolHandler.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GMSKController.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GMSKModem.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GMSKModemLibUsb.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GMSKModemWinUSB.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Golay.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HardwareController.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HeaderData.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="K8055Controller.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LogEvent.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Logger.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MMDVMController.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Modem.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="OutputQueue.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RepeaterProtocolHandler.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SerialDataController.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SerialLineController.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SerialPortSelector.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SlowDataDecoder.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SlowDataEncoder.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SoundCardController.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SoundCardReaderWriter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SplitController.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TCPReaderWriter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Timer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="UDPReaderWriter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Utils.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="URIUSBController.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IcomController.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="AMBEFEC.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="AnnouncementCallback.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="AnnouncementUnit.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ArduinoController.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="AudioCallback.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BeaconCallback.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BeaconUnit.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CallsignList.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CCITTChecksum.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CCITTChecksumReverse.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DStarDefines.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DStarGMSKDemodulator.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DStarGMSKModulator.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DStarRepeaterConfig.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DummyController.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DVAPController.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DVMegaController.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DVRPTRV1Controller.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DVRPTRV2Controller.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DVRPTRV3Controller.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DVTOOLFileReader.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DVTOOLFileWriter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ExternalController.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FIRFilter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GatewayProtocolHandler.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GMSKController.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GMSKModem.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GMSKModemLibUsb.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GMSKModemWinUSB.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Golay.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HardwareController.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HeaderData.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="K8055Controller.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="LogEvent.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Logger.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lusb0_usb.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MMDVMController.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Modem.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="OutputQueue.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RepeaterProtocolHandler.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RingBuffer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SerialDataController.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SerialLineController.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SerialPortSelector.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SlowDataDecoder.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SlowDataEncoder.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SoundCardController.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SoundCardReaderWriter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SplitController.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="TCPReaderWriter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Timer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="UDPReaderWriter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Utils.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Version.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="URIUSBController.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="IcomController.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Cross-platform byte-swap functions for the D-Star wire format.
|
||||
*
|
||||
* D-Star protocol fields are little-endian on the wire. This header provides
|
||||
* htole16/le16toh/htole32/le32toh/htobe32/be32toh using the appropriate
|
||||
* platform API (POSIX <endian.h> on Linux, OSByteOrder on macOS, and
|
||||
* _byteswap intrinsics on Windows x86). Include this wherever protocol
|
||||
* buffers are serialised or deserialised.
|
||||
*/
|
||||
|
||||
#ifndef EndianCompat_H
|
||||
#define EndianCompat_H
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <cstdlib>
|
||||
// Windows: use _byteswap intrinsics
|
||||
static inline uint16_t htole16(uint16_t x) { return x; } // x86 is little-endian
|
||||
static inline uint16_t le16toh(uint16_t x) { return x; }
|
||||
static inline uint32_t htole32(uint32_t x) { return x; }
|
||||
static inline uint32_t le32toh(uint32_t x) { return x; }
|
||||
static inline uint32_t htobe32(uint32_t x) { return _byteswap_ulong(x); }
|
||||
static inline uint32_t be32toh(uint32_t x) { return _byteswap_ulong(x); }
|
||||
#elif defined(__APPLE__)
|
||||
#include <libkern/OSByteOrder.h>
|
||||
#define htole16(x) OSSwapHostToLittleInt16(x)
|
||||
#define le16toh(x) OSSwapLittleToHostInt16(x)
|
||||
#define htole32(x) OSSwapHostToLittleInt32(x)
|
||||
#define le32toh(x) OSSwapLittleToHostInt32(x)
|
||||
#define htobe32(x) OSSwapHostToBigInt32(x)
|
||||
#define be32toh(x) OSSwapBigToHostInt32(x)
|
||||
#else
|
||||
#include <endian.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1,381 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "GMSKModemWinUSB.h"
|
||||
#include "DStarDefines.h"
|
||||
|
||||
#include <Setupapi.h>
|
||||
|
||||
const unsigned char SET_AD_INIT = 0x00U;
|
||||
const unsigned char SET_PTT = 0x05U;
|
||||
const unsigned char PUT_DATA = 0x10U;
|
||||
const unsigned char GET_DATA = 0x11U;
|
||||
const unsigned char GET_HEADER = 0x21U;
|
||||
const unsigned char GET_AD_STATUS = 0x30U;
|
||||
const unsigned char SET_MyCALL = 0x40U;
|
||||
const unsigned char SET_MyCALL2 = 0x41U;
|
||||
const unsigned char SET_YourCALL = 0x42U;
|
||||
const unsigned char SET_RPT1CALL = 0x43U;
|
||||
const unsigned char SET_RPT2CALL = 0x44U;
|
||||
const unsigned char SET_FLAGS = 0x45U;
|
||||
const unsigned char GET_REMAINSPACE = 0x50U;
|
||||
const unsigned char GET_VERSION = 0xFFU;
|
||||
|
||||
const unsigned char COS_OnOff = 0x02U;
|
||||
const unsigned char CRC_ERROR = 0x04U;
|
||||
const unsigned char LAST_FRAME = 0x08U;
|
||||
const unsigned char PTT_OnOff = 0x20U;
|
||||
|
||||
const unsigned char PTT_ON = 1U;
|
||||
const unsigned char PTT_OFF = 0U;
|
||||
|
||||
CGMSKModemWinUSB::CGMSKModemWinUSB(unsigned int address) :
|
||||
m_address(address),
|
||||
m_file(INVALID_HANDLE_VALUE),
|
||||
m_handle(INVALID_HANDLE_VALUE),
|
||||
m_brokenSpace(false)
|
||||
{
|
||||
}
|
||||
|
||||
CGMSKModemWinUSB::~CGMSKModemWinUSB()
|
||||
{
|
||||
}
|
||||
|
||||
bool CGMSKModemWinUSB::open()
|
||||
{
|
||||
wxASSERT(m_handle == INVALID_HANDLE_VALUE);
|
||||
|
||||
bool res = openModem();
|
||||
if (!res) {
|
||||
wxLogError(wxT("Cannot find the GMSK Modem with address: 0x%04X"), m_address);
|
||||
return false;
|
||||
}
|
||||
|
||||
wxLogInfo(wxT("Found the GMSK Modem with address: 0x%04X"), m_address);
|
||||
|
||||
wxString version;
|
||||
|
||||
int ret;
|
||||
do {
|
||||
unsigned char buffer[GMSK_MODEM_DATA_LENGTH];
|
||||
ret = io(GET_VERSION, 0xC0U, 0U, buffer, GMSK_MODEM_DATA_LENGTH);
|
||||
if (ret > 0) {
|
||||
wxString text((char*)buffer, wxConvLocal, ret);
|
||||
version.Append(text);
|
||||
} else if (ret < 0) {
|
||||
wxLogError(wxT("GET_VERSION returned %d"), -ret);
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
} while (ret == int(GMSK_MODEM_DATA_LENGTH));
|
||||
|
||||
wxLogInfo(wxT("Firmware version: %s"), version.c_str());
|
||||
|
||||
// Trap firmware version 0.1.00 of DUTCH*Star and complain loudly
|
||||
if (version.Find(wxT("DUTCH*Star")) != wxNOT_FOUND && version.Find(wxT("0.1.00")) != wxNOT_FOUND) {
|
||||
wxLogWarning(wxT("This modem firmware is not supported by the repeater"));
|
||||
wxLogWarning(wxT("Please upgrade to a newer version"));
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
|
||||
// DUTCH*Star firmware has a broken concept of free space
|
||||
if (version.Find(wxT("DUTCH*Star")) != wxNOT_FOUND)
|
||||
m_brokenSpace = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGMSKModemWinUSB::readHeader(unsigned char* header, unsigned int length)
|
||||
{
|
||||
wxASSERT(header != NULL);
|
||||
wxASSERT(length > (RADIO_HEADER_LENGTH_BYTES * 2U));
|
||||
|
||||
unsigned int offset = 0U;
|
||||
|
||||
while (offset < RADIO_HEADER_LENGTH_BYTES) {
|
||||
int ret = io(GET_HEADER, 0xC0U, 0U, header + offset, GMSK_MODEM_DATA_LENGTH);
|
||||
if (ret < 0) {
|
||||
wxLogError(wxT("GET_HEADER returned %d"), -ret);
|
||||
return false;
|
||||
} else if (ret == 0) {
|
||||
if (offset == 0U)
|
||||
return false;
|
||||
|
||||
::wxMilliSleep(10UL);
|
||||
|
||||
unsigned char status;
|
||||
ret = io(GET_AD_STATUS, 0xC0U, 0U, &status, 1U);
|
||||
if (ret < 0) {
|
||||
wxLogError(wxT("GET_COS returned %d"), -ret);
|
||||
return false;
|
||||
} else if (ret > 0) {
|
||||
if ((status & COS_OnOff) == COS_OnOff)
|
||||
offset = 0U;
|
||||
}
|
||||
} else {
|
||||
offset += ret;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char status;
|
||||
int ret = io(GET_AD_STATUS, 0xC0U, 0U, &status, 1U);
|
||||
if (ret < 0) {
|
||||
wxLogError(wxT("GET_CRC returned %d"), -ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((status & CRC_ERROR) == CRC_ERROR) {
|
||||
wxLogMessage(wxT("Invalid CRC on header"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int CGMSKModemWinUSB::readData(unsigned char* data, unsigned int length, bool& end)
|
||||
{
|
||||
wxASSERT(data != NULL);
|
||||
wxASSERT(length > 0U);
|
||||
|
||||
end = false;
|
||||
|
||||
int ret = io(GET_DATA, 0xC0U, 0U, data, GMSK_MODEM_DATA_LENGTH);
|
||||
if (ret < 0) {
|
||||
wxLogError(wxT("GET_DATA returned %d"), -ret);
|
||||
return ret;
|
||||
} else if (ret == 0) {
|
||||
unsigned char status;
|
||||
int ret = io(GET_AD_STATUS, 0xC0U, 0U, &status, 1U);
|
||||
if (ret < 0) {
|
||||
wxLogError(wxT("LAST_FRAME returned %d"), -ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((status & LAST_FRAME) == LAST_FRAME)
|
||||
end = true;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CGMSKModemWinUSB::writeHeader(unsigned char* header, unsigned int length)
|
||||
{
|
||||
wxASSERT(header != NULL);
|
||||
wxASSERT(length >= (RADIO_HEADER_LENGTH_BYTES - 2U));
|
||||
|
||||
io(SET_MyCALL2, 0x40U, 0U, header + 35U, SHORT_CALLSIGN_LENGTH);
|
||||
io(SET_MyCALL, 0x40U, 0U, header + 27U, LONG_CALLSIGN_LENGTH);
|
||||
io(SET_YourCALL, 0x40U, 0U, header + 19U, LONG_CALLSIGN_LENGTH);
|
||||
io(SET_RPT1CALL, 0x40U, 0U, header + 11U, LONG_CALLSIGN_LENGTH);
|
||||
io(SET_RPT2CALL, 0x40U, 0U, header + 3U, LONG_CALLSIGN_LENGTH);
|
||||
io(SET_FLAGS, 0x40U, 0U, header + 0U, 3U);
|
||||
}
|
||||
|
||||
TRISTATE CGMSKModemWinUSB::getPTT()
|
||||
{
|
||||
unsigned char status;
|
||||
int ret = io(GET_AD_STATUS, 0xC0U, 0U, &status, 1U);
|
||||
if (ret != 1) {
|
||||
wxLogError(wxT("GET_PTT returned %d"), -ret);
|
||||
return STATE_UNKNOWN;
|
||||
}
|
||||
|
||||
if ((status & PTT_OnOff) == PTT_OnOff)
|
||||
return STATE_TRUE;
|
||||
else
|
||||
return STATE_FALSE;
|
||||
}
|
||||
|
||||
void CGMSKModemWinUSB::setPTT(bool on)
|
||||
{
|
||||
unsigned char c;
|
||||
io(SET_PTT, 0x40U, on ? PTT_ON : PTT_OFF, &c, 0U);
|
||||
}
|
||||
|
||||
TRISTATE CGMSKModemWinUSB::hasSpace()
|
||||
{
|
||||
unsigned char space;
|
||||
int ret = io(GET_REMAINSPACE, 0xC0U, 0U, &space, 1U);
|
||||
if (ret != 1) {
|
||||
wxLogError(wxT("GET_REMAINSPACE returned %d"), -ret);
|
||||
return STATE_UNKNOWN;
|
||||
}
|
||||
|
||||
if (space >= DV_FRAME_LENGTH_BYTES)
|
||||
return STATE_TRUE;
|
||||
else
|
||||
return STATE_FALSE;
|
||||
}
|
||||
|
||||
int CGMSKModemWinUSB::writeData(unsigned char* data, unsigned int length)
|
||||
{
|
||||
wxASSERT(data != NULL);
|
||||
wxASSERT(length > 0U && length <= DV_FRAME_LENGTH_BYTES);
|
||||
|
||||
if (length > GMSK_MODEM_DATA_LENGTH) {
|
||||
int ret = io(PUT_DATA, 0x40U, 0U, data, GMSK_MODEM_DATA_LENGTH);
|
||||
if (ret < 0) {
|
||||
if (ret == -22) {
|
||||
wxLogError(wxT("PUT_DATA 1, returned %d"), -ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = io(PUT_DATA, 0x40U, 0U, data + GMSK_MODEM_DATA_LENGTH, length - GMSK_MODEM_DATA_LENGTH);
|
||||
if (ret < 0) {
|
||||
if (ret == -22) {
|
||||
wxLogError(wxT("PUT_DATA 2, returned %d"), -ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return int(GMSK_MODEM_DATA_LENGTH);
|
||||
}
|
||||
|
||||
return length;
|
||||
} else {
|
||||
int ret = io(PUT_DATA, 0x40U, 0U, data, length);
|
||||
if (ret < 0) {
|
||||
if (ret == -22) {
|
||||
wxLogError(wxT("PUT_DATA returned %d"), -ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
}
|
||||
|
||||
void CGMSKModemWinUSB::close()
|
||||
{
|
||||
wxASSERT(m_file != INVALID_HANDLE_VALUE);
|
||||
wxASSERT(m_handle != INVALID_HANDLE_VALUE);
|
||||
|
||||
::CloseHandle(m_file);
|
||||
::WinUsb_Free(m_handle);
|
||||
|
||||
m_file = INVALID_HANDLE_VALUE;
|
||||
m_handle = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
bool CGMSKModemWinUSB::openModem()
|
||||
{
|
||||
WCHAR id1[15U], id2[15U];
|
||||
::swprintf(id1, L"pid_%04x", m_address);
|
||||
::swprintf(id2, L"pid_%04X", m_address);
|
||||
|
||||
wxString wxId1(id1, wxConvLocal);
|
||||
wxString wxId2(id2, wxConvLocal);
|
||||
|
||||
CLSID clsId;
|
||||
LPOLESTR str = OLESTR("{136C76EF-3F4E-4030-A7E3-E1003EF0A715}");
|
||||
HRESULT result = ::CLSIDFromString(str, &clsId);
|
||||
if (result != NOERROR) {
|
||||
wxLogError(wxT("Error from CLSIDFromString: err=%lu"), ::GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
HDEVINFO devInfo = ::SetupDiGetClassDevs(&clsId, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
|
||||
if (devInfo == INVALID_HANDLE_VALUE) {
|
||||
wxLogError(wxT("Error from SetupDiGetClassDevs: err=%lu"), ::GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
SP_DEVICE_INTERFACE_DATA devInfoData;
|
||||
devInfoData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
||||
|
||||
for (unsigned int index = 0U; ::SetupDiEnumDeviceInterfaces(devInfo, NULL, &clsId, index, &devInfoData); index++) {
|
||||
DWORD length;
|
||||
::SetupDiGetDeviceInterfaceDetail(devInfo, &devInfoData, NULL, 0U, &length, NULL);
|
||||
|
||||
PSP_DEVICE_INTERFACE_DETAIL_DATA detailData = PSP_DEVICE_INTERFACE_DETAIL_DATA(::malloc(length));
|
||||
detailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
|
||||
|
||||
DWORD required;
|
||||
BOOL ret1 = ::SetupDiGetDeviceInterfaceDetail(devInfo, &devInfoData, detailData, length, &required, NULL);
|
||||
if (!ret1) {
|
||||
wxLogError(wxT("Error from SetupDiGetDeviceInterfaceDetail: err=%lu"), ::GetLastError());
|
||||
::SetupDiDestroyDeviceInfoList(devInfo);
|
||||
::free(detailData);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check the name to see if it's the correct vendor id and address
|
||||
if (::wcsstr(detailData->DevicePath, id1) == NULL && ::wcsstr(detailData->DevicePath, id2) == NULL) {
|
||||
::free(detailData);
|
||||
continue;
|
||||
}
|
||||
|
||||
m_file = ::CreateFile(detailData->DevicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
|
||||
if (m_file == INVALID_HANDLE_VALUE) {
|
||||
wxLogError(wxT("Error from CreateFile: err=%lu"), ::GetLastError());
|
||||
::SetupDiDestroyDeviceInfoList(devInfo);
|
||||
::free(detailData);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret1 = ::WinUsb_Initialize(m_file, &m_handle);
|
||||
if (!ret1) {
|
||||
wxLogError(wxT("Error from WinUsb_Initialize: err=%lu"), ::GetLastError());
|
||||
::SetupDiDestroyDeviceInfoList(devInfo);
|
||||
::CloseHandle(m_file);
|
||||
::free(detailData);
|
||||
return false;
|
||||
}
|
||||
|
||||
::SetupDiDestroyDeviceInfoList(devInfo);
|
||||
::free(detailData);
|
||||
|
||||
unsigned char c;
|
||||
io(SET_AD_INIT, 0x40U, 0U, &c, 0U);
|
||||
|
||||
setPTT(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
::SetupDiDestroyDeviceInfoList(devInfo);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int CGMSKModemWinUSB::io(unsigned char type, unsigned char n1, unsigned char n2, unsigned char* buffer, unsigned int length)
|
||||
{
|
||||
wxASSERT(m_handle != INVALID_HANDLE_VALUE);
|
||||
|
||||
WINUSB_SETUP_PACKET packet;
|
||||
packet.RequestType = n1;
|
||||
packet.Request = type;
|
||||
packet.Value = n2;
|
||||
packet.Index = 0U;
|
||||
packet.Length = length;
|
||||
|
||||
ULONG transferred;
|
||||
BOOL ret = ::WinUsb_ControlTransfer(m_handle, packet, buffer, length, &transferred, 0);
|
||||
if (!ret) {
|
||||
long error = ::GetLastError();
|
||||
return -error;
|
||||
}
|
||||
|
||||
return transferred;
|
||||
}
|
||||
|
||||
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef GMSKModemWinUSB_H
|
||||
#define GMSKModemWinUSB_H
|
||||
|
||||
#include "GMSKModem.h"
|
||||
#include "Utils.h"
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
#include "winusb.h"
|
||||
|
||||
class CGMSKModemWinUSB : public IGMSKModem {
|
||||
public:
|
||||
CGMSKModemWinUSB(unsigned int address);
|
||||
virtual ~CGMSKModemWinUSB();
|
||||
|
||||
virtual bool open();
|
||||
|
||||
virtual bool readHeader(unsigned char* header, unsigned int length);
|
||||
virtual int readData(unsigned char* data, unsigned int length, bool& end);
|
||||
|
||||
virtual TRISTATE getPTT();
|
||||
virtual void setPTT(bool on);
|
||||
|
||||
virtual TRISTATE hasSpace();
|
||||
|
||||
virtual void writeHeader(unsigned char* data, unsigned int length);
|
||||
virtual int writeData(unsigned char* data, unsigned int length);
|
||||
|
||||
virtual void close();
|
||||
|
||||
private:
|
||||
unsigned int m_address;
|
||||
HANDLE m_file;
|
||||
WINUSB_INTERFACE_HANDLE m_handle;
|
||||
bool m_brokenSpace;
|
||||
|
||||
bool openModem();
|
||||
int io(unsigned char type, unsigned char n1, unsigned char n2, unsigned char* buffer, unsigned int length);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "LogEvent.h"
|
||||
|
||||
CLogEvent::CLogEvent(const wxString& text, wxEventType type, int id) :
|
||||
wxEvent(id, type),
|
||||
m_text(text)
|
||||
{
|
||||
}
|
||||
|
||||
CLogEvent::CLogEvent(const CLogEvent& event) :
|
||||
wxEvent(event),
|
||||
m_text(event.m_text)
|
||||
{
|
||||
}
|
||||
|
||||
CLogEvent::~CLogEvent()
|
||||
{
|
||||
}
|
||||
|
||||
wxString CLogEvent::getText() const
|
||||
{
|
||||
return m_text;
|
||||
}
|
||||
|
||||
wxEvent* CLogEvent::Clone() const
|
||||
{
|
||||
return new CLogEvent(*this);
|
||||
}
|
||||
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef LogEvent_H
|
||||
#define LogEvent_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
class CLogEvent : public wxEvent {
|
||||
public:
|
||||
CLogEvent(const wxString& text, wxEventType type, int id = 0);
|
||||
virtual ~CLogEvent();
|
||||
|
||||
virtual wxString getText() const;
|
||||
|
||||
virtual wxEvent* Clone() const;
|
||||
|
||||
protected:
|
||||
CLogEvent(const CLogEvent& event);
|
||||
|
||||
private:
|
||||
wxString m_text;
|
||||
};
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue