mirror of https://github.com/wb2osz/direwolf.git
Merge branch 'dev' into gpiod
This commit is contained in:
commit
b8919baf20
39
CHANGES.md
39
CHANGES.md
|
@ -2,15 +2,36 @@
|
|||
# Revision History #
|
||||
|
||||
|
||||
## Version 1.6 -- Under Development ##
|
||||
## Version 1.7 -- Under Development ('dev' branch) ##
|
||||
|
||||
|
||||
### New Features: ###
|
||||
|
||||
- Improved Layer 2 Protocol [(IL2P)](https://en.wikipedia.org/wiki/FX.25_Forward_Error_Correction). Use "-I 1" on command line to enable transmit for first channel. Compatible with Nino TNC for 1200 and 9600 bps.
|
||||
|
||||
- Limited support for CM109/CM119 GPIO PTT on Windows.
|
||||
|
||||
- Dire Wolf now advertises itself using DNS Service Discovery. This allows suitable APRS / Packet Radio applications to find a network KISS TNC without knowing the IP address or TCP port. Thanks to Hessu for providing this. Currently available only for Linux and Mac OSX. [Read all about it here.](https://github.com/hessu/aprs-specs/blob/master/TCP-KISS-DNS-SD.md)
|
||||
|
||||
- The transmit calibration tone (-x) command line option now accepts a radio channel number and/or a single letter mode: a = alternate tones, m = mark tone, s = space tone, p = PTT only no sound.
|
||||
|
||||
- The BEACON configuration now recognizes the SOURCE= option. This replaces the AX.25 source address rather than using the MYCALL value for the channel. This is useful for sending more than 5 analog telemetry channels. Use two, or more, source addresses with up to 5 analog channels each.
|
||||
|
||||
- For more flexibility, the FX.25 transmit property can now be set individually by channel, rather than having a global setting for all channels. The -X on the command line applies only to channel 0. For other channels you need to add a new line to the configuration file.
|
||||
|
||||
> After: "CHANNEL 1" (or other channel)
|
||||
>
|
||||
> Add: "FX25TX 1" (or 16 or 32 or 64)
|
||||
|
||||
|
||||
## Version 1.6 -- October 2020 ##
|
||||
|
||||
### New Build Procedure: ###
|
||||
|
||||
|
||||
- Rather than trying to keep a bunch of different platform specific Makefiles in sync, "cmake" is now used for greater portability and easier maintenance.
|
||||
- Rather than trying to keep a bunch of different platform specific Makefiles in sync, "cmake" is now used for greater portability and easier maintenance. This was contributed by Davide Gerhard.
|
||||
|
||||
- README.md has a quick summary of the process. More details in the User Guide.
|
||||
- README.md has a quick summary of the process. More details in the ***User Guide***.
|
||||
|
||||
|
||||
### New Features: ###
|
||||
|
@ -45,15 +66,21 @@
|
|||
|
||||
- ***AX.25 + FEC = FX.25***
|
||||
|
||||
- ***AIS Reception***
|
||||
|
||||
- ***AX.25 Throughput: Why is 9600 bps Packet Radio only twice as fast as 1200?***
|
||||
|
||||
- [***Ham Radio of Things - IoT over Ham Radio***](https://github.com/wb2osz/hrot)
|
||||
- [***Ham Radio of Things (HRoT) - IoT over Ham Radio***](https://github.com/wb2osz/hrot)
|
||||
|
||||
- Power Point slide show in separate repository. [https://github.com/wb2osz/direwolf-presentation ](https://github.com/wb2osz/direwolf-presentation)
|
||||
- [***EAS SAME to APRS Message Converter***](https://github.com/wb2osz/eas2aprs)
|
||||
|
||||
- [***Dire Wolf PowerPoint Slide Show***](https://github.com/wb2osz/direwolf-presentation)
|
||||
|
||||
### Notes: ###
|
||||
|
||||
Windows binary distribution now uses gcc (MinGW) version 7.4.0.
|
||||
The Windows binary distribution now uses gcc (MinGW) version 7.4.0.
|
||||
The Windows version is built for both 32 and 64 bit operating systems.
|
||||
Use the 64 bit version if possible; it runs considerably faster.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -4,12 +4,13 @@ project(direwolf)
|
|||
|
||||
# configure version
|
||||
set(direwolf_VERSION_MAJOR "1")
|
||||
set(direwolf_VERSION_MINOR "6")
|
||||
set(direwolf_VERSION_MINOR "7")
|
||||
set(direwolf_VERSION_PATCH "0")
|
||||
set(direwolf_VERSION_SUFFIX "")
|
||||
set(direwolf_VERSION_SUFFIX "Development")
|
||||
|
||||
# options
|
||||
option(FORCE_SSE "Compile with SSE instruction only" OFF)
|
||||
# See Issue 297.
|
||||
option(FORCE_SSE "Compile with SSE instruction only" ON)
|
||||
option(FORCE_SSSE3 "Compile with SSSE3 instruction only" OFF)
|
||||
option(FORCE_SSE41 "Compile with SSE4.1 instruction only" OFF)
|
||||
option(OPTIONAL_TEST "Compile optional test (might be broken)" OFF)
|
||||
|
@ -71,6 +72,7 @@ set(CUSTOM_SRC_DIR "${CMAKE_SOURCE_DIR}/src")
|
|||
set(CUSTOM_EXTERNAL_DIR "${CMAKE_SOURCE_DIR}/external")
|
||||
set(CUSTOM_MISC_DIR "${CUSTOM_EXTERNAL_DIR}/misc")
|
||||
set(CUSTOM_REGEX_DIR "${CUSTOM_EXTERNAL_DIR}/regex")
|
||||
set(CUSTOM_HIDAPI_DIR "${CUSTOM_EXTERNAL_DIR}/hidapi")
|
||||
set(CUSTOM_GEOTRANZ_DIR "${CUSTOM_EXTERNAL_DIR}/geotranz")
|
||||
set(CUSTOM_DATA_DIR "${CMAKE_SOURCE_DIR}/data")
|
||||
set(CUSTOM_SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/scripts")
|
||||
|
@ -86,13 +88,21 @@ set(CUSTOM_SHELL_SHABANG "#!/bin/sh -e")
|
|||
set(CPACK_GENERATOR "ZIP")
|
||||
set(CPACK_STRIP_FILES true)
|
||||
set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
|
||||
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${direwolf_VERSION}_${CMAKE_SYSTEM_PROCESSOR}")
|
||||
# This has architecture of the build machine, not the target platform.
|
||||
# e.g. Comes out as x86_64 when building for i686 target platform.
|
||||
#set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${direwolf_VERSION}_${CMAKE_SYSTEM_PROCESSOR}")
|
||||
# We don't know the target yet so this is set after FindCPUflags.
|
||||
set(CPACK_PACKAGE_CONTACT "https://github.com/wb2osz/direwolf")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Dire Wolf is a software soundcard AX.25 packet modem/TNC and APRS encoder/decoder")
|
||||
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Dire Wolf is an AX.25 soundcard TNC, digipeater, APRS IGate, GPS tracker, and APRStt gateway")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
|
||||
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
|
||||
set(CPACK_SOURCE_IGNORE_FILES "${PROJECT_BINARY_DIR};/.git/;.gitignore;menu.yml;.travis.yml;.appveyor.yml;default.nix;.envrc;TODOs.org;/.scripts/")
|
||||
SET(CPACK_PACKAGE_VERSION "${direwolf_VERSION}")
|
||||
SET(CPACK_PACKAGE_VERSION_MAJOR "${direwolf_VERSION_MAJOR}")
|
||||
SET(CPACK_PACKAGE_VERSION_MINOR "${direwolf_VERSION_MINOR}")
|
||||
SET(CPACK_PACKAGE_VERSION_PATCH "${direwolf_VERSION_PATCH}")
|
||||
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libasound2,libgps23")
|
||||
|
||||
# if we don't set build_type
|
||||
if(NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||
|
@ -114,10 +124,16 @@ include(FindCompiler)
|
|||
# find cpu flags (and set compiler)
|
||||
include(FindCPUflags)
|
||||
|
||||
if(${ARCHITECTURE} MATCHES "x86")
|
||||
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${direwolf_VERSION}_i686")
|
||||
else()
|
||||
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${direwolf_VERSION}_${ARCHITECTURE}")
|
||||
endif()
|
||||
|
||||
# auto include current directory
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
# set OS dependant variables
|
||||
# set OS dependent variables
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
set(LINUX TRUE)
|
||||
|
||||
|
@ -129,6 +145,10 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
|||
configure_file("${CMAKE_SOURCE_DIR}/cmake/cpack/${CMAKE_PROJECT_NAME}.desktop.in"
|
||||
"${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.desktop" @ONLY)
|
||||
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
|
||||
set(OPENBSD TRUE)
|
||||
set(HAVE_SNDIO TRUE)
|
||||
|
||||
elseif(APPLE)
|
||||
if("${CMAKE_OSX_DEPLOYMENT_TARGET}" STREQUAL "")
|
||||
message(STATUS "Build for macOS target: local version")
|
||||
|
@ -142,6 +162,10 @@ elseif(APPLE)
|
|||
set(CMAKE_MACOSX_RPATH ON)
|
||||
message(STATUS "RPATH support: ${CMAKE_MACOSX_RPATH}")
|
||||
|
||||
# just blindly enable dns-sd
|
||||
set(USE_MACOS_DNSSD ON)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_MACOS_DNSSD")
|
||||
|
||||
elseif (WIN32)
|
||||
if(NOT VS2015 AND NOT VS2017 AND NOT VS2019)
|
||||
message(FATAL_ERROR "You must use Microsoft Visual Studio 2015 | 2017 | 2019 as compiler")
|
||||
|
@ -181,10 +205,16 @@ if (C_CLANG OR C_GCC)
|
|||
# I also took out -Wextra because it spews out so much noise a serious problem was not noticed.
|
||||
# It might go back in someday when I have more patience to clean up all the warnings.
|
||||
#
|
||||
|
||||
# TODO:
|
||||
# Try error checking -fsanitize=bounds-strict -fsanitize=leak
|
||||
# Requires libubsan and liblsan, respectively.
|
||||
|
||||
###set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wvla -ffast-math -ftree-vectorize -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE ${EXTRA_FLAGS}")
|
||||
if(FREEBSD)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wvla -ffast-math -ftree-vectorize -D_DEFAULT_SOURCE ${EXTRA_FLAGS}")
|
||||
else()
|
||||
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wvla -ffast-math -ftree-vectorize -D_GNU_SOURCE -fsanitize=bounds-strict ${EXTRA_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wvla -ffast-math -ftree-vectorize -D_GNU_SOURCE ${EXTRA_FLAGS}")
|
||||
endif()
|
||||
#
|
||||
|
@ -232,6 +262,20 @@ else()
|
|||
endif(WIN32 OR CYGWIN)
|
||||
|
||||
# requirements
|
||||
|
||||
include(CheckSymbolExists)
|
||||
# Some platforms provide their own strlcpy & strlcat. (BSD, MacOSX)
|
||||
# Others don't so we provide our own. (Most, but not all Linux)
|
||||
# Define the preprocessor macro so libgps does not supply its own version.
|
||||
check_symbol_exists(strlcpy string.h HAVE_STRLCPY)
|
||||
if(HAVE_STRLCPY)
|
||||
add_compile_options(-DHAVE_STRLCPY)
|
||||
endif()
|
||||
check_symbol_exists(strlcat string.h HAVE_STRLCAT)
|
||||
if(HAVE_STRLCAT)
|
||||
add_compile_options(-DHAVE_STRLCAT)
|
||||
endif()
|
||||
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
|
@ -270,6 +314,17 @@ if(LINUX)
|
|||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_CM108")
|
||||
endif()
|
||||
|
||||
find_package(Avahi)
|
||||
if(AVAHI_CLIENT_FOUND)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_AVAHI_CLIENT")
|
||||
endif()
|
||||
|
||||
elseif (HAVE_SNDIO)
|
||||
find_package(sndio REQUIRED)
|
||||
if(SNDIO_FOUND)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_SNDIO")
|
||||
endif()
|
||||
|
||||
elseif (NOT WIN32 AND NOT CYGWIN)
|
||||
find_package(Portaudio REQUIRED)
|
||||
if(PORTAUDIO_FOUND)
|
||||
|
@ -281,8 +336,12 @@ else()
|
|||
set(ALSA_LIBRARIES "")
|
||||
set(UDEV_INCLUDE_DIRS "")
|
||||
set(UDEV_LIBRARIES "")
|
||||
# Version 1.7 supports CM108/CM119 GPIO PTT for Windows.
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_CM108")
|
||||
set(PORTAUDIO_INCLUDE_DIRS "")
|
||||
set(PORTAUDIO_LIBRARIES "")
|
||||
set(SNDIO_INCLUDE_DIRS "")
|
||||
set(SNDIO_LIBRARIES "")
|
||||
endif()
|
||||
|
||||
# manage and fetch new data
|
||||
|
@ -291,6 +350,7 @@ add_subdirectory(data)
|
|||
# external libraries
|
||||
add_subdirectory(${CUSTOM_GEOTRANZ_DIR})
|
||||
add_subdirectory(${CUSTOM_REGEX_DIR})
|
||||
add_subdirectory(${CUSTOM_HIDAPI_DIR})
|
||||
add_subdirectory(${CUSTOM_MISC_DIR})
|
||||
|
||||
# direwolf source code and utilities
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
|
||||
all:
|
||||
@echo "The build procedure has changed in version 1.6."
|
||||
@echo "In general, it now looks like this:"
|
||||
@echo " "
|
||||
@echo "Download the source code:"
|
||||
@echo " "
|
||||
@echo " cd ~"
|
||||
@echo " git clone https://www.github.com/wb2osz/direwolf"
|
||||
@echo " cd direwolf"
|
||||
@echo " "
|
||||
@echo "Optional - Do this to get the latest development version"
|
||||
@echo "rather than the latest stable release."
|
||||
@echo " "
|
||||
@echo " git checkout dev"
|
||||
@echo " "
|
||||
@echo "Build it. There are two new steps not used for earlier releases."
|
||||
@echo " "
|
||||
@echo " mkdir build && cd build"
|
||||
@echo " cmake .."
|
||||
@echo " make -j4"
|
||||
@echo " "
|
||||
@echo "Install:"
|
||||
@echo " "
|
||||
@echo " sudo make install"
|
||||
@echo " make install-conf"
|
||||
@echo " "
|
||||
@echo "You will probably need to install additional applications and"
|
||||
@echo "libraries depending on your operating system."
|
||||
@echo "More details are in the README.md file."
|
||||
@echo " "
|
||||
@echo "Questions?"
|
||||
@echo " "
|
||||
@echo " - Extensive documentation can be found in the 'doc' directory."
|
||||
@echo " - Join the discussion forum here: https://groups.io/g/direwolf"
|
||||
@echo " "
|
56
README.md
56
README.md
|
@ -5,15 +5,19 @@
|
|||
|
||||
In the early days of Amateur Packet Radio, it was necessary to use an expensive "Terminal Node Controller" (TNC) with specialized hardware. Those days are gone. You can now get better results at lower cost by connecting your radio to the "soundcard" interface of a computer and using software to decode the signals.
|
||||
|
||||
Why settle for mediocre receive performance from a 1980's technology TNC using an old modem chip? Dire Wolf decodes over 1000 error-free frames from Track 2 of the [WA8LMF TNC Test CD](https://github.com/wb2osz/direwolf/tree/dev/doc/WA8LMF-TNC-Test-CD-Results.pdf), leaving all the hardware TNCs, and first generation "soundcard" modems, behind in the dust.
|
||||
Why waste $200 and settle for mediocre receive performance from a 1980's technology TNC using an old modem chip? Dire Wolf decodes over 1000 error-free frames from Track 2 of the [WA8LMF TNC Test CD](https://github.com/wb2osz/direwolf/tree/dev/doc/WA8LMF-TNC-Test-CD-Results.pdf), leaving all the hardware TNCs, and first generation "soundcard" modems, behind in the dust.
|
||||
|
||||
![](tnc-test-cd-results.png)
|
||||
|
||||
Dire Wolf now includes [FX.25](https://en.wikipedia.org/wiki/FX.25_Forward_Error_Correction/) which adds Forward Error Correction (FEC) in a way that is completely compatible with existing systems. If both ends are capable of FX.25, your information will continue to get through under conditions where regular AX.25 is completely useless.
|
||||
Dire Wolf now includes [FX.25](https://en.wikipedia.org/wiki/FX.25_Forward_Error_Correction) which adds Forward Error Correction (FEC) in a way that is completely compatible with existing systems. If both ends are capable of FX.25, your information will continue to get through under conditions where regular AX.25 is completely useless.
|
||||
|
||||
![](fx25.png)
|
||||
|
||||
Dire Wolf is a modern software replacement for the old 1980's style TNC built with special hardware.
|
||||
Version 1.7 adds [IL2P](https://en.wikipedia.org/wiki/Improved_Layer_2_Protocol), a different method of FEC with less overhead.
|
||||
|
||||
|
||||
|
||||
### Dire Wolf is a modern software replacement for the old 1980's style TNC built with special hardware. ###
|
||||
|
||||
Without any additional software, it can perform as:
|
||||
|
||||
|
@ -23,7 +27,7 @@ Without any additional software, it can perform as:
|
|||
- [APRStt](http://www.aprs.org/aprstt.html) gateway
|
||||
|
||||
|
||||
It can also be used as a virtual TNC for other applications such as [APRSIS32](http://aprsisce.wikidot.com/), [Xastir](http://xastir.org/index.php/Main_Page), [APRS-TW](http://aprstw.blandranch.net/), [YAAC](http://www.ka2ddo.org/ka2ddo/YAAC.html), [PinPoint APRS](http://www.pinpointaprs.com/), [UI-View32](http://www.ui-view.net/),[UISS](http://users.belgacom.net/hamradio/uiss.htm), [Linux AX25](http://www.linux-ax25.org/wiki/Main_Page), [SARTrack](http://www.sartrack.co.nz/index.html), [Winlink Express (formerly known as RMS Express, formerly known as Winlink 2000 or WL2K)](http://www.winlink.org/RMSExpress), [BPQ32](http://www.cantab.net/users/john.wiseman/Documents/BPQ32.html), [Outpost PM](http://www.outpostpm.org/), [Ham Radio of Things](https://github.com/wb2osz/hrot), and many others.
|
||||
It can also be used as a virtual TNC for other applications such as [APRSIS32](http://aprsisce.wikidot.com/), [Xastir](http://xastir.org/index.php/Main_Page), [APRS-TW](http://aprstw.blandranch.net/), [YAAC](http://www.ka2ddo.org/ka2ddo/YAAC.html), [PinPoint APRS](http://www.pinpointaprs.com/), [UI-View32](http://www.ui-view.net/),[UISS](http://users.belgacom.net/hamradio/uiss.htm), [Linux AX25](http://www.linux-ax25.org/wiki/Main_Page), [SARTrack](http://www.sartrack.co.nz/index.html), [Winlink Express (formerly known as RMS Express, formerly known as Winlink 2000 or WL2K)](http://www.winlink.org/RMSExpress), [BPQ32](http://www.cantab.net/users/john.wiseman/Documents/BPQ32.html), [Outpost PM](http://www.outpostpm.org/), [Ham Radio of Things](https://github.com/wb2osz/hrot), [Packet Compressed Sensing Imaging (PCSI)](https://maqifrnswa.github.io/PCSI/), and many others.
|
||||
|
||||
|
||||
## Features & Benefits ##
|
||||
|
@ -39,6 +43,7 @@ It can also be used as a virtual TNC for other applications such as [APRSIS32](h
|
|||
Send periodic beacons to provide information to others. For tracking the location is provided by a GPS receiver.
|
||||
Build your own telemetry applications with the toolkit.
|
||||
|
||||
|
||||
- **APRStt Gateway.**
|
||||
|
||||
Very few hams have portable equipment for APRS but nearly everyone has a handheld radio that can send DTMF tones. APRStt allows a user, equipped with only DTMF (commonly known as Touch Tone) generation capability, to enter information into the global APRS data network. Responses can be sent by Morse Code or synthesized speech.
|
||||
|
@ -51,7 +56,7 @@ It can also be used as a virtual TNC for other applications such as [APRSIS32](h
|
|||
|
||||
IGate stations allow communication between disjoint radio networks by allowing some content to flow between them over the Internet.
|
||||
|
||||
- **Ham Radio of Things.**
|
||||
- **Ham Radio of Things (HRoT).**
|
||||
|
||||
There have been occasional mentions of merging Ham Radio with the Internet of Things but only ad hoc incompatible narrowly focused applications. Here is a proposal for a standardized more flexible method so different systems can communicate with each other.
|
||||
|
||||
|
@ -63,7 +68,7 @@ It can also be used as a virtual TNC for other applications such as [APRSIS32](h
|
|||
|
||||
- **KISS Interface (TCP/IP, serial port, Bluetooth) & AGW network Interface (TCP/IP).**
|
||||
|
||||
Dire Wolf can be used as a virtual TNC for applications such as APRSIS32, UI-View32, Xastir, APRS-TW,YAAC, UISS, Linux AX25, SARTrack, Winlink / RMS Express, Outpost PM, and many others.
|
||||
Dire Wolf can be used as a virtual TNC for applications such as [APRSIS32](http://aprsisce.wikidot.com/), [Xastir](http://xastir.org/index.php/Main_Page), [APRS-TW](http://aprstw.blandranch.net/), [YAAC](http://www.ka2ddo.org/ka2ddo/YAAC.html), [PinPoint APRS](http://www.pinpointaprs.com/), [UI-View32](http://www.ui-view.net/),[UISS](http://users.belgacom.net/hamradio/uiss.htm), [Linux AX25](http://www.linux-ax25.org/wiki/Main_Page), [SARTrack](http://www.sartrack.co.nz/index.html), [Winlink Express (formerly known as RMS Express, formerly known as Winlink 2000 or WL2K)](http://www.winlink.org/RMSExpress), [BPQ32](http://www.cantab.net/users/john.wiseman/Documents/BPQ32.html), [Outpost PM](http://www.outpostpm.org/), [Ham Radio of Things](https://github.com/wb2osz/hrot), [Packet Compressed Sensing Imaging (PCSI)](https://maqifrnswa.github.io/PCSI/), and many others.
|
||||
|
||||
### Radio Interfaces: ###
|
||||
|
||||
|
@ -79,7 +84,7 @@ It can also be used as a virtual TNC for other applications such as [APRSIS32](h
|
|||
|
||||
- **DTMF ("Touch Tone") Decoding and Encoding.**
|
||||
|
||||
- **Speech Synthesizer & Morse code generator.**
|
||||
- **Speech Synthesizer interface & Morse code generator.**
|
||||
|
||||
Transmit human understandable messages.
|
||||
|
||||
|
@ -108,7 +113,7 @@ It can also be used as a virtual TNC for other applications such as [APRSIS32](h
|
|||
|
||||
Go to the [**releases** page](https://github.com/wb2osz/direwolf/releases). Download a zip file with "win" in its name, unzip it, and run direwolf.exe from a command window.
|
||||
|
||||
For more details see the **User Guide** in the [**doc** directory](https://github.com/wb2osz/direwolf/tree/master/doc).
|
||||
You can also build it yourself from source. For more details see the **User Guide** in the [**doc** directory](https://github.com/wb2osz/direwolf/tree/master/doc).
|
||||
|
||||
|
||||
|
||||
|
@ -117,35 +122,39 @@ For more details see the **User Guide** in the [**doc** directory](https://githu
|
|||
|
||||
***Note that this has changed for version 1.6. There are now a couple extra steps.***
|
||||
|
||||
A standard operating system install will probably include these already:
|
||||
|
||||
- git
|
||||
- gcc or clang compiler
|
||||
- make
|
||||
First you will need to install some software development packages using different commands depending on your flavor of Linux.
|
||||
In most cases, the first few will already be there and the package installer will tell you that installation is not necessary.
|
||||
|
||||
You will probably need to install additional packages:
|
||||
|
||||
On Debian / Ubuntu / Raspbian:
|
||||
On Debian / Ubuntu / Raspbian / Raspberry Pi OS:
|
||||
|
||||
sudo apt-get install git
|
||||
sudo apt-get install gcc
|
||||
sudo apt-get install g++
|
||||
sudo apt-get install make
|
||||
sudo apt-get install cmake
|
||||
sudo apt-get install libasound2-dev
|
||||
sudo apt-get install libudev-dev
|
||||
sudo apt-get install libavahi-client-dev
|
||||
|
||||
Or on Red Hat / Fedora / Centos:
|
||||
Or on Red Hat / Fedora / CentOS:
|
||||
|
||||
sudo yum install git
|
||||
sudo yum install gcc
|
||||
sudo yum install gcc-c++
|
||||
sudo yum install make
|
||||
sudo yum install alsa-lib-devel
|
||||
sudo yum install libudev-devel
|
||||
sudo yum install avahi-devel
|
||||
|
||||
CentOS 6 & 7 currently have cmake 2.8 but we need 3.1 or later.
|
||||
First you need to enable the EPEL repository. Add a symlink if you want to type cmake rather than cmake3.
|
||||
First you need to enable the EPEL repository. Add a symlink if you don't already have the older version and want to type cmake rather than cmake3.
|
||||
|
||||
sudo yum install epel-release
|
||||
sudo rpm -e cmake
|
||||
sudo yum install cmake3
|
||||
sudo ln -s /usr/bin/cmake3 /usr/bin/cmake
|
||||
|
||||
Continue with the other required packages:
|
||||
|
||||
sudo yum install alsa-lib-devel
|
||||
sudo yum install libudev-devel
|
||||
|
||||
Then on any flavor of Linux:
|
||||
|
||||
cd ~
|
||||
|
@ -187,6 +196,9 @@ Read the **User Guide** in the [**doc** directory](https://github.com/wb2osz/dir
|
|||
|
||||
If you have problems, post them to the [Dire Wolf packet TNC](https://groups.io/g/direwolf) discussion group.
|
||||
|
||||
You can also install a pre-built version from Mac Ports. Keeping this up to date depends on volunteers who perform the packaging. This version could lag behind development.
|
||||
|
||||
sudo port install direwolf
|
||||
|
||||
|
||||
## Join the conversation ##
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
find_library(AVAHI_COMMON_LIBRARY NAMES avahi-common PATHS ${PC_AVAHI_CLIENT_LIBRARY_DIRS})
|
||||
if(AVAHI_COMMON_LIBRARY)
|
||||
set(AVAHI_COMMON_FOUND TRUE)
|
||||
endif()
|
||||
|
||||
find_library(AVAHI_CLIENT_LIBRARY NAMES avahi-client PATHS ${PC_AVAHI_CLIENT_LIBRARY_DIRS})
|
||||
if(AVAHI_CLIENT_LIBRARY)
|
||||
set(AVAHI_CLIENT_FOUND TRUE)
|
||||
endif()
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(AVAHI DEFAULT_MSG AVAHI_COMMON_FOUND AVAHI_CLIENT_FOUND)
|
||||
|
||||
if (AVAHI_FOUND)
|
||||
set(AVAHI_INCLUDE_DIRS ${AVAHI_UI_INCLUDE_DIR})
|
||||
set(AVAHI_LIBRARIES ${AVAHI_COMMON_LIBRARY} ${AVAHI_CLIENT_LIBRARY})
|
||||
endif()
|
||||
|
||||
mark_as_advanced(AVAHI_INCLUDE_DIRS AVAHI_LIBRARIES)
|
|
@ -78,7 +78,6 @@ endfunction()
|
|||
# The default will be set for maximum portability so packagers won't need to
|
||||
# to anything special.
|
||||
#
|
||||
set(FORCE_SSE 1)
|
||||
#
|
||||
# While ENABLE_GENERIC also had the desired result (for x86_64), I don't think
|
||||
# it is the right approach. It prevents the detection of the architecture,
|
||||
|
@ -354,7 +353,12 @@ elseif(ARCHITECTURE_ARM)
|
|||
if(C_MSVC)
|
||||
try_run(RUN_NEON COMPILE_NEON "${CMAKE_BINARY_DIR}/tmp" "${TEST_DIR}/test_arm_neon.cxx" COMPILE_DEFINITIONS /O0)
|
||||
else()
|
||||
if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_SYSTEM_PROCESSOR})
|
||||
try_run(RUN_NEON COMPILE_NEON "${CMAKE_BINARY_DIR}/tmp" "${TEST_DIR}/test_arm_neon.cxx" COMPILE_DEFINITIONS -mfpu=neon -O0)
|
||||
else()
|
||||
try_compile(COMPILE_NEON "${CMAKE_BINARY_DIR}/tmp" "${TEST_DIR}/test_arm_neon.cxx" COMPILE_DEFINITIONS -mfpu=neon -O0)
|
||||
set(RUN_NEON 0)
|
||||
endif()
|
||||
endif()
|
||||
if(COMPILE_NEON AND RUN_NEON EQUAL 0)
|
||||
set(HAS_NEON ON CACHE BOOL "Architecture has NEON SIMD enabled")
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
# - Try to find sndio
|
||||
#
|
||||
# SNDIO_FOUND - system has sndio
|
||||
# SNDIO_LIBRARIES - location of the library for sndio
|
||||
# SNDIO_INCLUDE_DIRS - location of the include files for sndio
|
||||
|
||||
set(SNDIO_ROOT_DIR
|
||||
"${SNDIO_ROOT_DIR}"
|
||||
CACHE
|
||||
PATH
|
||||
"Directory to search for sndio")
|
||||
|
||||
# no need to check pkg-config
|
||||
|
||||
find_path(SNDIO_INCLUDE_DIRS
|
||||
NAMES
|
||||
sndio.h
|
||||
PATHS
|
||||
/usr/local/include
|
||||
/usr/include
|
||||
/opt/local/include
|
||||
HINTS
|
||||
${SNDIO_ROOT_DIR}
|
||||
)
|
||||
|
||||
find_library(SNDIO_LIBRARIES
|
||||
NAMES
|
||||
sndio
|
||||
PATHS
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
/usr/lib64
|
||||
/opt/local/lib
|
||||
HINTS
|
||||
${SNDIIO_ROOT_DIR}
|
||||
)
|
||||
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(SNDIO DEFAULT_MSG SNDIO_INCLUDE_DIRS SNDIO_LIBRARIES)
|
||||
|
||||
mark_as_advanced(SNDIO_INCLUDE_DIRS SNDIO_LIBRARIES)
|
|
@ -3,7 +3,7 @@
|
|||
# $ ls -l /dev/hidraw*
|
||||
# crw------- 1 root root 247, 0 Sep 24 09:40 /dev/hidraw0
|
||||
#
|
||||
# An ordinary user, trying to acccess it will be denied.
|
||||
# An ordinary user, trying to access it will be denied.
|
||||
#
|
||||
# Unnecessarily running applications as root is generally a bad idea because it makes it too easy
|
||||
# to accidentally trash your system. We need to relax the restrictions so ordinary users can use these devices.
|
||||
|
|
|
@ -1,536 +0,0 @@
|
|||
C#############################################################
|
||||
C# #
|
||||
C# Configuration file for Dire Wolf #
|
||||
C# #
|
||||
L# Linux version #
|
||||
W# Windows version #
|
||||
C# #
|
||||
C#############################################################
|
||||
R
|
||||
R
|
||||
R The sample config file was getting pretty messy
|
||||
R with the Windows and Linux differences.
|
||||
R It would be a maintenance burden to keep most of
|
||||
R two different versions in sync.
|
||||
R This common source is now used to generate the
|
||||
R two different variations while having only a single
|
||||
R copy of the common parts.
|
||||
R
|
||||
R The first column contains one of the following:
|
||||
R
|
||||
R R remark which is discarded.
|
||||
R C common to both versions.
|
||||
R W Windows version only.
|
||||
R L Linux version only.
|
||||
R
|
||||
C#
|
||||
C# Consult the User Guide for more details on configuration options.
|
||||
C#
|
||||
C#
|
||||
C# These are the most likely settings you might change:
|
||||
C#
|
||||
C# (1) MYCALL - call sign and SSID for your station.
|
||||
C#
|
||||
C# Look for lines starting with MYCALL and
|
||||
C# change NOCALL to your own.
|
||||
C#
|
||||
C# (2) PBEACON - enable position beaconing.
|
||||
C#
|
||||
C# Look for lines starting with PBEACON and
|
||||
C# modify for your call, location, etc.
|
||||
C#
|
||||
C# (3) DIGIPEATER - configure digipeating rules.
|
||||
C#
|
||||
C# Look for lines starting with DIGIPEATER.
|
||||
C# Most people will probably use the given example.
|
||||
C# Just remove the "#" from the start of the line
|
||||
C# to enable it.
|
||||
C#
|
||||
C# (4) IGSERVER, IGLOGIN - IGate server and login
|
||||
C#
|
||||
C# Configure an IGate client to relay messages between
|
||||
C# radio and internet servers.
|
||||
C#
|
||||
C#
|
||||
C# The default location is "direwolf.conf" in the current working directory.
|
||||
L# On Linux, the user's home directory will also be searched.
|
||||
C# An alternate configuration file location can be specified with the "-c" command line option.
|
||||
C#
|
||||
C# As you probably guessed by now, # indicates a comment line.
|
||||
C#
|
||||
C# Remove the # at the beginning of a line if you want to use a sample
|
||||
C# configuration that is currently commented out.
|
||||
C#
|
||||
C# Commands are a keyword followed by parameters.
|
||||
C#
|
||||
C# Command key words are case insensitive. i.e. upper and lower case are equivalent.
|
||||
C#
|
||||
C# Command parameters are generally case sensitive. i.e. upper and lower case are different.
|
||||
C#
|
||||
C
|
||||
C
|
||||
C#############################################################
|
||||
C# #
|
||||
C# FIRST AUDIO DEVICE PROPERTIES #
|
||||
C# (Channel 0 + 1 if in stereo) #
|
||||
C# #
|
||||
C#############################################################
|
||||
C
|
||||
C#
|
||||
C# Many people will simply use the default sound device.
|
||||
C# Some might want to use an alternative device by chosing it here.
|
||||
C#
|
||||
W# When the Windows version starts up, it displays something like
|
||||
W# this with the available sound devices and capabilities:
|
||||
W#
|
||||
W# Available audio input devices for receive (*=selected):
|
||||
W# * 0: Microphone (C-Media USB Headpho (channel 2)
|
||||
W# 1: Microphone (Bluetooth SCO Audio
|
||||
W# 2: Microphone (Bluetooth AV Audio)
|
||||
W# * 3: Microphone (Realtek High Defini (channels 0 & 1)
|
||||
W# Available audio output devices for transmit (*=selected):
|
||||
W# * 0: Speakers (C-Media USB Headphone (channel 2)
|
||||
W# 1: Speakers (Bluetooth SCO Audio)
|
||||
W# 2: Realtek Digital Output(Optical)
|
||||
W# 3: Speakers (Bluetooth AV Audio)
|
||||
W# * 4: Speakers (Realtek High Definiti (channels 0 & 1)
|
||||
W# 5: Realtek Digital Output (Realtek
|
||||
W#
|
||||
W# Example: To use the microphone and speaker connections on the
|
||||
W# system board, either of these forms can be used:
|
||||
W
|
||||
W#ADEVICE High
|
||||
W#ADEVICE 3 4
|
||||
W
|
||||
W
|
||||
W# Example: To use the USB Audio, use a command like this with
|
||||
W# the input and output device numbers. (Remove the # comment character.)
|
||||
W#ADEVICE USB
|
||||
W
|
||||
W# The position in the list can change when devices (e.g. USB) are added and removed.
|
||||
W# You can also specify devices by using part of the name.
|
||||
W# Here is an example of specifying the USB Audio device.
|
||||
W# This is case-sensitive. Upper and lower case are not treated the same.
|
||||
W
|
||||
W#ADEVICE USB
|
||||
W
|
||||
W
|
||||
L# Linux ALSA is complicated. See User Guide for discussion.
|
||||
L# To use something other than the default, generally use plughw
|
||||
L# and a card number reported by "arecord -l" command. Example:
|
||||
L
|
||||
L# ADEVICE plughw:1,0
|
||||
L
|
||||
L# Starting with version 1.0, you can also use "-" or "stdin" to
|
||||
L# pipe stdout from some other application such as a software defined
|
||||
L# radio. You can also specify "UDP:" and an optional port for input.
|
||||
L# Something different must be specified for output.
|
||||
L
|
||||
W# ADEVICE - 0
|
||||
W# ADEVICE UDP:7355 0
|
||||
L# ADEVICE - plughw:1,0
|
||||
L# ADEVICE UDP:7355 default
|
||||
L
|
||||
L
|
||||
C
|
||||
C#
|
||||
C# Number of audio channels for this souncard: 1 or 2.
|
||||
C#
|
||||
C
|
||||
CACHANNELS 1
|
||||
C#ACHANNELS 2
|
||||
C
|
||||
C
|
||||
C#############################################################
|
||||
C# #
|
||||
C# SECOND AUDIO DEVICE PROPERTIES #
|
||||
C# (Channel 2 + 3 if in stereo) #
|
||||
C# #
|
||||
C#############################################################
|
||||
C
|
||||
C#ADEVICE1 ...
|
||||
C
|
||||
C
|
||||
C#############################################################
|
||||
C# #
|
||||
C# THIRD AUDIO DEVICE PROPERTIES #
|
||||
C# (Channel 4 + 5 if in stereo) #
|
||||
C# #
|
||||
C#############################################################
|
||||
C
|
||||
C#ADEVICE2 ...
|
||||
C
|
||||
C
|
||||
C#############################################################
|
||||
C# #
|
||||
C# CHANNEL 0 PROPERTIES #
|
||||
C# #
|
||||
C#############################################################
|
||||
C
|
||||
CCHANNEL 0
|
||||
C
|
||||
C#
|
||||
C# The following MYCALL, MODEM, PTT, etc. configuration items
|
||||
C# apply to the most recent CHANNEL.
|
||||
C#
|
||||
C
|
||||
C#
|
||||
C# Station identifier for this channel.
|
||||
C# Multiple channels can have the same or different names.
|
||||
C#
|
||||
C# It can be up to 6 letters and digits with an optional ssid.
|
||||
C# The APRS specification requires that it be upper case.
|
||||
C#
|
||||
C# Example (don't use this unless you are me): MYCALL WB2OSZ-5
|
||||
C#
|
||||
C
|
||||
CMYCALL N0CALL
|
||||
C
|
||||
C#
|
||||
C# Pick a suitable modem speed based on your situation.
|
||||
C# 1200 Most common for VHF/UHF. Default if not specified.
|
||||
C# 300 Low speed for HF SSB.
|
||||
C# 9600 High speed - Can't use Microphone and Speaker connections.
|
||||
C#
|
||||
C# In the simplest form, just specify the speed.
|
||||
C#
|
||||
C
|
||||
CMODEM 1200
|
||||
C#MODEM 300
|
||||
C#MODEM 9600
|
||||
C
|
||||
C#
|
||||
C# These are the defaults should be fine for most cases. In special situations,
|
||||
C# you might want to specify different AFSK tones or the baseband mode which does
|
||||
C# not use AFSK.
|
||||
C#
|
||||
C#MODEM 1200 1200:2200
|
||||
C#MODEM 300 1600:1800
|
||||
C#MODEM 9600 0:0
|
||||
C#
|
||||
C#
|
||||
C# On HF SSB, you might want to use multiple demodulators on slightly different
|
||||
C# frequencies to compensate for stations off frequency. Here we have 7 different
|
||||
C# demodulators at 30 Hz intervals. This takes a lot of CPU power so you will
|
||||
C# probably need to reduce the audio sampling rate with the /n option.
|
||||
C
|
||||
C#MODEM 300 1600:1800 7@30 /4
|
||||
C
|
||||
C
|
||||
C#
|
||||
C# Uncomment line below to enable the DTMF decoder for this channel.
|
||||
C#
|
||||
C
|
||||
C#DTMF
|
||||
C
|
||||
C#
|
||||
C# If not using a VOX circuit, the transmitter Push to Talk (PTT)
|
||||
C# control is usually wired to a serial port with a suitable interface circuit.
|
||||
C# DON'T connect it directly!
|
||||
C#
|
||||
C# For the PTT command, specify the device and either RTS or DTR.
|
||||
C# RTS or DTR may be preceded by "-" to invert the signal.
|
||||
C# Both can be used for interfaces that want them driven with opposite polarity.
|
||||
C#
|
||||
L# COM1 can be used instead of /dev/ttyS0, COM2 for /dev/ttyS1, and so on.
|
||||
L#
|
||||
C
|
||||
C#PTT COM1 RTS
|
||||
C#PTT COM1 RTS -DTR
|
||||
L#PTT /dev/ttyUSB0 RTS
|
||||
C
|
||||
L#
|
||||
L# On Linux, you can also use general purpose I/O pins if
|
||||
L# your system is configured for user access to them.
|
||||
L# This would apply mostly to microprocessor boards, not a regular PC.
|
||||
L# See separate Raspberry Pi document for more details.
|
||||
L# The number may be preceded by "-" to invert the signal.
|
||||
L#
|
||||
L
|
||||
L#PTT GPIO 25
|
||||
L
|
||||
C# The Data Carrier Detect (DCD) signal can be sent to the same places
|
||||
C# as the PTT signal. This could be used to light up an LED like a normal TNC.
|
||||
C
|
||||
C#DCD COM1 -DTR
|
||||
L#DCD GPIO 24
|
||||
C
|
||||
C
|
||||
C#############################################################
|
||||
C# #
|
||||
C# CHANNEL 1 PROPERTIES #
|
||||
C# #
|
||||
C#############################################################
|
||||
C
|
||||
C#CHANNEL 1
|
||||
C
|
||||
C#
|
||||
C# Specify MYCALL, MODEM, PTT, etc. configuration items for
|
||||
C# CHANNEL 1. Repeat for any other channels.
|
||||
C
|
||||
C
|
||||
C#############################################################
|
||||
C# #
|
||||
C# TEXT TO SPEECH COMMAND FILE #
|
||||
C# #
|
||||
C#############################################################
|
||||
C
|
||||
W#SPEECH dwespeak.bat
|
||||
L#SPEECH dwespeak.sh
|
||||
C
|
||||
C
|
||||
C#############################################################
|
||||
C# #
|
||||
C# VIRTUAL TNC SERVER PROPERTIES #
|
||||
C# #
|
||||
C#############################################################
|
||||
C
|
||||
C#
|
||||
C# Dire Wolf acts as a virtual TNC and can communicate with
|
||||
C# client applications by different protocols:
|
||||
C#
|
||||
C# - the "AGW TCPIP Socket Interface" - default port 8000
|
||||
C# - KISS protocol over TCP socket - default port 8001
|
||||
W# - KISS TNC via serial port
|
||||
L# - KISS TNC via pseudo terminal (-p command line option)
|
||||
C#
|
||||
C
|
||||
CAGWPORT 8000
|
||||
CKISSPORT 8001
|
||||
C
|
||||
W#
|
||||
W# Some applications are designed to operate with only a physical
|
||||
W# TNC attached to a serial port. For these, we provide a virtual serial
|
||||
W# port that appears to be connected to a TNC.
|
||||
W#
|
||||
W# Take a look at the User Guide for instructions to set up
|
||||
W# two virtual serial ports named COM3 and COM4 connected by
|
||||
W# a null modem.
|
||||
W#
|
||||
W# Using the configuration described, Dire Wolf will connect to
|
||||
W# COM3 and the client application will use COM4.
|
||||
W#
|
||||
W# Uncomment following line to use this feature.
|
||||
W
|
||||
W#SERIALKISS COM3
|
||||
W
|
||||
W
|
||||
C#
|
||||
C# It is sometimes possible to recover frames with a bad FCS.
|
||||
C# This applies to all channels.
|
||||
C#
|
||||
C# 0 [NONE] - Don't try to repair.
|
||||
C# 1 [SINGLE] - Attempt to fix single bit error. (default)
|
||||
C# 2 [DOUBLE] - Also attempt to fix two adjacent bits.
|
||||
C# ... see User Guide for more values and in-depth discussion.
|
||||
C#
|
||||
C
|
||||
C#FIX_BITS 0
|
||||
C
|
||||
C#
|
||||
C#############################################################
|
||||
C# #
|
||||
C# BEACONING PROPERTIES #
|
||||
C# #
|
||||
C#############################################################
|
||||
C
|
||||
C
|
||||
C#
|
||||
C# Beaconing is configured with these two commands:
|
||||
C#
|
||||
C# PBEACON - for a position report (usually yourself)
|
||||
C# OBEACON - for an object report (usually some other entity)
|
||||
C#
|
||||
C# Each has a series of keywords and values for options.
|
||||
C# See User Guide for details.
|
||||
C#
|
||||
C# Example:
|
||||
C#
|
||||
C# This results in a broadcast once every 10 minutes.
|
||||
C# Every half hour, it can travel via two digipeater hops.
|
||||
C# The others are kept local.
|
||||
C#
|
||||
C
|
||||
C#PBEACON delay=1 every=30 overlay=S symbol="digi" lat=42^37.14N long=071^20.83W power=50 height=20 gain=4 comment="Chelmsford MA" via=WIDE1-1,WIDE2-1
|
||||
C#PBEACON delay=11 every=30 overlay=S symbol="digi" lat=42^37.14N long=071^20.83W power=50 height=20 gain=4 comment="Chelmsford MA"
|
||||
C#PBEACON delay=21 every=30 overlay=S symbol="digi" lat=42^37.14N long=071^20.83W power=50 height=20 gain=4 comment="Chelmsford MA"
|
||||
C
|
||||
C
|
||||
C# With UTM coordinates instead of latitude and longitude.
|
||||
C
|
||||
C#PBEACON delay=1 every=10 overlay=S symbol="digi" zone=19T easting=307477 northing=4720178
|
||||
C
|
||||
C
|
||||
C#
|
||||
C# When the destination field is set to "SPEECH" the information part is
|
||||
C# converted to speech rather than transmitted as a data frame.
|
||||
C#
|
||||
C
|
||||
C#CBEACON dest="SPEECH" info="Club meeting tonight at 7 pm."
|
||||
C
|
||||
C
|
||||
C#
|
||||
C# Modify for your particular situation before removing
|
||||
C# the # comment character from the beginning of appropriate lines above.
|
||||
C#
|
||||
C
|
||||
C
|
||||
C#############################################################
|
||||
C# #
|
||||
C# DIGIPEATER PROPERTIES #
|
||||
C# #
|
||||
C#############################################################
|
||||
C
|
||||
C#
|
||||
C# For most common situations, use something like this by removing
|
||||
C# the "#" from the beginning of the line below.
|
||||
C#
|
||||
C
|
||||
C#DIGIPEAT 0 0 ^WIDE[3-7]-[1-7]$|^TEST$ ^WIDE[12]-[12]$ TRACE
|
||||
C
|
||||
C# See User Guide for more explanation of what this means and how
|
||||
C# it can be customized for your particular needs.
|
||||
C
|
||||
C# Filtering can be used to limit was is digipeated.
|
||||
C# For example, only weather weather reports, received on channel 0,
|
||||
C# will be retransmitted on channel 1.
|
||||
C#
|
||||
C
|
||||
C#FILTER 0 1 t/wn
|
||||
C
|
||||
C
|
||||
C#############################################################
|
||||
C# #
|
||||
C# INTERNET GATEWAY #
|
||||
C# #
|
||||
C#############################################################
|
||||
C
|
||||
C# First you need to specify the name of a Tier 2 server.
|
||||
C# The current preferred way is to use one of these regional rotate addresses:
|
||||
C
|
||||
C# noam.aprs2.net - for North America
|
||||
C# soam.aprs2.net - for South America
|
||||
C# euro.aprs2.net - for Europe and Africa
|
||||
C# asia.aprs2.net - for Asia
|
||||
C# aunz.aprs2.net - for Oceania
|
||||
C
|
||||
C#IGSERVER noam.aprs2.net
|
||||
C
|
||||
C# You also need to specify your login name and passcode.
|
||||
C# Contact the author if you can't figure out how to generate the passcode.
|
||||
C
|
||||
C#IGLOGIN WB2OSZ-5 123456
|
||||
C
|
||||
C# That's all you need for a receive only IGate which relays
|
||||
C# messages from the local radio channel to the global servers.
|
||||
C
|
||||
C# Some might want to send an IGate client position directly to a server
|
||||
C# without sending it over the air and relying on someone else to
|
||||
C# forward it to an IGate server. This is done by using sendto=IG rather
|
||||
C# than a radio channel number. Overlay R for receive only, T for two way.
|
||||
C
|
||||
C#PBEACON sendto=IG delay=0:30 every=60:00 symbol="igate" overlay=R lat=42^37.14N long=071^20.83W
|
||||
C#PBEACON sendto=IG delay=0:30 every=60:00 symbol="igate" overlay=T lat=42^37.14N long=071^20.83W
|
||||
C
|
||||
C
|
||||
C# To relay messages from the Internet to radio, you need to add
|
||||
C# one more options with the transmit channel number and a VIA path.
|
||||
C
|
||||
C#IGTXVIA 0 WIDE1-1
|
||||
C
|
||||
C# The APRS Internet Server (APRS-IS) has its own idea about what you
|
||||
C# should be transmitting. This includes "messages" addressed to stations
|
||||
C# recently heard in your area. For special situations, you can subscribe
|
||||
C# to
|
||||
C# decrease what you are already subscribed to. This is known as a server
|
||||
C# side filter. Read here: http://www.aprs-is.net/javaprsfilter.aspx
|
||||
C# Example, positions and objects within 50 km of my location:
|
||||
C
|
||||
C#IGFILTER m/50
|
||||
C
|
||||
C# Sometimes the server will send you more than you want. You can also apply
|
||||
C# local filtering to limit what will be transmitted on the RF side.
|
||||
C# For example, transmit only "messages" (which is the default) on channel 0
|
||||
C# and weather reports on channel 1.
|
||||
C
|
||||
C#FILTER IG 0 i/30
|
||||
C#FILTER IG 1 t/wn
|
||||
C
|
||||
C# Finally, we don't want to flood the radio channel.
|
||||
C# The IGate function will limit the number of packets transmitted
|
||||
C# during 1 minute and 5 minute intervals. If a limit would
|
||||
C# be exceeded, the packet is dropped and message is displayed in red.
|
||||
C
|
||||
CIGTXLIMIT 6 10
|
||||
C
|
||||
C
|
||||
C#############################################################
|
||||
C# #
|
||||
C# APRStt GATEWAY #
|
||||
C# #
|
||||
C#############################################################
|
||||
C
|
||||
C#
|
||||
C# Dire Wolf can receive DTMF (commonly known as Touch Tone)
|
||||
C# messages and convert them to packet objects.
|
||||
C#
|
||||
C# See separate "APRStt-Implementation-Notes" document for details.
|
||||
C#
|
||||
C
|
||||
C#
|
||||
C# Sample gateway configuration based on:
|
||||
C#
|
||||
C# http://www.aprs.org/aprstt/aprstt-coding24.txt
|
||||
C# http://www.aprs.org/aprs-jamboree-2013.html
|
||||
C#
|
||||
C
|
||||
C# Define specific points.
|
||||
C
|
||||
CTTPOINT B01 37^55.37N 81^7.86W
|
||||
CTTPOINT B7495088 42.605237 -71.34456
|
||||
CTTPOINT B934 42.605237 -71.34456
|
||||
C
|
||||
CTTPOINT B901 42.661279 -71.364452
|
||||
CTTPOINT B902 42.660411 -71.364419
|
||||
CTTPOINT B903 42.659046 -71.364452
|
||||
CTTPOINT B904 42.657578 -71.364602
|
||||
C
|
||||
C
|
||||
C# For location at given bearing and distance from starting point.
|
||||
C
|
||||
CTTVECTOR B5bbbddd 37^55.37N 81^7.86W 0.01 mi
|
||||
C
|
||||
C# For location specified by x, y coordinates.
|
||||
C
|
||||
CTTGRID Byyyxxx 37^50.00N 81^00.00W 37^59.99N 81^09.99W
|
||||
C
|
||||
C# UTM location for Lowell-Dracut-Tyngsborough State Forest.
|
||||
C
|
||||
CTTUTM B6xxxyyy 19T 10 300000 4720000
|
||||
C
|
||||
C
|
||||
C
|
||||
C# Location for the corral.
|
||||
C
|
||||
CTTCORRAL 37^55.50N 81^7.00W 0^0.02N
|
||||
C
|
||||
C# Compact messages - Fixed locations xx and object yyy where
|
||||
C# Object numbers 100 - 199 = bicycle
|
||||
C# Object numbers 200 - 299 = fire truck
|
||||
C# Others = dog
|
||||
C
|
||||
CTTMACRO xx1yy B9xx*AB166*AA2B4C5B3B0A1yy
|
||||
CTTMACRO xx2yy B9xx*AB170*AA3C4C7C3B0A2yy
|
||||
CTTMACRO xxyyy B9xx*AB180*AA3A6C4A0Ayyy
|
||||
C
|
||||
CTTMACRO z Cz
|
||||
C
|
||||
C# Receive on channel 0, Transmit object reports on channel 1 with optional via path.
|
||||
C
|
||||
C#TTOBJ 0 1 WIDE1-1
|
||||
C
|
||||
C# Advertise gateway position with beacon.
|
||||
C
|
||||
C# OBEACON DELAY=0:15 EVERY=10:00 VIA=WIDE1-1 OBJNAME=WB2OSZ-tt SYMBOL=APRStt LAT=42^37.14N LONG=71^20.83W COMMENT="APRStt Gateway"
|
||||
C
|
||||
C
|
|
@ -26,8 +26,19 @@
|
|||
%R% M Macintosh version and possibly others (portaudio used).
|
||||
%R%
|
||||
%C%#
|
||||
%C%# Consult the User Guide for more details on configuration options.
|
||||
%C%# Extensive documentation can be found here:
|
||||
%C%# Stable release - https://github.com/wb2osz/direwolf/tree/master/doc
|
||||
%C%# Latest development - https://github.com/wb2osz/direwolf/tree/dev/doc
|
||||
%C%#
|
||||
%W%# The complete documentation set can also be found in the doc folder.
|
||||
%L%# The complete documentation set can also be found in
|
||||
%L%# /usr/local/share/doc/direwolf/ or /usr/share/doc/direwolf/
|
||||
%L%# Concise "man" pages are also available for Linux.
|
||||
%M%# /usr/local/share/doc/direwolf/ or /usr/share/doc/direwolf/
|
||||
%M%# Concise "man" pages are also available for Mac OSX.
|
||||
%C%#
|
||||
%C%# This sample file does not have examples for all of the possibilities.
|
||||
%C%# Consult the User Guide for more details on configuration options.%C%#
|
||||
%C%#
|
||||
%C%# These are the most likely settings you might change:
|
||||
%C%#
|
||||
|
@ -82,6 +93,8 @@
|
|||
%C%# Many people will simply use the default sound device.
|
||||
%C%# Some might want to use an alternative device by choosing it here.
|
||||
%C%#
|
||||
%R% ---------- Windows ----------
|
||||
%R%
|
||||
%W%# When the Windows version starts up, it displays something like
|
||||
%W%# this with the available sound devices and capabilities:
|
||||
%W%#
|
||||
|
@ -109,6 +122,16 @@
|
|||
%W%# the input and output device numbers. (Remove the # comment character.)
|
||||
%W%#ADEVICE USB
|
||||
%W%
|
||||
%W%# You can also use "-" or "stdin" to pipe stdout from
|
||||
%W%# some other application such as a software defined radio.
|
||||
%W%# "stdin" is not an audio device. Don't use this unless you
|
||||
%W%# understand what this means. Read the User Guide.
|
||||
%W%# You can also specify "UDP:" and an optional port for input.
|
||||
%W%# Something different must be specified for output.
|
||||
%W%
|
||||
%W%# ADEVICE stdin 0
|
||||
%W%# ADEVICE UDP:7355 0
|
||||
%W%
|
||||
%W%# The position in the list can change when devices (e.g. USB) are added and removed.
|
||||
%W%# You can also specify devices by using part of the name.
|
||||
%W%# Here is an example of specifying the USB Audio device.
|
||||
|
@ -117,17 +140,26 @@
|
|||
%W%#ADEVICE USB
|
||||
%W%
|
||||
%W%
|
||||
%R% ---------- Linux ----------
|
||||
%R%
|
||||
%L%# Linux ALSA is complicated. See User Guide for discussion.
|
||||
%L%# To use something other than the default, generally use plughw
|
||||
%L%# and a card number reported by "arecord -l" command. Example:
|
||||
%L%
|
||||
%L%# ADEVICE plughw:1,0
|
||||
%L%
|
||||
%L%# Starting with version 1.0, you can also use "-" or "stdin" to
|
||||
%L%# pipe stdout from some other application such as a software defined
|
||||
%L%# radio. You can also specify "UDP:" and an optional port for input.
|
||||
%L%# You can also use "-" or "stdin" to pipe stdout from
|
||||
%L%# some other application such as a software defined radio.
|
||||
%L%# "stdin" is not an audio device. Don't use this unless you
|
||||
%L%# understand what this means. Read the User Guide.
|
||||
%L%# You can also specify "UDP:" and an optional port for input.
|
||||
%L%# Something different must be specified for output.
|
||||
%L%
|
||||
%L%# ADEVICE stdin plughw:1,0
|
||||
%L%# ADEVICE UDP:7355 default
|
||||
%L%
|
||||
%R% ---------- Mac ----------
|
||||
%R%
|
||||
%M%# Macintosh Operating System uses portaudio driver for audio
|
||||
%M%# input/output. Default device selection not available. User/OP
|
||||
%M%# must configure the sound input/output option. Note that
|
||||
|
@ -136,23 +168,26 @@
|
|||
%M%#
|
||||
%M%# Examples:
|
||||
%M%#
|
||||
%M%ADEVICE "Built-in Input" "Built-in Output"
|
||||
%M%
|
||||
%M%# ADEVICE "USB Audio Codec:6" "USB Audio Codec:5"
|
||||
%M%#
|
||||
%M%#
|
||||
%W%# ADEVICE - 0
|
||||
%W%# ADEVICE UDP:7355 0
|
||||
%L%# ADEVICE - plughw:1,0
|
||||
%L%# ADEVICE UDP:7355 default
|
||||
%M%# You can also use "-" or "stdin" to pipe stdout from
|
||||
%M%# some other application such as a software defined radio.
|
||||
%M%# "stdin" is not an audio device. Don't use this unless you
|
||||
%M%# understand what this means. Read the User Guide.
|
||||
%M%# You can also specify "UDP:" and an optional port for input.
|
||||
%M%# Something different must be specified for output.
|
||||
%M%
|
||||
%M%# ADEVICE UDP:7355 default
|
||||
%M%#
|
||||
%L%
|
||||
%L%
|
||||
%C%
|
||||
%C%#
|
||||
%C%# Number of audio channels for this soundcard: 1 or 2.
|
||||
%C%# Number of audio channels for this souncard: 1 (mono) or 2 (stereo).
|
||||
%C%# 1 is the default so there is no need to specify it.
|
||||
%C%#
|
||||
%C%
|
||||
%C%ACHANNELS 1
|
||||
%C%#ACHANNELS 2
|
||||
%C%
|
||||
%C%
|
||||
|
@ -204,33 +239,23 @@
|
|||
%C%#
|
||||
%C%# Pick a suitable modem speed based on your situation.
|
||||
%C%# 1200 Most common for VHF/UHF. Default if not specified.
|
||||
%C%# 300 Low speed for HF SSB.
|
||||
%C%# 9600 High speed - Can't use Microphone and Speaker connections.
|
||||
%C%# 2400 QPSK compatible with MFJ-2400, and probably PK232-2400 & KPC-2400.
|
||||
%C%# 300 Low speed for HF SSB. Default tones 1600 & 1800.
|
||||
%C%# EAS Emergency Alert System (EAS) Specific Area Message Encoding (SAME).
|
||||
%C%# 9600 G3RUH style - Can't use Microphone and Speaker connections.
|
||||
%C%# AIS International system for tracking ships on VHF.
|
||||
%C%# Also uses 9600 bps so Speaker connection won't work.
|
||||
%C%#
|
||||
%C%# In the simplest form, just specify the speed.
|
||||
%C%# In most cases you can just specify the speed. Examples:
|
||||
%C%#
|
||||
%C%
|
||||
%C%MODEM 1200
|
||||
%C%#MODEM 300
|
||||
%C%#MODEM 9600
|
||||
%C%
|
||||
%C%#
|
||||
%C%# These are the defaults should be fine for most cases. In special situations,
|
||||
%C%# you might want to specify different AFSK tones or the baseband mode which does
|
||||
%C%# not use AFSK.
|
||||
%C%# Many options are available for great flexibility.
|
||||
%C%# See User Guide for details.
|
||||
%C%#
|
||||
%C%#MODEM 1200 1200:2200
|
||||
%C%#MODEM 300 1600:1800
|
||||
%C%#MODEM 9600 0:0
|
||||
%C%#
|
||||
%C%#
|
||||
%C%# On HF SSB, you might want to use multiple demodulators on slightly different
|
||||
%C%# frequencies to compensate for stations off frequency. Here we have 7 different
|
||||
%C%# demodulators at 30 Hz intervals. This takes a lot of CPU power so you will
|
||||
%C%# probably need to reduce the audio sampling rate with the /n option.
|
||||
%C%
|
||||
%C%#MODEM 300 1600:1800 7@30 /4
|
||||
%C%
|
||||
%C%
|
||||
%C%#
|
||||
%C%# Uncomment line below to enable the DTMF decoder for this channel.
|
||||
|
@ -238,10 +263,22 @@
|
|||
%C%
|
||||
%C%#DTMF
|
||||
%C%
|
||||
%C%#
|
||||
%C%# If not using a VOX circuit, the transmitter Push to Talk (PTT)
|
||||
%C%# control is usually wired to a serial port with a suitable interface circuit.
|
||||
%C%# DON'T connect it directly!
|
||||
%L%# If using a C-Media CM108/CM119 or similar USB Audio Adapter,
|
||||
%L%# you can use a GPIO pin for PTT control. This is very convenient
|
||||
%L%# because a single USB connection is used for both audio and PTT.
|
||||
%L%# Example:
|
||||
%L%
|
||||
%L%#PTT CM108
|
||||
%L%
|
||||
%W%# If using a C-Media CM108/CM119 or similar USB Audio Adapter,
|
||||
%W%# you can use a GPIO pin for PTT control. This is very convenient
|
||||
%W%# because a single USB connection is used for both audio and PTT.
|
||||
%W%# Example:
|
||||
%W%
|
||||
%W%#PTT CM108
|
||||
%W%%C%#
|
||||
%C%# The transmitter Push to Talk (PTT) control can be wired to a serial port
|
||||
%C%# with a suitable interface circuit. DON'T connect it directly!
|
||||
%C%#
|
||||
%C%# For the PTT command, specify the device and either RTS or DTR.
|
||||
%C%# RTS or DTR may be preceded by "-" to invert the signal.
|
||||
|
@ -336,7 +373,6 @@
|
|||
%C%#
|
||||
%C%# 0 [NONE] - Don't try to repair.
|
||||
%C%# 1 [SINGLE] - Attempt to fix single bit error. (default)
|
||||
%C%# 2 [DOUBLE] - Also attempt to fix two adjacent bits.
|
||||
%C%# ... see User Guide for more values and in-depth discussion.
|
||||
%C%#
|
||||
%C%
|
||||
|
@ -345,7 +381,7 @@
|
|||
%C%#
|
||||
%C%#############################################################
|
||||
%C%# #
|
||||
%C%# BEACONING PROPERTIES #
|
||||
%C%# FIXED POSIION BEACONING PROPERTIES #
|
||||
%C%# #
|
||||
%C%#############################################################
|
||||
%C%
|
||||
|
@ -397,7 +433,7 @@
|
|||
%C%
|
||||
%C%#############################################################
|
||||
%C%# #
|
||||
%C%# DIGIPEATER PROPERTIES #
|
||||
%C%# APRS DIGIPEATER PROPERTIES #
|
||||
%C%# #
|
||||
%C%#############################################################
|
||||
%C%
|
||||
|
@ -418,6 +454,8 @@
|
|||
%C%
|
||||
%C%#FILTER 0 1 t/wn
|
||||
%C%
|
||||
%C%# Traditional connected mode packet radio uses a different
|
||||
%C%# type of digipeating. See User Guide for details.
|
||||
%C%
|
||||
%C%#############################################################
|
||||
%C%# #
|
||||
|
@ -458,19 +496,6 @@
|
|||
%C%
|
||||
%C%#IGTXVIA 0 WIDE1-1
|
||||
%C%
|
||||
%C%# You might want to apply a filter for what packets will be obtained from the server.
|
||||
%C%# Read about filters here: http://www.aprs-is.net/javaprsfilter.aspx
|
||||
%C%# Example, positions and objects within 50 km of my location:
|
||||
%C%
|
||||
%C%#IGFILTER m/50
|
||||
%C%
|
||||
%C%# That is known as a server-side filter. It is processed by the IGate server.
|
||||
%C%# You can also apply local filtering to limit what will be transmitted on the
|
||||
%C%# RF side. For example, transmit only "messages" on channel 0 and weather
|
||||
%C%# reports on channel 1.
|
||||
%C%
|
||||
%C%#FILTER IG 0 t/m
|
||||
%C%#FILTER IG 1 t/wn
|
||||
%C%
|
||||
%C%# Finally, we don't want to flood the radio channel.
|
||||
%C%# The IGate function will limit the number of packets transmitted
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
APRS SYMBOL OVERLAY and EXTENSION TABLES in APRS 1.2 17 Jun 2018
|
||||
APRS SYMBOL OVERLAY and EXTENSION TABLES in APRS 1.2 17 Mar 2021
|
||||
------------------------------------------------------------------------
|
||||
|
||||
|
||||
BACKGROUND: Since October 2007, overlay characters (36/symbol) are
|
||||
allowed on all symbols. This allows thousands of uniquely specified
|
||||
symbols instead of the original 188 (94 primary and 94 alternate).
|
||||
|
@ -9,7 +8,9 @@ But the master symbol document, http://aprs.org/symbols/symbolsX.txt,
|
|||
only has one line per symbol. So this added overlay list below gives
|
||||
us thousands of new symbol codes.
|
||||
|
||||
17 Jun19: Added several overlays for RAIL symbol
|
||||
17 Mar 21 Added L& for LORA Igate
|
||||
24 Jun18: Updated CAR symbols
|
||||
17 Jun18: Added several overlays for RAIL symbol
|
||||
03 Apr17: Added Methane Hazard symbol "MH"
|
||||
13 Feb17: Added Ez = Emergency Power (shelter), Cars: P> = Plugin
|
||||
S> = Solar powered. Moved Ham club C- to Buildings Ch.
|
||||
|
@ -211,14 +212,18 @@ CARS: #> (Vehicles)
|
|||
/> = normal car (side view)
|
||||
\> = Top view and symbol POINTS in direction of travel
|
||||
#> = Reserve overlays 1-9 for numbered cars (new Aug 2014)
|
||||
B> = Battery (was E for electric)
|
||||
3> = Model 3 (Tesla)
|
||||
B> = BEV - Battery EV(was E for electric)
|
||||
D> = DIY - Do it yourself
|
||||
E> = Ethanol (was electric)
|
||||
F> = Fuelcell or hydrogen
|
||||
H> = Homemade
|
||||
P> = Plugin-hybrid
|
||||
H> = Hybrid
|
||||
L> = Leaf
|
||||
P> = PHEV - Plugin-hybrid
|
||||
S> = Solar powered
|
||||
T> = Tesla (temporary)
|
||||
V> = GM Volt (temporary)
|
||||
V> = Volt (temporary)
|
||||
X> = Model X
|
||||
|
||||
CIVIL DEFENSE or TRIANGLE: #c
|
||||
/c = Incident Command Post
|
||||
|
@ -269,6 +274,7 @@ FE = (F overlay) Fog was \{
|
|||
GATEWAYS: #&
|
||||
/& = HF Gateway <= the original primary table definition
|
||||
I& = Igate Generic (please use more specific overlay)
|
||||
L& - Lora Igate
|
||||
R& = Receive only IGate (do not send msgs back to RF)
|
||||
P& = PSKmail node
|
||||
T& = TX igate with path set to 1 hop only)
|
||||
|
@ -339,17 +345,17 @@ I; = Islands on the air
|
|||
S; = Summits on the air
|
||||
W; = WOTA
|
||||
|
||||
POWER or ENERGY: #%
|
||||
POWER and ENERGY: #%
|
||||
/% = DX cluster <= the original primary table definition
|
||||
C% = Coal
|
||||
E% = Emergency (new Aug 2014)
|
||||
G% = Geothermal
|
||||
G% = Gas Turbine
|
||||
H% = Hydroelectric
|
||||
N% = Nuclear
|
||||
P% = Portable (new Aug 2014)
|
||||
R% = Renewable (hydrogen etc fuels)
|
||||
S% = Solar
|
||||
T% = Turbine
|
||||
T% = Thermal (geo)
|
||||
W% = Wind
|
||||
|
||||
RAIL Symbols: #=
|
||||
|
|
108
data/tocalls.txt
108
data/tocalls.txt
|
@ -1,28 +1,30 @@
|
|||
<title>
|
||||
APRS TO-CALL VERSION NUMBERS 20 Jan 2020
|
||||
-------------------------------------------------------------------
|
||||
APRS TO-CALL VERSION NUMBERS 14 Dec 2021
|
||||
---------------------------------------------------------------------
|
||||
WB4APR
|
||||
</title>
|
||||
<version_notes>
|
||||
20 Jan 20 Added APBT62 for BTech DMR 6x2
|
||||
08 Jan 20 Added APCLUB for Brazil APRS network
|
||||
06 Jan 20 Added APMQxx for Ham Radio of Things WB2OSZ
|
||||
18 Dec 19 Added APTPNx: TARPN Packet Node Tracker by KN4ORB
|
||||
02 Dec 19 added APJ8xx For Jordan / KN4CRD JS8Call application
|
||||
8 Sep 19 Added APBSDx for OpenBSD or HamBSD https://hambsd.org/
|
||||
19 Aug 19 Added APNKMX for KAM-XL
|
||||
and Added APAT51 for Anytone AT-D578UV APRS radio
|
||||
16 Jul 19 expanded APMGxx to cover PiCrumbs and MiniGate
|
||||
24 Jun 19 Added APTCMA for CAPI tracker - PU1CMA Brazil
|
||||
4 Jun 19 added APATxx for Anytone
|
||||
8 May 19 added APQTHx for W8WJB's QTH.app
|
||||
12 Mar 19 added APLIGx for LightAPRS
|
||||
3 Dec 18 added APRARX forVK5QI's radiosonde tracking
|
||||
8 Nov 18 added APELKx for WB8ELK balloons
|
||||
24 Oct 18 added APGBLN for NW5W's GoBalloon
|
||||
18 Apr 18 added APBKxx for PY5BK Bravo Tracker in Brazil
|
||||
7 Mar 18 added APERSx Runner tracking by Jason,KG7YKZ
|
||||
8 Jan 18 added APTCHE PU3IKE in Brazil TcheTracker/Tcheduino
|
||||
14 Dec 21 Added APATAR ATA-R APRS Digipeater by TA7W/OH2UDS and TA6AEU
|
||||
26 Sep 21 Added APRRDZ EPS32 https://github.com/dl9rdz/rdz_ttgo_sonde
|
||||
18 Sep 21 Added APCSS for AMSAT Cubesat Simulator https://cubesatsim.org
|
||||
16 Sep 21 Added APY05D for Yaesu FT5D series
|
||||
04 Sep 21 APLOxx LoRa KISS TNC/Tracker https://github.com/SQ9MDD/TTGO-T-Beam-LoRa-APRS
|
||||
24 Aug 21 Added APLSxx SARIMESH http://www.sarimesh.net
|
||||
22 Aug 21 Added APE2Ax for VA3NNW's Email-2-APRS ap
|
||||
30 Jun 21 Added APCNxx for carNET by DG5OAW
|
||||
14 Jun 21 Added APN2xx for NOSaprs JNOS 2.0 - VE4KLM
|
||||
24 Apr 21 Added APMPAD for DF1JSL's WXBot clone and extension
|
||||
20 Apr 21 Added APLCxx for APRScube by DL3DCW
|
||||
19 Apr 21 Added APVMxx for DRCC-DVM Voice (Digital Radio China Club)
|
||||
13 Apr 21 Added APIxxx for all Dstar ICOMS (APRS via DPRS)
|
||||
23 MAr 20 Added APW9xx For 9A9Y Weather Tracker
|
||||
16 Feb 21 Added API970 for I com 9700
|
||||
|
||||
2020 Added APHBLx,APIZCI,APLGxx,APLTxx,APNVxx,APY300,APESPG,APESPW
|
||||
APGDTx,APOSWx,APOSBx,APBT62,APCLUB,APMQxx
|
||||
2019 Added APTPNx,APJ8xx,APBSDx,APNKMX,APAT51,APMGxx,APTCMA,
|
||||
APATxx,APQTHx,APLIGx
|
||||
2018 added APRARX,APELKx,APGBLN,APBKxx,APERSx,APTCHE
|
||||
2017 Added APHWxx,APDVxx,APPICO,APBMxx,APP6xx,APTAxx,APOCSG,APCSMS,
|
||||
APPMxx,APOFF,APDTMF,APRSON,APDIGI,APSAT,APTBxx,APIExx,
|
||||
APSFxx
|
||||
|
@ -42,6 +44,10 @@ bytes of the field are available to indicate the software version
|
|||
number or application. The following applications have requested
|
||||
a TOCALL number series:
|
||||
|
||||
Authors with similar alphabetic requirements are encouraged to share
|
||||
their address space with other software. Work out agreements amongst
|
||||
yourselves and keep me informed.
|
||||
|
||||
</description>
|
||||
<tocalls>
|
||||
|
||||
|
@ -59,7 +65,8 @@ a TOCALL number series:
|
|||
APAHxx AHub
|
||||
APAND1 APRSdroid (pre-release) http://aprsdroid.org/
|
||||
APAMxx Altus Metrum GPS trackers
|
||||
APATxx for Anytone. 81 for 878 HT
|
||||
APATAR ATA-R APRS Digipeater by TA7W/OH2UDS and TA6AEU
|
||||
APAT8x for Anytone. 81 for 878 HT
|
||||
APAT51 for Anytone AT-D578UV APRS mobile radio
|
||||
APAVT5 SainSonic AP510 which is a 1watt tracker
|
||||
APAWxx AGWPE
|
||||
|
@ -79,7 +86,9 @@ a TOCALL number series:
|
|||
APCLEZ Telit EZ10 GSM application ZS6CEY
|
||||
APCLUB Brazil APRS network
|
||||
APCLWX EYWeather GPRS/GSM WX station by ZS6EY
|
||||
APCNxx for carNET by DG5OAW
|
||||
APCSMS for Cosmos (used for sending commands @USNA)
|
||||
APCSS for AMSAT cubesats https://cubesatsim.org
|
||||
APCWP8 John GM7HHB, WinphoneAPRS
|
||||
APCYxx Cybiko applications
|
||||
APD APD4xx UP4DAR platform
|
||||
|
@ -102,10 +111,13 @@ a TOCALL number series:
|
|||
APDVxx OE6PLD's SSTV with APRS status exchange
|
||||
APDWxx DireWolf, WB2OSZ
|
||||
APE APExxx Telemetry devices
|
||||
APE2Ax VA3NNW's Email-2-APRS ap
|
||||
APECAN Pecan Pico APRS Balloon Tracker
|
||||
APELKx WB8ELK balloons
|
||||
APERXQ Experimental tracker by PE1RXQ
|
||||
APERSx Runner tracking by Jason,KG7YKZ
|
||||
APESPG ESP SmartBeacon APRS-IS Client
|
||||
APESPW ESP Weather Station APRS-IS Client
|
||||
APF APFxxx Firenet
|
||||
APFGxx Flood Gage (KP4DJT)
|
||||
APFIxx for APRS.FI OH7LZB, Hessu
|
||||
|
@ -113,14 +125,28 @@ a TOCALL number series:
|
|||
APG APGxxx Gates, etc
|
||||
APGOxx for AA3NJ PDA application
|
||||
APGBLN for NW5W's GoBalloon
|
||||
APGDTx for VK4FAST's Graphic Data Terminal
|
||||
APH APHKxx for LA1BR tracker/digipeater
|
||||
APHAXn SM2APRS by PY2UEP
|
||||
APHBLx for DMR Gateway by Eric - KF7EEL
|
||||
APHTxx HMTracker by IU0AAC
|
||||
APHWxx for use in "HamWAN
|
||||
API APICQx for ICQ
|
||||
API API282 for ICOM IC-2820
|
||||
API31 for ICOM ID-31
|
||||
API410 for ICOM ID-4100
|
||||
API51 for ICOM ID-51
|
||||
API510 for ICOM ID-5100
|
||||
API710 for ICOM IC-7100
|
||||
API80 for ICOM IC-80
|
||||
API880 for ICOM ID-880
|
||||
API910 for ICOM IC-9100
|
||||
API92 for ICOM IC-92
|
||||
API970 for ICOM 9700
|
||||
APICQx for ICQ
|
||||
APICxx HA9MCQ's Pic IGate
|
||||
APIExx W7KMV's PiAPRS system
|
||||
APINxx PinPoint by AB0WV
|
||||
APIZCI hymTR IZCI Tracker by TA7W/OH2UDS and TA6AEU
|
||||
APJ APJ8xx Jordan / KN4CRD JS8Call application
|
||||
APJAxx JavAPRS
|
||||
APJExx JeAPRS
|
||||
|
@ -133,15 +159,22 @@ a TOCALL number series:
|
|||
APK1xx Kenwood D700's
|
||||
APK102 Kenwood D710
|
||||
APKRAM KRAMstuff.com - Mark. G7LEU
|
||||
APL APLIGx LightAPRS - TA2MUN and TA9OHC
|
||||
APL APLCxx APRScube by DL3DCW
|
||||
APLGxx LoRa Gateway/Digipeater OE5BPA
|
||||
APLIGx LightAPRS - TA2MUN and TA9OHC
|
||||
APLOxx LoRa KISS TNC/Tracker
|
||||
APLQRU Charlie - QRU Server
|
||||
APLMxx WA0TQG transceiver controller
|
||||
APLSxx SARIMESH ( http://www.sarimesh.net )
|
||||
APLTxx LoRa Tracker - OE5BPA
|
||||
APM APMxxx MacAPRS,
|
||||
APMGxx PiCrumbs and MiniGate - Alex, AB0TJ
|
||||
APMIxx SQ3PLX http://microsat.com.pl/
|
||||
APMPAD DF1JSL's WXBot clone and extension
|
||||
APMQxx Ham Radio of Things WB2OSZ
|
||||
APMTxx LZ1PPL for tracker
|
||||
APN APNxxx Network nodes, digis, etc
|
||||
APN2xx NOSaprs for JNOS 2.0 - VE4KLM
|
||||
APN3xx Kantronics KPC-3 rom versions
|
||||
APN9xx Kantronics KPC-9612 Roms
|
||||
APNAxx WB6ZSU's APRServe
|
||||
|
@ -155,6 +188,7 @@ a TOCALL number series:
|
|||
APNPxx Paccom TNC roms
|
||||
APNTxx SV2AGW's TNT tnc as a digi
|
||||
APNUxx UIdigi
|
||||
APNVxx SQ8L's VP digi and Nodes
|
||||
APNXxx TNC-X (K6DBG)
|
||||
APNWxx SQ3FYK.com WX/Digi and SQ3PLX http://microsat.com.pl/
|
||||
APO APRSpoint
|
||||
|
@ -162,8 +196,10 @@ a TOCALL number series:
|
|||
APOLUx for OSCAR satellites for AMSAT-LU by LU9DO
|
||||
APOAxx OpenAPRS - Greg Carter
|
||||
APOCSG For N0AGI's APRS to POCSAG project
|
||||
APOTxx Open Track
|
||||
APOD1w Open Track with 1 wire WX
|
||||
APOSBx openSPOT3 by HA2NON at sharkrf.com
|
||||
APOSWx openSPOT2
|
||||
APOTxx Open Track
|
||||
APOU2k Open Track for Ultimeter
|
||||
APOZxx www.KissOZ.dk Tracker. OZ1EKD and OZ7HVO
|
||||
APP APP6xx for APRSlib
|
||||
|
@ -215,22 +251,30 @@ a TOCALL number series:
|
|||
APU3xx UIview terminal program
|
||||
APUDRx NW Digital Radio's UDR (APRS/Dstar)
|
||||
APV APVxxx Voice over Internet applications
|
||||
APVMxx DRCC-DVM Digital Voice (Digital Radio China Club)
|
||||
APVRxx for IRLP
|
||||
APVLxx for I-LINK
|
||||
APVExx for ECHO link
|
||||
APW APWxxx WinAPRS, etc
|
||||
APW9xx 9A9Y Weather Tracker
|
||||
APWAxx APRSISCE Android version
|
||||
APWSxx DF4IAN's WS2300 WX station
|
||||
APWMxx APRSISCE KJ4ERJ
|
||||
APWWxx APRSISCE win32 version
|
||||
APX APXnnn Xastir
|
||||
APXRnn Xrouter
|
||||
APY APYxxx Yeasu
|
||||
APY APYxxx Yaesu Radios
|
||||
APY008 Yaesu VX-8 series
|
||||
APY01D Yaesu FT1D series
|
||||
APY02D Yaesu FT2D series
|
||||
APY03D Yaesu FT3D series
|
||||
APY05D Yaesu FT5D series
|
||||
APY100 Yaesu FTM-100D series
|
||||
APY300 Yaesu FTM-300D series
|
||||
APY350 Yaesu FTM-350 series
|
||||
APYTxx for YagTracker
|
||||
APYSxx for W2GMD's Python APRS
|
||||
APY400 Yaesu FTM-400D series
|
||||
APZ APZxxx Experimental
|
||||
APZ200 old versions of JNOS
|
||||
APZ247 for UPRS NR0Q
|
||||
APZ0xx Xastir (old versions. See APX)
|
||||
APZMAJ Martyn M1MAJ DeLorme inReach Tracker
|
||||
|
@ -242,15 +286,11 @@ a TOCALL number series:
|
|||
</tocalls>
|
||||
<notes>
|
||||
|
||||
Authors with similar alphabetic requirements are encouraged to share
|
||||
their address space with other software. Work out agreements amongst
|
||||
yourselves and keep me informed.
|
||||
|
||||
</notes>
|
||||
<altnets>
|
||||
|
||||
REGISTERED ALTNETS:
|
||||
-------------------
|
||||
REGISTERED TOCALL ALTNETS:
|
||||
--------------------------
|
||||
|
||||
ALTNETS are uses of the AX-25 tocall to distinguish specialized
|
||||
traffic that may be flowing on the APRS-IS, but that are not intended
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,4 +1,4 @@
|
|||
# Documentation for Dire Wolf #
|
||||
# Documentation for Dire Wolf #
|
||||
|
||||
Click on the document name to view in your web browser or the link following to download the PDF file.
|
||||
|
||||
|
@ -11,11 +11,11 @@ Brief summary of packet radio / APRS history and the capbilities of Dire Wolf.
|
|||
|
||||
## Essential Reading ##
|
||||
|
||||
- [**User Guide**](User-Guide.pdf) [ [*download*](../../../raw/dev/doc/User-Guide.pdf) ]
|
||||
- [**User Guide**](User-Guide.pdf) [ [*download*](../../../raw/master/doc/User-Guide.pdf) ]
|
||||
|
||||
This is your primary source of information about installation, operation, and configuration.
|
||||
|
||||
- [**Raspberry Pi APRS**](Raspberry-Pi-APRS.pdf) [ [*download*](../../../raw/dev/doc/Raspberry-Pi-APRS.pdf) ]
|
||||
- [**Raspberry Pi APRS**](Raspberry-Pi-APRS.pdf) [ [*download*](../../../raw/master/doc/Raspberry-Pi-APRS.pdf) ]
|
||||
|
||||
The Raspberry Pi has some special considerations that
|
||||
make it different from other generic Linux systems.
|
||||
|
@ -46,38 +46,40 @@ These dive into more detail for specialized topics or typical usage scenarios.
|
|||
|
||||
- [**Successful APRS IGate Operation**](Successful-APRS-IGate-Operation.pdf) [ [*download*](../../../raw/dev/doc/Successful-APRS-IGate-Operation.pdf) ]
|
||||
|
||||
|
||||
Dire Wolf can serve as a gateway between the APRS radio network and APRS-IS servers on the Internet.
|
||||
|
||||
This explains how it all works, proper configuration, and troubleshooting.
|
||||
|
||||
- [**Bluetooth KISS TNC**](Bluetooth-KISS-TNC.pdf) [ [*download*](../../../raw/dev/doc/Bluetooth-KISS-TNC.pdf) ]
|
||||
- [**Bluetooth KISS TNC**](Bluetooth-KISS-TNC.pdf) [ [*download*](../../../raw/master/doc/Bluetooth-KISS-TNC.pdf) ]
|
||||
|
||||
Eliminate the cable between your TNC and application. Use Bluetooth instead.
|
||||
|
||||
- [**APRStt Implementation Notes**](APRStt-Implementation-Notes.pdf) [ [*download*](../../../raw/dev/doc/APRStt-Implementation-Notes.pdf) ]
|
||||
- [**APRStt Implementation Notes**](APRStt-Implementation-Notes.pdf) [ [*download*](../../../raw/master/doc/APRStt-Implementation-Notes.pdf) ]
|
||||
|
||||
Very few hams have portable equipment for APRS but nearly everyone has a handheld radio that can send DTMF tones. APRStt allows a user, equipped with only DTMF (commonly known as Touch Tone) generation capability, to enter information into the global APRS data network.
|
||||
This document explains how the APRStt concept was implemented in the Dire Wolf application.
|
||||
- [**APRStt Interface for SARTrack**](APRStt-interface-for-SARTrack.pdf) [ [*download*](../../../raw/dev/doc/APRStt-interface-for-SARTrack.pdf) ]
|
||||
|
||||
- [**APRStt Interface for SARTrack**](APRStt-interface-for-SARTrack.pdf) [ [*download*](../../../raw/master/doc/APRStt-interface-for-SARTrack.pdf) ]
|
||||
|
||||
This example illustrates how APRStt can be integrated with other applications such as SARTrack, APRSISCE/32, YAAC, or Xastir.
|
||||
|
||||
- [**APRStt Listening Example**](APRStt-Listening-Example.pdf) [ [*download*](../../../raw/dev/doc/APRStt-Listening-Example.pdf) ]
|
||||
- [**APRStt Listening Example**](APRStt-Listening-Example.pdf) [ [*download*](../../../raw/master/doc/APRStt-Listening-Example.pdf) ]
|
||||
|
||||
|
||||
WB4APR described a useful application for the [QIKCOM-2 Satallite Transponder](http://www.tapr.org/pipermail/aprssig/2015-November/045035.html).
|
||||
|
||||
Don’t have your own QIKCOM-2 Satellite Transponder? No Problem. You can do the same thing with an ordinary computer and the APRStt gateway built into Dire Wolf. Here’s how.
|
||||
|
||||
- [**Raspberry Pi APRS Tracker**](Raspberry-Pi-APRS-Tracker.pdf) [ [*download*](../../../raw/dev/doc/Raspberry-Pi-APRS-Tracker.pdf) ]
|
||||
- [**Raspberry Pi APRS Tracker**](Raspberry-Pi-APRS-Tracker.pdf) [ [*download*](../../../raw/master/doc/Raspberry-Pi-APRS-Tracker.pdf) ]
|
||||
|
||||
Build a tracking device which transmits position from a GPS receiver.
|
||||
|
||||
- [**Raspberry Pi SDR IGate**](Raspberry-Pi-SDR-IGate.pdf) [ [*download*](../../../raw/dev/doc/Raspberry-Pi-SDR-IGate.pdf) ]
|
||||
- [**Raspberry Pi SDR IGate**](Raspberry-Pi-SDR-IGate.pdf) [ [*download*](../../../raw/master/doc/Raspberry-Pi-SDR-IGate.pdf) ]
|
||||
|
||||
It's easy to build a receive-only APRS Internet Gateway (IGate) with only a Raspberry Pi and a software defined radio (RTL-SDR) dongle. Here’s how.
|
||||
|
||||
- [**APRS Telemetry Toolkit**](APRS-Telemetry-Toolkit.pdf) [ [*download*](../../../raw/dev/doc/APRS-Telemetry-Toolkit.pdf) ]
|
||||
- [**APRS Telemetry Toolkit**](APRS-Telemetry-Toolkit.pdf) [ [*download*](../../../raw/master/doc/APRS-Telemetry-Toolkit.pdf) ]
|
||||
|
||||
Describes scripts and methods to generate telemetry.
|
||||
Includes a complete example of attaching an analog to
|
||||
|
@ -86,12 +88,12 @@ These dive into more detail for specialized topics or typical usage scenarios.
|
|||
|
||||
|
||||
|
||||
- [**2400 & 4800 bps PSK for APRS / Packet Radio**](2400-4800-PSK-for-APRS-Packet-Radio.pdf) [ [*download*](../../../raw/dev/doc/2400-4800-PSK-for-APRS-Packet-Radio.pdf) ]
|
||||
- [**2400 & 4800 bps PSK for APRS / Packet Radio**](2400-4800-PSK-for-APRS-Packet-Radio.pdf) [ [*download*](../../../raw/master/doc/2400-4800-PSK-for-APRS-Packet-Radio.pdf) ]
|
||||
|
||||
|
||||
Double or quadruple your data rate by sending multiple bits at the same time.
|
||||
|
||||
- [**Going beyond 9600 baud**](Going-beyond-9600-baud.pdf) [ [*download*](../../../raw/dev/doc/Going-beyond-9600-baud.pdf) ]
|
||||
- [**Going beyond 9600 baud**](Going-beyond-9600-baud.pdf) [ [*download*](../../../raw/master/doc/Going-beyond-9600-baud.pdf) ]
|
||||
|
||||
|
||||
Why stop at 9600 baud? Go faster if your soundcard and radio can handle it.
|
||||
|
@ -101,11 +103,26 @@ These dive into more detail for specialized topics or typical usage scenarios.
|
|||
|
||||
AIS is an international tracking system for ships. Messages can contain position, speed, course, name, destination, status, vessel dimensions, and many other types of information. Learn how to receive these signals with an ordindary ham transceiver and display the ship locations with APRS applications or [OpenCPN](https://opencpn.org).
|
||||
|
||||
- **[EAS to APRS message converter](https://github.com/wb2osz/eas2aprs)**
|
||||
|
||||
|
||||
The [U.S. National Weather Service](https://www.weather.gov/nwr/) (NWS) operates more than 1,000 VHF FM radio stations that continuously transmit weather information. These stations also transmit special warnings about severe weather, disasters (natural & manmade), and public safety.
|
||||
|
||||
Alerts are sent in a digital form known as Emergency Alert System (EAS) Specific Area Message Encoding (SAME). [You can hear a sample here](https://en.wikipedia.org/wiki/Specific_Area_Message_Encoding).
|
||||
|
||||
It is possible to buy radios that decode these messages but what fun is that? We are ham radio operators so we want to build our own from stuff that we already have sitting around.
|
||||
|
||||
|
||||
## Miscellaneous ##
|
||||
|
||||
- **[Ham Radio of Things (HRoT)](https://github.com/wb2osz/hrot)**
|
||||
|
||||
- [**A Better APRS Packet Demodulator, part 1, 1200 baud**](A-Better-APRS-Packet-Demodulator-Part-1-1200-baud.pdf) [ [*download*](../../../raw/dev/doc/A-Better-APRS-Packet-Demodulator-Part-1-1200-baud.pdf) ]
|
||||
|
||||
Now that billions of computers and mobile phones (which are handheld computers) are all connected by the Internet, the large growth is expected from the “Internet of Things.” What is a “thing?” It could be a temperature sensor, garage door opener, motion detector, flood water level, smoke alarm, antenna rotator, coffee maker, lights, home thermostat, …, just about anything you might want to monitor or control.
|
||||
|
||||
There have been other occasional mentions of merging Ham Radio with the Internet of Things but only ad hoc incompatible narrowly focused applications. Here is a proposal for a standardized more flexible method so different systems can communicate with each other.
|
||||
|
||||
- [**A Better APRS Packet Demodulator, part 1, 1200 baud**](A-Better-APRS-Packet-Demodulator-Part-1-1200-baud.pdf) [ [*download*](../../../raw/master/doc/A-Better-APRS-Packet-Demodulator-Part-1-1200-baud.pdf) ]
|
||||
|
||||
Sometimes it's a little mystifying why an
|
||||
APRS / AX.25 Packet TNC will decode some signals
|
||||
|
@ -117,7 +134,7 @@ and a couple things that can be done about it.
|
|||
|
||||
|
||||
|
||||
- [**A Better APRS Packet Demodulator, part 2, 9600 baud**](A-Better-APRS-Packet-Demodulator-Part-2-9600-baud.pdf) [ [*download*](../../../raw/dev/doc/A-Better-APRS-Packet-Demodulator-Part-2-9600-baud.pdf) ]
|
||||
- [**A Better APRS Packet Demodulator, part 2, 9600 baud**](A-Better-APRS-Packet-Demodulator-Part-2-9600-baud.pdf) [ [*download*](../../../raw/master/doc/A-Better-APRS-Packet-Demodulator-Part-2-9600-baud.pdf) ]
|
||||
|
||||
In the first part of this series we discussed 1200 baud audio frequency shift keying (AFSK). The mismatch
|
||||
between FM transmitter pre-emphasis and the
|
||||
|
@ -126,13 +143,13 @@ and a couple things that can be done about it.
|
|||
This makes it more difficult to demodulate them accurately.
|
||||
9600 baud operation is an entirely different animal. ...
|
||||
|
||||
- [**WA8LMF TNC Test CD Results a.k.a. Battle of the TNCs**](WA8LMF-TNC-Test-CD-Results.pdf) [ [*download*](../../../raw/dev/doc/WA8LMF-TNC-Test-CD-Results.pdf) ]
|
||||
- [**WA8LMF TNC Test CD Results a.k.a. Battle of the TNCs**](WA8LMF-TNC-Test-CD-Results.pdf) [ [*download*](../../../raw/master/doc/WA8LMF-TNC-Test-CD-Results.pdf) ]
|
||||
|
||||
How can we compare how well the TNCs perform under real world conditions?
|
||||
The de facto standard of measurement is the number of packets decoded from [WA8LMF’s TNC Test CD](http://wa8lmf.net/TNCtest/index.htm).
|
||||
Many have published the number of packets they have been able to decode from this test. Here they are, all gathered in one place, for your reading pleasure.
|
||||
|
||||
- [**A Closer Look at the WA8LMF TNC Test CD**](A-Closer-Look-at-the-WA8LMF-TNC-Test-CD.pdf) [ [*download*](../../../raw/dev/doc/A-Closer-Look-at-the-WA8LMF-TNC-Test-CD.pdf) ]
|
||||
- [**A Closer Look at the WA8LMF TNC Test CD**](A-Closer-Look-at-the-WA8LMF-TNC-Test-CD.pdf) [ [*download*](../../../raw/master/doc/A-Closer-Look-at-the-WA8LMF-TNC-Test-CD.pdf) ]
|
||||
|
||||
Here, we take a closer look at some of the frames on the TNC Test CD in hopes of gaining some insights into why some are easily decoded and others are more difficult.
|
||||
There are a lot of ugly signals out there. Many can be improved by decreasing the transmit volume. Others are just plain weird and you have to wonder how they are being generated.
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -236,7 +236,7 @@ extern "C" {
|
|||
* The function Convert_MGRS_To_UPS converts an MGRS coordinate string
|
||||
* to UPS (hemisphere, easting, and northing) coordinates, according
|
||||
* to the current ellipsoid parameters. If any errors occur, the error
|
||||
* code(s) are returned by the function, otherwide UPS_NO_ERROR is returned.
|
||||
* code(s) are returned by the function, otherwise UPS_NO_ERROR is returned.
|
||||
*
|
||||
* MGRS : MGRS coordinate string (input)
|
||||
* Hemisphere : Hemisphere either 'N' or 'S' (output)
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
set(HIDAPI_LIBRARIES "" CACHE INTERNAL "")
|
||||
|
||||
if(WIN32 OR CYGWIN) # windows
|
||||
|
||||
set(HIDAPI_LIBRARIES hidapi CACHE INTERNAL "hidapi")
|
||||
|
||||
list(APPEND hidapi_SOURCES
|
||||
# Functions for accessing HID devices on Windows.
|
||||
# These were copied from https://github.com/libusb/hidapi
|
||||
${CUSTOM_HIDAPI_DIR}/hid.c
|
||||
)
|
||||
|
||||
add_library(hidapi STATIC
|
||||
${hidapi_SOURCES}
|
||||
)
|
||||
|
||||
set_target_properties(hidapi
|
||||
PROPERTIES COMPILE_FLAGS "-Dbool=int -Dtrue=1 -Dfalse=0 -DUSE_HIDAPI_STATIC"
|
||||
)
|
||||
|
||||
endif()
|
|
@ -0,0 +1,26 @@
|
|||
Copyright (c) 2010, Alan Ott, Signal 11 Software
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Signal 11 Software nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
@ -0,0 +1,9 @@
|
|||
HIDAPI - Multi-Platform library for
|
||||
communication with HID devices.
|
||||
|
||||
Copyright 2009, Alan Ott, Signal 11 Software.
|
||||
All Rights Reserved.
|
||||
|
||||
This software may be used by anyone for any reason so
|
||||
long as the copyright notice in the source files
|
||||
remains intact.
|
|
@ -0,0 +1,13 @@
|
|||
HIDAPI can be used under one of three licenses.
|
||||
|
||||
1. The GNU General Public License, version 3.0, in LICENSE-gpl3.txt
|
||||
2. A BSD-Style License, in LICENSE-bsd.txt.
|
||||
3. The more liberal original HIDAPI license. LICENSE-orig.txt
|
||||
|
||||
The license chosen is at the discretion of the user of HIDAPI. For example:
|
||||
1. An author of GPL software would likely use HIDAPI under the terms of the
|
||||
GPL.
|
||||
|
||||
2. An author of commercial closed-source software would likely use HIDAPI
|
||||
under the terms of the BSD-style license or the original HIDAPI license.
|
||||
|
|
@ -0,0 +1 @@
|
|||
This is from https://github.com/libusb/hidapi
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,498 @@
|
|||
/*******************************************************
|
||||
HIDAPI - Multi-Platform library for
|
||||
communication with HID devices.
|
||||
|
||||
Alan Ott
|
||||
Signal 11 Software
|
||||
|
||||
8/22/2009
|
||||
|
||||
Copyright 2009, All Rights Reserved.
|
||||
|
||||
At the discretion of the user of this library,
|
||||
this software may be licensed under the terms of the
|
||||
GNU General Public License v3, a BSD-Style license, or the
|
||||
original HIDAPI license as outlined in the LICENSE.txt,
|
||||
LICENSE-gpl3.txt, LICENSE-bsd.txt, and LICENSE-orig.txt
|
||||
files located at the root of the source distribution.
|
||||
These files may also be found in the public source
|
||||
code repository located at:
|
||||
https://github.com/libusb/hidapi .
|
||||
********************************************************/
|
||||
|
||||
/** @file
|
||||
* @defgroup API hidapi API
|
||||
*/
|
||||
|
||||
#ifndef HIDAPI_H__
|
||||
#define HIDAPI_H__
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define HID_API_EXPORT __declspec(dllexport)
|
||||
#define HID_API_CALL
|
||||
#else
|
||||
#define HID_API_EXPORT /**< API export macro */
|
||||
#define HID_API_CALL /**< API call macro */
|
||||
#endif
|
||||
|
||||
#define HID_API_EXPORT_CALL HID_API_EXPORT HID_API_CALL /**< API export and call macro*/
|
||||
|
||||
/** @brief Static/compile-time major version of the library.
|
||||
|
||||
@ingroup API
|
||||
*/
|
||||
#define HID_API_VERSION_MAJOR 0
|
||||
/** @brief Static/compile-time minor version of the library.
|
||||
|
||||
@ingroup API
|
||||
*/
|
||||
#define HID_API_VERSION_MINOR 10
|
||||
/** @brief Static/compile-time patch version of the library.
|
||||
|
||||
@ingroup API
|
||||
*/
|
||||
#define HID_API_VERSION_PATCH 1
|
||||
|
||||
/* Helper macros */
|
||||
#define HID_API_AS_STR_IMPL(x) #x
|
||||
#define HID_API_AS_STR(x) HID_API_AS_STR_IMPL(x)
|
||||
#define HID_API_TO_VERSION_STR(v1, v2, v3) HID_API_AS_STR(v1.v2.v3)
|
||||
|
||||
/** @brief Static/compile-time string version of the library.
|
||||
|
||||
@ingroup API
|
||||
*/
|
||||
#define HID_API_VERSION_STR HID_API_TO_VERSION_STR(HID_API_VERSION_MAJOR, HID_API_VERSION_MINOR, HID_API_VERSION_PATCH)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
struct hid_api_version {
|
||||
int major;
|
||||
int minor;
|
||||
int patch;
|
||||
};
|
||||
|
||||
struct hid_device_;
|
||||
typedef struct hid_device_ hid_device; /**< opaque hidapi structure */
|
||||
|
||||
/** hidapi info structure */
|
||||
struct hid_device_info {
|
||||
/** Platform-specific device path */
|
||||
char *path;
|
||||
/** Device Vendor ID */
|
||||
unsigned short vendor_id;
|
||||
/** Device Product ID */
|
||||
unsigned short product_id;
|
||||
/** Serial Number */
|
||||
wchar_t *serial_number;
|
||||
/** Device Release Number in binary-coded decimal,
|
||||
also known as Device Version Number */
|
||||
unsigned short release_number;
|
||||
/** Manufacturer String */
|
||||
wchar_t *manufacturer_string;
|
||||
/** Product string */
|
||||
wchar_t *product_string;
|
||||
/** Usage Page for this Device/Interface
|
||||
(Windows/Mac/hidraw only) */
|
||||
unsigned short usage_page;
|
||||
/** Usage for this Device/Interface
|
||||
(Windows/Mac/hidraw only) */
|
||||
unsigned short usage;
|
||||
/** The USB interface which this logical device
|
||||
represents.
|
||||
|
||||
* Valid on both Linux implementations in all cases.
|
||||
* Valid on the Windows implementation only if the device
|
||||
contains more than one interface.
|
||||
* Valid on the Mac implementation if and only if the device
|
||||
is a USB HID device. */
|
||||
int interface_number;
|
||||
|
||||
/** Pointer to the next device */
|
||||
struct hid_device_info *next;
|
||||
};
|
||||
|
||||
|
||||
/** @brief Initialize the HIDAPI library.
|
||||
|
||||
This function initializes the HIDAPI library. Calling it is not
|
||||
strictly necessary, as it will be called automatically by
|
||||
hid_enumerate() and any of the hid_open_*() functions if it is
|
||||
needed. This function should be called at the beginning of
|
||||
execution however, if there is a chance of HIDAPI handles
|
||||
being opened by different threads simultaneously.
|
||||
|
||||
@ingroup API
|
||||
|
||||
@returns
|
||||
This function returns 0 on success and -1 on error.
|
||||
*/
|
||||
int HID_API_EXPORT HID_API_CALL hid_init(void);
|
||||
|
||||
/** @brief Finalize the HIDAPI library.
|
||||
|
||||
This function frees all of the static data associated with
|
||||
HIDAPI. It should be called at the end of execution to avoid
|
||||
memory leaks.
|
||||
|
||||
@ingroup API
|
||||
|
||||
@returns
|
||||
This function returns 0 on success and -1 on error.
|
||||
*/
|
||||
int HID_API_EXPORT HID_API_CALL hid_exit(void);
|
||||
|
||||
/** @brief Enumerate the HID Devices.
|
||||
|
||||
This function returns a linked list of all the HID devices
|
||||
attached to the system which match vendor_id and product_id.
|
||||
If @p vendor_id is set to 0 then any vendor matches.
|
||||
If @p product_id is set to 0 then any product matches.
|
||||
If @p vendor_id and @p product_id are both set to 0, then
|
||||
all HID devices will be returned.
|
||||
|
||||
@ingroup API
|
||||
@param vendor_id The Vendor ID (VID) of the types of device
|
||||
to open.
|
||||
@param product_id The Product ID (PID) of the types of
|
||||
device to open.
|
||||
|
||||
@returns
|
||||
This function returns a pointer to a linked list of type
|
||||
struct #hid_device_info, containing information about the HID devices
|
||||
attached to the system, or NULL in the case of failure. Free
|
||||
this linked list by calling hid_free_enumeration().
|
||||
*/
|
||||
struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned short vendor_id, unsigned short product_id);
|
||||
|
||||
/** @brief Free an enumeration Linked List
|
||||
|
||||
This function frees a linked list created by hid_enumerate().
|
||||
|
||||
@ingroup API
|
||||
@param devs Pointer to a list of struct_device returned from
|
||||
hid_enumerate().
|
||||
*/
|
||||
void HID_API_EXPORT HID_API_CALL hid_free_enumeration(struct hid_device_info *devs);
|
||||
|
||||
/** @brief Open a HID device using a Vendor ID (VID), Product ID
|
||||
(PID) and optionally a serial number.
|
||||
|
||||
If @p serial_number is NULL, the first device with the
|
||||
specified VID and PID is opened.
|
||||
|
||||
This function sets the return value of hid_error().
|
||||
|
||||
@ingroup API
|
||||
@param vendor_id The Vendor ID (VID) of the device to open.
|
||||
@param product_id The Product ID (PID) of the device to open.
|
||||
@param serial_number The Serial Number of the device to open
|
||||
(Optionally NULL).
|
||||
|
||||
@returns
|
||||
This function returns a pointer to a #hid_device object on
|
||||
success or NULL on failure.
|
||||
*/
|
||||
HID_API_EXPORT hid_device * HID_API_CALL hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number);
|
||||
|
||||
/** @brief Open a HID device by its path name.
|
||||
|
||||
The path name be determined by calling hid_enumerate(), or a
|
||||
platform-specific path name can be used (eg: /dev/hidraw0 on
|
||||
Linux).
|
||||
|
||||
This function sets the return value of hid_error().
|
||||
|
||||
@ingroup API
|
||||
@param path The path name of the device to open
|
||||
|
||||
@returns
|
||||
This function returns a pointer to a #hid_device object on
|
||||
success or NULL on failure.
|
||||
*/
|
||||
HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path);
|
||||
|
||||
/** @brief Write an Output report to a HID device.
|
||||
|
||||
The first byte of @p data[] must contain the Report ID. For
|
||||
devices which only support a single report, this must be set
|
||||
to 0x0. The remaining bytes contain the report data. Since
|
||||
the Report ID is mandatory, calls to hid_write() will always
|
||||
contain one more byte than the report contains. For example,
|
||||
if a hid report is 16 bytes long, 17 bytes must be passed to
|
||||
hid_write(), the Report ID (or 0x0, for devices with a
|
||||
single report), followed by the report data (16 bytes). In
|
||||
this example, the length passed in would be 17.
|
||||
|
||||
hid_write() will send the data on the first OUT endpoint, if
|
||||
one exists. If it does not, it will send the data through
|
||||
the Control Endpoint (Endpoint 0).
|
||||
|
||||
This function sets the return value of hid_error().
|
||||
|
||||
@ingroup API
|
||||
@param dev A device handle returned from hid_open().
|
||||
@param data The data to send, including the report number as
|
||||
the first byte.
|
||||
@param length The length in bytes of the data to send.
|
||||
|
||||
@returns
|
||||
This function returns the actual number of bytes written and
|
||||
-1 on error.
|
||||
*/
|
||||
int HID_API_EXPORT HID_API_CALL hid_write(hid_device *dev, const unsigned char *data, size_t length);
|
||||
|
||||
/** @brief Read an Input report from a HID device with timeout.
|
||||
|
||||
Input reports are returned
|
||||
to the host through the INTERRUPT IN endpoint. The first byte will
|
||||
contain the Report number if the device uses numbered reports.
|
||||
|
||||
This function sets the return value of hid_error().
|
||||
|
||||
@ingroup API
|
||||
@param dev A device handle returned from hid_open().
|
||||
@param data A buffer to put the read data into.
|
||||
@param length The number of bytes to read. For devices with
|
||||
multiple reports, make sure to read an extra byte for
|
||||
the report number.
|
||||
@param milliseconds timeout in milliseconds or -1 for blocking wait.
|
||||
|
||||
@returns
|
||||
This function returns the actual number of bytes read and
|
||||
-1 on error. If no packet was available to be read within
|
||||
the timeout period, this function returns 0.
|
||||
*/
|
||||
int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds);
|
||||
|
||||
/** @brief Read an Input report from a HID device.
|
||||
|
||||
Input reports are returned
|
||||
to the host through the INTERRUPT IN endpoint. The first byte will
|
||||
contain the Report number if the device uses numbered reports.
|
||||
|
||||
This function sets the return value of hid_error().
|
||||
|
||||
@ingroup API
|
||||
@param dev A device handle returned from hid_open().
|
||||
@param data A buffer to put the read data into.
|
||||
@param length The number of bytes to read. For devices with
|
||||
multiple reports, make sure to read an extra byte for
|
||||
the report number.
|
||||
|
||||
@returns
|
||||
This function returns the actual number of bytes read and
|
||||
-1 on error. If no packet was available to be read and
|
||||
the handle is in non-blocking mode, this function returns 0.
|
||||
*/
|
||||
int HID_API_EXPORT HID_API_CALL hid_read(hid_device *dev, unsigned char *data, size_t length);
|
||||
|
||||
/** @brief Set the device handle to be non-blocking.
|
||||
|
||||
In non-blocking mode calls to hid_read() will return
|
||||
immediately with a value of 0 if there is no data to be
|
||||
read. In blocking mode, hid_read() will wait (block) until
|
||||
there is data to read before returning.
|
||||
|
||||
Nonblocking can be turned on and off at any time.
|
||||
|
||||
@ingroup API
|
||||
@param dev A device handle returned from hid_open().
|
||||
@param nonblock enable or not the nonblocking reads
|
||||
- 1 to enable nonblocking
|
||||
- 0 to disable nonblocking.
|
||||
|
||||
@returns
|
||||
This function returns 0 on success and -1 on error.
|
||||
*/
|
||||
int HID_API_EXPORT HID_API_CALL hid_set_nonblocking(hid_device *dev, int nonblock);
|
||||
|
||||
/** @brief Send a Feature report to the device.
|
||||
|
||||
Feature reports are sent over the Control endpoint as a
|
||||
Set_Report transfer. The first byte of @p data[] must
|
||||
contain the Report ID. For devices which only support a
|
||||
single report, this must be set to 0x0. The remaining bytes
|
||||
contain the report data. Since the Report ID is mandatory,
|
||||
calls to hid_send_feature_report() will always contain one
|
||||
more byte than the report contains. For example, if a hid
|
||||
report is 16 bytes long, 17 bytes must be passed to
|
||||
hid_send_feature_report(): the Report ID (or 0x0, for
|
||||
devices which do not use numbered reports), followed by the
|
||||
report data (16 bytes). In this example, the length passed
|
||||
in would be 17.
|
||||
|
||||
This function sets the return value of hid_error().
|
||||
|
||||
@ingroup API
|
||||
@param dev A device handle returned from hid_open().
|
||||
@param data The data to send, including the report number as
|
||||
the first byte.
|
||||
@param length The length in bytes of the data to send, including
|
||||
the report number.
|
||||
|
||||
@returns
|
||||
This function returns the actual number of bytes written and
|
||||
-1 on error.
|
||||
*/
|
||||
int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *dev, const unsigned char *data, size_t length);
|
||||
|
||||
/** @brief Get a feature report from a HID device.
|
||||
|
||||
Set the first byte of @p data[] to the Report ID of the
|
||||
report to be read. Make sure to allow space for this
|
||||
extra byte in @p data[]. Upon return, the first byte will
|
||||
still contain the Report ID, and the report data will
|
||||
start in data[1].
|
||||
|
||||
This function sets the return value of hid_error().
|
||||
|
||||
@ingroup API
|
||||
@param dev A device handle returned from hid_open().
|
||||
@param data A buffer to put the read data into, including
|
||||
the Report ID. Set the first byte of @p data[] to the
|
||||
Report ID of the report to be read, or set it to zero
|
||||
if your device does not use numbered reports.
|
||||
@param length The number of bytes to read, including an
|
||||
extra byte for the report ID. The buffer can be longer
|
||||
than the actual report.
|
||||
|
||||
@returns
|
||||
This function returns the number of bytes read plus
|
||||
one for the report ID (which is still in the first
|
||||
byte), or -1 on error.
|
||||
*/
|
||||
int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length);
|
||||
|
||||
/** @brief Get a input report from a HID device.
|
||||
|
||||
Set the first byte of @p data[] to the Report ID of the
|
||||
report to be read. Make sure to allow space for this
|
||||
extra byte in @p data[]. Upon return, the first byte will
|
||||
still contain the Report ID, and the report data will
|
||||
start in data[1].
|
||||
|
||||
@ingroup API
|
||||
@param device A device handle returned from hid_open().
|
||||
@param data A buffer to put the read data into, including
|
||||
the Report ID. Set the first byte of @p data[] to the
|
||||
Report ID of the report to be read, or set it to zero
|
||||
if your device does not use numbered reports.
|
||||
@param length The number of bytes to read, including an
|
||||
extra byte for the report ID. The buffer can be longer
|
||||
than the actual report.
|
||||
|
||||
@returns
|
||||
This function returns the number of bytes read plus
|
||||
one for the report ID (which is still in the first
|
||||
byte), or -1 on error.
|
||||
*/
|
||||
int HID_API_EXPORT HID_API_CALL hid_get_input_report(hid_device *dev, unsigned char *data, size_t length);
|
||||
|
||||
/** @brief Close a HID device.
|
||||
|
||||
This function sets the return value of hid_error().
|
||||
|
||||
@ingroup API
|
||||
@param dev A device handle returned from hid_open().
|
||||
*/
|
||||
void HID_API_EXPORT HID_API_CALL hid_close(hid_device *dev);
|
||||
|
||||
/** @brief Get The Manufacturer String from a HID device.
|
||||
|
||||
@ingroup API
|
||||
@param dev A device handle returned from hid_open().
|
||||
@param string A wide string buffer to put the data into.
|
||||
@param maxlen The length of the buffer in multiples of wchar_t.
|
||||
|
||||
@returns
|
||||
This function returns 0 on success and -1 on error.
|
||||
*/
|
||||
int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *dev, wchar_t *string, size_t maxlen);
|
||||
|
||||
/** @brief Get The Product String from a HID device.
|
||||
|
||||
@ingroup API
|
||||
@param dev A device handle returned from hid_open().
|
||||
@param string A wide string buffer to put the data into.
|
||||
@param maxlen The length of the buffer in multiples of wchar_t.
|
||||
|
||||
@returns
|
||||
This function returns 0 on success and -1 on error.
|
||||
*/
|
||||
int HID_API_EXPORT_CALL hid_get_product_string(hid_device *dev, wchar_t *string, size_t maxlen);
|
||||
|
||||
/** @brief Get The Serial Number String from a HID device.
|
||||
|
||||
@ingroup API
|
||||
@param dev A device handle returned from hid_open().
|
||||
@param string A wide string buffer to put the data into.
|
||||
@param maxlen The length of the buffer in multiples of wchar_t.
|
||||
|
||||
@returns
|
||||
This function returns 0 on success and -1 on error.
|
||||
*/
|
||||
int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *dev, wchar_t *string, size_t maxlen);
|
||||
|
||||
/** @brief Get a string from a HID device, based on its string index.
|
||||
|
||||
@ingroup API
|
||||
@param dev A device handle returned from hid_open().
|
||||
@param string_index The index of the string to get.
|
||||
@param string A wide string buffer to put the data into.
|
||||
@param maxlen The length of the buffer in multiples of wchar_t.
|
||||
|
||||
@returns
|
||||
This function returns 0 on success and -1 on error.
|
||||
*/
|
||||
int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *dev, int string_index, wchar_t *string, size_t maxlen);
|
||||
|
||||
/** @brief Get a string describing the last error which occurred.
|
||||
|
||||
Whether a function sets the last error is noted in its
|
||||
documentation. These functions will reset the last error
|
||||
to NULL before their execution.
|
||||
|
||||
Strings returned from hid_error() must not be freed by the user!
|
||||
|
||||
This function is thread-safe, and error messages are thread-local.
|
||||
|
||||
@ingroup API
|
||||
@param dev A device handle returned from hid_open(),
|
||||
or NULL to get the last non-device-specific error
|
||||
(e.g. for errors in hid_open() itself).
|
||||
|
||||
@returns
|
||||
This function returns a string containing the last error
|
||||
which occurred or NULL if none has occurred.
|
||||
*/
|
||||
HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *dev);
|
||||
|
||||
/** @brief Get a runtime version of the library.
|
||||
|
||||
@ingroup API
|
||||
|
||||
@returns
|
||||
Pointer to statically allocated struct, that contains version.
|
||||
*/
|
||||
HID_API_EXPORT const struct hid_api_version* HID_API_CALL hid_version(void);
|
||||
|
||||
|
||||
/** @brief Get a runtime version string of the library.
|
||||
|
||||
@ingroup API
|
||||
|
||||
@returns
|
||||
Pointer to statically allocated string, that contains version string.
|
||||
*/
|
||||
HID_API_EXPORT const char* HID_API_CALL hid_version_str(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -6,12 +6,31 @@ include_directories(
|
|||
)
|
||||
|
||||
if(LINUX)
|
||||
# Previously -
|
||||
# list(APPEND misc_SOURCES
|
||||
# # Provide our own copy of strlcpy and strlcat
|
||||
# # because they are not included with Linux.
|
||||
# ${CUSTOM_MISC_DIR}/strlcpy.c
|
||||
# ${CUSTOM_MISC_DIR}/strlcat.c
|
||||
# )
|
||||
# It seems that Alpine Linux and Void Linux have strlcpy and
|
||||
# strlcat so we need to handle the situation more delicately.
|
||||
# When doing it this way, there is probably no reason to
|
||||
# distinguish between Linux and BSD-like systems here.
|
||||
# If we kept going, the same thing could be done for each
|
||||
# of the functions and no OS check would be needed.
|
||||
|
||||
if (NOT HAVE_STRLCPY)
|
||||
list(APPEND misc_SOURCES
|
||||
# Provide our own copy of strlcpy and strlcat
|
||||
# because they are not included with Linux.
|
||||
${CUSTOM_MISC_DIR}/strlcpy.c
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NOT HAVE_STRLCAT)
|
||||
list(APPEND misc_SOURCES
|
||||
${CUSTOM_MISC_DIR}/strlcat.c
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(misc STATIC
|
||||
${misc_SOURCES}
|
||||
|
|
|
@ -18,7 +18,7 @@ if(WIN32 OR CYGWIN) # windows
|
|||
)
|
||||
|
||||
set_target_properties(regex
|
||||
PROPERTIES COMPILE_FLAGS "-Dbool=int -Dtrue=1 -Dfalse=0 -DUSE_REGEX_STATIC"
|
||||
PROPERTIES COMPILE_FLAGS "-Dbool=int -Dtrue=1 -Dfalse=0 -DREGEX_STATIC"
|
||||
)
|
||||
|
||||
endif()
|
||||
|
|
|
@ -35,17 +35,23 @@
|
|||
#if (defined __WIN32__) || (defined _WIN32)
|
||||
# ifdef BUILD_REGEX_DLL
|
||||
# define REGEX_DLL_IMPEXP __DLL_EXPORT__
|
||||
# define REGEX_VARIABLE_IMPEXP __DLL_EXPORT__
|
||||
# elif defined(REGEX_STATIC)
|
||||
# define REGEX_DLL_IMPEXP
|
||||
# define REGEX_VARIABLE_IMPEXP
|
||||
# elif defined (USE_REGEX_DLL)
|
||||
# define REGEX_DLL_IMPEXP __DLL_IMPORT__
|
||||
# define REGEX_VARIABLE_IMPEXP __DLL_IMPORT__
|
||||
# elif defined (USE_REGEX_STATIC)
|
||||
# define REGEX_DLL_IMPEXP
|
||||
# define REGEX_VARIABLE_IMPEXP extern
|
||||
# else /* assume USE_REGEX_DLL */
|
||||
# define REGEX_DLL_IMPEXP __DLL_IMPORT__
|
||||
# define REGEX_VARIABLE_IMPEXP __DLL_IMPORT__
|
||||
# endif
|
||||
#else /* __WIN32__ */
|
||||
# define REGEX_DLL_IMPEXP
|
||||
# define REGEX_VARIABLE_IMPEXP
|
||||
#endif
|
||||
|
||||
/* Allow the use in C++ code. */
|
||||
|
@ -202,7 +208,7 @@ typedef unsigned long int reg_syntax_t;
|
|||
some interfaces). When a regexp is compiled, the syntax used is
|
||||
stored in the pattern buffer, so changing this does not affect
|
||||
already-compiled regexps. */
|
||||
REGEX_DLL_IMPEXP reg_syntax_t re_syntax_options;
|
||||
REGEX_VARIABLE_IMPEXP reg_syntax_t re_syntax_options;
|
||||
|
||||
/* Define combinations of the above bits for the standard possibilities.
|
||||
(The [[[ comments delimit what gets put into the Texinfo file, so
|
||||
|
|
|
@ -61,6 +61,10 @@ Data rate in bits/sec for first channel. Standard values are 300, 1200, 2400, 4
|
|||
4800 bps uses 8PSK based on V.27 standard.
|
||||
.P
|
||||
9600 bps and up uses K9NG/G3RUH standard.
|
||||
.P
|
||||
AIS for ship Automatic Identification System.
|
||||
.P
|
||||
EAS for Emergency Alert System (EAS) Specific Area Message Encoding (SAME).
|
||||
.RE
|
||||
.RE
|
||||
.PD
|
||||
|
@ -81,6 +85,18 @@ Force G3RUH modem regardless of data rate.
|
|||
.BI "-D " "n"
|
||||
Divide audio sample by n for first channel.
|
||||
|
||||
.TP
|
||||
.BI "-X " "n"
|
||||
1 to enable FX.25 transmit. 16, 32, 64 for specific number of check bytes.
|
||||
|
||||
.TP
|
||||
.BI "-I " "n"
|
||||
Enable IL2P transmit. n=1 is recommended. 0 uses weaker FEC.
|
||||
|
||||
.TP
|
||||
.BI "-i " "n"
|
||||
Enable IL2P transmit, inverted polarity. n=1 is recommended. 0 uses weaker FEC.
|
||||
|
||||
.TP
|
||||
.BI "-d " "x"
|
||||
Debug options. Specify one or more of the following in place of x.
|
||||
|
@ -112,6 +128,10 @@ h = Hamlib verbose level. Repeat for more.
|
|||
m = Monitor heard station list.
|
||||
.P
|
||||
f = Packet filtering.
|
||||
.P
|
||||
x = FX.25 increase verbose level.
|
||||
.P
|
||||
d = APRStt (DTMF to APRS object conversion).
|
||||
.RE
|
||||
.RE
|
||||
.PD
|
||||
|
@ -125,24 +145,42 @@ Quiet (suppress output). Specify one or more of the following in place of x.
|
|||
h = Heard line with the audio level.
|
||||
.P
|
||||
d = Decoding of APRS packets.
|
||||
.P
|
||||
x = Silence FX.25 information.
|
||||
.RE
|
||||
.RE
|
||||
.PD
|
||||
|
||||
.TP
|
||||
.BI "-t " "n"
|
||||
Text colors. 1=normal, 0=disabled.
|
||||
Text colors. 0=disabled. 1=default. 2,3,4,... alternatives. Use 9 to test compatibility with your terminal.
|
||||
|
||||
|
||||
.TP
|
||||
.B "-p "
|
||||
Enable pseudo terminal for KISS protocol.
|
||||
|
||||
.TP
|
||||
.B "-x "
|
||||
.BI "-x "
|
||||
Send Xmit level calibration tones.
|
||||
.PD 0
|
||||
.RS
|
||||
.RS
|
||||
a = Alternating mark/space tones.
|
||||
.P
|
||||
m = steady Mark tone (e.g. 1200 Hz)
|
||||
.P
|
||||
s = steady Space tone (e.g. 2200 Hz)
|
||||
.P
|
||||
p = selence (set Ptt only).
|
||||
.P
|
||||
Optionally add a number to specify radio channel.
|
||||
.RE
|
||||
.RE
|
||||
.PD
|
||||
|
||||
.TP
|
||||
.B "-U "
|
||||
.B "-u "
|
||||
Print UTF-8 test string and exit.
|
||||
|
||||
.TP
|
||||
|
@ -153,6 +191,13 @@ Print Symbol tables and exit.
|
|||
.BI "-a " "n"
|
||||
Report audio device statistics each n seconds.
|
||||
|
||||
.TP
|
||||
.BI "-T " "fmt"
|
||||
Time stamp format for sent and received frames.
|
||||
|
||||
.TP
|
||||
.BI "-e " "ber"
|
||||
Receive Bit Error Rate (BER), e.g. 1e-5
|
||||
|
||||
.SH EXAMPLES
|
||||
gqrx (2.3 and later) has the ability to send streaming audio through a UDP socket to another application for further processing.
|
||||
|
|
|
@ -62,6 +62,18 @@ Force G3RUH modem regardless of data rate.
|
|||
.BI "-J "
|
||||
2400 bps QPSK compatible with MFJ-2400.
|
||||
|
||||
.TP
|
||||
.BI "-X " "n"
|
||||
1 to enable FX.25 transmit. 16, 32, 64 for specific number of check bytes.
|
||||
|
||||
.TP
|
||||
.BI "-I " "n"
|
||||
Enable IL2P transmit. n=1 is recommended. 0 uses weaker FEC.
|
||||
|
||||
.TP
|
||||
.BI "-i " "n"
|
||||
Enable IL2P transmit, inverted polarity. n=1 is recommended. 0 uses weaker FEC.
|
||||
|
||||
|
||||
.TP
|
||||
.BI "-m " "n"
|
||||
|
|
|
@ -45,7 +45,7 @@ Example: %H:%M:%S for current time in hours, minutes, seconds.
|
|||
|
||||
.TP
|
||||
.BI "-f " "xmit-directory"
|
||||
Files in this directory are transmited and deleted.
|
||||
Files in this directory are transmitted and deleted.
|
||||
Another application places a file here when it wants something to be transmitted.
|
||||
|
||||
.TP
|
||||
|
|
|
@ -11,7 +11,7 @@ tt2text \- Convert Touch Tone sequence to text
|
|||
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fBtt2text\fR converts a Touch Tone squence to text. There are two types
|
||||
\fBtt2text\fR converts a Touch Tone sequence to text. There are two types
|
||||
of encoding:
|
||||
.RS
|
||||
.HP
|
||||
|
|
|
@ -44,7 +44,8 @@ RUNMODE=AUTO
|
|||
|
||||
DIREWOLF="direwolf"
|
||||
|
||||
#Direwolf start up command :: two examples where example one is enabled
|
||||
|
||||
#Direwolf start up command :: Uncomment only one of the examples.
|
||||
#
|
||||
# 1. For normal operation as TNC, digipeater, IGate, etc.
|
||||
# Print audio statistics each 100 seconds for troubleshooting.
|
||||
|
@ -52,9 +53,14 @@ DIREWOLF="direwolf"
|
|||
|
||||
DWCMD="$DIREWOLF -a 100"
|
||||
|
||||
# 2. FX.25 Forward Error Correction (FEC) will allow your signal to
|
||||
# go farther under poor radio conditions. Add "-X 1" to the command line.
|
||||
|
||||
#DWCMD="$DIREWOLF -a 100 -X 1"
|
||||
|
||||
#---------------------------------------------------------------
|
||||
#
|
||||
# 2. Alternative for running with SDR receiver.
|
||||
# 3. Alternative for running with SDR receiver.
|
||||
# Piping one application into another makes it a little more complicated.
|
||||
# We need to use bash for the | to be recognized.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/python
|
||||
#!/usr/bin/python3
|
||||
|
||||
# Part of Dire Wolf APRS Telemetry Toolkit, WB2OSZ, 2015
|
||||
|
||||
|
@ -33,4 +33,4 @@ volts = adc.readADCSingleEnded(0, gain, sps) * 0.001 * (r1+r2) / r2
|
|||
# (multiply by expected value, divide by uncalibrated result.)
|
||||
#volts = volts * 4.98 / 4.889
|
||||
|
||||
print "%.3f" % (volts)
|
||||
print("%.3f" % (volts))
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
# global includes
|
||||
# not ideal but not so slow
|
||||
# otherwise use target_include_directories
|
||||
|
@ -7,8 +8,10 @@ include_directories(
|
|||
${ALSA_INCLUDE_DIRS}
|
||||
${UDEV_INCLUDE_DIRS}
|
||||
${PORTAUDIO_INCLUDE_DIRS}
|
||||
${SNDIO_INCLUDE_DIRS}
|
||||
${CUSTOM_GEOTRANZ_DIR}
|
||||
${GPIOD_INCLUDE_DIRS}
|
||||
${CUSTOM_HIDAPI_DIR}
|
||||
)
|
||||
|
||||
if(WIN32 OR CYGWIN)
|
||||
|
@ -58,6 +61,13 @@ list(APPEND direwolf_SOURCES
|
|||
hdlc_rec2.c
|
||||
hdlc_send.c
|
||||
igate.c
|
||||
il2p_codec.c
|
||||
il2p_scramble.c
|
||||
il2p_rec.c
|
||||
il2p_payload.c
|
||||
il2p_init.c
|
||||
il2p_header.c
|
||||
il2p_send.c
|
||||
kiss_frame.c
|
||||
kiss.c
|
||||
kissserial.c
|
||||
|
@ -97,9 +107,16 @@ if(LINUX)
|
|||
cm108.c
|
||||
)
|
||||
endif()
|
||||
if(AVAHI_CLIENT_FOUND)
|
||||
list(APPEND direwolf_SOURCES
|
||||
dns_sd_common.c
|
||||
dns_sd_avahi.c
|
||||
)
|
||||
endif()
|
||||
elseif(WIN32 OR CYGWIN) # windows
|
||||
list(APPEND direwolf_SOURCES
|
||||
audio_win.c
|
||||
cm108.c
|
||||
|
||||
# icon
|
||||
# require plain gcc binary or link
|
||||
|
@ -108,10 +125,20 @@ if(LINUX)
|
|||
list(REMOVE_ITEM direwolf_SOURCES
|
||||
dwgpsd.c
|
||||
)
|
||||
else() # macOS freebsd openbsd
|
||||
elseif(HAVE_SNDIO)
|
||||
list(APPEND direwolf_SOURCES
|
||||
audio.c
|
||||
)
|
||||
else() # macOS freebsd
|
||||
list(APPEND direwolf_SOURCES
|
||||
audio_portaudio.c
|
||||
)
|
||||
if(USE_MACOS_DNSSD)
|
||||
list(APPEND direwolf_SOURCES
|
||||
dns_sd_common.c
|
||||
dns_sd_macos.c
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(direwolf
|
||||
|
@ -122,6 +149,7 @@ target_link_libraries(direwolf
|
|||
${GEOTRANZ_LIBRARIES}
|
||||
${MISC_LIBRARIES}
|
||||
${REGEX_LIBRARIES}
|
||||
${HIDAPI_LIBRARIES}
|
||||
Threads::Threads
|
||||
${GPSD_LIBRARIES}
|
||||
${HAMLIB_LIBRARIES}
|
||||
|
@ -129,13 +157,15 @@ target_link_libraries(direwolf
|
|||
${UDEV_LIBRARIES}
|
||||
${PORTAUDIO_LIBRARIES}
|
||||
${GPIOD_LIBRARIES}
|
||||
${SNDIO_LIBRARIES}
|
||||
${AVAHI_LIBRARIES}
|
||||
)
|
||||
|
||||
if(WIN32 OR CYGWIN)
|
||||
set_target_properties(direwolf
|
||||
PROPERTIES COMPILE_FLAGS "-DUSE_REGEX_STATIC"
|
||||
)
|
||||
target_link_libraries(direwolf winmm ws2_32)
|
||||
target_link_libraries(direwolf winmm ws2_32 setupapi)
|
||||
endif()
|
||||
|
||||
# decode_aprs
|
||||
|
@ -268,12 +298,20 @@ target_link_libraries(log2gpx
|
|||
list(APPEND gen_packets_SOURCES
|
||||
gen_packets.c
|
||||
ax25_pad.c
|
||||
ax25_pad2.c
|
||||
fx25_encode.c
|
||||
fx25_extract.c
|
||||
fx25_init.c
|
||||
fx25_send.c
|
||||
hdlc_send.c
|
||||
fcs_calc.c
|
||||
gen_tone.c
|
||||
il2p_codec.c
|
||||
il2p_scramble.c
|
||||
il2p_payload.c
|
||||
il2p_init.c
|
||||
il2p_header.c
|
||||
il2p_send.c
|
||||
morse.c
|
||||
dtmf.c
|
||||
textcolor.c
|
||||
|
@ -300,14 +338,22 @@ list(APPEND atest_SOURCES
|
|||
demod_9600.c
|
||||
dsp.c
|
||||
fx25_extract.c
|
||||
fx25_encode.c
|
||||
fx25_init.c
|
||||
fx25_rec.c
|
||||
hdlc_rec.c
|
||||
hdlc_rec2.c
|
||||
il2p_codec.c
|
||||
il2p_scramble.c
|
||||
il2p_rec.c
|
||||
il2p_payload.c
|
||||
il2p_init.c
|
||||
il2p_header.c
|
||||
multi_modem.c
|
||||
rrbb.c
|
||||
fcs_calc.c
|
||||
ax25_pad.c
|
||||
ax25_pad2.c
|
||||
decode_aprs.c
|
||||
dwgpsnmea.c
|
||||
dwgps.c
|
||||
|
@ -400,9 +446,35 @@ if(WIN32 OR CYGWIN)
|
|||
endif()
|
||||
|
||||
|
||||
# TNC interoperability testing for AX.25 connected mode.
|
||||
# tnctest
|
||||
list(APPEND tnctest_SOURCES
|
||||
tnctest.c
|
||||
textcolor.c
|
||||
dtime_now.c
|
||||
serial_port.c
|
||||
)
|
||||
|
||||
add_executable(tnctest
|
||||
${tnctest_SOURCES}
|
||||
)
|
||||
|
||||
target_link_libraries(tnctest
|
||||
${MISC_LIBRARIES}
|
||||
Threads::Threads
|
||||
)
|
||||
|
||||
if(WIN32 OR CYGWIN)
|
||||
target_link_libraries(tnctest ws2_32)
|
||||
endif()
|
||||
|
||||
|
||||
# List USB audio adapters than can use GPIO for PTT.
|
||||
# Originally for Linux only (using udev).
|
||||
# Version 1.7 adds it for Windows. Needs hidapi library.
|
||||
|
||||
# cm108
|
||||
if(UDEV_FOUND)
|
||||
if(UDEV_FOUND OR WIN32 OR CYGWIN)
|
||||
list(APPEND cm108_SOURCES
|
||||
cm108.c
|
||||
textcolor.c
|
||||
|
@ -418,8 +490,21 @@ if(UDEV_FOUND)
|
|||
|
||||
target_link_libraries(cm108
|
||||
${MISC_LIBRARIES}
|
||||
)
|
||||
|
||||
if (LINUX)
|
||||
target_link_libraries(cm108
|
||||
${UDEV_LIBRARIES}
|
||||
)
|
||||
endif()
|
||||
|
||||
if (WIN32 OR CYGWIN)
|
||||
target_link_libraries(cm108
|
||||
${HIDAPI_LIBRARIES}
|
||||
ws2_32
|
||||
setupapi
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
|
@ -483,7 +568,8 @@ install(TARGETS gen_packets DESTINATION ${INSTALL_BIN_DIR})
|
|||
install(TARGETS atest DESTINATION ${INSTALL_BIN_DIR})
|
||||
install(TARGETS ttcalc DESTINATION ${INSTALL_BIN_DIR})
|
||||
install(TARGETS kissutil DESTINATION ${INSTALL_BIN_DIR})
|
||||
install(TARGETS tnctest DESTINATION ${INSTALL_BIN_DIR})
|
||||
install(TARGETS appserver DESTINATION ${INSTALL_BIN_DIR})
|
||||
if(UDEV_FOUND)
|
||||
if(UDEV_FOUND OR WIN32 OR CYGWIN)
|
||||
install(TARGETS cm108 DESTINATION ${INSTALL_BIN_DIR})
|
||||
endif()
|
||||
|
|
12
src/agwlib.c
12
src/agwlib.c
|
@ -321,7 +321,7 @@ static void * tnc_listen_thread (void *arg)
|
|||
s_tnc_sock = dwsock_connect (s_tnc_host, s_tnc_port, "TNC", 0, 0, tncaddr);
|
||||
|
||||
if (s_tnc_sock != -1) {
|
||||
dw_printf ("Succesfully reattached to network TNC.\n");
|
||||
dw_printf ("Successfully reattached to network TNC.\n");
|
||||
|
||||
// Might need to run TNC initialization again.
|
||||
// For example, a server would register its callsigns.
|
||||
|
@ -600,7 +600,7 @@ int agwlib_G_ask_port_information (void)
|
|||
* Returns: Number of bytes sent for success, -1 for error.
|
||||
*
|
||||
* Description: This only starts the sequence and does not wait.
|
||||
* Success or failue will be indicated sometime later by ?
|
||||
* Success or failure will be indicated sometime later by ?
|
||||
*
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
@ -635,7 +635,7 @@ int agwlib_C_connect (int chan, char *call_from, char *call_to)
|
|||
* Returns: Number of bytes sent for success, -1 for error.
|
||||
*
|
||||
* Description: This only starts the sequence and does not wait.
|
||||
* Success or failue will be indicated sometime later by ?
|
||||
* Success or failure will be indicated sometime later by ?
|
||||
*
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
@ -722,13 +722,13 @@ int agwlib_D_send_connected_data (int chan, int pid, char *call_from, char *call
|
|||
* hand we don't want to get TOO far ahead when transferring a large file.
|
||||
*
|
||||
* Before disconnecting from another station, it would be good to know
|
||||
* that it actually recevied the last message we sent. For this reason,
|
||||
* that it actually received the last message we sent. For this reason,
|
||||
* I think it would be good for this to include frames that were
|
||||
* transmitted but not yet acknowleged. (Even if it was transmitted once,
|
||||
* transmitted but not yet acknowledged. (Even if it was transmitted once,
|
||||
* it could still be transmitted again, if lost, so you could say it is
|
||||
* still waiting for transmission.)
|
||||
*
|
||||
* See server.c for a more precise definition of exacly how this is defined.
|
||||
* See server.c for a more precise definition of exactly how this is defined.
|
||||
*
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
|
|
@ -338,7 +338,7 @@ void ais_to_nmea (unsigned char *ais, int ais_len, char *nmea, int nmea_size)
|
|||
*
|
||||
* Name: ais_parse
|
||||
*
|
||||
* Purpose: Parse AIS sentence and extract interesing parts.
|
||||
* Purpose: Parse AIS sentence and extract interesting parts.
|
||||
*
|
||||
* Inputs: sentence NMEA sentence.
|
||||
*
|
||||
|
@ -594,7 +594,7 @@ int ais_parse (char *sentence, int quiet, char *descr, int descr_size, char *mss
|
|||
*
|
||||
* Returns: -1 Invalid message type.
|
||||
* 0 Good length.
|
||||
* 1 Unexpected lenth.
|
||||
* 1 Unexpected length.
|
||||
*
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
|
|
@ -320,7 +320,7 @@ static void poll_timing_test (void)
|
|||
*
|
||||
* data - Should look something like this for incoming:
|
||||
* *** CONNECTED to Station xxx\r
|
||||
* and ths for my request being accepted:
|
||||
* and this for my request being accepted:
|
||||
* *** CONNECTED With Station xxx\r
|
||||
*
|
||||
* session_id - Session id to be used in data transfer and
|
||||
|
@ -491,15 +491,19 @@ void agw_cb_D_connected_data (int chan, char *call_from, char *call_to, int data
|
|||
// who - list people currently logged in.
|
||||
|
||||
int n;
|
||||
char greeting[80];
|
||||
char greeting[128];
|
||||
|
||||
snprintf (greeting, sizeof(greeting), "Session Channel User Since\r");
|
||||
agwlib_D_send_connected_data (chan, 0xF0, mycall, call_from, strlen(greeting), greeting);
|
||||
|
||||
for (n = 0; n < MAX_SESSIONS; n++) {
|
||||
if (session[n].client_addr[0]) {
|
||||
// I think compiler is confused. It says up to 520 characters can be written.
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat-truncation"
|
||||
snprintf (greeting, sizeof(greeting), " %2d %d %-9s [time later]\r",
|
||||
n, session[n].channel, session[n].client_addr);
|
||||
#pragma GCC diagnostic pop
|
||||
agwlib_D_send_connected_data (chan, 0xF0, mycall, call_from, strlen(greeting), greeting);
|
||||
}
|
||||
}
|
||||
|
|
151
src/aprs_tt.c
151
src/aprs_tt.c
|
@ -115,6 +115,8 @@ static int find_ttloc_match (char *e, char *xstr, char *ystr, char *zstr, char *
|
|||
static void check_result (void);
|
||||
#endif
|
||||
|
||||
static int tt_debug = 0;
|
||||
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
*
|
||||
|
@ -122,7 +124,8 @@ static void check_result (void);
|
|||
*
|
||||
* Purpose: Initialize the APRStt gateway at system startup time.
|
||||
*
|
||||
* Inputs: Configuration options gathered by config.c.
|
||||
* Inputs: P - Pointer to configuration options gathered by config.c.
|
||||
* debug - Debug printing control.
|
||||
*
|
||||
* Global out: Make our own local copy of the structure here.
|
||||
*
|
||||
|
@ -164,9 +167,10 @@ static struct ttloc_s test_config[] = {
|
|||
#endif
|
||||
|
||||
|
||||
void aprs_tt_init (struct tt_config_s *p)
|
||||
void aprs_tt_init (struct tt_config_s *p, int debug)
|
||||
{
|
||||
int c;
|
||||
tt_debug = debug;
|
||||
|
||||
#if TT_MAIN
|
||||
/* For unit testing. */
|
||||
|
@ -208,7 +212,7 @@ void aprs_tt_init (struct tt_config_s *p)
|
|||
* The complete message is then processed.
|
||||
* The touch tone decoder sends $ if no activity
|
||||
* for some amount of time, perhaps 5 seconds.
|
||||
* A partially accumulated messge is discarded if
|
||||
* A partially accumulated message is discarded if
|
||||
* there is a long gap.
|
||||
*
|
||||
* '.' means no activity during processing period.
|
||||
|
@ -483,7 +487,19 @@ static int parse_fields (char *msg)
|
|||
//text_color_set(DW_COLOR_DEBUG);
|
||||
//dw_printf ("parse_fields (%s).\n", msg);
|
||||
|
||||
strlcpy (stemp, msg, sizeof(stemp));
|
||||
// Make a copy of msg because strtok corrupts the original.
|
||||
// While we are at it, remove any blanks.
|
||||
// This should not happen with DTMF reception but could happen
|
||||
// in manually crafted strings for testing.
|
||||
|
||||
int n = 0;
|
||||
for (char *m = msg; *m != '\0' && n < sizeof(stemp)-1; m++) {
|
||||
if (*m != ' ') {
|
||||
stemp[n++] = *m;
|
||||
}
|
||||
}
|
||||
stemp[n] = '\0';
|
||||
|
||||
e = strtok_r (stemp, "*#", &save);
|
||||
while (e != NULL) {
|
||||
|
||||
|
@ -551,7 +567,7 @@ static int parse_fields (char *msg)
|
|||
default:
|
||||
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Field does not start with A, B, C, or digit: \"%s\"\n", msg);
|
||||
dw_printf ("Field does not start with A, B, C, or digit: \"%s\"\n", e);
|
||||
return (TT_ERROR_D_MSG);
|
||||
|
||||
}
|
||||
|
@ -574,7 +590,7 @@ static int parse_fields (char *msg)
|
|||
* Purpose: Expand compact form "macro" to full format then process.
|
||||
*
|
||||
* Inputs: e - An "entry" extracted from a complete
|
||||
* APRStt messsage.
|
||||
* APRStt message.
|
||||
* In this case, it should contain only digits.
|
||||
*
|
||||
* Returns: 0 for success or one of the TT_ERROR_... codes.
|
||||
|
@ -689,18 +705,16 @@ static int expand_macro (char *e)
|
|||
* Purpose: Extract traditional format callsign or object name from touch tone sequence.
|
||||
*
|
||||
* Inputs: e - An "entry" extracted from a complete
|
||||
* APRStt messsage.
|
||||
* In this case, it should start with "A".
|
||||
* APRStt message.
|
||||
* In this case, it should start with "A" then a digit.
|
||||
*
|
||||
* Outputs: m_callsign
|
||||
*
|
||||
* m_symtab_or_overlay - Set to 0-9 or A-Z if specified.
|
||||
*
|
||||
* m_symbol_code - Always set to 'A'.
|
||||
* NO! This should be applied only if we
|
||||
* have the default value at this point.
|
||||
* The symbol might have been explicitly
|
||||
* set already and we don't want to overwrite that.
|
||||
* m_symbol_code - Always set to 'A' (Box, DTMF or RFID)
|
||||
* If you want a different symbol, use the new
|
||||
* object name format and separate symbol specification.
|
||||
*
|
||||
* Returns: 0 for success or one of the TT_ERROR_... codes.
|
||||
*
|
||||
|
@ -752,6 +766,11 @@ static int parse_callsign (char *e)
|
|||
int len;
|
||||
char tttemp[40], stemp[30];
|
||||
|
||||
if (tt_debug) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("APRStt parse callsign (starts with A then digit): \"%s\"\n", e);
|
||||
}
|
||||
|
||||
assert (*e == 'A');
|
||||
|
||||
len = strlen(e);
|
||||
|
@ -762,6 +781,10 @@ static int parse_callsign (char *e)
|
|||
|
||||
if (len == 4 && isdigit(e[1]) && isdigit(e[2]) && isdigit(e[3])) {
|
||||
strlcpy (m_callsign, e+1, sizeof(m_callsign));
|
||||
if (tt_debug) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("Special case, 3 digit tactical call: \"%s\"\n", m_callsign);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -779,7 +802,7 @@ static int parse_callsign (char *e)
|
|||
return (cs_err);
|
||||
}
|
||||
|
||||
strncpy (m_callsign, e+1, 3);
|
||||
memcpy (m_callsign, e+1, 3);
|
||||
m_callsign[3] = '\0';
|
||||
|
||||
if (len == 7) {
|
||||
|
@ -789,10 +812,20 @@ static int parse_callsign (char *e)
|
|||
tt_two_key_to_text (tttemp, 0, stemp);
|
||||
m_symbol_code = APRSTT_DEFAULT_SYMBOL;
|
||||
m_symtab_or_overlay = stemp[0];
|
||||
if (tt_debug) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("Three digit abbreviation1: callsign \"%s\", symbol code '%c (Box DTMF)', overlay '%c', checksum %c\n",
|
||||
m_callsign, m_symbol_code, m_symtab_or_overlay, e[len-1]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_symbol_code = APRSTT_DEFAULT_SYMBOL;
|
||||
m_symtab_or_overlay = e[len-2];
|
||||
if (tt_debug) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("Three digit abbreviation2: callsign \"%s\", symbol code '%c' (Box DTMF), overlay '%c', checksum %c\n",
|
||||
m_callsign, m_symbol_code, m_symtab_or_overlay, e[len-1]);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
@ -810,7 +843,7 @@ static int parse_callsign (char *e)
|
|||
}
|
||||
|
||||
if (isupper(e[len-2])) {
|
||||
strncpy (tttemp, e+1, len-4);
|
||||
memcpy (tttemp, e+1, len-4);
|
||||
tttemp[len-4] = '\0';
|
||||
tt_two_key_to_text (tttemp, 0, m_callsign);
|
||||
|
||||
|
@ -820,14 +853,24 @@ static int parse_callsign (char *e)
|
|||
tt_two_key_to_text (tttemp, 0, stemp);
|
||||
m_symbol_code = APRSTT_DEFAULT_SYMBOL;
|
||||
m_symtab_or_overlay = stemp[0];
|
||||
if (tt_debug) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("Callsign in two key format1: callsign \"%s\", symbol code '%c' (Box DTMF), overlay '%c', checksum %c\n",
|
||||
m_callsign, m_symbol_code, m_symtab_or_overlay, e[len-1]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
strncpy (tttemp, e+1, len-3);
|
||||
memcpy (tttemp, e+1, len-3);
|
||||
tttemp[len-3] = '\0';
|
||||
tt_two_key_to_text (tttemp, 0, m_callsign);
|
||||
|
||||
m_symbol_code = APRSTT_DEFAULT_SYMBOL;
|
||||
m_symtab_or_overlay = e[len-2];
|
||||
if (tt_debug) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("Callsign in two key format2: callsign \"%s\", symbol code '%c' (Box DTMF), overlay '%c', checksum %c\n",
|
||||
m_callsign, m_symbol_code, m_symtab_or_overlay, e[len-1]);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
@ -845,7 +888,7 @@ static int parse_callsign (char *e)
|
|||
* Purpose: Extract object name from touch tone sequence.
|
||||
*
|
||||
* Inputs: e - An "entry" extracted from a complete
|
||||
* APRStt messsage.
|
||||
* APRStt message.
|
||||
* In this case, it should start with "AA".
|
||||
*
|
||||
* Outputs: m_callsign
|
||||
|
@ -864,9 +907,11 @@ static int parse_callsign (char *e)
|
|||
static int parse_object_name (char *e)
|
||||
{
|
||||
int len;
|
||||
//int c_length;
|
||||
//char tttemp[40];
|
||||
//char stemp[30];
|
||||
|
||||
if (tt_debug) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("APRStt parse object name (starts with AA): \"%s\"\n", e);
|
||||
}
|
||||
|
||||
assert (e[0] == 'A');
|
||||
assert (e[1] == 'A');
|
||||
|
@ -882,6 +927,10 @@ static int parse_object_name (char *e)
|
|||
if (tt_two_key_to_text (e+2, 0, m_callsign) == 0) {
|
||||
m_callsign[9] = '\0'; /* truncate to 9 */
|
||||
m_ssid = 0; /* No ssid for object name */
|
||||
if (tt_debug) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("Object name in two key format: \"%s\"\n", m_callsign);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
@ -901,7 +950,7 @@ static int parse_object_name (char *e)
|
|||
* Purpose: Extract symbol from touch tone sequence.
|
||||
*
|
||||
* Inputs: e - An "entry" extracted from a complete
|
||||
* APRStt messsage.
|
||||
* APRStt message.
|
||||
* In this case, it should start with "AB".
|
||||
*
|
||||
* Outputs: m_symtab_or_overlay
|
||||
|
@ -935,6 +984,11 @@ static int parse_symbol (char *e)
|
|||
int nn;
|
||||
char stemp[10];
|
||||
|
||||
if (tt_debug) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("APRStt parse symbol (starts with AB): \"%s\"\n", e);
|
||||
}
|
||||
|
||||
assert (e[0] == 'A');
|
||||
assert (e[1] == 'B');
|
||||
|
||||
|
@ -959,12 +1013,22 @@ static int parse_symbol (char *e)
|
|||
case '1':
|
||||
m_symtab_or_overlay = '/';
|
||||
m_symbol_code = 32 + nn;
|
||||
if (tt_debug) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("symbol code '%c', primary symbol table '%c'\n",
|
||||
m_symbol_code, m_symtab_or_overlay);
|
||||
}
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case '2':
|
||||
m_symtab_or_overlay = '\\';
|
||||
m_symbol_code = 32 + nn;
|
||||
if (tt_debug) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("symbol code '%c', alternate symbol table '%c'\n",
|
||||
m_symbol_code, m_symtab_or_overlay);
|
||||
}
|
||||
return (0);
|
||||
break;
|
||||
|
||||
|
@ -973,6 +1037,11 @@ static int parse_symbol (char *e)
|
|||
if (tt_two_key_to_text (e+5, 0, stemp) == 0) {
|
||||
m_symbol_code = 32 + nn;
|
||||
m_symtab_or_overlay = stemp[0];
|
||||
if (tt_debug) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("symbol code '%c', alternate symbol table with overlay '%c'\n",
|
||||
m_symbol_code, m_symtab_or_overlay);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
@ -995,7 +1064,7 @@ static int parse_symbol (char *e)
|
|||
* Purpose: Extract QIKcom-2 / APRStt 3 ten digit call or five digit suffix.
|
||||
*
|
||||
* Inputs: e - An "entry" extracted from a complete
|
||||
* APRStt messsage.
|
||||
* APRStt message.
|
||||
* In this case, it should start with "AC".
|
||||
*
|
||||
* Outputs: m_callsign
|
||||
|
@ -1018,6 +1087,11 @@ static int parse_aprstt3_call (char *e)
|
|||
assert (e[0] == 'A');
|
||||
assert (e[1] == 'C');
|
||||
|
||||
if (tt_debug) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("APRStt parse QIKcom-2 / APRStt 3 ten digit call or five digit suffix (starts with AC): \"%s\"\n", e);
|
||||
}
|
||||
|
||||
if (strlen(e) == 2+10) {
|
||||
char call[12];
|
||||
|
||||
|
@ -1073,7 +1147,7 @@ static int parse_aprstt3_call (char *e)
|
|||
* Purpose: Extract location from touch tone sequence.
|
||||
*
|
||||
* Inputs: e - An "entry" extracted from a complete
|
||||
* APRStt messsage.
|
||||
* APRStt message.
|
||||
* In this case, it should start with "B".
|
||||
*
|
||||
* Outputs: m_latitude
|
||||
|
@ -1125,6 +1199,11 @@ static int parse_location (char *e)
|
|||
char mh[20];
|
||||
char stemp[32];
|
||||
|
||||
if (tt_debug) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("APRStt parse location (starts with B): \"%s\"\n", e);
|
||||
// TODO: more detail later...
|
||||
}
|
||||
|
||||
assert (*e == 'B');
|
||||
|
||||
|
@ -1204,13 +1283,26 @@ static int parse_location (char *e)
|
|||
|
||||
lat0 = tt_config.ttloc_ptr[ipat].grid.lat0;
|
||||
lat9 = tt_config.ttloc_ptr[ipat].grid.lat9;
|
||||
double yrange = lat9 - lat0;
|
||||
y = atof(ystr);
|
||||
m_latitude = lat0 + y * (lat9-lat0) / (pow(10., strlen(ystr)) - 1.);
|
||||
|
||||
double user_y_max = round(pow(10., strlen(ystr)) - 1.); // e.g. 999 for 3 digits
|
||||
m_latitude = lat0 + yrange * y / user_y_max;
|
||||
#if 0
|
||||
dw_printf ("TTLOC_GRID LAT min=%f, max=%f, range=%f\n", lat0, lat9, yrange);
|
||||
dw_printf ("TTLOC_GRID LAT user_y=%f, user_y_max=%f\n", y, user_y_max);
|
||||
dw_printf ("TTLOC_GRID LAT min + yrange * user_y / user_y_range = %f\n", m_latitude);
|
||||
#endif
|
||||
lon0 = tt_config.ttloc_ptr[ipat].grid.lon0;
|
||||
lon9 = tt_config.ttloc_ptr[ipat].grid.lon9;
|
||||
double xrange = lon9 - lon0;
|
||||
x = atof(xstr);
|
||||
m_longitude = lon0 + x * (lon9-lon0) / (pow(10., strlen(xstr)) - 1.);
|
||||
double user_x_max = round(pow(10., strlen(xstr)) - 1.);
|
||||
m_longitude = lon0 + xrange * x / user_x_max;
|
||||
#if 0
|
||||
dw_printf ("TTLOC_GRID LON min=%f, max=%f, range=%f\n", lon0, lon9, xrange);
|
||||
dw_printf ("TTLOC_GRID LON user_x=%f, user_x_max=%f\n", x, user_x_max);
|
||||
dw_printf ("TTLOC_GRID LON min + xrange * user_x / user_x_range = %f\n", m_longitude);
|
||||
#endif
|
||||
|
||||
m_dao[2] = e[0];
|
||||
m_dao[3] = e[1];
|
||||
|
@ -1415,7 +1507,7 @@ static int parse_location (char *e)
|
|||
* defined in the configuration file.
|
||||
*
|
||||
* Inputs: e - An "entry" extracted from a complete
|
||||
* APRStt messsage.
|
||||
* APRStt message.
|
||||
* In this case, it should start with "B".
|
||||
*
|
||||
* valstrsize - size of the outputs so we can check for buffer overflow.
|
||||
|
@ -1566,7 +1658,7 @@ static int find_ttloc_match (char *e, char *xstr, char *ystr, char *zstr, char *
|
|||
* Purpose: Extract comment / status or other special information from touch tone message.
|
||||
*
|
||||
* Inputs: e - An "entry" extracted from a complete
|
||||
* APRStt messsage.
|
||||
* APRStt message.
|
||||
* In this case, it should start with "C".
|
||||
*
|
||||
* Outputs: m_comment
|
||||
|
@ -1893,6 +1985,7 @@ static const struct {
|
|||
/* Latitude comes out ok, 37.9137 -> 55.82 min. */
|
||||
/* Longitude -81.1254 -> 8.20 min */
|
||||
{ "B21234*A67979#", "679", "12", "7A", "", "", "12.3400", "56.1200", "!TB2!" },
|
||||
|
||||
{ "B533686*A67979#", "679", "12", "7A", "", "", "37.9222", "81.1143", "!TB5!" },
|
||||
|
||||
// TODO: should test other coordinate systems.
|
||||
|
@ -1985,7 +2078,7 @@ static void check_result (void)
|
|||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
aprs_tt_init (NULL);
|
||||
aprs_tt_init (NULL, 0);
|
||||
|
||||
error_count = 0;
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ struct tt_config_s {
|
|||
int obj_recv_chan; /* Channel to listen for tones. */
|
||||
|
||||
int obj_xmit_chan; /* Channel to transmit object report. */
|
||||
/* -1 for none. This could happpen if we */
|
||||
/* -1 for none. This could happen if we */
|
||||
/* are only sending to application */
|
||||
/* and/or IGate. */
|
||||
|
||||
|
@ -165,7 +165,7 @@ struct tt_config_s {
|
|||
|
||||
|
||||
|
||||
void aprs_tt_init (struct tt_config_s *p_config);
|
||||
void aprs_tt_init (struct tt_config_s *p_config, int debug);
|
||||
|
||||
void aprs_tt_button (int chan, char button);
|
||||
|
||||
|
|
36
src/atest.c
36
src/atest.c
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
||||
//
|
||||
// Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2019 John Langner, WB2OSZ
|
||||
// Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2019, 2021 John Langner, WB2OSZ
|
||||
//
|
||||
// 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
|
||||
|
@ -25,10 +25,10 @@
|
|||
*
|
||||
* Purpose: Test fixture for the AFSK demodulator.
|
||||
*
|
||||
* Inputs: Takes audio from a .WAV file insted of the audio device.
|
||||
* Inputs: Takes audio from a .WAV file instead of the audio device.
|
||||
*
|
||||
* Description: This can be used to test the AFSK demodulator under
|
||||
* controlled and reproducable conditions for tweaking.
|
||||
* controlled and reproducible conditions for tweaking.
|
||||
*
|
||||
* For example
|
||||
*
|
||||
|
@ -82,6 +82,7 @@
|
|||
#include "ptt.h"
|
||||
#include "dtime_now.h"
|
||||
#include "fx25.h"
|
||||
#include "il2p.h"
|
||||
#include "hdlc_rec.h"
|
||||
|
||||
|
||||
|
@ -189,6 +190,7 @@ static int h_opt = 0; // Hexadecimal display of received packet.
|
|||
static char P_opt[16] = ""; // Demodulator profiles.
|
||||
static int d_x_opt = 1; // FX.25 debug.
|
||||
static int d_o_opt = 0; // "-d o" option for DCD output control. */
|
||||
static int d_2_opt = 0; // "-d 2" option for IL2P details. */
|
||||
static int dcd_count = 0;
|
||||
static int dcd_missing_errors = 0;
|
||||
|
||||
|
@ -236,7 +238,7 @@ int main (int argc, char *argv[])
|
|||
my_audio_config.achan[channel].space_freq = DEFAULT_SPACE_FREQ;
|
||||
my_audio_config.achan[channel].baud = DEFAULT_BAUD;
|
||||
|
||||
strlcpy (my_audio_config.achan[channel].profiles, "E", sizeof(my_audio_config.achan[channel].profiles));
|
||||
strlcpy (my_audio_config.achan[channel].profiles, "A", sizeof(my_audio_config.achan[channel].profiles));
|
||||
|
||||
my_audio_config.achan[channel].num_freq = 1;
|
||||
my_audio_config.achan[channel].offset = 0;
|
||||
|
@ -389,6 +391,7 @@ int main (int argc, char *argv[])
|
|||
switch (*p) {
|
||||
case 'x': d_x_opt++; break; // FX.25
|
||||
case 'o': d_o_opt++; break; // DCD output control
|
||||
case '2': d_2_opt++; break; // IL2P debug out
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
@ -430,19 +433,21 @@ int main (int argc, char *argv[])
|
|||
/* We have similar logic in direwolf.c, config.c, gen_packets.c, and atest.c, */
|
||||
/* that need to be kept in sync. Maybe it could be a common function someday. */
|
||||
|
||||
if (my_audio_config.achan[0].baud == 100) {
|
||||
if (my_audio_config.achan[0].baud == 100) { // What was this for?
|
||||
my_audio_config.achan[0].modem_type = MODEM_AFSK;
|
||||
my_audio_config.achan[0].mark_freq = 1615;
|
||||
my_audio_config.achan[0].space_freq = 1785;
|
||||
strlcpy (my_audio_config.achan[0].profiles, "D", sizeof(my_audio_config.achan[0].profiles));
|
||||
//strlcpy (my_audio_config.achan[0].profiles, "A", sizeof(my_audio_config.achan[0].profiles));
|
||||
}
|
||||
else if (my_audio_config.achan[0].baud < 600) {
|
||||
else if (my_audio_config.achan[0].baud < 600) { // e.g. HF SSB packet
|
||||
my_audio_config.achan[0].modem_type = MODEM_AFSK;
|
||||
my_audio_config.achan[0].mark_freq = 1600;
|
||||
my_audio_config.achan[0].space_freq = 1800;
|
||||
strlcpy (my_audio_config.achan[0].profiles, "D", sizeof(my_audio_config.achan[0].profiles));
|
||||
// Previously we had a "D" which was fine tuned for 300 bps.
|
||||
// In v1.7, it's not clear if we should use "B" or just stick with "A".
|
||||
//strlcpy (my_audio_config.achan[0].profiles, "B", sizeof(my_audio_config.achan[0].profiles));
|
||||
}
|
||||
else if (my_audio_config.achan[0].baud < 1800) {
|
||||
else if (my_audio_config.achan[0].baud < 1800) { // common 1200
|
||||
my_audio_config.achan[0].modem_type = MODEM_AFSK;
|
||||
my_audio_config.achan[0].mark_freq = DEFAULT_MARK_FREQ;
|
||||
my_audio_config.achan[0].space_freq = DEFAULT_SPACE_FREQ;
|
||||
|
@ -460,7 +465,7 @@ int main (int argc, char *argv[])
|
|||
my_audio_config.achan[0].space_freq = 0;
|
||||
strlcpy (my_audio_config.achan[0].profiles, "", sizeof(my_audio_config.achan[0].profiles));
|
||||
}
|
||||
else if (my_audio_config.achan[0].baud == 12345) {
|
||||
else if (my_audio_config.achan[0].baud == 12345) { // Hack for different use of 9600
|
||||
my_audio_config.achan[0].modem_type = MODEM_AIS;
|
||||
my_audio_config.achan[0].baud = 9600;
|
||||
my_audio_config.achan[0].mark_freq = 0;
|
||||
|
@ -473,7 +478,7 @@ int main (int argc, char *argv[])
|
|||
// Will make more precise in afsk demod init.
|
||||
my_audio_config.achan[0].mark_freq = 2083; // Actually 2083.3 - logic 1.
|
||||
my_audio_config.achan[0].space_freq = 1563; // Actually 1562.5 - logic 0.
|
||||
strlcpy (my_audio_config.achan[0].profiles, "D", sizeof(my_audio_config.achan[0].profiles));
|
||||
strlcpy (my_audio_config.achan[0].profiles, "A", sizeof(my_audio_config.achan[0].profiles));
|
||||
}
|
||||
else {
|
||||
my_audio_config.achan[0].modem_type = MODEM_SCRAMBLE;
|
||||
|
@ -537,6 +542,7 @@ int main (int argc, char *argv[])
|
|||
}
|
||||
|
||||
fx25_init (d_x_opt);
|
||||
il2p_init (d_2_opt);
|
||||
|
||||
start_time = dtime_now();
|
||||
|
||||
|
@ -614,9 +620,9 @@ int main (int argc, char *argv[])
|
|||
my_audio_config.adev[0].bits_per_sample = format.wbitspersample;
|
||||
my_audio_config.adev[0].num_channels = format.nchannels;
|
||||
|
||||
my_audio_config.achan[0].medium = MEDIUM_RADIO;
|
||||
my_audio_config.chan_medium[0] = MEDIUM_RADIO;
|
||||
if (format.nchannels == 2) {
|
||||
my_audio_config.achan[1].medium = MEDIUM_RADIO;
|
||||
my_audio_config.chan_medium[1] = MEDIUM_RADIO;
|
||||
}
|
||||
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
|
@ -703,7 +709,7 @@ int main (int argc, char *argv[])
|
|||
dw_printf ("%d packets decoded in %.3f seconds. %.1f x realtime\n", packets_decoded_total, elapsed, total_filetime/elapsed);
|
||||
if (d_o_opt) {
|
||||
dw_printf ("DCD count = %d\n", dcd_count);
|
||||
dw_printf ("DCD missing erors = %d\n", dcd_missing_errors);
|
||||
dw_printf ("DCD missing errors = %d\n", dcd_missing_errors);
|
||||
}
|
||||
|
||||
if (error_if_less_than != -1 && packets_decoded_total < error_if_less_than) {
|
||||
|
@ -880,7 +886,7 @@ void dlq_rec_frame (int chan, int subchan, int slice, packet_t pp, alevel_t alev
|
|||
|
||||
decode_aprs_t A;
|
||||
|
||||
decode_aprs (&A, pp, 0);
|
||||
decode_aprs (&A, pp, 0, 0);
|
||||
|
||||
// Temp experiment to see how different systems set the RR bits in the source and destination.
|
||||
// log_rr_bits (&A, pp);
|
||||
|
|
249
src/audio.c
249
src/audio.c
|
@ -75,18 +75,17 @@
|
|||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
#if USE_ALSA
|
||||
#include <alsa/asoundlib.h>
|
||||
#else
|
||||
#include <errno.h>
|
||||
#ifdef __OpenBSD__
|
||||
#include <soundcard.h>
|
||||
#elif USE_SNDIO
|
||||
#include <sndio.h>
|
||||
#include <poll.h>
|
||||
#else
|
||||
#include <sys/soundcard.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#include "audio.h"
|
||||
|
@ -111,6 +110,9 @@ static struct adev_s {
|
|||
|
||||
int bytes_per_frame; /* number of bytes for a sample from all channels. */
|
||||
/* e.g. 4 for stereo 16 bit. */
|
||||
#elif USE_SNDIO
|
||||
struct sio_hdl *sndio_in_handle;
|
||||
struct sio_hdl *sndio_out_handle;
|
||||
|
||||
#else
|
||||
int oss_audio_device_fd; /* Single device, both directions. */
|
||||
|
@ -141,6 +143,9 @@ static struct adev_s {
|
|||
#if USE_ALSA
|
||||
static int set_alsa_params (int a, snd_pcm_t *handle, struct audio_s *pa, char *name, char *dir);
|
||||
//static void alsa_select_device (char *pick_dev, int direction, char *result);
|
||||
#elif USE_SNDIO
|
||||
static int set_sndio_params (int a, struct sio_hdl *handle, struct audio_s *pa, char *devname, char *inout);
|
||||
static int poll_sndio (struct sio_hdl *hdl, int events);
|
||||
#else
|
||||
static int set_oss_params (int a, int fd, struct audio_s *pa);
|
||||
#endif
|
||||
|
@ -201,7 +206,7 @@ static int calcbufsize(int rate, int chans, int bits)
|
|||
* more restrictive in its capabilities.
|
||||
* It might say, the best I can do is mono, 8 bit, 8000/sec.
|
||||
*
|
||||
* The sofware modem must use this ACTUAL information
|
||||
* The software modem must use this ACTUAL information
|
||||
* that the device is supplying, that could be different
|
||||
* than what the user specified.
|
||||
*
|
||||
|
@ -212,7 +217,9 @@ static int calcbufsize(int rate, int chans, int bits)
|
|||
|
||||
int audio_open (struct audio_s *pa)
|
||||
{
|
||||
#if !USE_SNDIO
|
||||
int err;
|
||||
#endif
|
||||
int chan;
|
||||
int a;
|
||||
char audio_in_name[30];
|
||||
|
@ -224,7 +231,11 @@ int audio_open (struct audio_s *pa)
|
|||
memset (adev, 0, sizeof(adev));
|
||||
|
||||
for (a=0; a<MAX_ADEVS; a++) {
|
||||
#ifndef USE_ALSA
|
||||
#if USE_ALSA
|
||||
adev[a].audio_in_handle = adev[a].audio_out_handle = NULL;
|
||||
#elif USE_SNDIO
|
||||
adev[a].sndio_in_handle = adev[a].sndio_out_handle = NULL;
|
||||
#else
|
||||
adev[a].oss_audio_device_fd = -1;
|
||||
#endif
|
||||
adev[a].udp_sock = -1;
|
||||
|
@ -348,6 +359,24 @@ int audio_open (struct audio_s *pa)
|
|||
|
||||
adev[a].inbuf_size_in_bytes = set_alsa_params (a, adev[a].audio_in_handle, pa, audio_in_name, "input");
|
||||
|
||||
#elif USE_SNDIO
|
||||
adev[a].sndio_in_handle = sio_open (audio_in_name, SIO_REC, 0);
|
||||
if (adev[a].sndio_in_handle == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Could not open audio device %s for input\n",
|
||||
audio_in_name);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
adev[a].inbuf_size_in_bytes = set_sndio_params (a, adev[a].sndio_in_handle, pa, audio_in_name, "input");
|
||||
|
||||
if (!sio_start (adev[a].sndio_in_handle)) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Could not start audio device %s for input\n",
|
||||
audio_in_name);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
#else // OSS
|
||||
adev[a].oss_audio_device_fd = open (pa->adev[a].adevice_in, O_RDWR);
|
||||
|
||||
|
@ -439,6 +468,27 @@ int audio_open (struct audio_s *pa)
|
|||
return (-1);
|
||||
}
|
||||
|
||||
#elif USE_SNDIO
|
||||
adev[a].sndio_out_handle = sio_open (audio_out_name, SIO_PLAY, 0);
|
||||
if (adev[a].sndio_out_handle == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Could not open audio device %s for output\n",
|
||||
audio_out_name);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
adev[a].outbuf_size_in_bytes = set_sndio_params (a, adev[a].sndio_out_handle, pa, audio_out_name, "output");
|
||||
|
||||
if (adev[a].inbuf_size_in_bytes <= 0 || adev[a].outbuf_size_in_bytes <= 0) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (!sio_start (adev[a].sndio_out_handle)) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Could not start audio device %s for output\n",
|
||||
audio_out_name);
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -675,6 +725,112 @@ static int set_alsa_params (int a, snd_pcm_t *handle, struct audio_s *pa, char *
|
|||
} /* end alsa_set_params */
|
||||
|
||||
|
||||
#elif USE_SNDIO
|
||||
|
||||
/*
|
||||
* Set parameters for sound card. (sndio)
|
||||
*
|
||||
* See /usr/include/sndio.h for details.
|
||||
*/
|
||||
|
||||
static int set_sndio_params (int a, struct sio_hdl *handle, struct audio_s *pa, char *devname, char *inout)
|
||||
{
|
||||
|
||||
struct sio_par q, r;
|
||||
|
||||
/* Signed 16 bit little endian or unsigned 8 bit. */
|
||||
sio_initpar (&q);
|
||||
q.bits = pa->adev[a].bits_per_sample;
|
||||
q.bps = (q.bits + 7) / 8;
|
||||
q.sig = (q.bits == 8) ? 0 : 1;
|
||||
q.le = 1; /* always little endian */
|
||||
q.msb = 0; /* LSB aligned */
|
||||
q.rchan = q.pchan = pa->adev[a].num_channels;
|
||||
q.rate = pa->adev[a].samples_per_sec;
|
||||
q.xrun = SIO_IGNORE;
|
||||
q.appbufsz = calcbufsize(pa->adev[a].samples_per_sec, pa->adev[a].num_channels, pa->adev[a].bits_per_sample);
|
||||
|
||||
|
||||
#if DEBUG
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("suggest buffer size %d bytes for %s %s.\n",
|
||||
q.appbufsz, devname, inout);
|
||||
#endif
|
||||
|
||||
/* challenge new setting */
|
||||
if (!sio_setpar (handle, &q)) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Could not set hardware parameter for %s %s.\n",
|
||||
devname, inout);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* get response */
|
||||
if (!sio_getpar (handle, &r)) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Could not obtain current hardware setting for %s %s.\n",
|
||||
devname, inout);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("audio buffer size %d bytes for %s %s.\n",
|
||||
r.appbufsz, devname, inout);
|
||||
#endif
|
||||
if (q.rate != r.rate) {
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("Asked for %d samples/sec but got %d for %s %s.",
|
||||
pa->adev[a].samples_per_sec, r.rate, devname, inout);
|
||||
pa->adev[a].samples_per_sec = r.rate;
|
||||
}
|
||||
|
||||
/* not supported */
|
||||
if (q.bits != r.bits || q.bps != r.bps || q.sig != r.sig ||
|
||||
(q.bits > 8 && q.le != r.le) ||
|
||||
(*inout == 'o' && q.pchan != r.pchan) ||
|
||||
(*inout == 'i' && q.rchan != r.rchan)) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Unsupported format for %s %s.\n", devname, inout);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return r.appbufsz;
|
||||
|
||||
} /* end set_sndio_params */
|
||||
|
||||
static int poll_sndio (struct sio_hdl *hdl, int events)
|
||||
{
|
||||
struct pollfd *pfds;
|
||||
int nfds, revents;
|
||||
|
||||
nfds = sio_nfds (hdl);
|
||||
pfds = alloca (nfds * sizeof(struct pollfd));
|
||||
|
||||
do {
|
||||
nfds = sio_pollfd (hdl, pfds, events);
|
||||
if (nfds < 1) {
|
||||
/* no need to wait */
|
||||
return (0);
|
||||
}
|
||||
if (poll (pfds, nfds, -1) < 0) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("poll %d\n", errno);
|
||||
return (-1);
|
||||
}
|
||||
revents = sio_revents (hdl, pfds);
|
||||
} while (!(revents & (events | POLLHUP)));
|
||||
|
||||
/* unrecoverable error occurred */
|
||||
if (revents & POLLHUP) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("waited for %s, POLLHUP received\n", (events & POLLIN) ? "POLLIN" : "POLLOUT");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
|
@ -769,7 +925,7 @@ static int set_oss_params (int a, int fd, struct audio_s *pa)
|
|||
* This was long ago under different conditions.
|
||||
* Should study this again some day.
|
||||
*
|
||||
* Your milage may vary.
|
||||
* Your mileage may vary.
|
||||
*/
|
||||
err = ioctl (fd, SNDCTL_DSP_GETBLKSIZE, &ossbuf_size_in_bytes);
|
||||
if (err == -1) {
|
||||
|
@ -842,7 +998,9 @@ __attribute__((hot))
|
|||
int audio_get (int a)
|
||||
{
|
||||
int n;
|
||||
#if USE_ALSA
|
||||
int retries = 0;
|
||||
#endif
|
||||
|
||||
#if STATISTICS
|
||||
/* Gather numbers for read from audio device. */
|
||||
|
@ -936,6 +1094,8 @@ int audio_get (int a)
|
|||
dw_printf ("This is most likely caused by the CPU being too slow to keep up with the audio stream.\n");
|
||||
dw_printf ("Use the \"top\" command, in another command window, to look at CPU usage.\n");
|
||||
dw_printf ("This might be a temporary condition so we will attempt to recover a few times before giving up.\n");
|
||||
dw_printf ("If using a very slow CPU, try reducing the CPU load by using -P- command\n");
|
||||
dw_printf ("line option for 9600 bps or -D3 for slower AFSK .\n");
|
||||
}
|
||||
|
||||
audio_stats (a,
|
||||
|
@ -970,7 +1130,28 @@ int audio_get (int a)
|
|||
}
|
||||
|
||||
|
||||
#else /* end ALSA, begin OSS */
|
||||
#elif USE_SNDIO
|
||||
|
||||
while (adev[a].inbuf_next >= adev[a].inbuf_len) {
|
||||
|
||||
assert (adev[a].sndio_in_handle != NULL);
|
||||
if (poll_sndio (adev[a].sndio_in_handle, POLLIN) < 0) {
|
||||
adev[a].inbuf_len = 0;
|
||||
adev[a].inbuf_next = 0;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
n = sio_read (adev[a].sndio_in_handle, adev[a].inbuf_ptr, adev[a].inbuf_size_in_bytes);
|
||||
adev[a].inbuf_len = n;
|
||||
adev[a].inbuf_next = 0;
|
||||
|
||||
audio_stats (a,
|
||||
save_audio_config_p->adev[a].num_channels,
|
||||
n / (save_audio_config_p->adev[a].num_channels * save_audio_config_p->adev[a].bits_per_sample / 8),
|
||||
save_audio_config_p->statistics_interval);
|
||||
}
|
||||
|
||||
#else /* begin OSS */
|
||||
|
||||
/* Fixed in 1.2. This was formerly outside of the switch */
|
||||
/* so the OSS version did not process stdin or UDP. */
|
||||
|
@ -1250,6 +1431,37 @@ int audio_flush (int a)
|
|||
adev[a].outbuf_len = 0;
|
||||
return (-1);
|
||||
|
||||
#elif USE_SNDIO
|
||||
|
||||
int k;
|
||||
unsigned char *ptr;
|
||||
int len;
|
||||
|
||||
ptr = adev[a].outbuf_ptr;
|
||||
len = adev[a].outbuf_len;
|
||||
|
||||
while (len > 0) {
|
||||
assert (adev[a].sndio_out_handle != NULL);
|
||||
if (poll_sndio (adev[a].sndio_out_handle, POLLOUT) < 0) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
perror("Can't write to audio device");
|
||||
adev[a].outbuf_len = 0;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
k = sio_write (adev[a].sndio_out_handle, ptr, len);
|
||||
#if DEBUGx
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("audio_flush(): write %d returns %d\n", len, k);
|
||||
fflush (stdout);
|
||||
#endif
|
||||
ptr += k;
|
||||
len -= k;
|
||||
}
|
||||
|
||||
adev[a].outbuf_len = 0;
|
||||
return (0);
|
||||
|
||||
#else /* OSS */
|
||||
|
||||
int k;
|
||||
|
@ -1351,6 +1563,10 @@ void audio_wait (int a)
|
|||
* Either way, the caller will now compensate for it.
|
||||
*/
|
||||
|
||||
#elif USE_SNDIO
|
||||
|
||||
poll_sndio (adev[a].sndio_out_handle, POLLOUT);
|
||||
|
||||
#else
|
||||
|
||||
assert (adev[a].oss_audio_device_fd > 0);
|
||||
|
@ -1397,6 +1613,21 @@ int audio_close (void)
|
|||
snd_pcm_close (adev[a].audio_in_handle);
|
||||
snd_pcm_close (adev[a].audio_out_handle);
|
||||
|
||||
adev[a].audio_in_handle = adev[a].audio_out_handle = NULL;
|
||||
|
||||
#elif USE_SNDIO
|
||||
|
||||
if (adev[a].sndio_in_handle != NULL && adev[a].sndio_out_handle != NULL) {
|
||||
|
||||
audio_wait (a);
|
||||
|
||||
sio_stop (adev[a].sndio_in_handle);
|
||||
sio_stop (adev[a].sndio_out_handle);
|
||||
sio_close (adev[a].sndio_in_handle);
|
||||
sio_close (adev[a].sndio_out_handle);
|
||||
|
||||
adev[a].sndio_in_handle = adev[a].sndio_out_handle = NULL;
|
||||
|
||||
#else
|
||||
|
||||
if (adev[a].oss_audio_device_fd > 0) {
|
||||
|
|
73
src/audio.h
73
src/audio.h
|
@ -108,10 +108,11 @@ struct audio_s {
|
|||
float recv_ber; /* Receive Bit Error Rate (BER). */
|
||||
/* Probability of inverting a bit coming out of the modem. */
|
||||
|
||||
int fx25_xmit_enable; /* Enable transmission of FX.25. */
|
||||
//int fx25_xmit_enable; /* Enable transmission of FX.25. */
|
||||
/* See fx25_init.c for explanation of values. */
|
||||
/* Initially this applies to all channels. */
|
||||
/* This should probably be per channel. One step at a time. */
|
||||
/* v1.7 - replaced by layer2_xmit==LAYER2_FX25 */
|
||||
|
||||
int fx25_auto_enable; /* Turn on FX.25 for current connected mode session */
|
||||
/* under poor conditions. */
|
||||
|
@ -119,32 +120,39 @@ struct audio_s {
|
|||
/* I put it here, rather than with the rest of the link layer */
|
||||
/* parameters because it is really a part of the HDLC layer */
|
||||
/* and is part of the KISS TNC functionality rather than our data link layer. */
|
||||
/* Future: not used yet. */
|
||||
|
||||
|
||||
char timestamp_format[40]; /* -T option */
|
||||
/* Precede received & transmitted frames with timestamp. */
|
||||
/* Command line option uses "strftime" format string. */
|
||||
|
||||
|
||||
/* Properties for each channel, common to receive and transmit. */
|
||||
/* Can be different for each radio channel. */
|
||||
|
||||
/* originally a "channel" was always connected to an internal modem. */
|
||||
/* In version 1.6, this is generalized so that a channel (as seen by client application) */
|
||||
/* can be connected to something else. Initially, this will allow application */
|
||||
/* access to the IGate. Later we might have network TNCs or other internal functions. */
|
||||
|
||||
// Properties for all channels.
|
||||
|
||||
enum medium_e chan_medium[MAX_TOTAL_CHANS];
|
||||
// MEDIUM_NONE for invalid.
|
||||
// MEDIUM_RADIO for internal modem. (only possibility earlier)
|
||||
// MEDIUM_IGATE allows application access to IGate.
|
||||
// MEDIUM_NETTNC for external TNC via TCP.
|
||||
|
||||
int igate_vchannel; /* Virtual channel mapped to APRS-IS. */
|
||||
/* -1 for none. */
|
||||
/* Redundant but it makes things quicker and simpler */
|
||||
/* than always searching thru above. */
|
||||
|
||||
/* Properties for each radio channel, common to receive and transmit. */
|
||||
/* Can be different for each radio channel. */
|
||||
|
||||
struct achan_param_s {
|
||||
|
||||
// Originally there was a boolean, called "valid", to indicate that the
|
||||
// channel is valid. This has been replaced with the new "medium" which
|
||||
// will allow channels to correspond to things other than internal modems.
|
||||
|
||||
enum medium_e medium; // MEDIUM_NONE for invalid.
|
||||
// MEDIUM_RADIO for internal modem. (only possibility earlier)
|
||||
// MEDIUM_IGATE allows application access to IGate.
|
||||
|
||||
|
||||
// What else should be moved out of structure and enlarged when NETTNC is implemented. ???
|
||||
char mycall[AX25_MAX_ADDR_LEN]; /* Call associated with this radio channel. */
|
||||
/* Could all be the same or different. */
|
||||
|
||||
|
@ -157,9 +165,26 @@ struct audio_s {
|
|||
/* Might try MFJ-2400 / CCITT v.26 / Bell 201 someday. */
|
||||
/* No modem. Might want this for DTMF only channel. */
|
||||
|
||||
enum layer2_t { LAYER2_AX25 = 0, LAYER2_FX25, LAYER2_IL2P } layer2_xmit;
|
||||
|
||||
// IL2P - New for version 1.7.
|
||||
// New layer 2 with FEC. Much less overhead than FX.25 but no longer backward compatible.
|
||||
// Only applies to transmit.
|
||||
// Listening for FEC sync word should add negligible overhead so
|
||||
// we leave reception enabled all the time as we do with FX.25.
|
||||
// TODO: FX.25 should probably be put here rather than global for all channels.
|
||||
|
||||
int fx25_strength; // Strength of FX.25 FEC.
|
||||
// 16, 23, 64 for specific number of parity symbols.
|
||||
// 1 for automatic selection based on frame size.
|
||||
|
||||
int il2p_max_fec; // 1 for max FEC length, 0 for automatic based on size.
|
||||
|
||||
int il2p_invert_polarity; // 1 means invert on transmit. Receive handles either automatically.
|
||||
|
||||
enum v26_e { V26_UNSPECIFIED=0, V26_A, V26_B } v26_alternative;
|
||||
|
||||
// Original implementaion used alternative A for 2400 bbps PSK.
|
||||
// Original implementation used alternative A for 2400 bbps PSK.
|
||||
// Years later, we discover that MFJ-2400 used alternative B.
|
||||
// It's likely the others did too. it also works a little better.
|
||||
// Default to MFJ compatible and print warning if user did not
|
||||
|
@ -241,15 +266,17 @@ struct audio_s {
|
|||
|
||||
ptt_method_t ptt_method; /* none, serial port, GPIO, LPT, HAMLIB, CM108. */
|
||||
|
||||
char ptt_device[100]; /* Serial device name for PTT. e.g. COM1 or /dev/ttyS0 */
|
||||
char ptt_device[128]; /* Serial device name for PTT. e.g. COM1 or /dev/ttyS0 */
|
||||
/* Also used for HAMLIB. Could be host:port when model is 1. */
|
||||
/* For years, 20 characters was plenty then we start getting extreme names like this: */
|
||||
/* /dev/serial/by-id/usb-FTDI_Navigator__CAT___2nd_PTT__00000000-if00-port0 */
|
||||
/* /dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0 */
|
||||
/* Issue 104, changed to 100 bytes in version 1.5. */
|
||||
|
||||
/* This same field is also used for CM108 GPIO PTT which will */
|
||||
/* have a name like /dev/hidraw1. */
|
||||
/* This same field is also used for CM108/CM119 GPIO PTT which will */
|
||||
/* have a name like /dev/hidraw1 for Linux or */
|
||||
/* \\?\hid#vid_0d8c&pid_0008&mi_03#8&39d3555&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} */
|
||||
/* for Windows. Largest observed was 95 but add some extra to be safe. */
|
||||
|
||||
ptt_line_t ptt_line; /* Control line when using serial port. PTT_LINE_RTS, PTT_LINE_DTR. */
|
||||
ptt_line_t ptt_line2; /* Optional second one: PTT_LINE_NONE when not used. */
|
||||
|
@ -257,12 +284,12 @@ struct audio_s {
|
|||
int out_gpio_num; /* GPIO number. Originally this was only for PTT. */
|
||||
/* It is now more general. */
|
||||
/* octrl array is indexed by PTT, DCD, or CONnected indicator. */
|
||||
/* For CM108, this should be in range of 1-8. */
|
||||
/* For CM108/CM119, this should be in range of 1-8. */
|
||||
|
||||
#define MAX_GPIO_NAME_LEN 20 // 12 would cover any case I've seen so this should be safe
|
||||
|
||||
char out_gpio_name[MAX_GPIO_NAME_LEN];
|
||||
/* orginally, gpio number NN was assumed to simply */
|
||||
/* originally, gpio number NN was assumed to simply */
|
||||
/* have the name gpioNN but this turned out not to be */
|
||||
/* the case for CubieBoard where it was longer. */
|
||||
/* This is filled in by ptt_init so we don't have to */
|
||||
|
@ -280,6 +307,8 @@ struct audio_s {
|
|||
#ifdef USE_HAMLIB
|
||||
|
||||
int ptt_model; /* HAMLIB model. -1 for AUTO. 2 for rigctld. Others are radio model. */
|
||||
int ptt_rate; /* Serial port speed when using hamlib CAT control for PTT. */
|
||||
/* If zero, hamlib will come up with a default for pariticular rig. */
|
||||
#endif
|
||||
|
||||
} octrl[NUM_OCTYPES];
|
||||
|
@ -298,7 +327,7 @@ struct audio_s {
|
|||
int in_gpio_num; /* GPIO number */
|
||||
|
||||
char in_gpio_name[MAX_GPIO_NAME_LEN];
|
||||
/* orginally, gpio number NN was assumed to simply */
|
||||
/* originally, gpio number NN was assumed to simply */
|
||||
/* have the name gpioNN but this turned out not to be */
|
||||
/* the case for CubieBoard where it was longer. */
|
||||
/* This is filled in by ptt_init so we don't have to */
|
||||
|
@ -312,7 +341,7 @@ struct audio_s {
|
|||
int dwait; /* First wait extra time for receiver squelch. */
|
||||
/* Default 0 units of 10 mS each . */
|
||||
|
||||
int slottime; /* Slot time in 10 mS units for persistance algorithm. */
|
||||
int slottime; /* Slot time in 10 mS units for persistence algorithm. */
|
||||
/* Typical value is 10 meaning 100 milliseconds. */
|
||||
|
||||
int persist; /* Sets probability for transmitting after each */
|
||||
|
@ -350,8 +379,8 @@ struct audio_s {
|
|||
#define DEFAULT_ADEVICE "" /* Mac OSX: Empty string = default audio device. */
|
||||
#elif USE_ALSA
|
||||
#define DEFAULT_ADEVICE "default" /* Use default device for ALSA. */
|
||||
#elif __OpenBSD__
|
||||
#define DEFAULT_ADEVICE "default" /* Use default device for OpenBSD-portaudio. */
|
||||
#elif USE_SNDIO
|
||||
#define DEFAULT_ADEVICE "default" /* Use default device for sndio. */
|
||||
#else
|
||||
#define DEFAULT_ADEVICE "/dev/dsp" /* First audio device for OSS. (FreeBSD) */
|
||||
#endif
|
||||
|
|
|
@ -156,7 +156,7 @@ static int calcbufsize(int rate, int chans, int bits)
|
|||
* the same device name for more then one connected device
|
||||
* (ie two SignaLinks). Appending a Portaudio device index to the
|
||||
* the device name ensure we can find the correct one. And if it's not
|
||||
* available return the first occurence that matches the device name.
|
||||
* available return the first occurrence that matches the device name.
|
||||
*----------------------------------------------------------------*/
|
||||
static int searchPADevice(struct adev_s *dev, char *_devName, int reqDeviceNo, int io_flag)
|
||||
{
|
||||
|
@ -513,7 +513,7 @@ static int paOutput16CB( const void *inputBuffer, void *outputBuffer,
|
|||
* more restrictive in its capabilities.
|
||||
* It might say, the best I can do is mono, 8 bit, 8000/sec.
|
||||
*
|
||||
* The sofware modem must use this ACTUAL information
|
||||
* The software modem must use this ACTUAL information
|
||||
* that the device is supplying, that could be different
|
||||
* than what the user specified.
|
||||
*
|
||||
|
|
|
@ -209,7 +209,7 @@ static struct adev_s {
|
|||
* more restrictive in its capabilities.
|
||||
* It might say, the best I can do is mono, 8 bit, 8000/sec.
|
||||
*
|
||||
* The sofware modem must use this ACTUAL information
|
||||
* The software modem must use this ACTUAL information
|
||||
* that the device is supplying, that could be different
|
||||
* than what the user specified.
|
||||
*
|
||||
|
@ -561,6 +561,8 @@ int audio_open (struct audio_s *pa)
|
|||
*/
|
||||
case AUDIO_IN_TYPE_SOUNDCARD:
|
||||
|
||||
// Use InitializeCriticalSectionAndSpinCount to avoid exceptions in low memory situations?
|
||||
|
||||
InitializeCriticalSection (&(A->in_cs));
|
||||
|
||||
err = waveInOpen (&(A->audio_in_handle), in_dev_no[a], &wf, (DWORD_PTR)in_callback, a, CALLBACK_FUNCTION);
|
||||
|
@ -921,7 +923,7 @@ int audio_get (int a)
|
|||
* c - One byte in range of 0 - 255.
|
||||
*
|
||||
*
|
||||
* Global In: out_current - index of output buffer currenly being filled.
|
||||
* Global In: out_current - index of output buffer currently being filled.
|
||||
*
|
||||
* Returns: Normally non-negative.
|
||||
* -1 for any type of error.
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
* Establish connections and transfer data in the proper
|
||||
* order with retries.
|
||||
*
|
||||
* Using the term "data link" is rather unfortunate because it causes
|
||||
* confusion to someone familiar with the OSI networking model.
|
||||
* This corresponds to the layer 4 transport, not layer 2 data link.
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Typical sequence for establishing a connection
|
||||
|
@ -255,7 +259,7 @@ typedef struct ax25_dlsm_s {
|
|||
// addrs[OWNCALL] is owncall for this end of link.
|
||||
// Note that we are acting on behalf of
|
||||
// a client application so the APRS mycall
|
||||
// might not be relevent.
|
||||
// might not be relevant.
|
||||
|
||||
#define PEERCALL AX25_DESTINATION
|
||||
// addrs[PEERCALL] is call for other end.
|
||||
|
@ -319,8 +323,8 @@ typedef struct ax25_dlsm_s {
|
|||
|
||||
int reject_exception; // A REJ frame has been sent to the remote station. (boolean)
|
||||
|
||||
// This is used only when receving an I frame, in states 3 & 4, SREJ not enabled.
|
||||
// When an I frame has an unepected N(S),
|
||||
// This is used only when receiving an I frame, in states 3 & 4, SREJ not enabled.
|
||||
// When an I frame has an unexpected N(S),
|
||||
// - if not already set, set it and send REJ.
|
||||
// When an I frame with expected N(S) is received, clear it.
|
||||
// This would prevent us from sending additional REJ while
|
||||
|
@ -824,6 +828,11 @@ static ax25_dlsm_t *get_link_handle (char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LE
|
|||
// Create new data link state machine.
|
||||
|
||||
p = calloc (sizeof(ax25_dlsm_t), 1);
|
||||
if (p == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FATAL ERROR: Out of memory.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
p->magic1 = MAGIC1;
|
||||
p->start_time = dtime_now();
|
||||
p->stream_id = next_stream_id++;
|
||||
|
@ -1157,7 +1166,7 @@ void dl_disconnect_request (dlq_item_t *E)
|
|||
*
|
||||
* Erratum: Not sure how to interpret that. See example below for how it was implemented.
|
||||
*
|
||||
* Version 1.6: Bug 252. Segmentation was occuring for a V2.0 link. From the spec:
|
||||
* Version 1.6: Bug 252. Segmentation was occurring for a V2.0 link. From the spec:
|
||||
* "The receipt of an XID response from the other station establishes that both
|
||||
* stations are using AX.25 version 2.2 or higher and enables the use of the
|
||||
* segmenter/reassembler and selective reject."
|
||||
|
@ -1493,6 +1502,11 @@ void dl_register_callsign (dlq_item_t *E)
|
|||
}
|
||||
|
||||
r = calloc(sizeof(reg_callsign_t),1);
|
||||
if (r == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FATAL ERROR: Out of memory.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
strlcpy (r->callsign, E->addrs[0], sizeof(r->callsign));
|
||||
r->chan = E->chan;
|
||||
r->client = E->client;
|
||||
|
@ -1564,7 +1578,7 @@ void dl_unregister_callsign (dlq_item_t *E)
|
|||
*
|
||||
* Description: This is the sum of:
|
||||
* - Incoming connected data, from application still in the queue.
|
||||
* - I frames which have been transmitted but not yet acknowleged.
|
||||
* - I frames which have been transmitted but not yet acknowledged.
|
||||
*
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
|
@ -1633,7 +1647,7 @@ void dl_outstanding_frames_request (dlq_item_t *E)
|
|||
* Description: By client application we mean something that attached with the
|
||||
* AGW network protocol.
|
||||
*
|
||||
* Clean out anything related to the specfied client application.
|
||||
* Clean out anything related to the specified client application.
|
||||
* This would include state machines and registered callsigns.
|
||||
*
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
@ -2201,7 +2215,7 @@ void lm_data_indication (dlq_item_t *E)
|
|||
break;
|
||||
|
||||
// Erratum: The AX.25 spec is not clear about whether SREJ should be command, response, or both.
|
||||
// The underlying X.25 spec clearly says it is reponse only. Let's go with that.
|
||||
// The underlying X.25 spec clearly says it is response only. Let's go with that.
|
||||
|
||||
case frame_type_S_SREJ:
|
||||
case frame_type_U_DM:
|
||||
|
@ -2224,7 +2238,7 @@ void lm_data_indication (dlq_item_t *E)
|
|||
case frame_type_U_UI:
|
||||
// Don't test at this point in case an APRS frame gets thru.
|
||||
// APRS doesn't specify what to put in the Source and Dest C bits.
|
||||
// In practice we see all 4 possble combinations.
|
||||
// In practice we see all 4 possible combinations.
|
||||
// I have an opinion about what would be "correct" (discussed elsewhere)
|
||||
// but in practice no one seems to care.
|
||||
break;
|
||||
|
@ -2701,7 +2715,7 @@ static void i_frame_continued (ax25_dlsm_t *S, int p, int ns, int pid, char *inf
|
|||
|
||||
if (S->rxdata_by_ns[ns] != NULL) {
|
||||
// There is a possibility that we might have another received frame stashed
|
||||
// away from 8 or 128 (modulo) frames back. Remove it so it doesn't accidently
|
||||
// away from 8 or 128 (modulo) frames back. Remove it so it doesn't accidentally
|
||||
// show up at some future inopportune time.
|
||||
|
||||
cdata_delete (S->rxdata_by_ns[ns]);
|
||||
|
@ -2786,7 +2800,7 @@ static void i_frame_continued (ax25_dlsm_t *S, int p, int ns, int pid, char *inf
|
|||
// we discard 3,4,5,6, and tell the other end to resend everything starting with 2.
|
||||
|
||||
// At one time, I had some doubts about when to use command or response for REJ.
|
||||
// I now believe that reponse, as implied by setting F in the flow chart, is correct.
|
||||
// I now believe that response, as implied by setting F in the flow chart, is correct.
|
||||
|
||||
int f = p;
|
||||
int nr = S->vr; // Next expected sequence number.
|
||||
|
@ -2796,7 +2810,7 @@ static void i_frame_continued (ax25_dlsm_t *S, int p, int ns, int pid, char *inf
|
|||
S->reject_exception = 1;
|
||||
|
||||
if (s_debug_retry) {
|
||||
text_color_set(DW_COLOR_ERROR); // make it more noticable.
|
||||
text_color_set(DW_COLOR_ERROR); // make it more noticeable.
|
||||
dw_printf ("sending REJ, at %s %d, SREJ not enabled case, V(R)=%d", __func__, __LINE__, S->vr);
|
||||
}
|
||||
|
||||
|
@ -2860,7 +2874,7 @@ static void i_frame_continued (ax25_dlsm_t *S, int p, int ns, int pid, char *inf
|
|||
// In version 1.4:
|
||||
// We end up sending more SREJ than necessary and and get back redundant information. Example:
|
||||
// When we see 113 missing, we ask for a resend.
|
||||
// When we see 115 & 116 missing, a cummulative SREJ asks for everything.
|
||||
// When we see 115 & 116 missing, a cumulative SREJ asks for everything.
|
||||
// The other end dutifully sends 113 twice.
|
||||
//
|
||||
// [0.4] DW1>DW0:(SREJ res, n(r)=113, f=0)
|
||||
|
@ -2890,7 +2904,7 @@ static void i_frame_continued (ax25_dlsm_t *S, int p, int ns, int pid, char *inf
|
|||
// int allow_f1 = 0; // F=1 from X.25 2.4.6.4 b) 3)
|
||||
int allow_f1 = 1; // F=1 from X.25 2.4.6.4 b) 3)
|
||||
|
||||
// send only for this gap, not cummulative from V(R).
|
||||
// send only for this gap, not cumulative from V(R).
|
||||
|
||||
int last = AX25MODULO(ns - 1, S->modulo, __FILE__, __func__, __LINE__);
|
||||
int first = last;
|
||||
|
@ -2993,7 +3007,7 @@ dw_printf ("%s:%d, %d srej exceptions, V(R)=%d, N(S)=%d\n", __func__, __LINE__,
|
|||
if (first == AX25MODULO(S->vr - 1, S->modulo, __FILE__, __func__, __LINE__)) {
|
||||
// Oops! Went too far. This I frame was already processed.
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("INTERNAL ERROR calulating what to put in SREJ, %s line %d\n", __func__, __LINE__);
|
||||
dw_printf ("INTERNAL ERROR calculating what to put in SREJ, %s line %d\n", __func__, __LINE__);
|
||||
dw_printf ("V(R)=%d, N(S)=%d, SREJ exception=%d, first=%d, ask_resend_count=%d\n", S->vr, ns, selective_reject_exception(S), first, ask_resend_count);
|
||||
int k;
|
||||
for (k=0; k<128; k++) {
|
||||
|
@ -3146,7 +3160,7 @@ static void send_srej_frames (ax25_dlsm_t *S, int *resend, int count, int allow_
|
|||
if (s_debug_retry) {
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("%s line %d\n", __func__, __LINE__);
|
||||
//dw_printf ("state=%d, count=%d, k=%d, V(R)=%d, SREJ exeception=%d\n", S->state, count, S->k_maxframe, S->vr, selective_reject_exception(S));
|
||||
//dw_printf ("state=%d, count=%d, k=%d, V(R)=%d, SREJ exception=%d\n", S->state, count, S->k_maxframe, S->vr, selective_reject_exception(S));
|
||||
dw_printf ("state=%d, count=%d, k=%d, V(R)=%d\n", S->state, count, S->k_maxframe, S->vr);
|
||||
|
||||
dw_printf ("resend[]=");
|
||||
|
@ -3447,7 +3461,7 @@ static void rr_rnr_frame (ax25_dlsm_t *S, int ready, cmdres_t cr, int pf, int nr
|
|||
// we received RR frames with N(R) values indicating that the other side received everything
|
||||
// that we sent. Eventually rc could reach the limit and we would get an error.
|
||||
// If we are in state 4, and other guy ack'ed last I frame we sent, transition to state 3.
|
||||
// The same thing was done for receving I frames after check_i_frame_ackd.
|
||||
// The same thing was done for receiving I frames after check_i_frame_ackd.
|
||||
|
||||
// Thought: Could we simply call check_i_frame_ackd, for consistency, rather than only setting V(A)?
|
||||
|
||||
|
@ -3759,7 +3773,7 @@ static void rej_frame (ax25_dlsm_t *S, cmdres_t cr, int pf, int nr)
|
|||
*
|
||||
* The SREJ command/response initiates more-efficient error recovery by requesting the retransmission of a
|
||||
* single I frame following the detection of a sequence error. This is an advancement over the earlier versions in
|
||||
* which the requested I frame was retransmitted togther with all additional I frames subsequently transmitted and
|
||||
* which the requested I frame was retransmitted together with all additional I frames subsequently transmitted and
|
||||
* successfully received.
|
||||
*
|
||||
* When a TNC sends one or more SREJ commands, each with the P bit set to "0" or "1", or one or more SREJ
|
||||
|
@ -4409,7 +4423,7 @@ static void disc_frame (ax25_dlsm_t *S, int p)
|
|||
* earliest opportunity. If the TNC is not capable of accepting a SABME command, it responds with a DM frame.
|
||||
*
|
||||
* A TNC that uses a version of AX.25 prior to v2.2 responds with a FRMR.
|
||||
* ( I think the KPC-3+ has a bug - it replys with DM - WB2OSZ )
|
||||
* ( I think the KPC-3+ has a bug - it replies with DM - WB2OSZ )
|
||||
*
|
||||
* 4.3.3.5. Disconnected Mode (DM) Response
|
||||
*
|
||||
|
@ -4636,7 +4650,7 @@ static void ua_frame (ax25_dlsm_t *S, int f)
|
|||
if (f == 1) {
|
||||
if (S->layer_3_initiated) {
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
// TODO: add via if apppropriate.
|
||||
// TODO: add via if appropriate.
|
||||
dw_printf ("Stream %d: Connected to %s. (%s)\n", S->stream_id, S->addrs[PEERCALL], S->state == state_5_awaiting_v22_connection ? "v2.2" : "v2.0");
|
||||
// There is a subtle difference here between connect confirm and indication.
|
||||
// connect *confirm* means "has been made"
|
||||
|
@ -5615,7 +5629,7 @@ static void clear_exception_conditions (ax25_dlsm_t *S)
|
|||
*
|
||||
* Other guy gets RR/RNR command P=1.
|
||||
* Same action for either state 3 or 4.
|
||||
* Whether he has outstanding un-ack'ed sent I frames is irrelevent.
|
||||
* Whether he has outstanding un-ack'ed sent I frames is irrelevant.
|
||||
* He calls "enquiry response" which sends RR/RNR response F=1.
|
||||
* (Read about detour 1 below and in enquiry_response.)
|
||||
*
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
*
|
||||
*
|
||||
* APRS uses only UI frames.
|
||||
* Each starts with 2-10 addressses (14-70 octets):
|
||||
* Each starts with 2-10 addresses (14-70 octets):
|
||||
*
|
||||
* * Destination Address (note: opposite order in printed format)
|
||||
*
|
||||
|
@ -350,8 +350,9 @@ void ax25_delete (packet_t this_p)
|
|||
* strict - True to enforce rules for packets sent over the air.
|
||||
* False to be more lenient for packets from IGate server.
|
||||
*
|
||||
* Messages from an IGate server can have longer
|
||||
* Packets from an IGate server can have longer
|
||||
* addresses after qAC. Up to 9 observed so far.
|
||||
* The SSID can be 2 alphanumeric characters, not just 1 to 15.
|
||||
*
|
||||
* We can just truncate the name because we will only
|
||||
* end up discarding it. TODO: check on this.
|
||||
|
@ -372,7 +373,7 @@ packet_t ax25_from_text (char *monitor, int strict)
|
|||
/*
|
||||
* Tearing it apart is destructive so make our own copy first.
|
||||
*/
|
||||
char stuff[512];
|
||||
char stuff[AX25_MAX_PACKET_LEN+1];
|
||||
char *pinfo;
|
||||
|
||||
int ssid_temp, heard_temp;
|
||||
|
@ -511,6 +512,13 @@ packet_t ax25_from_text (char *monitor, int strict)
|
|||
|
||||
// printf ("DEBUG: get digi loop, num addr = %d, address = '%s'\n", k, pa);// FIXME
|
||||
|
||||
// Hack for q construct, from APRS-IS, so it does not cause panic later.
|
||||
|
||||
if ( ! strict && pa[0] == 'q' && pa[1] == 'A') {
|
||||
pa[0] = 'Q';
|
||||
pa[2] = toupper(pa[2]);
|
||||
}
|
||||
|
||||
if ( ! ax25_parse_addr (k, pa, strict, atemp, &ssid_temp, &heard_temp)) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Failed to create packet from text. Bad digipeater address\n");
|
||||
|
@ -733,6 +741,7 @@ packet_t ax25_dup (packet_t copy_from)
|
|||
* alphanumeric characters for the SSID.
|
||||
* We also get messages like this from a server.
|
||||
* KB1POR>APU25N,TCPIP*,qAC,T2NUENGLD:...
|
||||
* K1BOS-B>APOSB,TCPIP,WR2X-2*:...
|
||||
*
|
||||
* 2 (extra true) will complain if * is found at end.
|
||||
*
|
||||
|
@ -940,7 +949,7 @@ int ax25_check_addresses (packet_t pp)
|
|||
*
|
||||
* Name: ax25_unwrap_third_party
|
||||
*
|
||||
* Purpose: Unwrap a third party messge from the header.
|
||||
* Purpose: Unwrap a third party message from the header.
|
||||
*
|
||||
* Inputs: copy_from - Existing packet object.
|
||||
*
|
||||
|
@ -1717,6 +1726,19 @@ int ax25_get_info (packet_t this_p, unsigned char **paddr)
|
|||
} /* end ax25_get_info */
|
||||
|
||||
|
||||
void ax25_set_info (packet_t this_p, unsigned char *new_info_ptr, int new_info_len)
|
||||
{
|
||||
unsigned char *old_info_ptr;
|
||||
int old_info_len = ax25_get_info (this_p, &old_info_ptr);
|
||||
this_p->frame_len -= old_info_len;
|
||||
|
||||
if (new_info_len < 0) new_info_len = 0;
|
||||
if (new_info_len > AX25_MAX_INFO_LEN) new_info_len = AX25_MAX_INFO_LEN;
|
||||
memcpy (old_info_ptr, new_info_ptr, new_info_len);
|
||||
this_p->frame_len += new_info_len;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
*
|
||||
* Name: ax25_cut_at_crlf
|
||||
|
@ -1892,6 +1914,25 @@ void ax25_set_modulo (packet_t this_p, int modulo)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
*
|
||||
* Name: ax25_get_modulo
|
||||
*
|
||||
* Purpose: Get modulo value for I and S frame sequence numbers.
|
||||
*
|
||||
* Returns: 8 or 128 if known.
|
||||
* 0 if unknown.
|
||||
*
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
int ax25_get_modulo (packet_t this_p)
|
||||
{
|
||||
assert (this_p->magic1 == MAGIC);
|
||||
assert (this_p->magic2 == MAGIC);
|
||||
|
||||
return (this_p->modulo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1944,6 +1985,7 @@ void ax25_format_addrs (packet_t this_p, char *result)
|
|||
}
|
||||
|
||||
ax25_get_addr_with_ssid (this_p, AX25_SOURCE, stemp);
|
||||
// FIXME: For ALL strcat: Pass in sizeof result and use strlcat.
|
||||
strcat (result, stemp);
|
||||
strcat (result, ">");
|
||||
|
||||
|
@ -2598,6 +2640,15 @@ int ax25_get_frame_len (packet_t this_p)
|
|||
} /* end ax25_get_frame_len */
|
||||
|
||||
|
||||
unsigned char *ax25_get_frame_data_ptr (packet_t this_p)
|
||||
{
|
||||
assert (this_p->magic1 == MAGIC);
|
||||
assert (this_p->magic2 == MAGIC);
|
||||
|
||||
return (this_p->frame_data);
|
||||
|
||||
} /* end ax25_get_frame_data_ptr */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
*
|
||||
|
@ -2710,6 +2761,7 @@ unsigned short ax25_m_m_crc (packet_t pp)
|
|||
unsigned char fbuf[AX25_MAX_PACKET_LEN];
|
||||
int flen;
|
||||
|
||||
// TODO: I think this can be more efficient by getting the packet content pointer instead of copying.
|
||||
flen = ax25_pack (pp, fbuf);
|
||||
|
||||
crc = 0xffff;
|
||||
|
@ -2762,7 +2814,8 @@ unsigned short ax25_m_m_crc (packet_t pp)
|
|||
*
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
#define MAXSAFE 500
|
||||
//#define MAXSAFE 500
|
||||
#define MAXSAFE AX25_MAX_INFO_LEN
|
||||
|
||||
void ax25_safe_print (char *pstr, int len, int ascii_only)
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
|
||||
#define AX25_MAX_REPEATERS 8
|
||||
#define AX25_MIN_ADDRS 2 /* Destinatin & Source. */
|
||||
#define AX25_MIN_ADDRS 2 /* Destination & Source. */
|
||||
#define AX25_MAX_ADDRS 10 /* Destination, Source, 8 digipeaters. */
|
||||
|
||||
#define AX25_DESTINATION 0 /* Address positions in frame. */
|
||||
|
@ -98,7 +98,7 @@ struct packet_s {
|
|||
*
|
||||
* Bits: H R R SSID 0
|
||||
*
|
||||
* H for digipeaters set to 0 intially.
|
||||
* H for digipeaters set to 0 initially.
|
||||
* Changed to 1 when position has been used.
|
||||
*
|
||||
* for source & destination it is called
|
||||
|
@ -397,6 +397,7 @@ extern int ax25_get_first_not_repeated(packet_t pp);
|
|||
extern int ax25_get_rr (packet_t this_p, int n);
|
||||
|
||||
extern int ax25_get_info (packet_t pp, unsigned char **paddr);
|
||||
extern void ax25_set_info (packet_t pp, unsigned char *info_ptr, int info_len);
|
||||
extern int ax25_cut_at_crlf (packet_t this_p);
|
||||
|
||||
extern void ax25_set_nextp (packet_t this_p, packet_t next_p);
|
||||
|
@ -409,6 +410,7 @@ extern void ax25_set_release_time (packet_t this_p, double release_time);
|
|||
extern double ax25_get_release_time (packet_t this_p);
|
||||
|
||||
extern void ax25_set_modulo (packet_t this_p, int modulo);
|
||||
extern int ax25_get_modulo (packet_t this_p);
|
||||
|
||||
extern void ax25_format_addrs (packet_t pp, char *);
|
||||
extern void ax25_format_via_path (packet_t this_p, char *result, size_t result_size);
|
||||
|
@ -428,6 +430,7 @@ extern int ax25_get_c2 (packet_t this_p);
|
|||
extern int ax25_get_pid (packet_t this_p);
|
||||
|
||||
extern int ax25_get_frame_len (packet_t this_p);
|
||||
extern unsigned char *ax25_get_frame_data_ptr (packet_t this_p);
|
||||
|
||||
extern unsigned short ax25_dedupe_crc (packet_t pp);
|
||||
|
||||
|
|
|
@ -102,7 +102,9 @@
|
|||
*
|
||||
* RR note: It seems that some implementations put a hint
|
||||
* in the "RR" reserved bits.
|
||||
* http://www.tapr.org/pipermail/ax25-layer2/2005-October/000297.html
|
||||
* http://www.tapr.org/pipermail/ax25-layer2/2005-October/000297.html (now broken)
|
||||
* https://elixir.bootlin.com/linux/latest/source/net/ax25/ax25_addr.c#L237
|
||||
*
|
||||
* The RR bits can also be used for "DAMA" which is
|
||||
* some sort of channel access coordination scheme.
|
||||
* http://internet.freepage.de/cgi-bin/feets/freepage_ext/41030x030A/rewrite/hennig/afu/afudoc/afudama.html
|
||||
|
@ -406,7 +408,7 @@ packet_t ax25_s_frame (char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LEN], int num_ad
|
|||
}
|
||||
|
||||
// Erratum: The AX.25 spec is not clear about whether SREJ should be command, response, or both.
|
||||
// The underlying X.25 spec clearly says it is reponse only. Let's go with that.
|
||||
// The underlying X.25 spec clearly says it is response only. Let's go with that.
|
||||
|
||||
if (ftype == frame_type_S_SREJ && cr != cr_res) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
|
|
24
src/beacon.c
24
src/beacon.c
|
@ -163,8 +163,8 @@ void beacon_init (struct audio_s *pmodem, struct misc_config_s *pconfig, struct
|
|||
|
||||
if (chan < 0) chan = 0; /* For IGate, use channel 0 call. */
|
||||
|
||||
if (g_modem_config_p->achan[chan].medium == MEDIUM_RADIO ||
|
||||
g_modem_config_p->achan[chan].medium == MEDIUM_NETTNC) {
|
||||
if (g_modem_config_p->chan_medium[chan] == MEDIUM_RADIO ||
|
||||
g_modem_config_p->chan_medium[chan] == MEDIUM_NETTNC) {
|
||||
|
||||
if (strlen(g_modem_config_p->achan[chan].mycall) > 0 &&
|
||||
strcasecmp(g_modem_config_p->achan[chan].mycall, "N0CALL") != 0 &&
|
||||
|
@ -614,6 +614,21 @@ static void * beacon_thread (void *arg)
|
|||
/* i.e. Don't take relative to now in case there was some delay. */
|
||||
|
||||
bp->next += bp->every;
|
||||
|
||||
// https://github.com/wb2osz/direwolf/pull/301
|
||||
// https://github.com/wb2osz/direwolf/pull/301
|
||||
// This happens with a portable system with no Internet connection.
|
||||
// On reboot, the time is in the past.
|
||||
// After time gets set from GPS, all beacons from that interval are sent.
|
||||
// FIXME: This will surely break time slotted scheduling.
|
||||
|
||||
/* craigerl: if next beacon is scheduled in the past, then set next beacon relative to now (happens when NTP pushes clock AHEAD) */
|
||||
/* fixme: if NTP sets clock BACK an hour, this thread will sleep for that hour */
|
||||
if ( bp->next < now ) {
|
||||
bp->next = now + bp->every;
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf("\nSystem clock appears to have jumped forward. Beacon schedule updated.\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
} /* if time to send it */
|
||||
|
@ -804,7 +819,12 @@ static void beacon_send (int j, dwgps_info_t *gpsinfo)
|
|||
* src > dest [ , via ]
|
||||
*/
|
||||
|
||||
if (bp->source != NULL) {
|
||||
strlcpy (beacon_text, bp->source, sizeof(beacon_text));
|
||||
}
|
||||
else {
|
||||
strlcpy (beacon_text, mycall, sizeof(beacon_text));
|
||||
}
|
||||
strlcat (beacon_text, ">", sizeof(beacon_text));
|
||||
|
||||
if (bp->dest != NULL) {
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
* are significantly different and I thought it would be
|
||||
* too confusing to munge them together.
|
||||
*
|
||||
* References: The Ax.25 protcol barely mentions digipeaters and
|
||||
* References: The Ax.25 protocol barely mentions digipeaters and
|
||||
* and doesn't describe how they should work.
|
||||
*
|
||||
*------------------------------------------------------------------*/
|
||||
|
@ -49,7 +49,7 @@
|
|||
#include <stdio.h>
|
||||
#include <ctype.h> /* for isdigit, isupper */
|
||||
#include "regex.h"
|
||||
#include <sys/unistd.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "ax25_pad.h"
|
||||
#include "cdigipeater.h"
|
||||
|
@ -132,7 +132,7 @@ void cdigipeater (int from_chan, packet_t pp)
|
|||
// Connected mode is allowed only for channels with internal modem.
|
||||
// It probably wouldn't matter for digipeating but let's keep that rule simple and consistent.
|
||||
|
||||
if ( from_chan < 0 || from_chan >= MAX_CHANS || save_audio_config_p->achan[from_chan].medium != MEDIUM_RADIO) {
|
||||
if ( from_chan < 0 || from_chan >= MAX_CHANS || save_audio_config_p->chan_medium[from_chan] != MEDIUM_RADIO) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("cdigipeater: Did not expect to receive on invalid channel %d.\n", from_chan);
|
||||
return;
|
||||
|
@ -255,7 +255,7 @@ static packet_t cdigipeat_match (int from_chan, packet_t pp, char *mycall_rec, c
|
|||
* Originally this was the only one.
|
||||
* Should we change it to AFILTER to make it clearer?
|
||||
* CFILTER - Similar for connected moded digipeater.
|
||||
* IGFILTER - APRS-IS (IGate) server side - completely diffeent.
|
||||
* IGFILTER - APRS-IS (IGate) server side - completely different.
|
||||
* Confusing with similar name but much different idea.
|
||||
* Maybe this should be renamed to SUBSCRIBE or something like that.
|
||||
*
|
||||
|
|
327
src/cm108.c
327
src/cm108.c
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
||||
//
|
||||
// Copyright (C) 2017,2019 John Langner, WB2OSZ
|
||||
// Copyright (C) 2017,2019,2021 John Langner, WB2OSZ
|
||||
//
|
||||
// Parts of this were adapted from "hamlib" which contains the notice:
|
||||
//
|
||||
|
@ -30,9 +30,10 @@
|
|||
*
|
||||
* Description:
|
||||
*
|
||||
* There is an incresing demand for using the GPIO pins of USB audio devices for PTT.
|
||||
* There is an increasing demand for using the GPIO pins of USB audio devices for PTT.
|
||||
* We have a few commercial products:
|
||||
*
|
||||
* DINAH https://hamprojects.info/dinah/
|
||||
* DMK URI http://www.dmkeng.com/URI_Order_Page.htm
|
||||
* RB-USB RIM http://www.repeater-builder.com/products/usb-rim-lite.html
|
||||
* RA-35 http://www.masterscommunications.com/products/radio-adapter/ra35.html
|
||||
|
@ -44,14 +45,15 @@
|
|||
* http://www.repeater-builder.com/projects/fob/USB-Fob-Construction.pdf
|
||||
* https://irongarment.wordpress.com/2011/03/29/cm108-compatible-chips-with-gpio/
|
||||
*
|
||||
* Usually GPIO 3 is used because it is easier to tack solder a wire to a pin on the end.
|
||||
* Homebrew plans all use GPIO 3 because it is easier to tack solder a wire to a pin on the end.
|
||||
* All of the products, that I have seen, also use the same pin so this is the default.
|
||||
*
|
||||
* Soundmodem and hamlib paved the way but didn't get too far.
|
||||
* Dire Wolf 1.3 added HAMLIB support (Linux only) which theoretically allows this in a
|
||||
* painful roundabout way. This is documented in the User Guide, section called,
|
||||
* "Hamlib PTT Example 2: Use GPIO of USB audio adapter. (e.g. DMK URI)"
|
||||
*
|
||||
* It's rather involved and the explantion doesn't cover the case of multiple
|
||||
* It's rather involved and the explanation doesn't cover the case of multiple
|
||||
* USB-Audio adapters. It is not as straightforward as you might expect. Here we have
|
||||
* an example of 3 C-Media USB adapters, a SignaLink USB, a keyboard, and a mouse.
|
||||
*
|
||||
|
@ -87,23 +89,28 @@
|
|||
* Dire Wolf version 1.5 makes this much more flexible and easier to use by supporting multiple
|
||||
* sound devices and automatically determining the corresponding HID for the PTT signal.
|
||||
*
|
||||
* In version 1.7, we add a half-backed solution for Windows. It's fine for situations
|
||||
* with a single USB Audio Adapter, but does not automatically handle the multiple device case.
|
||||
* Manual configuration needs to be used in this case.
|
||||
*
|
||||
*---------------------------------------------------------------*/
|
||||
|
||||
#include "direwolf.h"
|
||||
|
||||
#ifndef USE_CM108
|
||||
|
||||
#ifdef CM108_MAIN
|
||||
|
||||
#include "direwolf.h"
|
||||
|
||||
#include "textcolor.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
text_color_init (0); // Turn off text color.
|
||||
#if defined(__OpenBSD__) || defined(__FreeBSD__)
|
||||
dw_printf ("CM108 PTT support is not available for BSD.\n");
|
||||
dw_printf ("CM108 PTT support is not available for this operating system.\n");
|
||||
#else
|
||||
dw_printf ("CM108 PTT support was disabled in Makefile.linux.\n");
|
||||
dw_printf ("It was excluded because /usr/include/libudev.h was missing.\n");
|
||||
dw_printf ("CM108 PTT support was excluded because /usr/include/libudev.h was missing.\n");
|
||||
dw_printf ("Install it with \"sudo apt-get install libudev-dev\" or\n");
|
||||
dw_printf ("\"sudo yum install libudev-devel\" then rebuild.\n");
|
||||
#endif
|
||||
|
@ -112,11 +119,8 @@ int main (void)
|
|||
|
||||
#endif
|
||||
|
||||
#else // USE_CM108 is defined.
|
||||
#else // USE_CM108 is defined
|
||||
|
||||
#include "direwolf.h"
|
||||
|
||||
#include <libudev.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <locale.h>
|
||||
|
@ -124,12 +128,18 @@ int main (void)
|
|||
#include <string.h>
|
||||
#include <regex.h>
|
||||
|
||||
#if __WIN32__
|
||||
#include <wchar.h>
|
||||
#include "hidapi.h"
|
||||
#else
|
||||
#include <libudev.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h> // ioctl, _IOR
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <linux/hidraw.h> // for HIDIOCGRAWINFO
|
||||
#endif
|
||||
|
||||
#include "textcolor.h"
|
||||
#include "cm108.h"
|
||||
|
@ -216,6 +226,8 @@ static int cm108_write (char *name, int iomask, int iodata);
|
|||
|
||||
// Used to process regular expression matching results.
|
||||
|
||||
#ifndef __WIN32__
|
||||
|
||||
static void substr_se (char *dest, const char *src, int start, int endp1)
|
||||
{
|
||||
int len = endp1 - start;
|
||||
|
@ -229,6 +241,7 @@ static void substr_se (char *dest, const char *src, int start, int endp1)
|
|||
|
||||
} /* end substr_se */
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Result of taking inventory of USB soundcards and USB HIDs.
|
||||
|
@ -237,15 +250,17 @@ static void substr_se (char *dest, const char *src, int start, int endp1)
|
|||
struct thing_s {
|
||||
int vid; // vendor id, displayed as four hexadecimal digits.
|
||||
int pid; // product id, displayed as four hexadecimal digits.
|
||||
char card_number[8]; // Number. e.g. 2 for plughw:2,0
|
||||
char card_name[32]; // Name, assigned by system (e.g. Device_1) or by udev rule.
|
||||
char card_number[8]; // "Card" Number. e.g. 2 for plughw:2,0
|
||||
char card_name[32]; // Audio Card Name, assigned by system (e.g. Device_1) or by udev rule.
|
||||
char product[32]; // product name (e.g. manufacturer, model)
|
||||
char devnode_sound[22]; // e.g. /dev/snd/pcmC0D0p
|
||||
char plughw[72]; // Above in more familiar format e.g. plughw:0,0
|
||||
// Oversized to silence a compiler warning.
|
||||
char plughw2[72]; // With name rather than number.
|
||||
char devpath[128]; // Kernel dev path. Does not include /sys mount point.
|
||||
char devnode_hidraw[17]; // e.g. /dev/hidraw3
|
||||
char devnode_hidraw[128]; // e.g. /dev/hidraw3 - for Linux - was length 17
|
||||
// The Windows path for a HID looks like this, lengths up to 95 seen.
|
||||
// \\?\hid#vid_0d8c&pid_000c&mi_03#8&164d11c9&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
|
||||
char devnode_usb[25]; // e.g. /dev/bus/usb/001/012
|
||||
// This is what we use to match up audio and HID.
|
||||
};
|
||||
|
@ -259,6 +274,13 @@ int cm108_inventory (struct thing_s *things, int max_things);
|
|||
*
|
||||
* Purpose: Useful utility to list USB audio and HID devices.
|
||||
*
|
||||
* Optional command line arguments:
|
||||
*
|
||||
* HID path
|
||||
* GPIO number (default 3)
|
||||
*
|
||||
* When specified the pin will be set high and low until interrupted.
|
||||
*
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
//#define EXTRA 1
|
||||
|
@ -267,18 +289,111 @@ int cm108_inventory (struct thing_s *things, int max_things);
|
|||
|
||||
#ifdef CM108_MAIN
|
||||
|
||||
int main (void)
|
||||
static void usage(void)
|
||||
{
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("\n");
|
||||
dw_printf ("Usage: cm108 [ device-path [ gpio-num ] ]\n");
|
||||
dw_printf ("\n");
|
||||
dw_printf ("With no command line arguments, this will produce a list of\n");
|
||||
#if __WIN32__
|
||||
dw_printf ("Human Interface Devices (HID) and indicate which ones can be\n");
|
||||
dw_printf ("used for GPIO PTT.\n");
|
||||
#else
|
||||
dw_printf ("Audio devices and Human Interface Devices (HID) and indicate\n");
|
||||
dw_printf ("which ones can be used for GPIO PTT.\n");
|
||||
#endif
|
||||
dw_printf ("\n");
|
||||
dw_printf ("Specify the HID device path to test the PTT function.\n");
|
||||
dw_printf ("Its state should change once per second.\n");
|
||||
#if __WIN32__
|
||||
dw_printf ("You might need to quote the path depending on the command processor.\n");
|
||||
#endif
|
||||
dw_printf ("GPIO 3 is the default. A different number can be optionally specified.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
struct thing_s things[MAXX_THINGS];
|
||||
int num_things;
|
||||
int i;
|
||||
|
||||
text_color_init (0); // Turn off text color.
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
|
||||
if (argc >=2) {
|
||||
char path[128];
|
||||
strlcpy(path, argv[1], sizeof(path));
|
||||
int gpio = 3;
|
||||
if (argc >= 3) {
|
||||
gpio = atoi(argv[2]);
|
||||
}
|
||||
if (gpio < 1 || gpio > 8) {
|
||||
dw_printf ("GPIO number must be in range of 1 - 8.\n");
|
||||
usage();
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
int state = 0;
|
||||
while (1) {
|
||||
dw_printf ("%d", state);
|
||||
fflush (stdout);
|
||||
int err = cm108_set_gpio_pin (path, gpio, state);
|
||||
if (err != 0) {
|
||||
dw_printf ("\nWRITE ERROR for USB Audio Adapter GPIO!\n");
|
||||
usage();
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
SLEEP_SEC(1);
|
||||
state = ! state;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Take inventory of USB Audio adapters and other HID devices.
|
||||
|
||||
num_things = cm108_inventory (things, MAXX_THINGS);
|
||||
|
||||
#if __WIN32__
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Windows - Remove the sound related columns for now.
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
dw_printf (" VID PID %-*s %-*s"
|
||||
"\n", (int)sizeof(things[0].product), "Product",
|
||||
17, "HID [ptt]"
|
||||
);
|
||||
|
||||
dw_printf (" --- --- %-*s %-*s"
|
||||
|
||||
"\n", (int)sizeof(things[0].product), "-------",
|
||||
17, "---------"
|
||||
);
|
||||
for (i = 0; i < num_things; i++) {
|
||||
|
||||
dw_printf ("%2s %04x %04x %-*s %s"
|
||||
|
||||
"\n",
|
||||
GOOD_DEVICE(things[i].vid,things[i].pid) ? "**" : " ",
|
||||
things[i].vid, things[i].pid,
|
||||
(int)sizeof(things[i].product), things[i].product,
|
||||
things[i].devnode_hidraw
|
||||
);
|
||||
}
|
||||
dw_printf ("\n");
|
||||
dw_printf ("** = Can use Audio Adapter GPIO for PTT.\n");
|
||||
dw_printf ("\n");
|
||||
|
||||
// T.B.D. - additional text ???
|
||||
|
||||
#else
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Linux
|
||||
/////////////////////////////////////////////
|
||||
|
||||
|
||||
dw_printf (" VID PID %-*s %-*s %-*s %-*s %-*s"
|
||||
#if EXTRA
|
||||
" %-*s"
|
||||
|
@ -287,7 +402,7 @@ int main (void)
|
|||
(int)sizeof(things[0].devnode_sound), "Sound",
|
||||
(int)sizeof(things[0].plughw)/5, "ADEVICE",
|
||||
(int)sizeof(things[0].plughw2)/4, "ADEVICE",
|
||||
(int)sizeof(things[0].devnode_hidraw), "HID [ptt]"
|
||||
17, "HID [ptt]"
|
||||
#if EXTRA
|
||||
, (int)sizeof(things[0].devnode_usb), "USB"
|
||||
#endif
|
||||
|
@ -301,14 +416,14 @@ int main (void)
|
|||
(int)sizeof(things[0].devnode_sound), "-----",
|
||||
(int)sizeof(things[0].plughw)/5, "-------",
|
||||
(int)sizeof(things[0].plughw2)/4, "-------",
|
||||
(int)sizeof(things[0].devnode_hidraw), "---------"
|
||||
17, "---------"
|
||||
#if EXTRA
|
||||
, (int)sizeof(things[0].devnode_usb), "---"
|
||||
#endif
|
||||
);
|
||||
for (i = 0; i < num_things; i++) {
|
||||
|
||||
dw_printf ("%2s %04x %04x %-*s %-*s %-*s %-*s %-*s"
|
||||
dw_printf ("%2s %04x %04x %-*s %-*s %-*s %-*s %s"
|
||||
#if EXTRA
|
||||
" %-*s"
|
||||
#endif
|
||||
|
@ -319,22 +434,22 @@ int main (void)
|
|||
(int)sizeof(things[i].devnode_sound), things[i].devnode_sound,
|
||||
(int)sizeof(things[0].plughw)/5, things[i].plughw,
|
||||
(int)sizeof(things[0].plughw2)/4, things[i].plughw2,
|
||||
(int)sizeof(things[i].devnode_hidraw), things[i].devnode_hidraw
|
||||
things[i].devnode_hidraw
|
||||
#if EXTRA
|
||||
, (int)sizeof(things[i].devnode_usb), things[i].devnode_usb
|
||||
#endif
|
||||
);
|
||||
//dw_printf (" %-*s\n", (int)sizeof(things[i].devpath), things[i].devpath);
|
||||
}
|
||||
dw_printf ("\n");
|
||||
dw_printf ("** = Can use Audio Adapter GPIO for PTT.\n");
|
||||
dw_printf ("\n");
|
||||
|
||||
static const char *suggested_names[] = {"Fred", "Wilma", "Pebbles", "Dino", "Barney", "Betty", "Bamm_Bamm" };
|
||||
static const char *suggested_names[] = {"Fred", "Wilma", "Pebbles", "Dino", "Barney", "Betty", "Bamm_Bamm", "Chip", "Roxy" };
|
||||
int iname = 0;
|
||||
|
||||
// From example in https://alsa.opensrc.org/Udev
|
||||
|
||||
dw_printf ("\n");
|
||||
dw_printf ("** = Can use Audio Adapter GPIO for PTT.\n");
|
||||
dw_printf ("\n");
|
||||
dw_printf ("Notice that each USB Audio adapter is assigned a number and a name. These are not predictable so you could\n");
|
||||
dw_printf ("end up using the wrong adapter after adding or removing other USB devices or after rebooting. You can assign a\n");
|
||||
dw_printf ("name to each USB adapter so you can refer to the same one each time. This can be based on any characteristics\n");
|
||||
|
@ -372,7 +487,7 @@ int main (void)
|
|||
}
|
||||
dw_printf ("LABEL=\"my_usb_audio_end\"\n");
|
||||
dw_printf ("\n");
|
||||
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -400,6 +515,47 @@ int main (void)
|
|||
|
||||
int cm108_inventory (struct thing_s *things, int max_things)
|
||||
{
|
||||
int num_things = 0;
|
||||
memset (things, 0, sizeof(struct thing_s) * max_things);
|
||||
|
||||
#if __WIN32__
|
||||
|
||||
struct hid_device_info *devs, *cur_dev;
|
||||
|
||||
if (hid_init()) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf("cm108_inventory: hid_init() failed.\n");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
devs = hid_enumerate(0x0, 0x0);
|
||||
cur_dev = devs;
|
||||
while (cur_dev) {
|
||||
#if 0
|
||||
printf("Device Found\n type: %04hx %04hx\n path: %s\n serial_number: %ls", cur_dev->vendor_id, cur_dev->product_id, cur_dev->path, cur_dev->serial_number);
|
||||
printf("\n");
|
||||
printf(" Manufacturer: %ls\n", cur_dev->manufacturer_string);
|
||||
printf(" Product: %ls\n", cur_dev->product_string);
|
||||
printf(" Release: %hx\n", cur_dev->release_number);
|
||||
printf(" Interface: %d\n", cur_dev->interface_number);
|
||||
printf(" Usage (page): 0x%hx (0x%hx)\n", cur_dev->usage, cur_dev->usage_page);
|
||||
printf("\n");
|
||||
#endif
|
||||
if (num_things < max_things && cur_dev->vendor_id != 0x051d) { // FIXME - remove exception
|
||||
things[num_things].vid = cur_dev->vendor_id;
|
||||
things[num_things].pid = cur_dev->product_id;
|
||||
wcstombs (things[num_things].product, cur_dev->product_string, sizeof(things[num_things].product));
|
||||
things[num_things].product[sizeof(things[num_things].product) - 1] = '\0';
|
||||
strlcpy (things[num_things].devnode_hidraw, cur_dev->path, sizeof(things[num_things].devnode_hidraw));
|
||||
|
||||
num_things++;
|
||||
}
|
||||
cur_dev = cur_dev->next;
|
||||
}
|
||||
hid_free_enumeration(devs);
|
||||
|
||||
#else // Linux, with udev
|
||||
|
||||
struct udev *udev;
|
||||
struct udev_enumerate *enumerate;
|
||||
struct udev_list_entry *devices, *dev_list_entry;
|
||||
|
@ -410,8 +566,6 @@ int cm108_inventory (struct thing_s *things, int max_things)
|
|||
char const *pattrs_number = NULL;
|
||||
char card_devpath[128] = "";
|
||||
|
||||
int num_things = 0;
|
||||
memset (things, 0, sizeof(struct thing_s) * max_things);
|
||||
|
||||
/*
|
||||
* First get a list of the USB audio devices.
|
||||
|
@ -561,6 +715,8 @@ int cm108_inventory (struct thing_s *things, int max_things)
|
|||
}
|
||||
}
|
||||
|
||||
#endif // end Linux
|
||||
|
||||
return (num_things);
|
||||
|
||||
} /* end cm108_inventory */
|
||||
|
@ -584,7 +740,7 @@ int cm108_inventory (struct thing_s *things, int max_things)
|
|||
* ptt_device_size - Size of result area to avoid buffer overflow.
|
||||
*
|
||||
* Outputs: ptt_device - Device name, something like /dev/hidraw2.
|
||||
* Will be emptry string if no match found.
|
||||
* Will be empty string if no match found.
|
||||
*
|
||||
* Returns: none
|
||||
*
|
||||
|
@ -594,13 +750,48 @@ void cm108_find_ptt (char *output_audio_device, char *ptt_device, int ptt_devic
|
|||
{
|
||||
struct thing_s things[MAXX_THINGS];
|
||||
int num_things;
|
||||
int i;
|
||||
|
||||
//dw_printf ("DEBUG: cm108_find_ptt('%s')\n", output_audio_device);
|
||||
|
||||
strlcpy (ptt_device, "", ptt_device_size);
|
||||
|
||||
// Possible improvement: Skip if inventory already taken.
|
||||
num_things = cm108_inventory (things, MAXX_THINGS);
|
||||
|
||||
#if __WIN32__
|
||||
// FIXME - This is just a half baked implementation.
|
||||
// I have not been able to figure out how to find the connection
|
||||
// between the audio device and HID in the same package.
|
||||
// This is fine for a single USB Audio Adapter, good enough for most people.
|
||||
// Those with multiple devices will need to manually configure PTT device path.
|
||||
|
||||
// Count how many good devices we have.
|
||||
|
||||
int good_devices = 0;
|
||||
|
||||
for (int i = 0; i < num_things; i++) {
|
||||
if (GOOD_DEVICE(things[i].vid,things[i].pid) ) {
|
||||
good_devices++;
|
||||
//dw_printf ("DEBUG: success! returning '%s'\n", things[i].devnode_hidraw);
|
||||
strlcpy (ptt_device, things[i].devnode_hidraw, ptt_device_size);
|
||||
}
|
||||
}
|
||||
|
||||
if (good_devices == 0) return; // None found - caller will print a message.
|
||||
|
||||
if (good_devices == 1) return; // Success - Only one candidate device.
|
||||
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("There are multiple USB Audio Devices with GPIO capability.\n");
|
||||
dw_printf ("Explicitly specify one of them for more predictable results:\n");
|
||||
for (int i = 0; i < num_things; i++) {
|
||||
if (GOOD_DEVICE(things[i].vid,things[i].pid) ) {
|
||||
dw_printf (" \"%s\"\n", things[i].devnode_hidraw);
|
||||
}
|
||||
}
|
||||
dw_printf ("Run the \"cm108\" utility for more details.\n");
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
#else
|
||||
regex_t sound_re;
|
||||
char emsg[100];
|
||||
int e = regcomp (&sound_re, ".+:(CARD=)?([A-Za-z0-9_]+)(,.*)?", REG_EXTENDED);
|
||||
|
@ -625,7 +816,7 @@ void cm108_find_ptt (char *output_audio_device, char *ptt_device, int ptt_devic
|
|||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_things; i++) {
|
||||
for (int i = 0; i < num_things; i++) {
|
||||
//dw_printf ("DEBUG: i=%d, card_name='%s', card_number='%s'\n", i, things[i].card_name, things[i].card_number);
|
||||
if (strcmp(num_or_name,things[i].card_name) == 0 || strcmp(num_or_name,things[i].card_number) == 0) {
|
||||
//dw_printf ("DEBUG: success! returning '%s'\n", things[i].devnode_hidraw);
|
||||
|
@ -638,6 +829,7 @@ void cm108_find_ptt (char *output_audio_device, char *ptt_device, int ptt_devic
|
|||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} /* end cm108_find_ptt */
|
||||
|
||||
|
@ -649,7 +841,8 @@ void cm108_find_ptt (char *output_audio_device, char *ptt_device, int ptt_devic
|
|||
*
|
||||
* Purpose: Set one GPIO pin of the CM108 or similar.
|
||||
*
|
||||
* Inputs: name - Name of device such as /dev/hidraw2.
|
||||
* Inputs: name - Name of device such as /dev/hidraw2 or
|
||||
* \\?\hid#vid_0d8c&pid_0008&mi_03#8&39d3555&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
|
||||
*
|
||||
* num - GPIO number, range 1 thru 8.
|
||||
*
|
||||
|
@ -661,7 +854,7 @@ void cm108_find_ptt (char *output_audio_device, char *ptt_device, int ptt_devic
|
|||
*
|
||||
* Future: For our initial implementation we are making the simplifying
|
||||
* restriction of using only one GPIO pin per device and limit
|
||||
* configuratin to PTT only.
|
||||
* configuration to PTT only.
|
||||
* Longer term, we might want to have DCD, and maybe other
|
||||
* controls thru the same chip.
|
||||
* In this case, we would need to retain bit masks for each
|
||||
|
@ -669,44 +862,6 @@ void cm108_find_ptt (char *output_audio_device, char *ptt_device, int ptt_devic
|
|||
*
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
#if TESTCM
|
||||
|
||||
// Switch pin between input, output-low, and output-high.
|
||||
|
||||
// gcc -DTESTCM=1 -DUSE_CM108 cm108.c textcolor.c misc.a -ludev
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
#define MODE_IN 0
|
||||
#define MODE_OUT 0x04 // GPIO 3 = bit 2
|
||||
#define OUT_LOW 0
|
||||
#define OUT_HIGH 0x04
|
||||
|
||||
if (argc != 2) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Specify HID path on command line.\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("Input-L\n");
|
||||
cm108_write (argv[1], MODE_IN, OUT_LOW);
|
||||
sleep(5);
|
||||
dw_printf ("Input-H\n");
|
||||
cm108_write (argv[1], MODE_IN, OUT_HIGH);
|
||||
sleep(5);
|
||||
dw_printf ("Out-LOW\n");
|
||||
cm108_write (argv[1], MODE_OUT, OUT_LOW);
|
||||
sleep(5);
|
||||
dw_printf ("out-HIGH\n");
|
||||
cm108_write (argv[1], MODE_OUT, OUT_HIGH);
|
||||
sleep(5);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
int cm108_set_gpio_pin (char *name, int num, int state)
|
||||
{
|
||||
|
@ -758,6 +913,36 @@ int cm108_set_gpio_pin (char *name, int num, int state)
|
|||
|
||||
static int cm108_write (char *name, int iomask, int iodata)
|
||||
{
|
||||
|
||||
#if __WIN32__
|
||||
|
||||
//text_color_set(DW_COLOR_DEBUG);
|
||||
//dw_printf ("TEMP DEBUG cm108_write: %s %d %d\n", name, iomask, iodata);
|
||||
|
||||
hid_device *handle = hid_open_path(name);
|
||||
if (handle == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Could not open %s for write\n", name);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
unsigned char io[5];
|
||||
io[0] = 0;
|
||||
io[1] = 0;
|
||||
io[2] = iodata;
|
||||
io[3] = iomask;
|
||||
io[4] = 0;
|
||||
|
||||
int res = hid_write(handle, io, sizeof(io));
|
||||
if (res < 0) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Write failed to %s\n", name);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
hid_close(handle);
|
||||
|
||||
#else
|
||||
int fd;
|
||||
struct hidraw_devinfo info;
|
||||
char io[5];
|
||||
|
@ -862,6 +1047,8 @@ static int cm108_write (char *name, int iomask, int iodata)
|
|||
}
|
||||
|
||||
close (fd);
|
||||
|
||||
#endif
|
||||
return (0);
|
||||
|
||||
} /* end cm108_write */
|
||||
|
|
496
src/config.c
496
src/config.c
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
||||
//
|
||||
// Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 John Langner, WB2OSZ
|
||||
// Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2021 John Langner, WB2OSZ
|
||||
//
|
||||
// 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
|
||||
|
@ -63,7 +63,7 @@
|
|||
#include "tt_text.h"
|
||||
#include "ax25_link.h"
|
||||
|
||||
#ifdef USE_CM108 // Linux only
|
||||
#if USE_CM108 // Current Linux or Windows only
|
||||
#include "cm108.h"
|
||||
#endif
|
||||
|
||||
|
@ -317,7 +317,7 @@ static double parse_ll (char *str, enum parse_ll_which_e which, int line)
|
|||
* - Negative zone for south.
|
||||
* - Separate North or South.
|
||||
*
|
||||
* I'm using the first alternatve.
|
||||
* I'm using the first alternative.
|
||||
* GEOTRANS uses the third.
|
||||
* We will also recognize the second one but I'm not sure if I want to document it.
|
||||
*
|
||||
|
@ -585,7 +585,7 @@ static int check_via_path (char *via_path)
|
|||
*
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#define MAXCMDLEN 256
|
||||
#define MAXCMDLEN 1200
|
||||
|
||||
|
||||
static char *split (char *string, int rest_of_line)
|
||||
|
@ -736,6 +736,8 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
|
||||
memset (p_audio_config, 0, sizeof(struct audio_s));
|
||||
|
||||
p_audio_config->igate_vchannel = -1; // none.
|
||||
|
||||
/* First audio device is always available with defaults. */
|
||||
/* Others must be explicitly defined before use. */
|
||||
|
||||
|
@ -755,7 +757,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
for (channel=0; channel<MAX_CHANS; channel++) {
|
||||
int ot, it;
|
||||
|
||||
p_audio_config->achan[channel].medium = MEDIUM_NONE; /* One or both channels will be */
|
||||
p_audio_config->chan_medium[channel] = MEDIUM_NONE; /* One or both channels will be */
|
||||
/* set to radio when corresponding */
|
||||
/* audio device is defined. */
|
||||
p_audio_config->achan[channel].modem_type = MODEM_AFSK;
|
||||
|
@ -770,6 +772,10 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
p_audio_config->achan[channel].num_freq = 1;
|
||||
p_audio_config->achan[channel].offset = 0;
|
||||
|
||||
p_audio_config->achan[channel].layer2_xmit = LAYER2_AX25;
|
||||
p_audio_config->achan[channel].il2p_max_fec = 1;
|
||||
p_audio_config->achan[channel].il2p_invert_polarity = 0;
|
||||
|
||||
p_audio_config->achan[channel].fix_bits = DEFAULT_FIX_BITS;
|
||||
p_audio_config->achan[channel].sanity_test = SANITY_APRS;
|
||||
p_audio_config->achan[channel].passall = 0;
|
||||
|
@ -804,7 +810,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
/* First channel should always be valid. */
|
||||
/* If there is no ADEVICE, it uses default device in mono. */
|
||||
|
||||
p_audio_config->achan[0].medium = MEDIUM_RADIO;
|
||||
p_audio_config->chan_medium[0] = MEDIUM_RADIO;
|
||||
|
||||
memset (p_digi_config, 0, sizeof(struct digi_config_s)); // APRS digipeater
|
||||
p_digi_config->dedupe_time = DEFAULT_DEDUPE;
|
||||
|
@ -852,10 +858,19 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
|
||||
memset (p_misc_config, 0, sizeof(struct misc_config_s));
|
||||
p_misc_config->agwpe_port = DEFAULT_AGWPE_PORT;
|
||||
p_misc_config->kiss_port = DEFAULT_KISS_PORT;
|
||||
|
||||
for (int i=0; i<MAX_KISS_TCP_PORTS; i++) {
|
||||
p_misc_config->kiss_port[i] = 0; // entry not used.
|
||||
p_misc_config->kiss_chan[i] = -1;
|
||||
}
|
||||
p_misc_config->kiss_port[0] = DEFAULT_KISS_PORT;
|
||||
p_misc_config->kiss_chan[0] = -1; // all channels.
|
||||
|
||||
p_misc_config->enable_kiss_pt = 0; /* -p option */
|
||||
p_misc_config->kiss_copy = 0;
|
||||
|
||||
p_misc_config->dns_sd_enabled = 1;
|
||||
|
||||
/* Defaults from http://info.aprs.net/index.php?title=SmartBeaconing */
|
||||
|
||||
p_misc_config->sb_configured = 0; /* TRUE if SmartBeaconing is configured. */
|
||||
|
@ -1018,7 +1033,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
p_audio_config->adev[adevice].defined = 1;
|
||||
|
||||
/* First channel of device is valid. */
|
||||
p_audio_config->achan[ADEVFIRSTCHAN(adevice)].medium = MEDIUM_RADIO;
|
||||
p_audio_config->chan_medium[ADEVFIRSTCHAN(adevice)] = MEDIUM_RADIO;
|
||||
|
||||
strlcpy (p_audio_config->adev[adevice].adevice_in, t, sizeof(p_audio_config->adev[adevice].adevice_in));
|
||||
strlcpy (p_audio_config->adev[adevice].adevice_out, t, sizeof(p_audio_config->adev[adevice].adevice_out));
|
||||
|
@ -1073,7 +1088,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
p_audio_config->adev[adevice].defined = 1;
|
||||
|
||||
/* First channel of device is valid. */
|
||||
p_audio_config->achan[ADEVFIRSTCHAN(adevice)].medium = MEDIUM_RADIO;
|
||||
p_audio_config->chan_medium[ADEVFIRSTCHAN(adevice)] = MEDIUM_RADIO;
|
||||
|
||||
strlcpy (p_audio_config->adev[adevice].adevice_in, t, sizeof(p_audio_config->adev[adevice].adevice_in));
|
||||
}
|
||||
|
@ -1100,7 +1115,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
p_audio_config->adev[adevice].defined = 1;
|
||||
|
||||
/* First channel of device is valid. */
|
||||
p_audio_config->achan[ADEVFIRSTCHAN(adevice)].medium = MEDIUM_RADIO;
|
||||
p_audio_config->chan_medium[ADEVFIRSTCHAN(adevice)] = MEDIUM_RADIO;
|
||||
|
||||
strlcpy (p_audio_config->adev[adevice].adevice_out, t, sizeof(p_audio_config->adev[adevice].adevice_out));
|
||||
}
|
||||
|
@ -1147,9 +1162,9 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
|
||||
/* Set valid channels depending on mono or stereo. */
|
||||
|
||||
p_audio_config->achan[ADEVFIRSTCHAN(adevice)].medium = MEDIUM_RADIO;
|
||||
p_audio_config->chan_medium[ADEVFIRSTCHAN(adevice)] = MEDIUM_RADIO;
|
||||
if (n == 2) {
|
||||
p_audio_config->achan[ADEVFIRSTCHAN(adevice) + 1].medium = MEDIUM_RADIO;
|
||||
p_audio_config->chan_medium[ADEVFIRSTCHAN(adevice) + 1] = MEDIUM_RADIO;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1163,7 +1178,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
*/
|
||||
|
||||
/*
|
||||
* CHANNEL - Set channel for following commands.
|
||||
* CHANNEL n - Set channel for channel-specific commands.
|
||||
*/
|
||||
|
||||
else if (strcasecmp(t, "CHANNEL") == 0) {
|
||||
|
@ -1179,7 +1194,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
|
||||
channel = n;
|
||||
|
||||
if (p_audio_config->achan[n].medium != MEDIUM_RADIO) {
|
||||
if (p_audio_config->chan_medium[n] != MEDIUM_RADIO) {
|
||||
|
||||
if ( ! p_audio_config->adev[ACHAN2ADEV(n)].defined) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
|
@ -1199,6 +1214,44 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ICHANNEL n - Define IGate virtual channel.
|
||||
*
|
||||
* This allows a client application to talk to to APRS-IS
|
||||
* by using a channel number outside the normal range for modems.
|
||||
* In the future there might be other typs of virtual channels.
|
||||
* This does not change the current channel number used by MODEM, PTT, etc.
|
||||
*/
|
||||
|
||||
else if (strcasecmp(t, "ICHANNEL") == 0) {
|
||||
t = split(NULL,0);
|
||||
if (t == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Line %d: Missing virtual channel number for ICHANNEL command.\n", line);
|
||||
continue;
|
||||
}
|
||||
int ichan = atoi(t);
|
||||
if (ichan >= MAX_CHANS && ichan < MAX_TOTAL_CHANS) {
|
||||
|
||||
if (p_audio_config->chan_medium[ichan] == MEDIUM_NONE) {
|
||||
|
||||
p_audio_config->chan_medium[ichan] = MEDIUM_IGATE;
|
||||
|
||||
// This is redundant but saves the time of searching through all
|
||||
// the channels for each packet.
|
||||
p_audio_config->igate_vchannel = ichan;
|
||||
}
|
||||
else {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Line %d: ICHANNEL can't use %d because it is already in use.\n", line, ichan);
|
||||
}
|
||||
}
|
||||
else {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Line %d: ICHANNEL number must in range of %d to %d.\n", line, MAX_CHANS, MAX_TOTAL_CHANS-1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* MYCALL station
|
||||
*/
|
||||
|
@ -1277,17 +1330,17 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
continue;
|
||||
}
|
||||
if (strcasecmp(t,"AIS") == 0) {
|
||||
n = 12345; // See special case later.
|
||||
n = MAX_BAUD-1; // Hack - See special case later.
|
||||
}
|
||||
else if (strcasecmp(t,"EAS") == 0) {
|
||||
n = 23456; // See special case later.
|
||||
n = MAX_BAUD-2; // Hack - See special case later.
|
||||
}
|
||||
else {
|
||||
n = atoi(t);
|
||||
}
|
||||
if (n >= MIN_BAUD && n <= MAX_BAUD) {
|
||||
p_audio_config->achan[channel].baud = n;
|
||||
if (n != 300 && n != 1200 && n != 2400 && n != 4800 && n != 9600 && n != 19200) {
|
||||
if (n != 300 && n != 1200 && n != 2400 && n != 4800 && n != 9600 && n != 19200 && n != MAX_BAUD-1 && n != MAX_BAUD-2) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Line %d: Warning: Non-standard data rate of %d bits per second. Are you sure?\n", line, n);
|
||||
}
|
||||
|
@ -1326,18 +1379,18 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
p_audio_config->achan[channel].mark_freq = 0;
|
||||
p_audio_config->achan[channel].space_freq = 0;
|
||||
}
|
||||
else if (p_audio_config->achan[channel].baud == 12345) {
|
||||
else if (p_audio_config->achan[channel].baud == MAX_BAUD-1) {
|
||||
p_audio_config->achan[channel].modem_type = MODEM_AIS;
|
||||
p_audio_config->achan[channel].mark_freq = 0;
|
||||
p_audio_config->achan[channel].space_freq = 0;
|
||||
}
|
||||
else if (p_audio_config->achan[channel].baud == 23456) {
|
||||
else if (p_audio_config->achan[channel].baud == MAX_BAUD-2) {
|
||||
p_audio_config->achan[channel].modem_type = MODEM_EAS;
|
||||
p_audio_config->achan[channel].baud = 521; // Actually 520.83 but we have an integer field here.
|
||||
// Will make more precise in afsk demod init.
|
||||
p_audio_config->achan[channel].mark_freq = 2083; // Actually 2083.3 - logic 1.
|
||||
p_audio_config->achan[channel].space_freq = 1563; // Actually 1562.5 - logic 0.
|
||||
// ? strlcpy (p_audio_config->achan[channel].profiles, "D", sizeof(p_audio_config->achan[channel].profiles));
|
||||
// ? strlcpy (p_audio_config->achan[channel].profiles, "A", sizeof(p_audio_config->achan[channel].profiles));
|
||||
}
|
||||
else {
|
||||
p_audio_config->achan[channel].modem_type = MODEM_SCRAMBLE;
|
||||
|
@ -1641,6 +1694,9 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("Line %d: Using a FIX_BITS value greater than %d is not recommended for normal operation.\n",
|
||||
line, DEFAULT_FIX_BITS);
|
||||
dw_printf ("FIX_BITS > 1 was an interesting experiment but turned out to be a bad idea.\n");
|
||||
dw_printf ("Don't be surprised if it takes 100%% CPU, direwolf can't keep up with the audio stream,\n");
|
||||
dw_printf ("and you see messages like \"Audio input device 0 error code -32: Broken pipe\"\n");
|
||||
}
|
||||
|
||||
t = split(NULL,0);
|
||||
|
@ -1682,8 +1738,8 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
* xxx serial-port [-]rts-or-dtr [ [-]rts-or-dtr ]
|
||||
* xxx GPIO [-]gpio-num
|
||||
* xxx LPT [-]bit-num
|
||||
* PTT RIG model port
|
||||
* PTT RIG AUTO port
|
||||
* PTT RIG model port [ rate ]
|
||||
* PTT RIG AUTO port [ rate ]
|
||||
* PTT CM108 [ [-]bit-num ] [ hid-device ]
|
||||
*
|
||||
* When model is 2, port would host:port like 127.0.0.1:4532
|
||||
|
@ -1845,6 +1901,19 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
}
|
||||
strlcpy (p_audio_config->achan[channel].octrl[ot].ptt_device, t, sizeof(p_audio_config->achan[channel].octrl[ot].ptt_device));
|
||||
|
||||
// Optional serial port rate for CAT control PTT.
|
||||
|
||||
t = split(NULL,0);
|
||||
if (t != NULL) {
|
||||
if ( ! alldigits(t)) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file line %d: An optional number is required here for CAT serial port speed: %s\n", line, t);
|
||||
continue;
|
||||
}
|
||||
int n = atoi(t);
|
||||
p_audio_config->achan[channel].octrl[ot].ptt_rate = n;
|
||||
}
|
||||
|
||||
t = split(NULL,0);
|
||||
if (t != NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
|
@ -1869,9 +1938,9 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
}
|
||||
else if (strcasecmp(t, "CM108") == 0) {
|
||||
|
||||
/* CM108 - GPIO of USB sound card. case, Linux only. */
|
||||
/* CM108 - GPIO of USB sound card. case, Linux and Windows only. */
|
||||
|
||||
#ifdef USE_CM108
|
||||
#if USE_CM108
|
||||
|
||||
if (ot != OCTYPE_PTT) {
|
||||
// Future project: Allow DCD and CON via the same device.
|
||||
|
@ -1908,6 +1977,16 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
p_audio_config->achan[channel].octrl[ot].out_gpio_num = atoi(t);
|
||||
p_audio_config->achan[channel].octrl[ot].ptt_invert = 0;
|
||||
}
|
||||
#if __WIN32__
|
||||
else if (*t == '\\') {
|
||||
strlcpy (p_audio_config->achan[channel].octrl[ot].ptt_device, t, sizeof(p_audio_config->achan[channel].octrl[ot].ptt_device));
|
||||
}
|
||||
else {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file line %d: Found \"%s\" when expecting GPIO number or device name like \\\\?\\hid#vid_0d8c&... .\n", line, t);
|
||||
continue;
|
||||
}
|
||||
#else
|
||||
else if (*t == '/') {
|
||||
strlcpy (p_audio_config->achan[channel].octrl[ot].ptt_device, t, sizeof(p_audio_config->achan[channel].octrl[ot].ptt_device));
|
||||
}
|
||||
|
@ -1916,6 +1995,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
dw_printf ("Config file line %d: Found \"%s\" when expecting GPIO number or device name like /dev/hidraw1.\n", line, t);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (p_audio_config->achan[channel].octrl[ot].out_gpio_num < 1 || p_audio_config->achan[channel].octrl[ot].out_gpio_num > 8) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
|
@ -1927,22 +2007,23 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file line %d: Could not determine USB Audio GPIO PTT device for audio output %s.\n", line,
|
||||
p_audio_config->adev[ACHAN2ADEV(channel)].adevice_out);
|
||||
#if __WIN32__
|
||||
dw_printf ("You must explicitly mention a HID path.\n");
|
||||
#else
|
||||
dw_printf ("You must explicitly mention a device name such as /dev/hidraw1.\n");
|
||||
dw_printf ("See User Guide for details.\n");
|
||||
#endif
|
||||
dw_printf ("Run \"cm108\" utility to get a list.\n");
|
||||
dw_printf ("See Interface Guide for details.\n");
|
||||
continue;
|
||||
}
|
||||
p_audio_config->achan[channel].octrl[ot].ptt_method = PTT_METHOD_CM108;
|
||||
|
||||
#else
|
||||
#if __WIN32__
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file line %d: CM108 USB Audio GPIO PTT is not available for Windows.\n", line);
|
||||
#else
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file line %d: %s with CM108 is only available when USB Audio GPIO support is enabled.\n", line, otname);
|
||||
dw_printf ("You must rebuild direwolf with CM108 Audio Adapter GPIO PTT support.\n");
|
||||
dw_printf ("See User Guide for details.\n");
|
||||
#endif
|
||||
dw_printf ("See Interface Guide for details.\n");
|
||||
|
||||
exit (EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -2255,7 +2336,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
* 0 = off, 1 = auto mode, others are suggestions for testing
|
||||
* or special cases. 16, 32, 64 is number of parity bytes to add.
|
||||
* Also set by "-X n" command line option.
|
||||
* Current a global setting. Could be per channel someday.
|
||||
* V1.7 changed from global to per-channel setting.
|
||||
*/
|
||||
|
||||
else if (strcasecmp(t, "FX25TX") == 0) {
|
||||
|
@ -2268,13 +2349,15 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
}
|
||||
n = atoi(t);
|
||||
if (n >= 0 && n < 200) {
|
||||
p_audio_config->fx25_xmit_enable = n;
|
||||
p_audio_config->achan[channel].fx25_strength = n;
|
||||
p_audio_config->achan[channel].layer2_xmit = LAYER2_FX25;
|
||||
}
|
||||
else {
|
||||
p_audio_config->fx25_xmit_enable = 1;
|
||||
p_audio_config->achan[channel].fx25_strength = 1;
|
||||
p_audio_config->achan[channel].layer2_xmit = LAYER2_FX25;
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Line %d: Unreasonable value for FX.25 transmission mode. Using %d.\n",
|
||||
line, p_audio_config->fx25_xmit_enable);
|
||||
line, p_audio_config->achan[channel].fx25_strength);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2307,12 +2390,57 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* IL2PTX [ + - ] [ 0 1 ] - Enable IL2P transmission. Default off.
|
||||
* "+" means normal polarity. Redundant since it is the default.
|
||||
* (command line -I for first channel)
|
||||
* "-" means inverted polarity. Do not use for 1200 bps.
|
||||
* (command line -i for first channel)
|
||||
* "0" means weak FEC. Not recommended.
|
||||
* "1" means stronger FEC. "Max FEC." Default if not specified.
|
||||
*/
|
||||
|
||||
else if (strcasecmp(t, "IL2PTX") == 0) {
|
||||
|
||||
p_audio_config->achan[channel].layer2_xmit = LAYER2_IL2P;
|
||||
p_audio_config->achan[channel].il2p_max_fec = 1;
|
||||
p_audio_config->achan[channel].il2p_invert_polarity = 0;
|
||||
|
||||
while ((t = split(NULL,0)) != NULL) {
|
||||
for (char *c = t; *t != '\0'; c++) {
|
||||
switch (*c) {
|
||||
case '+':
|
||||
p_audio_config->achan[channel].il2p_invert_polarity = 0;
|
||||
break;
|
||||
case '-':
|
||||
p_audio_config->achan[channel].il2p_invert_polarity = 1;
|
||||
break;
|
||||
case '0':
|
||||
p_audio_config->achan[channel].il2p_max_fec = 0;
|
||||
break;
|
||||
case '1':
|
||||
p_audio_config->achan[channel].il2p_max_fec = 1;
|
||||
break;
|
||||
default:
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Line %d: Invalid parameter '%c' fol IL2PTX command.\n", line, *c);
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ==================== APRS Digipeater parameters ====================
|
||||
*/
|
||||
|
||||
/*
|
||||
* DIGIPEAT from-chan to-chan alias-pattern wide-pattern [ OFF|DROP|MARK|TRACE ]
|
||||
* DIGIPEAT from-chan to-chan alias-pattern wide-pattern [ OFF|DROP|MARK|TRACE | ATGP=alias ]
|
||||
*
|
||||
* ATGP is an ugly hack for the specific need of ATGP which needs more that 8 digipeaters.
|
||||
* DO NOT put this in the User Guide. On a need to know basis.
|
||||
*/
|
||||
|
||||
else if (strcasecmp(t, "DIGIPEAT") == 0 || strcasecmp(t, "DIGIPEATER") == 0) {
|
||||
|
@ -2343,8 +2471,8 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
|
||||
// Channels specified must be radio channels or network TNCs.
|
||||
|
||||
if (p_audio_config->achan[from_chan].medium != MEDIUM_RADIO &&
|
||||
p_audio_config->achan[from_chan].medium != MEDIUM_NETTNC) {
|
||||
if (p_audio_config->chan_medium[from_chan] != MEDIUM_RADIO &&
|
||||
p_audio_config->chan_medium[from_chan] != MEDIUM_NETTNC) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file, line %d: FROM-channel %d is not valid.\n",
|
||||
line, from_chan);
|
||||
|
@ -2371,8 +2499,8 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
continue;
|
||||
}
|
||||
|
||||
if (p_audio_config->achan[to_chan].medium != MEDIUM_RADIO &&
|
||||
p_audio_config->achan[to_chan].medium != MEDIUM_NETTNC) {
|
||||
if (p_audio_config->chan_medium[to_chan] != MEDIUM_RADIO &&
|
||||
p_audio_config->chan_medium[to_chan] != MEDIUM_NETTNC) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file, line %d: TO-channel %d is not valid.\n",
|
||||
line, to_chan);
|
||||
|
@ -2438,6 +2566,10 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
p_digi_config->preempt[from_chan][to_chan] = PREEMPT_TRACE;
|
||||
t = split(NULL,0);
|
||||
}
|
||||
else if (strncasecmp(t, "ATGP=", 5) == 0) {
|
||||
strlcpy (p_digi_config->atgp[from_chan][to_chan], t+5, sizeof(p_digi_config->atgp[from_chan][to_chan]));;
|
||||
t = split(NULL,0);
|
||||
}
|
||||
}
|
||||
|
||||
if (t != NULL) {
|
||||
|
@ -2500,7 +2632,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
|
||||
// Only radio channels are valid for regenerate.
|
||||
|
||||
if (p_audio_config->achan[from_chan].medium != MEDIUM_RADIO) {
|
||||
if (p_audio_config->chan_medium[from_chan] != MEDIUM_RADIO) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file, line %d: FROM-channel %d is not valid.\n",
|
||||
line, from_chan);
|
||||
|
@ -2526,7 +2658,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
MAX_CHANS-1, line);
|
||||
continue;
|
||||
}
|
||||
if (p_audio_config->achan[to_chan].medium != MEDIUM_RADIO) {
|
||||
if (p_audio_config->chan_medium[to_chan] != MEDIUM_RADIO) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file, line %d: TO-channel %d is not valid.\n",
|
||||
line, to_chan);
|
||||
|
@ -2577,7 +2709,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
// There is discussion about this in the document called
|
||||
// Why-is-9600-only-twice-as-fast-as-1200.pdf
|
||||
|
||||
if (p_audio_config->achan[from_chan].medium != MEDIUM_RADIO) {
|
||||
if (p_audio_config->chan_medium[from_chan] != MEDIUM_RADIO) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file, line %d: FROM-channel %d is not valid.\n",
|
||||
line, from_chan);
|
||||
|
@ -2604,7 +2736,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
MAX_CHANS-1, line);
|
||||
continue;
|
||||
}
|
||||
if (p_audio_config->achan[to_chan].medium != MEDIUM_RADIO) {
|
||||
if (p_audio_config->chan_medium[to_chan] != MEDIUM_RADIO) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file, line %d: TO-channel %d is not valid.\n",
|
||||
line, to_chan);
|
||||
|
@ -2666,11 +2798,11 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
* There is discussion about this in the document called
|
||||
* Why-is-9600-only-twice-as-fast-as-1200.pdf
|
||||
*
|
||||
* IGFILTER - APRS-IS (IGate) server side - completely diffeent.
|
||||
* IGFILTER - APRS-IS (IGate) server side - completely different.
|
||||
* I'm not happy with this name because IG sounds like IGate
|
||||
* which is really the client side. More comments later.
|
||||
* Maybe it should be called subscribe or something like that
|
||||
* because the subscriptions are cummulative.
|
||||
* because the subscriptions are cumulative.
|
||||
*/
|
||||
|
||||
else if (strcasecmp(t, "FILTER") == 0) {
|
||||
|
@ -2695,14 +2827,14 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
continue;
|
||||
}
|
||||
|
||||
if (p_audio_config->achan[from_chan].medium != MEDIUM_RADIO &&
|
||||
p_audio_config->achan[from_chan].medium != MEDIUM_NETTNC) {
|
||||
if (p_audio_config->chan_medium[from_chan] != MEDIUM_RADIO &&
|
||||
p_audio_config->chan_medium[from_chan] != MEDIUM_NETTNC) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file, line %d: FROM-channel %d is not valid.\n",
|
||||
line, from_chan);
|
||||
continue;
|
||||
}
|
||||
if (p_audio_config->achan[from_chan].medium == MEDIUM_IGATE) {
|
||||
if (p_audio_config->chan_medium[from_chan] == MEDIUM_IGATE) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file, line %d: Use 'IG' rather than %d for FROM-channel.\n",
|
||||
line, from_chan);
|
||||
|
@ -2727,14 +2859,14 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
MAX_CHANS-1, line);
|
||||
continue;
|
||||
}
|
||||
if (p_audio_config->achan[to_chan].medium != MEDIUM_RADIO &&
|
||||
p_audio_config->achan[to_chan].medium != MEDIUM_NETTNC) {
|
||||
if (p_audio_config->chan_medium[to_chan] != MEDIUM_RADIO &&
|
||||
p_audio_config->chan_medium[to_chan] != MEDIUM_NETTNC) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file, line %d: TO-channel %d is not valid.\n",
|
||||
line, to_chan);
|
||||
continue;
|
||||
}
|
||||
if (p_audio_config->achan[to_chan].medium == MEDIUM_IGATE) {
|
||||
if (p_audio_config->chan_medium[to_chan] == MEDIUM_IGATE) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file, line %d: Use 'IG' rather than %d for TO-channel.\n",
|
||||
line, to_chan);
|
||||
|
@ -2793,7 +2925,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
// DO NOT allow a network TNC here.
|
||||
// Must be internal modem to have necessary knowledge about channel status.
|
||||
|
||||
if (p_audio_config->achan[from_chan].medium != MEDIUM_RADIO) {
|
||||
if (p_audio_config->chan_medium[from_chan] != MEDIUM_RADIO) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file, line %d: FROM-channel %d is not valid.\n",
|
||||
line, from_chan);
|
||||
|
@ -2814,7 +2946,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
MAX_CHANS-1, line);
|
||||
continue;
|
||||
}
|
||||
if (p_audio_config->achan[to_chan].medium != MEDIUM_RADIO) {
|
||||
if (p_audio_config->chan_medium[to_chan] != MEDIUM_RADIO) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file, line %d: TO-channel %d is not valid.\n",
|
||||
line, to_chan);
|
||||
|
@ -3128,7 +3260,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
t = split(NULL,0);
|
||||
if (t == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Line %d: Missing latitude for TTGRID command.\n", line);
|
||||
dw_printf ("Line %d: Missing minimum latitude for TTGRID command.\n", line);
|
||||
continue;
|
||||
}
|
||||
tl->grid.lat0 = parse_ll(t,LAT,line);
|
||||
|
@ -3138,7 +3270,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
t = split(NULL,0);
|
||||
if (t == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Line %d: Missing longitude for TTGRID command.\n", line);
|
||||
dw_printf ("Line %d: Missing minimum longitude for TTGRID command.\n", line);
|
||||
continue;
|
||||
}
|
||||
tl->grid.lon0 = parse_ll(t,LON,line);
|
||||
|
@ -3148,7 +3280,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
t = split(NULL,0);
|
||||
if (t == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Line %d: Missing latitude for TTGRID command.\n", line);
|
||||
dw_printf ("Line %d: Missing maximum latitude for TTGRID command.\n", line);
|
||||
continue;
|
||||
}
|
||||
tl->grid.lat9 = parse_ll(t,LAT,line);
|
||||
|
@ -3158,13 +3290,16 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
t = split(NULL,0);
|
||||
if (t == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Line %d: Missing longitude for TTGRID command.\n", line);
|
||||
dw_printf ("Line %d: Missing maximum longitude for TTGRID command.\n", line);
|
||||
continue;
|
||||
}
|
||||
tl->grid.lon0 = parse_ll(t,LON,line);
|
||||
tl->grid.lon9 = parse_ll(t,LON,line);
|
||||
|
||||
/* temp debugging */
|
||||
|
||||
// dw_printf ("CONFIG TTGRID min %f %f\n", tl->grid.lat0, tl->grid.lon0);
|
||||
// dw_printf ("CONFIG TTGRID max %f %f\n", tl->grid.lat9, tl->grid.lon9);
|
||||
|
||||
//for (j=0; j<p_tt_config->ttloc_len; j++) {
|
||||
// dw_printf ("debug ttloc %d/%d %s\n", j, p_tt_config->ttloc_size,
|
||||
// p_tt_config->ttloc_ptr[j].pattern);
|
||||
|
@ -3701,7 +3836,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
strlcpy(tl->pattern, "", sizeof(tl->pattern));
|
||||
|
||||
/* Pattern: Any combination of digits, x, y, and z. */
|
||||
/* Also make note of which letters are used in pattern and defintition. */
|
||||
/* Also make note of which letters are used in pattern and definition. */
|
||||
/* Version 1.2: also allow A,B,C,D in the pattern. */
|
||||
|
||||
t = split(NULL,0);
|
||||
|
@ -3975,7 +4110,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
// I suppose we need internal modem channel here.
|
||||
// otherwise a DTMF decoder would not be available.
|
||||
|
||||
if (p_audio_config->achan[r].medium != MEDIUM_RADIO) {
|
||||
if (p_audio_config->chan_medium[r] != MEDIUM_RADIO) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file, line %d: TTOBJ DTMF receive channel %d is not valid.\n",
|
||||
line, r);
|
||||
|
@ -4001,8 +4136,8 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
dw_printf ("Config file: Transmit channel must be in range of 0 to %d on line %d.\n", MAX_CHANS-1, line);
|
||||
x = -1;
|
||||
}
|
||||
else if (p_audio_config->achan[x].medium != MEDIUM_RADIO &&
|
||||
p_audio_config->achan[x].medium != MEDIUM_NETTNC) {
|
||||
else if (p_audio_config->chan_medium[x] != MEDIUM_RADIO &&
|
||||
p_audio_config->chan_medium[x] != MEDIUM_NETTNC) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file, line %d: TTOBJ transmit channel %d is not valid.\n", line, x);
|
||||
x = -1;
|
||||
|
@ -4477,6 +4612,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
*
|
||||
* In version 1.2 we allow 0 to disable listening.
|
||||
*/
|
||||
// FIXME: complain if extra parameter e.g. port as in KISSPORT
|
||||
|
||||
else if (strcasecmp(t, "AGWPORT") == 0) {
|
||||
int n;
|
||||
|
@ -4499,26 +4635,88 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
}
|
||||
|
||||
/*
|
||||
* KISSPORT - Port number for KISS over IP.
|
||||
* KISSPORT port [ chan ] - Port number for KISS over IP.
|
||||
*/
|
||||
|
||||
// Previously we allowed only a single TCP port for KISS.
|
||||
// An increasing number of people want to run multiple radios.
|
||||
// Unfortunately, most applications don't know how to deal with multi-radio TNCs.
|
||||
// They ignore the channel on receive and always transmit to channel 0.
|
||||
// Running multiple instances of direwolf is a work-around but this leads to
|
||||
// more complex configuration and we lose the cross-channel digipeating capability.
|
||||
// In release 1.7 we add a new feature to assign a single radio channel to a TCP port.
|
||||
// e.g.
|
||||
// KISSPORT 8001 # default, all channels. Radio channel = KISS channel.
|
||||
//
|
||||
// KISSPORT 7000 0 # Only radio channel 0 for receive.
|
||||
// # Transmit to radio channel 0, ignoring KISS channel.
|
||||
//
|
||||
// KISSPORT 7001 1 # Only radio channel 1 for receive. KISS channel set to 0.
|
||||
// # Transmit to radio channel 1, ignoring KISS channel.
|
||||
|
||||
// FIXME
|
||||
else if (strcasecmp(t, "KISSPORT") == 0) {
|
||||
int n;
|
||||
int tcp_port = 0;
|
||||
int chan = -1; // optional. default to all if not specified.
|
||||
t = split(NULL,0);
|
||||
if (t == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Line %d: Missing port number for KISSPORT command.\n", line);
|
||||
dw_printf ("Line %d: Missing TCP port number for KISSPORT command.\n", line);
|
||||
continue;
|
||||
}
|
||||
n = atoi(t);
|
||||
if ((n >= MIN_IP_PORT_NUMBER && n <= MAX_IP_PORT_NUMBER) || n == 0) {
|
||||
p_misc_config->kiss_port = n;
|
||||
tcp_port = n;
|
||||
}
|
||||
else {
|
||||
p_misc_config->kiss_port = DEFAULT_KISS_PORT;
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Line %d: Invalid port number for KISS TCPIP Socket Interface. Using %d.\n",
|
||||
line, p_misc_config->kiss_port);
|
||||
dw_printf ("Line %d: Invalid TCP port number for KISS TCPIP Socket Interface.\n", line);
|
||||
dw_printf ("Use something in the range of %d to %d.\n", MIN_IP_PORT_NUMBER, MAX_IP_PORT_NUMBER);
|
||||
continue;
|
||||
}
|
||||
|
||||
t = split(NULL,0);
|
||||
if (t != NULL) {
|
||||
chan = atoi(t);
|
||||
if (chan < 0 || chan >= MAX_CHANS) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Line %d: Invalid channel %d for KISSPORT command. Must be in range 0 thru %d.\n", line, chan, MAX_CHANS-1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// "KISSPORT 0" is used to remove the default entry.
|
||||
|
||||
if (tcp_port == 0) {
|
||||
p_misc_config->kiss_port[0] = 0; // Should all be wiped out?
|
||||
}
|
||||
else {
|
||||
|
||||
// Try to find an empty slot.
|
||||
// A duplicate TCP port number will overwrite the previous value.
|
||||
|
||||
int slot = -1;
|
||||
for (int i = 0; i < MAX_KISS_TCP_PORTS && slot == -1; i++) {
|
||||
if (p_misc_config->kiss_port[i] == tcp_port) {
|
||||
slot = i;
|
||||
if ( ! (slot == 0 && tcp_port == DEFAULT_KISS_PORT)) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Line %d: Warning: Duplicate TCP port %d will overwrite previous value.\n", line, tcp_port);
|
||||
}
|
||||
}
|
||||
else if (p_misc_config->kiss_port[i] == 0) {
|
||||
slot = i;
|
||||
}
|
||||
}
|
||||
if (slot >= 0) {
|
||||
p_misc_config->kiss_port[slot] = tcp_port;
|
||||
p_misc_config->kiss_chan[slot] = chan;
|
||||
}
|
||||
else {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Line %d: Too many KISSPORT commands.\n", line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4581,6 +4779,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
|
||||
/*
|
||||
* KISSCOPY - Data from network KISS client is copied to all others.
|
||||
* This does not apply to pseudo terminal KISS.
|
||||
*/
|
||||
|
||||
else if (strcasecmp(t, "KISSCOPY") == 0) {
|
||||
|
@ -4589,7 +4788,44 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
|
||||
|
||||
/*
|
||||
* GPSNMEA - Device name for reading from GPS receiver.
|
||||
* DNSSD - Enable or disable (1/0) dns-sd, DNS Service Discovery announcements
|
||||
* DNSSDNAME - Set DNS-SD service name, defaults to "Dire Wolf on <hostname>"
|
||||
*/
|
||||
|
||||
else if (strcasecmp(t, "DNSSD") == 0) {
|
||||
int n;
|
||||
t = split(NULL,0);
|
||||
if (t == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Line %d: Missing integer value for DNSSD command.\n", line);
|
||||
continue;
|
||||
}
|
||||
n = atoi(t);
|
||||
if (n == 0 || n == 1) {
|
||||
p_misc_config->dns_sd_enabled = n;
|
||||
} else {
|
||||
p_misc_config->dns_sd_enabled = 0;
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Line %d: Invalid integer value for DNSSD. Disabling dns-sd.\n", line);
|
||||
}
|
||||
}
|
||||
|
||||
else if (strcasecmp(t, "DNSSDNAME") == 0) {
|
||||
t = split(NULL, 1);
|
||||
if (t == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Line %d: Missing service name for DNSSDNAME.\n", line);
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
strlcpy(p_misc_config->dns_sd_name, t, sizeof(p_misc_config->dns_sd_name));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* GPSNMEA serial-device [ speed ] - Direct connection to GPS receiver.
|
||||
*/
|
||||
else if (strcasecmp(t, "gpsnmea") == 0) {
|
||||
t = split(NULL,0);
|
||||
|
@ -4598,8 +4834,15 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
dw_printf ("Config file, line %d: Missing serial port name for GPS receiver.\n", line);
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
strlcpy (p_misc_config->gpsnmea_port, t, sizeof(p_misc_config->gpsnmea_port));
|
||||
|
||||
t = split(NULL,0);
|
||||
if (t != NULL) {
|
||||
int n = atoi(t);
|
||||
p_misc_config->gpsnmea_speed = n;
|
||||
}
|
||||
else {
|
||||
p_misc_config->gpsnmea_speed = 4800; // The standard at one time.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4688,26 +4931,26 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
strlcpy (p_misc_config->waypoint_serial_port, t, sizeof(p_misc_config->waypoint_serial_port));
|
||||
}
|
||||
|
||||
/* Anthing remaining is the formats to enable. */
|
||||
/* Anything remaining is the formats to enable. */
|
||||
|
||||
t = split(NULL,1);
|
||||
if (t != NULL) {
|
||||
for ( ; *t != '\0' ; t++ ) {
|
||||
switch (toupper(*t)) {
|
||||
case 'N':
|
||||
p_misc_config->waypoint_formats |= WPT_FORMAT_NMEA_GENERIC;
|
||||
p_misc_config->waypoint_formats |= WPL_FORMAT_NMEA_GENERIC;
|
||||
break;
|
||||
case 'G':
|
||||
p_misc_config->waypoint_formats |= WPT_FORMAT_GARMIN;
|
||||
p_misc_config->waypoint_formats |= WPL_FORMAT_GARMIN;
|
||||
break;
|
||||
case 'M':
|
||||
p_misc_config->waypoint_formats |= WPT_FORMAT_MAGELLAN;
|
||||
p_misc_config->waypoint_formats |= WPL_FORMAT_MAGELLAN;
|
||||
break;
|
||||
case 'K':
|
||||
p_misc_config->waypoint_formats |= WPT_FORMAT_KENWOOD;
|
||||
p_misc_config->waypoint_formats |= WPL_FORMAT_KENWOOD;
|
||||
break;
|
||||
case 'A':
|
||||
p_misc_config->waypoint_formats |= WPT_FORMAT_AIS;
|
||||
p_misc_config->waypoint_formats |= WPL_FORMAT_AIS;
|
||||
break;
|
||||
case ' ':
|
||||
case ',':
|
||||
|
@ -5055,7 +5298,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
/*
|
||||
* V20 address [ address ... ] - Stations known to support only AX.25 v2.0.
|
||||
* When connecting to these, skip SABME and go right to SABM.
|
||||
* Possible to have multiple and they are cummulative.
|
||||
* Possible to have multiple and they are cumulative.
|
||||
*/
|
||||
|
||||
else if (strcasecmp(t, "V20") == 0) {
|
||||
|
@ -5089,9 +5332,9 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
|
||||
/*
|
||||
* NOXID address [ address ... ] - Stations known not to understand XID.
|
||||
* After connecting to these (with v2.2 obviously), don't try using XID commmand.
|
||||
* After connecting to these (with v2.2 obviously), don't try using XID command.
|
||||
* AX.25 for Linux is the one known case so far.
|
||||
* Possible to have multiple and they are cummulative.
|
||||
* Possible to have multiple and they are cumulative.
|
||||
*/
|
||||
|
||||
else if (strcasecmp(t, "NOXID") == 0) {
|
||||
|
@ -5221,7 +5464,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
/* When IGate is enabled, all radio channels must have a callsign associated. */
|
||||
|
||||
if (strlen(p_igate_config->t2_login) > 0 &&
|
||||
(p_audio_config->achan[i].medium == MEDIUM_RADIO || p_audio_config->achan[i].medium == MEDIUM_NETTNC)) {
|
||||
(p_audio_config->chan_medium[i] == MEDIUM_RADIO || p_audio_config->chan_medium[i] == MEDIUM_NETTNC)) {
|
||||
|
||||
if (strcmp(p_audio_config->achan[i].mycall, "NOCALL") == 0 || strcmp(p_audio_config->achan[i].mycall, "N0CALL") == 0) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
|
@ -5247,7 +5490,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
|
||||
if (strlen(p_igate_config->t2_login) > 0) {
|
||||
for (j=0; j<MAX_CHANS; j++) {
|
||||
if (p_audio_config->achan[j].medium == MEDIUM_RADIO || p_audio_config->achan[j].medium == MEDIUM_NETTNC) {
|
||||
if (p_audio_config->chan_medium[j] == MEDIUM_RADIO || p_audio_config->chan_medium[j] == MEDIUM_NETTNC) {
|
||||
if (p_digi_config->filter_str[MAX_CHANS][j] == NULL) {
|
||||
p_digi_config->filter_str[MAX_CHANS][j] = strdup("i/60");
|
||||
}
|
||||
|
@ -5269,6 +5512,10 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
* Returns 1 for success, 0 for serious error.
|
||||
*/
|
||||
|
||||
// FIXME: provide error messages when non applicable option is used for particular beacon type.
|
||||
// e.g. IBEACON DELAY=1 EVERY=1 SENDTO=IG OVERLAY=R SYMBOL="igate" LAT=37^44.46N LONG=122^27.19W COMMENT="N1KOL-1 IGATE"
|
||||
// Just ignores overlay, symbol, lat, long, and comment.
|
||||
|
||||
static int beacon_options(char *cmd, struct beacon_s *b, int line, struct audio_s *p_audio_config)
|
||||
{
|
||||
char *t;
|
||||
|
@ -5297,11 +5544,13 @@ static int beacon_options(char *cmd, struct beacon_s *b, int line, struct audio_
|
|||
b->freq = G_UNKNOWN;
|
||||
b->tone = G_UNKNOWN;
|
||||
b->offset = G_UNKNOWN;
|
||||
b->source = NULL;
|
||||
b->dest = NULL;
|
||||
|
||||
while ((t = split(NULL,0)) != NULL) {
|
||||
|
||||
char keyword[20];
|
||||
char value[200];
|
||||
char value[1000];
|
||||
char *e;
|
||||
char *p;
|
||||
|
||||
|
@ -5316,6 +5565,44 @@ static int beacon_options(char *cmd, struct beacon_s *b, int line, struct audio_
|
|||
strlcpy (keyword, t, sizeof(keyword));
|
||||
strlcpy (value, e+1, sizeof(value));
|
||||
|
||||
// QUICK TEMP EXPERIMENT, maybe permanent new feature.
|
||||
// Recognize \xnn as hexadecimal value. Handy for UTF-8 in comment.
|
||||
// Maybe recognize the <0xnn> form that we print.
|
||||
//
|
||||
// # Convert between languages here: https://translate.google.com/ then
|
||||
// # Convert to UTF-8 bytes here: https://codebeautify.org/utf8-converter
|
||||
//
|
||||
// pbeacon delay=0:05 every=0:30 sendto=R0 lat=12.5N long=69.97W comment="\xe3\x82\xa2\xe3\x83\x9e\xe3\x83\x81\xe3\x83\xa5\xe3\x82\xa2\xe7\x84\xa1\xe7\xb7\x9a \xce\xa1\xce\xb1\xce\xb4\xce\xb9\xce\xbf\xce\xb5\xcf\x81\xce\xb1\xcf\x83\xce\xb9\xcf\x84\xce\xb5\xcf\x87\xce\xbd\xce\xb9\xcf\x83\xce\xbc\xcf\x8c\xcf\x82"
|
||||
|
||||
char temp[256];
|
||||
int tlen = 0;
|
||||
|
||||
for (char *p = value; *p != '\0'; ) {
|
||||
if (p[0] == '\\' && p[1] == 'x' && strlen(p) >= 4 && isxdigit(p[2]) && isxdigit(p[3])) {
|
||||
int n = 0;
|
||||
for (int i = 2; i < 4; i++) {
|
||||
n = n * 16;
|
||||
if (islower(p[i])) {
|
||||
n += p[i] - 'a' + 10;
|
||||
}
|
||||
else if (isupper(p[i])) {
|
||||
n += p[i] - 'A' + 10;
|
||||
}
|
||||
else { // must be digit due to isxdigit test above.
|
||||
n += p[i] - '0';
|
||||
}
|
||||
}
|
||||
temp[tlen++] = n;
|
||||
p += 4;
|
||||
}
|
||||
else {
|
||||
temp[tlen++] = *p++;
|
||||
}
|
||||
}
|
||||
temp[tlen] = '\0';
|
||||
strlcpy (value, temp, sizeof(value));
|
||||
|
||||
// end
|
||||
if (strcasecmp(keyword, "DELAY") == 0) {
|
||||
b->delay = parse_interval(value,line);
|
||||
}
|
||||
|
@ -5338,7 +5625,7 @@ static int beacon_options(char *cmd, struct beacon_s *b, int line, struct audio_
|
|||
}
|
||||
else if (value[0] == 'r' || value[0] == 'R') {
|
||||
int n = atoi(value+1);
|
||||
if ( n < 0 || n >= MAX_CHANS || p_audio_config->achan[n].medium == MEDIUM_NONE) {
|
||||
if ( n < 0 || n >= MAX_CHANS || p_audio_config->chan_medium[n] == MEDIUM_NONE) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file, line %d: Simulated receive on channel %d is not valid.\n", line, n);
|
||||
continue;
|
||||
|
@ -5348,7 +5635,7 @@ static int beacon_options(char *cmd, struct beacon_s *b, int line, struct audio_
|
|||
}
|
||||
else if (value[0] == 't' || value[0] == 'T' || value[0] == 'x' || value[0] == 'X') {
|
||||
int n = atoi(value+1);
|
||||
if ( n < 0 || n >= MAX_CHANS || p_audio_config->achan[n].medium == MEDIUM_NONE) {
|
||||
if ( n < 0 || n >= MAX_CHANS || p_audio_config->chan_medium[n] == MEDIUM_NONE) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file, line %d: Send to channel %d is not valid.\n", line, n);
|
||||
continue;
|
||||
|
@ -5359,7 +5646,7 @@ static int beacon_options(char *cmd, struct beacon_s *b, int line, struct audio_
|
|||
}
|
||||
else {
|
||||
int n = atoi(value);
|
||||
if ( n < 0 || n >= MAX_CHANS || p_audio_config->achan[n].medium == MEDIUM_NONE) {
|
||||
if ( n < 0 || n >= MAX_CHANS || p_audio_config->chan_medium[n] == MEDIUM_NONE) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file, line %d: Send to channel %d is not valid.\n", line, n);
|
||||
continue;
|
||||
|
@ -5368,6 +5655,17 @@ static int beacon_options(char *cmd, struct beacon_s *b, int line, struct audio_
|
|||
b->sendto_chan = n;
|
||||
}
|
||||
}
|
||||
else if (strcasecmp(keyword, "SOURCE") == 0) {
|
||||
b->source = strdup(value);
|
||||
for (p = b->source; *p != '\0'; p++) {
|
||||
if (islower(*p)) {
|
||||
*p = toupper(*p); /* silently force upper case. */
|
||||
}
|
||||
}
|
||||
if (strlen(b->source) > 9) {
|
||||
b->source[9] = '\0';
|
||||
}
|
||||
}
|
||||
else if (strcasecmp(keyword, "DEST") == 0) {
|
||||
b->dest = strdup(value);
|
||||
for (p = b->dest; *p != '\0'; p++) {
|
||||
|
@ -5428,8 +5726,30 @@ static int beacon_options(char *cmd, struct beacon_s *b, int line, struct audio_
|
|||
}
|
||||
}
|
||||
else if (strcasecmp(keyword, "ALT") == 0 || strcasecmp(keyword, "ALTITUDE") == 0) {
|
||||
|
||||
char *unit = strpbrk(value, "abcedfghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
if (unit != NULL) {
|
||||
float meters = 0;
|
||||
for (int j=0; j<NUM_UNITS && meters == 0; j++) {
|
||||
if (strcasecmp(units[j].name, unit) == 0) {
|
||||
meters = units[j].meters;
|
||||
}
|
||||
}
|
||||
if (meters == 0) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Line %d: Unrecognized unit '%s' for altitude. Using meter.\n", line, unit);
|
||||
dw_printf ("Try using singular form. e.g. ft or foot rather than feet.\n");
|
||||
b->alt_m = atof(value);
|
||||
}
|
||||
else {
|
||||
// valid unit
|
||||
b->alt_m = atof(value) * meters;
|
||||
}
|
||||
} else {
|
||||
// no unit specified
|
||||
b->alt_m = atof(value);
|
||||
}
|
||||
}
|
||||
else if (strcasecmp(keyword, "ZONE") == 0) {
|
||||
strlcpy(zone, value, sizeof(zone));
|
||||
}
|
||||
|
@ -5504,7 +5824,7 @@ static int beacon_options(char *cmd, struct beacon_s *b, int line, struct audio_
|
|||
}
|
||||
|
||||
/*
|
||||
* Convert UTM coordintes to lat / long.
|
||||
* Convert UTM coordinates to lat / long.
|
||||
*/
|
||||
if (strlen(zone) > 0 || easting != G_UNKNOWN || northing != G_UNKNOWN) {
|
||||
|
||||
|
@ -5571,7 +5891,7 @@ static int beacon_options(char *cmd, struct beacon_s *b, int line, struct audio_
|
|||
|
||||
if (b->sendto_type == SENDTO_XMIT) {
|
||||
|
||||
if ( b->sendto_chan < 0 || b->sendto_chan >= MAX_CHANS || p_audio_config->achan[b->sendto_chan].medium == MEDIUM_NONE) {
|
||||
if ( b->sendto_chan < 0 || b->sendto_chan >= MAX_CHANS || p_audio_config->chan_medium[b->sendto_chan] == MEDIUM_NONE) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Config file, line %d: Send to channel %d is not valid.\n", line, b->sendto_chan);
|
||||
return (0);
|
||||
|
|
43
src/config.h
43
src/config.h
|
@ -30,11 +30,31 @@ enum sendto_type_e { SENDTO_XMIT, SENDTO_IGATE, SENDTO_RECV };
|
|||
|
||||
|
||||
#define MAX_BEACONS 30
|
||||
#define MAX_KISS_TCP_PORTS (MAX_CHANS+1)
|
||||
|
||||
struct misc_config_s {
|
||||
|
||||
int agwpe_port; /* Port number for the "AGW TCPIP Socket Interface" */
|
||||
int kiss_port; /* Port number for the "TCP KISS" protocol. */
|
||||
int agwpe_port; /* TCP Port number for the "AGW TCPIP Socket Interface" */
|
||||
|
||||
// Previously we allowed only a single TCP port for KISS.
|
||||
// An increasing number of people want to run multiple radios.
|
||||
// Unfortunately, most applications don't know how to deal with multi-radio TNCs.
|
||||
// They ignore the channel on receive and always transmit to channel 0.
|
||||
// Running multiple instances of direwolf is a work-around but this leads to
|
||||
// more complex configuration and we lose the cross-channel digipeating capability.
|
||||
// In release 1.7 we add a new feature to assign a single radio channel to a TCP port.
|
||||
// e.g.
|
||||
// KISSPORT 8001 # default, all channels. Radio channel = KISS channel.
|
||||
//
|
||||
// KISSPORT 7000 0 # Only radio channel 0 for receive.
|
||||
// # Transmit to radio channel 0, ignoring KISS channel.
|
||||
//
|
||||
// KISSPORT 7001 1 # Only radio channel 1 for receive. KISS channel set to 0.
|
||||
// # Transmit to radio channel 1, ignoring KISS channel.
|
||||
|
||||
int kiss_port[MAX_KISS_TCP_PORTS]; /* TCP Port number for the "TCP KISS" protocol. */
|
||||
int kiss_chan[MAX_KISS_TCP_PORTS]; /* Radio Channel number for this port or -1 for all. */
|
||||
|
||||
int kiss_copy; /* Data from network KISS client is copied to all others. */
|
||||
int enable_kiss_pt; /* Enable pseudo terminal for KISS. */
|
||||
/* Want this to be off by default because it hangs */
|
||||
|
@ -56,7 +76,8 @@ struct misc_config_s {
|
|||
|
||||
char gpsnmea_port[20]; /* Serial port name for reading NMEA sentences from GPS. */
|
||||
/* e.g. COM22, /dev/ttyACM0 */
|
||||
/* Currently no option for setting non-standard speed. */
|
||||
|
||||
int gpsnmea_speed; /* Speed for above, baud, default 4800. */
|
||||
|
||||
char gpsd_host[20]; /* Host for gpsd server. */
|
||||
/* e.g. localhost, 192.168.1.2 */
|
||||
|
@ -77,17 +98,20 @@ struct misc_config_s {
|
|||
|
||||
int waypoint_formats; /* Which sentence formats should be generated? */
|
||||
|
||||
#define WPT_FORMAT_NMEA_GENERIC 0x01 /* N $GPWPT */
|
||||
#define WPT_FORMAT_GARMIN 0x02 /* G $PGRMW */
|
||||
#define WPT_FORMAT_MAGELLAN 0x04 /* M $PMGNWPL */
|
||||
#define WPT_FORMAT_KENWOOD 0x08 /* K $PKWDWPL */
|
||||
#define WPT_FORMAT_AIS 0x10 /* A !AIVDM */
|
||||
#define WPL_FORMAT_NMEA_GENERIC 0x01 /* N $GPWPL */
|
||||
#define WPL_FORMAT_GARMIN 0x02 /* G $PGRMW */
|
||||
#define WPL_FORMAT_MAGELLAN 0x04 /* M $PMGNWPL */
|
||||
#define WPL_FORMAT_KENWOOD 0x08 /* K $PKWDWPL */
|
||||
#define WPL_FORMAT_AIS 0x10 /* A !AIVDM */
|
||||
|
||||
|
||||
int log_daily_names; /* True to generate new log file each day. */
|
||||
|
||||
char log_path[80]; /* Either directory or full file name depending on above. */
|
||||
|
||||
int dns_sd_enabled; /* DNS Service Discovery announcement enabled. */
|
||||
char dns_sd_name[64]; /* Name announced on dns-sd; defaults to "Dire Wolf on <hostname>" */
|
||||
|
||||
int sb_configured; /* TRUE if SmartBeaconing is configured. */
|
||||
int sb_fast_speed; /* MPH */
|
||||
int sb_fast_rate; /* seconds */
|
||||
|
@ -160,6 +184,9 @@ struct misc_config_s {
|
|||
|
||||
time_t next; /* Unix time to transmit next one. */
|
||||
|
||||
char *source; /* NULL or explicit AX.25 source address to use */
|
||||
/* instead of the mycall value for the channel. */
|
||||
|
||||
char *dest; /* NULL or explicit AX.25 destination to use */
|
||||
/* instead of the software version such as APDW11. */
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -26,9 +26,9 @@ typedef struct decode_aprs_s {
|
|||
|
||||
char g_src[AX25_MAX_ADDR_LEN];
|
||||
|
||||
char g_msg_type[60]; /* APRS data type. Telemetry descriptions get pretty long. */
|
||||
/* Putting msg in the name was a poor choice because */
|
||||
/* "message" has a specific meaning. Rename it someday. */
|
||||
char g_dest[AX25_MAX_ADDR_LEN];
|
||||
|
||||
char g_data_type_desc[100]; /* APRS data type description. Telemetry descriptions get pretty long. */
|
||||
|
||||
char g_symbol_table; /* The Symbol Table Identifier character selects one */
|
||||
/* of the two Symbol Tables, or it may be used as */
|
||||
|
@ -77,9 +77,13 @@ typedef struct decode_aprs_s {
|
|||
message_subtype_directed_query
|
||||
} g_message_subtype; /* Various cases of the overloaded "message." */
|
||||
|
||||
char g_message_number[8]; /* Message number. Should be 1 - 5 characters if used. */
|
||||
char g_message_number[8]; /* Message number. Should be 1 - 5 alphanumeric characters if used. */
|
||||
/* Addendum 1.1 has new format {mm} or {mm}aa with only two */
|
||||
/* characters for message number and an ack riding piggyback. */
|
||||
|
||||
float g_speed_mph; /* Speed in MPH. */
|
||||
/* The APRS transmission uses knots so watch out for */
|
||||
/* conversions when sending and receiving APRS packets. */
|
||||
|
||||
float g_course; /* 0 = North, 90 = East, etc. */
|
||||
|
||||
|
@ -94,6 +98,9 @@ typedef struct decode_aprs_s {
|
|||
float g_range; /* Precomputed radio range in miles. */
|
||||
|
||||
float g_altitude_ft; /* Feet above median sea level. */
|
||||
/* I used feet here because the APRS specification */
|
||||
/* has units of feet for alititude. Meters would be */
|
||||
/* more natural to the other 96% of the world. */
|
||||
|
||||
char g_mfr[80]; /* Manufacturer or application. */
|
||||
|
||||
|
@ -135,7 +142,7 @@ typedef struct decode_aprs_s {
|
|||
|
||||
|
||||
|
||||
extern void decode_aprs (decode_aprs_t *A, packet_t pp, int quiet);
|
||||
extern void decode_aprs (decode_aprs_t *A, packet_t pp, int quiet, int third_party);
|
||||
|
||||
extern void decode_aprs_print (decode_aprs_t *A);
|
||||
|
||||
|
|
169
src/demod.c
169
src/demod.c
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
||||
//
|
||||
// Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2019 John Langner, WB2OSZ
|
||||
// Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2019, 2021 John Langner, WB2OSZ
|
||||
//
|
||||
// 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
|
||||
|
@ -60,10 +60,6 @@
|
|||
static struct audio_s *save_audio_config_p;
|
||||
|
||||
|
||||
// TODO: temp experiment.
|
||||
|
||||
|
||||
static int zerostuff = 1; // temp experiment.
|
||||
|
||||
// Current state of all the decoders.
|
||||
|
||||
|
@ -106,7 +102,7 @@ int demod_init (struct audio_s *pa)
|
|||
|
||||
for (chan = 0; chan < MAX_CHANS; chan++) {
|
||||
|
||||
if (save_audio_config_p->achan[chan].medium == MEDIUM_RADIO) {
|
||||
if (save_audio_config_p->chan_medium[chan] == MEDIUM_RADIO) {
|
||||
|
||||
char *p;
|
||||
char just_letters[16];
|
||||
|
@ -199,45 +195,56 @@ int demod_init (struct audio_s *pa)
|
|||
|
||||
/*
|
||||
* Pick a good default demodulator if none specified.
|
||||
* Previously, we had "D" optimized for 300 bps.
|
||||
* Gone in 1.7 so it is always "A+".
|
||||
*/
|
||||
if (num_letters == 0) {
|
||||
strlcpy (just_letters, "A", sizeof(just_letters));
|
||||
num_letters = strlen(just_letters);
|
||||
|
||||
if (save_audio_config_p->achan[chan].baud < 600) {
|
||||
|
||||
/* This has been optimized for 300 baud. */
|
||||
|
||||
strlcpy (just_letters, "D", sizeof(just_letters));
|
||||
|
||||
}
|
||||
else {
|
||||
#if __arm__
|
||||
/* We probably don't have a lot of CPU power available. */
|
||||
/* Previously we would use F if possible otherwise fall back to A. */
|
||||
|
||||
/* In version 1.2, new default is E+ /3. */
|
||||
strlcpy (just_letters, "E", sizeof(just_letters)); // version 1.2 now E.
|
||||
if (have_plus != -1) have_plus = 1; // Add as default for version 1.2
|
||||
// If not explicitly turned off.
|
||||
}
|
||||
|
||||
/*
|
||||
* Special case for ARM.
|
||||
* The higher end ARM chips have loads of power but many people
|
||||
* are using a single core Pi Zero or similar.
|
||||
* (I'm still using a model 1 for my digipeater/IGate!)
|
||||
* Decreasing CPU requirement has a negligible impact on decoding performance.
|
||||
*
|
||||
* atest -PA- 01_Track_1.wav --> 1002 packets decoded.
|
||||
* atest -PA- -D3 01_Track_1.wav --> 997 packets decoded.
|
||||
*
|
||||
* Someone concerned about 1/2 of one percent difference can add "-D 1"
|
||||
*/
|
||||
#if __arm__
|
||||
if (save_audio_config_p->achan[chan].decimate == 0) {
|
||||
if (save_audio_config_p->adev[ACHAN2ADEV(chan)].samples_per_sec > 40000) {
|
||||
save_audio_config_p->achan[chan].decimate = 3;
|
||||
}
|
||||
}
|
||||
#else
|
||||
strlcpy (just_letters, "E", sizeof(just_letters)); // version 1.2 changed C to E.
|
||||
if (have_plus != -1) have_plus = 1; // Add as default for version 1.2
|
||||
// If not explicitly turned off.
|
||||
#endif
|
||||
}
|
||||
num_letters = 1;
|
||||
|
||||
/*
|
||||
* Number of filter taps is proportional to number of audio samples in a "symbol" duration.
|
||||
* These can get extremely large for low speeds, e.g. 300 baud.
|
||||
* In this case, increase the decimation ration. Crude approximation. Could be improved.
|
||||
*/
|
||||
if (save_audio_config_p->achan[chan].decimate == 0 &&
|
||||
save_audio_config_p->adev[ACHAN2ADEV(chan)].samples_per_sec > 40000 &&
|
||||
save_audio_config_p->achan[chan].baud < 600) {
|
||||
|
||||
// Avoid enormous number of filter taps.
|
||||
|
||||
save_audio_config_p->achan[chan].decimate = 3;
|
||||
}
|
||||
|
||||
|
||||
assert (num_letters == (int)(strlen(just_letters)));
|
||||
|
||||
/*
|
||||
* Put it back together again.
|
||||
*/
|
||||
assert (num_letters == (int)(strlen(just_letters)));
|
||||
|
||||
/* At this point, have_plus can have 3 values: */
|
||||
/* 1 = turned on, either explicitly or by applied default */
|
||||
|
@ -286,7 +293,7 @@ int demod_init (struct audio_s *pa)
|
|||
|
||||
if (save_audio_config_p->achan[chan].decimate == 0) {
|
||||
save_audio_config_p->achan[chan].decimate = 1;
|
||||
if (strchr (just_letters, 'D') != NULL && save_audio_config_p->adev[ACHAN2ADEV(chan)].samples_per_sec > 40000) {
|
||||
if (strchr (just_letters, 'B') != NULL && save_audio_config_p->adev[ACHAN2ADEV(chan)].samples_per_sec > 40000) {
|
||||
save_audio_config_p->achan[chan].decimate = 3;
|
||||
}
|
||||
}
|
||||
|
@ -492,7 +499,7 @@ int demod_init (struct audio_s *pa)
|
|||
// In versions 1.4 and 1.5, V.26 "Alternative A" was used.
|
||||
// years later, I discover that the MFJ-2400 used "Alternative B."
|
||||
// It looks like the other two manufacturers use the same but we
|
||||
// can't be sure until we find one for compatbility testing.
|
||||
// can't be sure until we find one for compatibility testing.
|
||||
|
||||
// In version 1.6 we add a choice for the user.
|
||||
// If neither one was explicitly specified, print a message and take
|
||||
|
@ -503,8 +510,8 @@ int demod_init (struct audio_s *pa)
|
|||
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Two incompatible versions of 2400 bps QPSK are now available.\n");
|
||||
dw_printf ("For compatbility with direwolf <= 1.5, use 'V26A' modem option in config file.\n");
|
||||
dw_printf ("For compatbility MFJ-2400 use 'V26B' modem option in config file.\n");
|
||||
dw_printf ("For compatibility with direwolf <= 1.5, use 'V26A' modem option in config file.\n");
|
||||
dw_printf ("For compatibility MFJ-2400 use 'V26B' modem option in config file.\n");
|
||||
dw_printf ("Command line options -j and -J can be used for channel 0.\n");
|
||||
dw_printf ("For more information, read the Dire Wolf User Guide and\n");
|
||||
dw_printf ("2400-4800-PSK-for-APRS-Packet-Radio.pdf.\n");
|
||||
|
@ -665,12 +672,6 @@ int demod_init (struct audio_s *pa)
|
|||
strlcpy (save_audio_config_p->achan[chan].profiles, "+", sizeof(save_audio_config_p->achan[chan].profiles));
|
||||
}
|
||||
|
||||
|
||||
#ifdef TUNE_ZEROSTUFF
|
||||
zerostuff = TUNE_ZEROSTUFF;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* We need a minimum number of audio samples per bit time for good performance.
|
||||
* Easier to check here because demod_9600_init might have an adjusted sample rate.
|
||||
|
@ -685,26 +686,32 @@ int demod_init (struct audio_s *pa)
|
|||
|
||||
if (save_audio_config_p->achan[chan].upsample == 0) {
|
||||
|
||||
if (ratio < 5) {
|
||||
if (ratio < 4) {
|
||||
|
||||
// example: 44100 / 9600 is 4.59
|
||||
// Big improvement with x2.
|
||||
// x4 seems to work the best.
|
||||
// The other parameters are not as touchy.
|
||||
// Might reduce on ARM if it takes too much CPU power.
|
||||
// This is extreme.
|
||||
// No one should be using a sample rate this low but
|
||||
// amazingly a recording with 22050 rate can be decoded.
|
||||
// 3 and 4 are the same. Need more tests.
|
||||
|
||||
save_audio_config_p->achan[chan].upsample = 4;
|
||||
}
|
||||
else if (ratio < 5) {
|
||||
|
||||
// example: 44100 / 9600 is 4.59
|
||||
// 3 is slightly better than 2 or 4.
|
||||
|
||||
save_audio_config_p->achan[chan].upsample = 3;
|
||||
}
|
||||
else if (ratio < 10) {
|
||||
|
||||
// 48000 / 9600 is 5.00
|
||||
// Need more reasearch. Treat like above for now.
|
||||
// example: 48000 / 9600 = 5
|
||||
// 3 is slightly better than 2 or 4.
|
||||
|
||||
save_audio_config_p->achan[chan].upsample = 4;
|
||||
save_audio_config_p->achan[chan].upsample = 3;
|
||||
}
|
||||
else if (ratio < 15) {
|
||||
|
||||
// ...
|
||||
// ... guessing
|
||||
|
||||
save_audio_config_p->achan[chan].upsample = 2;
|
||||
}
|
||||
|
@ -775,7 +782,8 @@ int demod_init (struct audio_s *pa)
|
|||
}
|
||||
|
||||
demod_9600_init (save_audio_config_p->achan[chan].modem_type,
|
||||
save_audio_config_p->achan[chan].upsample * save_audio_config_p->adev[ACHAN2ADEV(chan)].samples_per_sec,
|
||||
save_audio_config_p->adev[ACHAN2ADEV(chan)].samples_per_sec,
|
||||
save_audio_config_p->achan[chan].upsample,
|
||||
save_audio_config_p->achan[chan].baud, D);
|
||||
|
||||
if (strchr(save_audio_config_p->achan[chan].profiles, '+') != NULL) {
|
||||
|
@ -796,10 +804,23 @@ int demod_init (struct audio_s *pa)
|
|||
|
||||
} /* switch on modulation type. */
|
||||
|
||||
} /* if channel number is valid */
|
||||
} /* if channel medium is radio */
|
||||
|
||||
// FIXME dw_printf ("-------- end of loop for chn %d \n", chan);
|
||||
|
||||
} /* for chan ... */
|
||||
|
||||
// Now the virtual channels. FIXME: could be single loop.
|
||||
|
||||
for (chan = MAX_CHANS; chan < MAX_TOTAL_CHANS; chan++) {
|
||||
|
||||
// FIXME dw_printf ("-------- virtual channel loop %d \n", chan);
|
||||
|
||||
if (chan == save_audio_config_p->igate_vchannel) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("Channel %d: IGate virtual channel.\n", chan);
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
||||
|
@ -821,7 +842,7 @@ int demod_init (struct audio_s *pa)
|
|||
* Global In: save_audio_config_p->adev[ACHAN2ADEV(chan)].bits_per_sample - So we know whether to
|
||||
* read 1 or 2 bytes from audio stream.
|
||||
*
|
||||
* Description: Grab 1 or two btyes depending on data source.
|
||||
* Description: Grab 1 or two bytes depending on data source.
|
||||
*
|
||||
* When processing stereo, the caller will call this
|
||||
* at twice the normal rate to obtain alternating left
|
||||
|
@ -836,7 +857,7 @@ __attribute__((hot))
|
|||
int demod_get_sample (int a)
|
||||
{
|
||||
int x1, x2;
|
||||
signed short sam; /* short to force sign extention. */
|
||||
signed short sam; /* short to force sign extension. */
|
||||
|
||||
|
||||
assert (save_audio_config_p->adev[a].bits_per_sample == 8 || save_audio_config_p->adev[a].bits_per_sample == 16);
|
||||
|
@ -913,7 +934,7 @@ __attribute__((hot))
|
|||
void demod_process_sample (int chan, int subchan, int sam)
|
||||
{
|
||||
float fsam;
|
||||
int k;
|
||||
//int k;
|
||||
|
||||
|
||||
struct demodulator_state_s *D;
|
||||
|
@ -1005,47 +1026,7 @@ void demod_process_sample (int chan, int subchan, int sam)
|
|||
case MODEM_AIS:
|
||||
default:
|
||||
|
||||
if (zerostuff) {
|
||||
/* Literature says this is better if followed */
|
||||
/* by appropriate low pass filter. */
|
||||
/* So far, both are same in tests with different */
|
||||
/* optimal low pass filter parameters. */
|
||||
|
||||
for (k=1; k<save_audio_config_p->achan[chan].upsample; k++) {
|
||||
demod_9600_process_sample (chan, 0, D);
|
||||
}
|
||||
demod_9600_process_sample (chan, sam * save_audio_config_p->achan[chan].upsample, D);
|
||||
}
|
||||
else {
|
||||
|
||||
/* Linear interpolation. */
|
||||
static int prev_sam;
|
||||
|
||||
switch (save_audio_config_p->achan[chan].upsample) {
|
||||
case 1:
|
||||
demod_9600_process_sample (chan, sam, D);
|
||||
break;
|
||||
case 2:
|
||||
demod_9600_process_sample (chan, (prev_sam + sam) / 2, D);
|
||||
demod_9600_process_sample (chan, sam, D);
|
||||
break;
|
||||
case 3:
|
||||
demod_9600_process_sample (chan, (2 * prev_sam + sam) / 3, D);
|
||||
demod_9600_process_sample (chan, (prev_sam + 2 * sam) / 3, D);
|
||||
demod_9600_process_sample (chan, sam, D);
|
||||
break;
|
||||
case 4:
|
||||
demod_9600_process_sample (chan, (3 * prev_sam + sam) / 4, D);
|
||||
demod_9600_process_sample (chan, (prev_sam + sam) / 2, D);
|
||||
demod_9600_process_sample (chan, (prev_sam + 3 * sam) / 4, D);
|
||||
demod_9600_process_sample (chan, sam, D);
|
||||
break;
|
||||
default:
|
||||
assert (0);
|
||||
break;
|
||||
}
|
||||
prev_sam = sam;
|
||||
}
|
||||
demod_9600_process_sample (chan, sam, save_audio_config_p->achan[chan].upsample, D);
|
||||
break;
|
||||
|
||||
} /* switch modem_type */
|
||||
|
|
198
src/demod_9600.c
198
src/demod_9600.c
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
||||
//
|
||||
// Copyright (C) 2011, 2012, 2013, 2015, 2019 John Langner, WB2OSZ
|
||||
// Copyright (C) 2011, 2012, 2013, 2015, 2019, 2021 John Langner, WB2OSZ
|
||||
//
|
||||
// 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
|
||||
|
@ -25,7 +25,8 @@
|
|||
*
|
||||
* Module: demod_9600.c
|
||||
*
|
||||
* Purpose: Demodulator for scrambled baseband encoding.
|
||||
* Purpose: Demodulator for baseband signal.
|
||||
* This is used for AX.25 (with scrambling) and IL2P without.
|
||||
*
|
||||
* Input: Audio samples from either a file or the "sound card."
|
||||
*
|
||||
|
@ -45,12 +46,14 @@
|
|||
#include <ctype.h>
|
||||
|
||||
// Fine tuning for different demodulator types.
|
||||
// Don't remove this section. It is here for a reason.
|
||||
|
||||
#define DCD_THRESH_ON 32 // Hysteresis: Can miss 0 out of 32 for detecting lock.
|
||||
// This is best for actual on-the-air signals.
|
||||
// Still too many brief false matches.
|
||||
#define DCD_THRESH_OFF 8 // Might want a little more fine tuning.
|
||||
#define DCD_GOOD_WIDTH 1024 // No more than 1024!!!
|
||||
|
||||
#include "fsk_demod_state.h" // Values above override defaults.
|
||||
|
||||
#include "tune.h"
|
||||
|
@ -125,9 +128,12 @@ static inline float agc (float in, float fast_attack, float slow_decay, float *p
|
|||
*
|
||||
* Inputs: modem_type - Determines whether scrambling is used.
|
||||
*
|
||||
* samples_per_sec - Number of samples per second.
|
||||
* Might be upsampled in hopes of
|
||||
* reducing the PLL jitter.
|
||||
* samples_per_sec - Number of samples per second for audio.
|
||||
*
|
||||
* upsample - Factor to upsample the incoming stream.
|
||||
* After a lot of experimentation, I discovered that
|
||||
* it works better if the data is upsampled.
|
||||
* This reduces the jitter for PLL synchronization.
|
||||
*
|
||||
* baud - Data rate in bits per second.
|
||||
*
|
||||
|
@ -137,10 +143,13 @@ static inline float agc (float in, float fast_attack, float slow_decay, float *p
|
|||
*
|
||||
*----------------------------------------------------------------*/
|
||||
|
||||
void demod_9600_init (enum modem_t modem_type, int samples_per_sec, int baud, struct demodulator_state_s *D)
|
||||
void demod_9600_init (enum modem_t modem_type, int original_sample_rate, int upsample, int baud, struct demodulator_state_s *D)
|
||||
{
|
||||
float fc;
|
||||
int j;
|
||||
if (upsample < 1) upsample = 1;
|
||||
if (upsample > 4) upsample = 4;
|
||||
|
||||
|
||||
memset (D, 0, sizeof(struct demodulator_state_s));
|
||||
D->modem_type = modem_type;
|
||||
|
@ -155,12 +164,13 @@ void demod_9600_init (enum modem_t modem_type, int samples_per_sec, int baud, st
|
|||
// case 'L': // upsample x4 with filtering.
|
||||
|
||||
|
||||
D->lp_filter_len_bits = 1.0;
|
||||
D->lp_filter_len_bits = 1.0; // -U4 = 61 4.59 samples/symbol
|
||||
|
||||
// Works best with odd number in some tests. Even is better in others.
|
||||
//D->lp_filter_size = ((int) (0.5f * ( D->lp_filter_len_bits * (float)samples_per_sec / (float)baud ))) * 2 + 1;
|
||||
//D->lp_filter_size = ((int) (0.5f * ( D->lp_filter_len_bits * (float)original_sample_rate / (float)baud ))) * 2 + 1;
|
||||
|
||||
D->lp_filter_size = (int) (( D->lp_filter_len_bits * (float)samples_per_sec / baud) + 0.5f);
|
||||
// Just round to nearest integer.
|
||||
D->lp_filter_size = (int) (( D->lp_filter_len_bits * (float)original_sample_rate / baud) + 0.5f);
|
||||
|
||||
D->lp_window = BP_WINDOW_COSINE;
|
||||
|
||||
|
@ -185,8 +195,11 @@ void demod_9600_init (enum modem_t modem_type, int samples_per_sec, int baud, st
|
|||
dw_printf ("samples per bit = %.1f\n", (double)samples_per_sec / baud);
|
||||
#endif
|
||||
|
||||
|
||||
// PLL needs to use the upsampled rate.
|
||||
|
||||
D->pll_step_per_sample =
|
||||
(int) round(TICKS_PER_PLL_CYCLE * (double) baud / (double)samples_per_sec);
|
||||
(int) round(TICKS_PER_PLL_CYCLE * (double) baud / (double)(original_sample_rate * upsample));
|
||||
|
||||
|
||||
#ifdef TUNE_LP_WINDOW
|
||||
|
@ -217,13 +230,87 @@ void demod_9600_init (enum modem_t modem_type, int samples_per_sec, int baud, st
|
|||
D->pll_searching_inertia = TUNE_PLL_SEARCHING;
|
||||
#endif
|
||||
|
||||
fc = (float)baud * D->lpf_baud / (float)samples_per_sec;
|
||||
// Initial filter (before scattering) is based on upsampled rate.
|
||||
|
||||
fc = (float)baud * D->lpf_baud / (float)(original_sample_rate * upsample);
|
||||
|
||||
//dw_printf ("demod_9600_init: call gen_lowpass(fc=%.2f, , size=%d, )\n", fc, D->lp_filter_size);
|
||||
|
||||
(void)gen_lowpass (fc, D->lp_filter, D->lp_filter_size, D->lp_window, 0);
|
||||
gen_lowpass (fc, D->u.bb.lp_filter, D->lp_filter_size * upsample, D->lp_window);
|
||||
|
||||
// New in 1.7 -
|
||||
// Use a polyphase filter to reduce the CPU load.
|
||||
// Originally I used zero stuffing to upsample.
|
||||
// Here is the general idea.
|
||||
//
|
||||
// Suppose the input samples are 1 2 3 4 5 6 7 8 9 ...
|
||||
// Filter coefficients are a b c d e f g h i ...
|
||||
//
|
||||
// With original sampling rate, the filtering would involve multiplying and adding:
|
||||
//
|
||||
// 1a 2b 3c 4d 5e 6f ...
|
||||
//
|
||||
// When upsampling by 3, each of these would need to be evaluated
|
||||
// for each audio sample:
|
||||
//
|
||||
// 1a 0b 0c 2d 0e 0f 3g 0h 0i ...
|
||||
// 0a 1b 0c 0d 2e 0f 0g 3h 0i ...
|
||||
// 0a 0b 1c 0d 0e 2f 0g 0h 3i ...
|
||||
//
|
||||
// 2/3 of the multiplies are always by a stuffed zero.
|
||||
// We can do this more efficiently by removing them.
|
||||
//
|
||||
// 1a 2d 3g ...
|
||||
// 1b 2e 3h ...
|
||||
// 1c 2f 3i ...
|
||||
//
|
||||
// We scatter the original filter across multiple shorter filters.
|
||||
// Each input sample cycles around them to produce the upsampled rate.
|
||||
//
|
||||
// a d g ...
|
||||
// b e h ...
|
||||
// c f i ...
|
||||
//
|
||||
// There are countless sources of information DSP but this one is unique
|
||||
// in that it is a college course that mentions APRS.
|
||||
// https://www2.eecs.berkeley.edu/Courses/EE123
|
||||
//
|
||||
// Was the effort worthwhile? Times on an RPi 3.
|
||||
//
|
||||
// command: atest -B9600 ~/walkabout9600[abc]-compressed*.wav
|
||||
//
|
||||
// These are 3 recordings of a portable system being carried out of
|
||||
// range and back in again. It is a real world test for weak signals.
|
||||
//
|
||||
// options num decoded seconds x realtime
|
||||
// 1.6 1.7 1.6 1.7 1.6 1.7
|
||||
// --- --- --- --- --- ---
|
||||
// -P- 171 172 23.928 17.967 14.9 19.9
|
||||
// -P+ 180 180 54.688 48.772 6.5 7.3
|
||||
// -P- -F1 177 178 32.686 26.517 10.9 13.5
|
||||
//
|
||||
// So, it turns out that -P+ doesn't have a dramatic improvement, only
|
||||
// around 4%, for drastically increased CPU requirements.
|
||||
// Maybe we should turn that off by default, especially for ARM.
|
||||
//
|
||||
|
||||
int k = 0;
|
||||
for (int i = 0; i < D->lp_filter_size; i++) {
|
||||
D->u.bb.lp_polyphase_1[i] = D->u.bb.lp_filter[k++];
|
||||
if (upsample >= 2) {
|
||||
D->u.bb.lp_polyphase_2[i] = D->u.bb.lp_filter[k++];
|
||||
if (upsample >= 3) {
|
||||
D->u.bb.lp_polyphase_3[i] = D->u.bb.lp_filter[k++];
|
||||
if (upsample >= 4) {
|
||||
D->u.bb.lp_polyphase_4[i] = D->u.bb.lp_filter[k++];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Version 1.2: Experiment with different slicing levels. */
|
||||
// Really didn't help that much because we should have a symmetrical signal.
|
||||
|
||||
for (j = 0; j < MAX_SUBCHANS; j++) {
|
||||
slice_point[j] = 0.02f * (j - 0.5f * (MAX_SUBCHANS-1));
|
||||
|
@ -259,7 +346,7 @@ void demod_9600_init (enum modem_t modem_type, int samples_per_sec, int baud, st
|
|||
* been distorted by going thru voice transceivers not
|
||||
* intended to pass this sort of "audio" signal.
|
||||
*
|
||||
* Data is "scrambled" to reduce the amount of DC bias.
|
||||
* For G3RUH mode, data is "scrambled" to reduce the amount of DC bias.
|
||||
* The data stream must be unscrambled at the receiving end.
|
||||
*
|
||||
* We also have a digital phase locked loop (PLL)
|
||||
|
@ -276,6 +363,9 @@ void demod_9600_init (enum modem_t modem_type, int samples_per_sec, int baud, st
|
|||
* of the function to be called for each bit recovered
|
||||
* from the demodulator. For now, it's simply hard-coded.
|
||||
*
|
||||
* After experimentation, I found that this works better if
|
||||
* the original signal is upsampled by 2x or even 4x.
|
||||
*
|
||||
* References: 9600 Baud Packet Radio Modem Design
|
||||
* http://www.amsat.org/amsat/articles/g3ruh/109.html
|
||||
*
|
||||
|
@ -290,63 +380,57 @@ void demod_9600_init (enum modem_t modem_type, int samples_per_sec, int baud, st
|
|||
|
||||
inline static void nudge_pll (int chan, int subchan, int slice, float demod_out, struct demodulator_state_s *D);
|
||||
|
||||
__attribute__((hot))
|
||||
void demod_9600_process_sample (int chan, int sam, struct demodulator_state_s *D)
|
||||
{
|
||||
static void process_filtered_sample (int chan, float fsam, struct demodulator_state_s *D);
|
||||
|
||||
|
||||
__attribute__((hot))
|
||||
void demod_9600_process_sample (int chan, int sam, int upsample, struct demodulator_state_s *D)
|
||||
{
|
||||
float fsam;
|
||||
float amp;
|
||||
float demod_out;
|
||||
|
||||
#if DEBUG4
|
||||
static FILE *demod_log_fp = NULL;
|
||||
static int log_file_seq = 0; /* Part of log file name */
|
||||
#endif
|
||||
|
||||
|
||||
int subchan = 0;
|
||||
int demod_data; /* Still scrambled. */
|
||||
|
||||
|
||||
assert (chan >= 0 && chan < MAX_CHANS);
|
||||
assert (subchan >= 0 && subchan < MAX_SUBCHANS);
|
||||
|
||||
|
||||
/*
|
||||
* Filters use last 'filter_size' samples.
|
||||
*
|
||||
* First push the older samples down.
|
||||
*
|
||||
* Finally, put the most recent at the beginning.
|
||||
*
|
||||
* Future project? Rather than shifting the samples,
|
||||
* it might be faster to add another variable to keep
|
||||
* track of the most recent sample and change the
|
||||
* indexing in the later loops that multipy and add.
|
||||
*/
|
||||
|
||||
/* Scale to nice number for convenience. */
|
||||
/* Consistent with the AFSK demodulator, we'd like to use */
|
||||
/* only half of the dynamic range to have some headroom. */
|
||||
/* i.e. input range +-16k becomes +-1 here and is */
|
||||
/* displayed in the heard line as audio level 100. */
|
||||
|
||||
fsam = sam / 16384.0;
|
||||
fsam = (float)sam / 16384.0f;
|
||||
|
||||
#if defined(TUNE_ZEROSTUFF) && TUNE_ZEROSTUFF == 0
|
||||
// experiment - no filtering.
|
||||
// Low pass filter
|
||||
push_sample (fsam, D->u.bb.audio_in, D->lp_filter_size);
|
||||
|
||||
amp = fsam;
|
||||
fsam = convolve (D->u.bb.audio_in, D->u.bb.lp_polyphase_1, D->lp_filter_size);
|
||||
process_filtered_sample (chan, fsam, D);
|
||||
if (upsample >= 2) {
|
||||
fsam = convolve (D->u.bb.audio_in, D->u.bb.lp_polyphase_2, D->lp_filter_size);
|
||||
process_filtered_sample (chan, fsam, D);
|
||||
if (upsample >= 3) {
|
||||
fsam = convolve (D->u.bb.audio_in, D->u.bb.lp_polyphase_3, D->lp_filter_size);
|
||||
process_filtered_sample (chan, fsam, D);
|
||||
if (upsample >= 4) {
|
||||
fsam = convolve (D->u.bb.audio_in, D->u.bb.lp_polyphase_4, D->lp_filter_size);
|
||||
process_filtered_sample (chan, fsam, D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
push_sample (fsam, D->raw_cb, D->lp_filter_size);
|
||||
|
||||
/*
|
||||
* Low pass filter to reduce noise yet pass the data.
|
||||
*/
|
||||
__attribute__((hot))
|
||||
static void process_filtered_sample (int chan, float fsam, struct demodulator_state_s *D)
|
||||
{
|
||||
|
||||
amp = convolve (D->raw_cb, D->lp_filter, D->lp_filter_size);
|
||||
#endif
|
||||
int subchan = 0;
|
||||
|
||||
/*
|
||||
* Version 1.2: Capture the post-filtering amplitude for display.
|
||||
|
@ -359,18 +443,18 @@ void demod_9600_process_sample (int chan, int sam, struct demodulator_state_s *D
|
|||
|
||||
// TODO: probably no need for this. Just use D->m_peak, D->m_valley
|
||||
|
||||
if (amp >= D->alevel_mark_peak) {
|
||||
D->alevel_mark_peak = amp * D->quick_attack + D->alevel_mark_peak * (1.0f - D->quick_attack);
|
||||
if (fsam >= D->alevel_mark_peak) {
|
||||
D->alevel_mark_peak = fsam * D->quick_attack + D->alevel_mark_peak * (1.0f - D->quick_attack);
|
||||
}
|
||||
else {
|
||||
D->alevel_mark_peak = amp * D->sluggish_decay + D->alevel_mark_peak * (1.0f - D->sluggish_decay);
|
||||
D->alevel_mark_peak = fsam * D->sluggish_decay + D->alevel_mark_peak * (1.0f - D->sluggish_decay);
|
||||
}
|
||||
|
||||
if (amp <= D->alevel_space_peak) {
|
||||
D->alevel_space_peak = amp * D->quick_attack + D->alevel_space_peak * (1.0f - D->quick_attack);
|
||||
if (fsam <= D->alevel_space_peak) {
|
||||
D->alevel_space_peak = fsam * D->quick_attack + D->alevel_space_peak * (1.0f - D->quick_attack);
|
||||
}
|
||||
else {
|
||||
D->alevel_space_peak = amp * D->sluggish_decay + D->alevel_space_peak * (1.0f - D->sluggish_decay);
|
||||
D->alevel_space_peak = fsam * D->sluggish_decay + D->alevel_space_peak * (1.0f - D->sluggish_decay);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -381,12 +465,14 @@ void demod_9600_process_sample (int chan, int sam, struct demodulator_state_s *D
|
|||
* This works by looking at the minimum and maximum signal peaks
|
||||
* and scaling the results to be roughly in the -1.0 to +1.0 range.
|
||||
*/
|
||||
float demod_out;
|
||||
int demod_data; /* Still scrambled. */
|
||||
|
||||
demod_out = agc (amp, D->agc_fast_attack, D->agc_slow_decay, &(D->m_peak), &(D->m_valley));
|
||||
demod_out = agc (fsam, D->agc_fast_attack, D->agc_slow_decay, &(D->m_peak), &(D->m_valley));
|
||||
|
||||
// TODO: There is potential for multiple decoders with one filter.
|
||||
|
||||
//dw_printf ("peak=%.2f valley=%.2f amp=%.2f norm=%.2f\n", D->m_peak, D->m_valley, amp, norm);
|
||||
//dw_printf ("peak=%.2f valley=%.2f fsam=%.2f norm=%.2f\n", D->m_peak, D->m_valley, fsam, norm);
|
||||
|
||||
if (D->num_slicers <= 1) {
|
||||
|
||||
|
@ -435,7 +521,7 @@ void demod_9600_process_sample (int chan, int sam, struct demodulator_state_s *D
|
|||
|
||||
fprintf (demod_log_fp, "%.3f, %.3f, %.3f, %.3f, %.3f, %d, %.2f\n",
|
||||
fsam + 6,
|
||||
amp + 4,
|
||||
fsam + 4,
|
||||
D->m_peak + 4,
|
||||
D->m_valley + 4,
|
||||
demod_out + 2,
|
||||
|
@ -478,7 +564,7 @@ void demod_9600_process_sample (int chan, int sam, struct demodulator_state_s *D
|
|||
*
|
||||
* Returns: None
|
||||
*
|
||||
* Descripton: A PLL is used to sample near the centers of the data bits.
|
||||
* Description: A PLL is used to sample near the centers of the data bits.
|
||||
*
|
||||
* D->data_clock_pll is a SIGNED 32 bit variable.
|
||||
* When it overflows from a large positive value to a negative value, we
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
#include "fsk_demod_state.h"
|
||||
|
||||
|
||||
void demod_9600_init (enum modem_t modem_type, int samples_per_sec, int baud, struct demodulator_state_s *D);
|
||||
void demod_9600_init (enum modem_t modem_type, int original_sample_rate, int upsample, int baud, struct demodulator_state_s *D);
|
||||
|
||||
void demod_9600_process_sample (int chan, int sam, struct demodulator_state_s *D);
|
||||
void demod_9600_process_sample (int chan, int sam, int upsample, struct demodulator_state_s *D);
|
||||
|
||||
|
||||
|
||||
|
|
939
src/demod_afsk.c
939
src/demod_afsk.c
File diff suppressed because it is too large
Load Diff
|
@ -60,7 +60,7 @@
|
|||
* "bis" and "ter" are from Latin for second and third.
|
||||
* I used the "ter" version which has phase shifts of 0, 90, 180, and 270 degrees.
|
||||
*
|
||||
* There are ealier references to an alternative B which uses other phase shifts offset
|
||||
* There are earlier references to an alternative B which uses other phase shifts offset
|
||||
* by another 45 degrees.
|
||||
*
|
||||
* After getting QPSK working, it was not much more effort to add V.27 with 8 phases.
|
||||
|
@ -129,7 +129,8 @@ static inline float convolve (const float *__restrict__ data, const float *__res
|
|||
float sum = 0.0;
|
||||
int j;
|
||||
|
||||
#pragma GCC ivdep
|
||||
//Does pragma make any difference? Annoying warning on Mac.
|
||||
//#pragma GCC ivdep
|
||||
for (j=0; j<filter_size; j++) {
|
||||
sum += filter[j] * data[j];
|
||||
}
|
||||
|
@ -500,7 +501,7 @@ void demod_psk_init (enum modem_t modem_type, enum v26_e v26_alt, int samples_pe
|
|||
*/
|
||||
|
||||
float fc = correct_baud * D->u.psk.lpf_baud / (float)samples_per_sec;
|
||||
gen_lowpass (fc, D->u.psk.lp_filter, D->u.psk.lp_filter_taps, D->u.psk.lp_window, 0);
|
||||
gen_lowpass (fc, D->u.psk.lp_filter, D->u.psk.lp_filter_taps, D->u.psk.lp_window);
|
||||
|
||||
/*
|
||||
* No point in having multiple numbers for signal level.
|
||||
|
@ -780,7 +781,7 @@ static void nudge_pll (int chan, int subchan, int slice, int demod_bits, struct
|
|||
* If we adjust it too quickly, the clock will have too much jitter.
|
||||
* If we adjust it too slowly, it will take too long to lock on to a new signal.
|
||||
*
|
||||
* Be a little more agressive about adjusting the PLL
|
||||
* Be a little more aggressive about adjusting the PLL
|
||||
* phase when searching for a signal.
|
||||
* Don't change it as much when locked on to a signal.
|
||||
*/
|
||||
|
|
157
src/digipeater.c
157
src/digipeater.c
|
@ -62,7 +62,7 @@
|
|||
#include <stdio.h>
|
||||
#include <ctype.h> /* for isdigit, isupper */
|
||||
#include "regex.h"
|
||||
#include <sys/unistd.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "ax25_pad.h"
|
||||
#include "digipeater.h"
|
||||
|
@ -73,7 +73,7 @@
|
|||
|
||||
|
||||
static packet_t digipeat_match (int from_chan, packet_t pp, char *mycall_rec, char *mycall_xmit,
|
||||
regex_t *uidigi, regex_t *uitrace, int to_chan, enum preempt_e preempt, char *type_filter);
|
||||
regex_t *uidigi, regex_t *uitrace, int to_chan, enum preempt_e preempt, char *atgp, char *type_filter);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -154,8 +154,8 @@ void digipeater (int from_chan, packet_t pp)
|
|||
// Network TNC is OK for UI frames where we don't care about timing.
|
||||
|
||||
if ( from_chan < 0 || from_chan >= MAX_CHANS ||
|
||||
(save_audio_config_p->achan[from_chan].medium != MEDIUM_RADIO &&
|
||||
save_audio_config_p->achan[from_chan].medium != MEDIUM_NETTNC)) {
|
||||
(save_audio_config_p->chan_medium[from_chan] != MEDIUM_RADIO &&
|
||||
save_audio_config_p->chan_medium[from_chan] != MEDIUM_NETTNC)) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("APRS digipeater: Did not expect to receive on invalid channel %d.\n", from_chan);
|
||||
}
|
||||
|
@ -176,6 +176,7 @@ void digipeater (int from_chan, packet_t pp)
|
|||
save_audio_config_p->achan[to_chan].mycall,
|
||||
&save_digi_config_p->alias[from_chan][to_chan], &save_digi_config_p->wide[from_chan][to_chan],
|
||||
to_chan, save_digi_config_p->preempt[from_chan][to_chan],
|
||||
save_digi_config_p->atgp[from_chan][to_chan],
|
||||
save_digi_config_p->filter_str[from_chan][to_chan]);
|
||||
if (result != NULL) {
|
||||
dedupe_remember (pp, to_chan);
|
||||
|
@ -202,6 +203,7 @@ void digipeater (int from_chan, packet_t pp)
|
|||
save_audio_config_p->achan[to_chan].mycall,
|
||||
&save_digi_config_p->alias[from_chan][to_chan], &save_digi_config_p->wide[from_chan][to_chan],
|
||||
to_chan, save_digi_config_p->preempt[from_chan][to_chan],
|
||||
save_digi_config_p->atgp[from_chan][to_chan],
|
||||
save_digi_config_p->filter_str[from_chan][to_chan]);
|
||||
if (result != NULL) {
|
||||
dedupe_remember (pp, to_chan);
|
||||
|
@ -244,6 +246,9 @@ void digipeater (int from_chan, packet_t pp)
|
|||
*
|
||||
* preempt - Option for "preemptive" digipeating.
|
||||
*
|
||||
* atgp - No tracing if this matches alias prefix.
|
||||
* Hack added for special needs of ATGP.
|
||||
*
|
||||
* filter_str - Filter expression string or NULL.
|
||||
*
|
||||
* Returns: Packet object for transmission or NULL.
|
||||
|
@ -260,32 +265,9 @@ void digipeater (int from_chan, packet_t pp)
|
|||
*
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#define OBSOLETE14 1
|
||||
|
||||
|
||||
#ifndef OBSOLETE14
|
||||
static char *dest_ssid_path[16] = {
|
||||
"", /* Use VIA path */
|
||||
"WIDE1-1",
|
||||
"WIDE2-2",
|
||||
"WIDE3-3",
|
||||
"WIDE4-4",
|
||||
"WIDE5-5",
|
||||
"WIDE6-6",
|
||||
"WIDE7-7",
|
||||
"WIDE1-1", /* North */
|
||||
"WIDE1-1", /* South */
|
||||
"WIDE1-1", /* East */
|
||||
"WIDE1-1", /* West */
|
||||
"WIDE2-2", /* North */
|
||||
"WIDE2-2", /* South */
|
||||
"WIDE2-2", /* East */
|
||||
"WIDE2-2" }; /* West */
|
||||
#endif
|
||||
|
||||
|
||||
static packet_t digipeat_match (int from_chan, packet_t pp, char *mycall_rec, char *mycall_xmit,
|
||||
regex_t *alias, regex_t *wide, int to_chan, enum preempt_e preempt, char *filter_str)
|
||||
regex_t *alias, regex_t *wide, int to_chan, enum preempt_e preempt, char *atgp, char *filter_str)
|
||||
{
|
||||
char source[AX25_MAX_ADDR_LEN];
|
||||
int ssid;
|
||||
|
@ -323,15 +305,6 @@ static packet_t digipeat_match (int from_chan, packet_t pp, char *mycall_rec, ch
|
|||
* Otherwise we don't want to modify the input because this could be called multiple times.
|
||||
*/
|
||||
|
||||
#ifndef OBSOLETE14 // Took it out in 1.4
|
||||
|
||||
if (ax25_get_num_repeaters(pp) == 0 && (ssid = ax25_get_ssid(pp, AX25_DESTINATION)) > 0) {
|
||||
ax25_set_addr(pp, AX25_REPEATER_1, dest_ssid_path[ssid]);
|
||||
ax25_set_ssid(pp, AX25_DESTINATION, 0);
|
||||
/* Continue with general case, below. */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Find the first repeater station which doesn't have "has been repeated" set.
|
||||
|
@ -510,6 +483,40 @@ static packet_t digipeat_match (int from_chan, packet_t pp, char *mycall_rec, ch
|
|||
err = regexec(wide,repeater,0,NULL,0);
|
||||
if (err == 0) {
|
||||
|
||||
// Special hack added for ATGP to behave like some combination of options in some old TNC
|
||||
// so the via path does not continue to grow and exceed the 8 available positions.
|
||||
// The strange thing about this is that the used up digipeater is left there but
|
||||
// removed by the next digipeater.
|
||||
|
||||
if (strlen(atgp) > 0 && strncasecmp(repeater, atgp, strlen(atgp)) == 0) {
|
||||
|
||||
if (ssid >= 1 && ssid <= 7) {
|
||||
packet_t result;
|
||||
|
||||
result = ax25_dup (pp);
|
||||
assert (result != NULL);
|
||||
|
||||
// First, remove any already used digipeaters.
|
||||
|
||||
while (ax25_get_num_addr(result) >= 3 && ax25_get_h(result,AX25_REPEATER_1) == 1) {
|
||||
ax25_remove_addr (result, AX25_REPEATER_1);
|
||||
r--;
|
||||
}
|
||||
|
||||
ssid = ssid - 1;
|
||||
ax25_set_ssid(result, r, ssid); // could be zero.
|
||||
if (ssid == 0) {
|
||||
ax25_set_h (result, r);
|
||||
}
|
||||
|
||||
// Insert own call at beginning and mark it used.
|
||||
|
||||
ax25_insert_addr (result, AX25_REPEATER_1, mycall_xmit);
|
||||
ax25_set_h (result, AX25_REPEATER_1);
|
||||
return (result);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If ssid == 1, we simply replace the repeater with my call and
|
||||
* mark it as being used.
|
||||
|
@ -608,7 +615,7 @@ void digi_regen (int from_chan, packet_t pp)
|
|||
*
|
||||
* Name: main
|
||||
*
|
||||
* Purpose: Standalone test case for this funtionality.
|
||||
* Purpose: Standalone test case for this functionality.
|
||||
*
|
||||
* Usage: make -f Makefile.<platform> dtest
|
||||
* ./dtest
|
||||
|
@ -617,7 +624,7 @@ void digi_regen (int from_chan, packet_t pp)
|
|||
|
||||
#if DIGITEST
|
||||
|
||||
static char mycall[] = "WB2OSZ-9";
|
||||
static char mycall[12];
|
||||
|
||||
static regex_t alias_re;
|
||||
|
||||
|
@ -627,6 +634,7 @@ static int failed;
|
|||
|
||||
static enum preempt_e preempt = PREEMPT_OFF;
|
||||
|
||||
static char config_atgp[AX25_MAX_ADDR_LEN] = "HOP";
|
||||
|
||||
|
||||
static void test (char *in, char *out)
|
||||
|
@ -640,6 +648,7 @@ static void test (char *in, char *out)
|
|||
int frame_len;
|
||||
alevel_t alevel;
|
||||
|
||||
|
||||
dw_printf ("\n");
|
||||
|
||||
/*
|
||||
|
@ -691,7 +700,7 @@ static void test (char *in, char *out)
|
|||
|
||||
//TODO: Add filtering to test.
|
||||
// V
|
||||
result = digipeat_match (0, pp, mycall, mycall, &alias_re, &wide_re, 0, preempt, NULL);
|
||||
result = digipeat_match (0, pp, mycall, mycall, &alias_re, &wide_re, 0, preempt, config_atgp, NULL);
|
||||
|
||||
if (result != NULL) {
|
||||
|
||||
|
@ -726,6 +735,7 @@ int main (int argc, char *argv[])
|
|||
int e;
|
||||
failed = 0;
|
||||
char message[256];
|
||||
strlcpy(mycall, "WB2OSZ-9", sizeof(mycall));
|
||||
|
||||
dedupe_init (4);
|
||||
|
||||
|
@ -740,7 +750,7 @@ int main (int argc, char *argv[])
|
|||
exit (1);
|
||||
}
|
||||
|
||||
e = regcomp (&wide_re, "^WIDE[1-7]-[1-7]$|^TRACE[1-7]-[1-7]$|^MA[1-7]-[1-7]$", REG_EXTENDED|REG_NOSUB);
|
||||
e = regcomp (&wide_re, "^WIDE[1-7]-[1-7]$|^TRACE[1-7]-[1-7]$|^MA[1-7]-[1-7]$|^HOP[1-7]-[1-7]$", REG_EXTENDED|REG_NOSUB);
|
||||
if (e != 0) {
|
||||
regerror (e, &wide_re, message, sizeof(message));
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
|
@ -830,11 +840,8 @@ int main (int argc, char *argv[])
|
|||
*/
|
||||
|
||||
test ( "W1ABC>TEST-3:",
|
||||
#ifndef OBSOLETE14
|
||||
"W1ABC>TEST,WB2OSZ-9*,WIDE3-2:");
|
||||
#else
|
||||
"");
|
||||
#endif
|
||||
|
||||
test ( "W1DEF>TEST-3,WIDE2-2:",
|
||||
"W1DEF>TEST-3,WB2OSZ-9*,WIDE2-1:");
|
||||
|
||||
|
@ -844,17 +851,17 @@ int main (int argc, char *argv[])
|
|||
* The 4th case might be controversial.
|
||||
*/
|
||||
|
||||
test ( "W1XYZ>TEST,R1*,WIDE3-2:info1",
|
||||
"W1XYZ>TEST,R1,WB2OSZ-9*,WIDE3-1:info1");
|
||||
test ( "W1XYZ>TESTD,R1*,WIDE3-2:info1",
|
||||
"W1XYZ>TESTD,R1,WB2OSZ-9*,WIDE3-1:info1");
|
||||
|
||||
test ( "W1XYZ>TEST,R2*,WIDE3-2:info1",
|
||||
test ( "W1XYZ>TESTD,R2*,WIDE3-2:info1",
|
||||
"");
|
||||
|
||||
test ( "W1XYZ>TEST,R3*,WIDE3-2:info1",
|
||||
test ( "W1XYZ>TESTD,R3*,WIDE3-2:info1",
|
||||
"");
|
||||
|
||||
test ( "W1XYZ>TEST,R1*,WB2OSZ-9:has explicit routing",
|
||||
"W1XYZ>TEST,R1,WB2OSZ-9*:has explicit routing");
|
||||
test ( "W1XYZ>TESTD,R1*,WB2OSZ-9:has explicit routing",
|
||||
"W1XYZ>TESTD,R1,WB2OSZ-9*:has explicit routing");
|
||||
|
||||
|
||||
/*
|
||||
|
@ -931,6 +938,54 @@ int main (int argc, char *argv[])
|
|||
test ( "WB2OSZ-15>TEST14,WIDE1-1,WIDE1-1:stuff",
|
||||
"WB2OSZ-15>TEST14,WB2OSZ-9*,WIDE1-1:stuff");
|
||||
|
||||
// New in 1.7 - ATGP Hack
|
||||
|
||||
preempt = PREEMPT_OFF; // Shouldn't make a difference here.
|
||||
|
||||
test ( "W1ABC>TEST51,HOP7-7,HOP7-7:stuff1",
|
||||
"W1ABC>TEST51,WB2OSZ-9*,HOP7-6,HOP7-7:stuff1");
|
||||
|
||||
test ( "W1ABC>TEST52,ABCD*,HOP7-1,HOP7-7:stuff2",
|
||||
"W1ABC>TEST52,WB2OSZ-9,HOP7*,HOP7-7:stuff2"); // Used up address remains.
|
||||
|
||||
test ( "W1ABC>TEST53,HOP7*,HOP7-7:stuff3",
|
||||
"W1ABC>TEST53,WB2OSZ-9*,HOP7-6:stuff3"); // But it gets removed here.
|
||||
|
||||
test ( "W1ABC>TEST54,HOP7*,HOP7-1:stuff4",
|
||||
"W1ABC>TEST54,WB2OSZ-9,HOP7*:stuff4"); // Remains again here.
|
||||
|
||||
test ( "W1ABC>TEST55,HOP7,HOP7*:stuff5",
|
||||
"");
|
||||
|
||||
// Examples given for desired result.
|
||||
|
||||
strlcpy (mycall, "CLNGMN-1", sizeof(mycall));
|
||||
test ( "W1ABC>TEST60,HOP7-7,HOP7-7:",
|
||||
"W1ABC>TEST60,CLNGMN-1*,HOP7-6,HOP7-7:");
|
||||
test ( "W1ABC>TEST61,ROAN-3*,HOP7-6,HOP7-7:",
|
||||
"W1ABC>TEST61,CLNGMN-1*,HOP7-5,HOP7-7:");
|
||||
|
||||
strlcpy (mycall, "GDHILL-8", sizeof(mycall));
|
||||
test ( "W1ABC>TEST62,MDMTNS-7*,HOP7-1,HOP7-7:",
|
||||
"W1ABC>TEST62,GDHILL-8,HOP7*,HOP7-7:");
|
||||
test ( "W1ABC>TEST63,CAMLBK-9*,HOP7-1,HOP7-7:",
|
||||
"W1ABC>TEST63,GDHILL-8,HOP7*,HOP7-7:");
|
||||
|
||||
strlcpy (mycall, "MDMTNS-7", sizeof(mycall));
|
||||
test ( "W1ABC>TEST64,GDHILL-8*,HOP7*,HOP7-7:",
|
||||
"W1ABC>TEST64,MDMTNS-7*,HOP7-6:");
|
||||
|
||||
strlcpy (mycall, "CAMLBK-9", sizeof(mycall));
|
||||
test ( "W1ABC>TEST65,GDHILL-8,HOP7*,HOP7-7:",
|
||||
"W1ABC>TEST65,CAMLBK-9*,HOP7-6:");
|
||||
|
||||
strlcpy (mycall, "KATHDN-15", sizeof(mycall));
|
||||
test ( "W1ABC>TEST66,MTWASH-14*,HOP7-1:",
|
||||
"W1ABC>TEST66,KATHDN-15,HOP7*:");
|
||||
|
||||
strlcpy (mycall, "SPRNGR-1", sizeof(mycall));
|
||||
test ( "W1ABC>TEST67,CLNGMN-1*,HOP7-1:",
|
||||
"W1ABC>TEST67,SPRNGR-1,HOP7*:");
|
||||
|
||||
|
||||
if (failed == 0) {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
|
||||
#ifndef DIGIPEATER_H
|
||||
#define DIGIPEATER_H 1
|
||||
|
||||
|
@ -38,6 +37,11 @@ struct digi_config_s {
|
|||
|
||||
enum preempt_e { PREEMPT_OFF, PREEMPT_DROP, PREEMPT_MARK, PREEMPT_TRACE } preempt[MAX_CHANS][MAX_CHANS];
|
||||
|
||||
// ATGP is an ugly hack for the specific need of ATGP which needs more that 8 digipeaters.
|
||||
// DO NOT put this in the User Guide. On a need to know basis.
|
||||
|
||||
char atgp[MAX_CHANS][MAX_CHANS][AX25_MAX_ADDR_LEN];
|
||||
|
||||
char *filter_str[MAX_CHANS+1][MAX_CHANS+1];
|
||||
// NULL or optional Packet Filter strings such as "t/m".
|
||||
// Notice the size of arrays is one larger than normal.
|
||||
|
|
301
src/direwolf.c
301
src/direwolf.c
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
||||
//
|
||||
// Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2020 John Langner, WB2OSZ
|
||||
// Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2020, 2021 John Langner, WB2OSZ
|
||||
//
|
||||
// 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
|
||||
|
@ -33,7 +33,9 @@
|
|||
* Internet Gateway (IGate)
|
||||
* Ham Radio of Things - IoT with Ham Radio
|
||||
* FX.25 Forward Error Correction.
|
||||
*
|
||||
* IL2P Forward Error Correction.
|
||||
* Emergency Alert System (EAS) Specific Area Message Encoding (SAME) receiver.
|
||||
* AIS receiver for tracking ships.
|
||||
*
|
||||
*---------------------------------------------------------------*/
|
||||
|
||||
|
@ -67,9 +69,8 @@
|
|||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#ifdef __OpenBSD__
|
||||
#include <soundcard.h>
|
||||
#elif __APPLE__
|
||||
#if USE_SNDIO || __APPLE__
|
||||
// no need to include <soundcard.h>
|
||||
#else
|
||||
#include <sys/soundcard.h>
|
||||
#endif
|
||||
|
@ -124,7 +125,9 @@
|
|||
#include "ax25_link.h"
|
||||
#include "dtime_now.h"
|
||||
#include "fx25.h"
|
||||
#include "il2p.h"
|
||||
#include "dwsock.h"
|
||||
#include "dns_sd_dw.h"
|
||||
|
||||
|
||||
//static int idx_decoded = 0;
|
||||
|
@ -193,7 +196,6 @@ int main (int argc, char *argv[])
|
|||
//int eof;
|
||||
int j;
|
||||
char config_file[100];
|
||||
int xmit_calibrate_option = 0;
|
||||
int enable_pseudo_terminal = 0;
|
||||
struct digi_config_s digi_config;
|
||||
struct cdigi_config_s cdigi_config;
|
||||
|
@ -223,13 +225,22 @@ int main (int argc, char *argv[])
|
|||
int d_h_opt = 0; /* "-d h" option for hamlib debugging. Repeat for more detail */
|
||||
#endif
|
||||
int d_x_opt = 1; /* "-d x" option for FX.25. Default minimal. Repeat for more detail. -qx to silence. */
|
||||
int d_2_opt = 0; /* "-d 2" option for IL2P. Default minimal. Repeat for more detail. */
|
||||
|
||||
int E_tx_opt = 0; /* "-E n" Error rate % for clobbering trasmit frames. */
|
||||
int aprstt_debug = 0; /* "-d d" option for APRStt (think Dtmf) debug. */
|
||||
|
||||
int E_tx_opt = 0; /* "-E n" Error rate % for clobbering transmit frames. */
|
||||
int E_rx_opt = 0; /* "-E Rn" Error rate % for clobbering receive frames. */
|
||||
|
||||
float e_recv_ber = 0.0; /* Receive Bit Error Rate (BER). */
|
||||
int X_fx25_xmit_enable = 0; /* FX.25 transmit enable. */
|
||||
|
||||
int I_opt = -1; /* IL2P transmit, normal polarity, arg is max_fec. */
|
||||
int i_opt = -1; /* IL2P transmit, inverted polarity, arg is max_fec. */
|
||||
|
||||
char x_opt_mode = ' '; /* "-x N" option for transmitting calibration tones. */
|
||||
int x_opt_chan = 0; /* Split into 2 parts. Mode e.g. m, a, and optional channel. */
|
||||
|
||||
strlcpy(l_opt_logdir, "", sizeof(l_opt_logdir));
|
||||
strlcpy(L_opt_logfile, "", sizeof(L_opt_logfile));
|
||||
strlcpy(P_opt, "", sizeof(P_opt));
|
||||
|
@ -288,11 +299,11 @@ int main (int argc, char *argv[])
|
|||
text_color_init(t_opt);
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
//dw_printf ("Dire Wolf version %d.%d (%s) Beta Test 4\n", MAJOR_VERSION, MINOR_VERSION, __DATE__);
|
||||
dw_printf ("Dire Wolf DEVELOPMENT version %d.%d %s (%s)\n", MAJOR_VERSION, MINOR_VERSION, "G", __DATE__);
|
||||
dw_printf ("Dire Wolf DEVELOPMENT version %d.%d %s (%s)\n", MAJOR_VERSION, MINOR_VERSION, "E", __DATE__);
|
||||
//dw_printf ("Dire Wolf version %d.%d\n", MAJOR_VERSION, MINOR_VERSION);
|
||||
|
||||
|
||||
#if defined(ENABLE_GPSD) || defined(USE_HAMLIB) || defined(USE_CM108)
|
||||
#if defined(ENABLE_GPSD) || defined(USE_HAMLIB) || defined(USE_CM108) || USE_AVAHI_CLIENT || USE_MACOS_DNSSD
|
||||
dw_printf ("Includes optional support for: ");
|
||||
#if defined(ENABLE_GPSD)
|
||||
dw_printf (" gpsd");
|
||||
|
@ -305,12 +316,15 @@ int main (int argc, char *argv[])
|
|||
#endif
|
||||
#if defined(USE_GPIOD)
|
||||
dw_printf (" libgpiod");
|
||||
#if (USE_AVAHI_CLIENT|USE_MACOS_DNSSD)
|
||||
dw_printf (" dns-sd");
|
||||
#endif
|
||||
dw_printf ("\n");
|
||||
#endif
|
||||
|
||||
|
||||
#if __WIN32__
|
||||
//setlinebuf (stdout); setvbuf???
|
||||
SetConsoleCtrlHandler ((PHANDLER_ROUTINE)cleanup_win, TRUE);
|
||||
#else
|
||||
setlinebuf (stdout);
|
||||
|
@ -360,7 +374,20 @@ int main (int argc, char *argv[])
|
|||
text_color_set(DW_COLOR_INFO);
|
||||
#endif
|
||||
|
||||
// I've seen many references to people running this as root.
|
||||
// There is no reason to do that.
|
||||
// There is for some privileges to access the audio system, GPIO (if needed for PTT),
|
||||
// etc. but ordinary users have those abilities.
|
||||
// Giving an applications permission to do things it does not need to do
|
||||
// is a huge security risk.
|
||||
|
||||
#ifndef __WIN32__
|
||||
if (getuid() == 0 || geteuid() == 0) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Dire Wolf requires only privileges available to ordinary users.\n");
|
||||
dw_printf ("Running this as root is an unnecessary security risk.\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default location of configuration file is current directory.
|
||||
|
@ -390,7 +417,7 @@ int main (int argc, char *argv[])
|
|||
|
||||
/* ':' following option character means arg is required. */
|
||||
|
||||
c = getopt_long(argc, argv, "hP:B:gjJD:U:c:pxr:b:n:d:q:t:ul:L:Sa:E:T:e:X:A",
|
||||
c = getopt_long(argc, argv, "hP:B:gjJD:U:c:px:r:b:n:d:q:t:ul:L:Sa:E:T:e:X:AI:i:",
|
||||
long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
@ -492,9 +519,43 @@ int main (int argc, char *argv[])
|
|||
}
|
||||
break;
|
||||
|
||||
case 'x': /* -x for transmit calibration tones. */
|
||||
case 'x': /* -x N for transmit calibration tones. */
|
||||
/* N is composed of a channel number and/or one letter */
|
||||
/* for the mode: mark, space, alternate, ptt-only. */
|
||||
|
||||
xmit_calibrate_option = 1;
|
||||
for (char *p = optarg; *p != '\0'; p++ ) {
|
||||
switch (*p) {
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
x_opt_chan = x_opt_chan * 10 + *p - '0';
|
||||
if (x_opt_mode == ' ') x_opt_mode = 'a';
|
||||
break;
|
||||
case 'a': x_opt_mode = *p; break; // Alternating tones
|
||||
case 'm': x_opt_mode = *p; break; // Mark tone
|
||||
case 's': x_opt_mode = *p; break; // Space tone
|
||||
case 'p': x_opt_mode = *p; break; // Set PTT only
|
||||
default:
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Invalid option '%c' for -x. Must be a, m, s, or p.\n", *p);
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
exit (EXIT_FAILURE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (x_opt_chan < 0 || x_opt_chan >= MAX_CHANS) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Invalid channel %d for -x. \n", x_opt_chan);
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'r': /* -r audio samples/sec. e.g. 44100 */
|
||||
|
@ -569,6 +630,8 @@ int main (int argc, char *argv[])
|
|||
case 'h': d_h_opt++; break; // Hamlib verbose level.
|
||||
#endif
|
||||
case 'x': d_x_opt++; break; // FX.25
|
||||
case '2': d_2_opt++; break; // IL2P
|
||||
case 'd': aprstt_debug++; break; // APRStt (mnemonic Dtmf)
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
@ -656,6 +719,16 @@ int main (int argc, char *argv[])
|
|||
X_fx25_xmit_enable = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'I': // IL2P, normal polarity
|
||||
|
||||
I_opt = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'i': // IL2P, inverted polarity
|
||||
|
||||
i_opt = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'A': // -A convert AIS to APRS object
|
||||
|
||||
A_opt_ais_to_obj = 1;
|
||||
|
@ -706,7 +779,7 @@ int main (int argc, char *argv[])
|
|||
if (n_opt != 0) {
|
||||
audio_config.adev[0].num_channels = n_opt;
|
||||
if (n_opt == 2) {
|
||||
audio_config.achan[1].medium = MEDIUM_RADIO;
|
||||
audio_config.chan_medium[1] = MEDIUM_RADIO;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -761,7 +834,7 @@ int main (int argc, char *argv[])
|
|||
// Will make more precise in afsk demod init.
|
||||
audio_config.achan[0].mark_freq = 2083; // Actually 2083.3 - logic 1.
|
||||
audio_config.achan[0].space_freq = 1563; // Actually 1562.5 - logic 0.
|
||||
strlcpy (audio_config.achan[0].profiles, "D", sizeof(audio_config.achan[0].profiles));
|
||||
strlcpy (audio_config.achan[0].profiles, "A", sizeof(audio_config.achan[0].profiles));
|
||||
}
|
||||
else {
|
||||
audio_config.achan[0].modem_type = MODEM_SCRAMBLE;
|
||||
|
@ -856,7 +929,45 @@ int main (int argc, char *argv[])
|
|||
|
||||
audio_config.recv_ber = e_recv_ber;
|
||||
|
||||
audio_config.fx25_xmit_enable = X_fx25_xmit_enable;
|
||||
if (X_fx25_xmit_enable > 0) {
|
||||
if (I_opt != -1 || i_opt != -1) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Can't mix -X with -I or -i.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
audio_config.achan[0].fx25_strength = X_fx25_xmit_enable;
|
||||
audio_config.achan[0].layer2_xmit = LAYER2_FX25;
|
||||
}
|
||||
|
||||
if (I_opt != -1 && i_opt != -1) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Can't use both -I and -i at the same time.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (I_opt >= 0) {
|
||||
audio_config.achan[0].layer2_xmit = LAYER2_IL2P;
|
||||
audio_config.achan[0].il2p_max_fec = (I_opt > 0);
|
||||
if (audio_config.achan[0].il2p_max_fec == 0) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("It is highly recommended that 1, rather than 0, is used with -I for best results.\n");
|
||||
}
|
||||
audio_config.achan[0].il2p_invert_polarity = 0; // normal
|
||||
}
|
||||
|
||||
if (i_opt >= 0) {
|
||||
audio_config.achan[0].layer2_xmit = LAYER2_IL2P;
|
||||
audio_config.achan[0].il2p_max_fec = (i_opt > 0);
|
||||
if (audio_config.achan[0].il2p_max_fec == 0) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("It is highly recommended that 1, rather than 0, is used with -i for best results.\n");
|
||||
}
|
||||
audio_config.achan[0].il2p_invert_polarity = 1; // invert for transmit
|
||||
if (audio_config.achan[0].baud == 1200) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Using -i with 1200 bps is a bad idea. Use -I instead.\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -877,16 +988,17 @@ int main (int argc, char *argv[])
|
|||
}
|
||||
|
||||
/*
|
||||
* Initialize the demodulator(s) and HDLC decoder.
|
||||
* Initialize the demodulator(s) and layer 2 decoder (HDLC, IL2P).
|
||||
*/
|
||||
multi_modem_init (&audio_config);
|
||||
fx25_init (d_x_opt);
|
||||
il2p_init (d_2_opt);
|
||||
|
||||
/*
|
||||
* Initialize the touch tone decoder & APRStt gateway.
|
||||
*/
|
||||
dtmf_init (&audio_config, audio_amplitude);
|
||||
aprs_tt_init (&tt_config);
|
||||
aprs_tt_init (&tt_config, aprstt_debug);
|
||||
tt_user_init (&audio_config, &tt_config);
|
||||
|
||||
/*
|
||||
|
@ -908,29 +1020,76 @@ int main (int argc, char *argv[])
|
|||
xmit_init (&audio_config, d_p_opt);
|
||||
|
||||
/*
|
||||
* If -x option specified, transmit alternating tones for transmitter
|
||||
* If -x N option specified, transmit calibration tones for transmitter
|
||||
* audio level adjustment, up to 1 minute then quit.
|
||||
* TODO: enhance for more than one channel.
|
||||
* a: Alternating mark/space tones
|
||||
* m: Mark tone (e.g. 1200Hz)
|
||||
* s: Space tone (e.g. 2200Hz)
|
||||
* p: Set PTT only.
|
||||
* A leading or trailing number is the channel.
|
||||
*/
|
||||
|
||||
if (xmit_calibrate_option) {
|
||||
|
||||
int max_duration = 60; /* seconds */
|
||||
int n = audio_config.achan[0].baud * max_duration;
|
||||
int chan = 0;
|
||||
if (x_opt_mode != ' ') {
|
||||
if (audio_config.chan_medium[x_opt_chan] == MEDIUM_RADIO) {
|
||||
if (audio_config.achan[x_opt_chan].mark_freq
|
||||
&& audio_config.achan[x_opt_chan].space_freq) {
|
||||
int max_duration = 60;
|
||||
int n = audio_config.achan[x_opt_chan].baud * max_duration;
|
||||
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("\nSending transmit calibration tones. Press control-C to terminate.\n");
|
||||
ptt_set(OCTYPE_PTT, x_opt_chan, 1);
|
||||
|
||||
ptt_set (OCTYPE_PTT, chan, 1);
|
||||
switch (x_opt_mode) {
|
||||
default:
|
||||
case 'a': // Alternating tones: -x a
|
||||
dw_printf("\nSending alternating mark/space calibration tones (%d/%dHz) on channel %d.\nPress control-C to terminate.\n",
|
||||
audio_config.achan[x_opt_chan].mark_freq,
|
||||
audio_config.achan[x_opt_chan].space_freq,
|
||||
x_opt_chan);
|
||||
while (n-- > 0) {
|
||||
|
||||
tone_gen_put_bit (chan, n & 1);
|
||||
|
||||
tone_gen_put_bit(x_opt_chan, n & 1);
|
||||
}
|
||||
ptt_set (OCTYPE_PTT, chan, 0);
|
||||
exit (0);
|
||||
break;
|
||||
case 'm': // "Mark" tone: -x m
|
||||
dw_printf("\nSending mark calibration tone (%dHz) on channel %d.\nPress control-C to terminate.\n",
|
||||
audio_config.achan[x_opt_chan].mark_freq,
|
||||
x_opt_chan);
|
||||
while (n-- > 0) {
|
||||
tone_gen_put_bit(x_opt_chan, 0);
|
||||
}
|
||||
break;
|
||||
case 's': // "Space" tone: -x s
|
||||
dw_printf("\nSending space calibration tone (%dHz) on channel %d.\nPress control-C to terminate.\n",
|
||||
audio_config.achan[x_opt_chan].space_freq,
|
||||
x_opt_chan);
|
||||
while (n-- > 0) {
|
||||
tone_gen_put_bit(x_opt_chan, 1);
|
||||
}
|
||||
break;
|
||||
case 'p': // Silence - set PTT only: -x p
|
||||
dw_printf("\nSending silence (Set PTT only) on channel %d.\nPress control-C to terminate.\n", x_opt_chan);
|
||||
SLEEP_SEC(max_duration);
|
||||
break;
|
||||
}
|
||||
|
||||
ptt_set(OCTYPE_PTT, x_opt_chan, 0);
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
} else {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf("\nMark/Space frequencies not defined for channel %d. Cannot calibrate using this modem type.\n", x_opt_chan);
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf("\nChannel %d is not configured as a radio channel.\n", x_opt_chan);
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Initialize the digipeater and IGate functions.
|
||||
|
@ -947,6 +1106,11 @@ int main (int argc, char *argv[])
|
|||
server_init (&audio_config, &misc_config);
|
||||
kissnet_init (&misc_config);
|
||||
|
||||
#if (USE_AVAHI_CLIENT|USE_MACOS_DNSSD)
|
||||
if (misc_config.kiss_port > 0 && misc_config.dns_sd_enabled)
|
||||
dns_sd_announce(&misc_config);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Create a pseudo terminal and KISS TNC emulator.
|
||||
*/
|
||||
|
@ -1022,8 +1186,8 @@ void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alev
|
|||
int h;
|
||||
char display_retries[32];
|
||||
|
||||
assert (chan >= 0 && chan < MAX_CHANS);
|
||||
assert (subchan >= -1 && subchan < MAX_SUBCHANS);
|
||||
assert (chan >= 0 && chan < MAX_TOTAL_CHANS); // TOTAL for virtual channels
|
||||
assert (subchan >= -2 && subchan < MAX_SUBCHANS);
|
||||
assert (slice >= 0 && slice < MAX_SLICERS);
|
||||
assert (pp != NULL); // 1.1J+
|
||||
|
||||
|
@ -1059,8 +1223,11 @@ void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alev
|
|||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("\n");
|
||||
|
||||
if (( ! q_h_opt ) && alevel.rec >= 0) { /* suppress if "-q h" option */
|
||||
// The HEARD line.
|
||||
|
||||
if (( ! q_h_opt ) && alevel.rec >= 0) { /* suppress if "-q h" option */
|
||||
// FIXME: rather than checking for ichannel, how about checking medium==radio
|
||||
if (chan != audio_config.igate_vchannel) { // suppress if from ICHANNEL
|
||||
if (h != -1 && h != AX25_SOURCE) {
|
||||
dw_printf ("Digipeater ");
|
||||
}
|
||||
|
@ -1104,6 +1271,7 @@ void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alev
|
|||
dw_printf ("%s audio level = %s %s %s\n", heard, alevel_text, display_retries, spectrum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Version 1.2: Cranking the input level way up produces 199. */
|
||||
/* Keeping it under 100 gives us plenty of headroom to avoid saturation. */
|
||||
|
@ -1116,6 +1284,12 @@ void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alev
|
|||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Audio input level is too high. Reduce so most stations are around 50.\n");
|
||||
}
|
||||
// FIXME: rather than checking for ichannel, how about checking medium==radio
|
||||
else if (alevel.rec < 5 && chan != audio_config.igate_vchannel) {
|
||||
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Audio input level is too low. Increase so most stations are around 50.\n");
|
||||
}
|
||||
|
||||
|
||||
// Display non-APRS packets in a different color.
|
||||
|
@ -1140,6 +1314,10 @@ void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alev
|
|||
text_color_set(DW_COLOR_REC);
|
||||
dw_printf ("[%d.dtmf%s] ", chan, ts);
|
||||
}
|
||||
else if (subchan == -2) {
|
||||
text_color_set(DW_COLOR_REC);
|
||||
dw_printf ("[%d.is%s] ", chan, ts);
|
||||
}
|
||||
else {
|
||||
if (ax25_is_aprs(pp)) {
|
||||
text_color_set(DW_COLOR_REC);
|
||||
|
@ -1250,7 +1428,7 @@ void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alev
|
|||
// we still want to decode it for logging and other processing.
|
||||
// Just be quiet about errors if "-qd" is set.
|
||||
|
||||
decode_aprs (&A, pp, q_d_opt);
|
||||
decode_aprs (&A, pp, q_d_opt, 0);
|
||||
|
||||
if ( ! q_d_opt ) {
|
||||
|
||||
|
@ -1329,9 +1507,9 @@ void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alev
|
|||
flen = ax25_pack(pp, fbuf);
|
||||
|
||||
server_send_rec_packet (chan, pp, fbuf, flen); // AGW net protocol
|
||||
kissnet_send_rec_packet (chan, KISS_CMD_DATA_FRAME, fbuf, flen, -1); // KISS TCP
|
||||
kissserial_send_rec_packet (chan, KISS_CMD_DATA_FRAME, fbuf, flen, -1); // KISS serial port
|
||||
kisspt_send_rec_packet (chan, KISS_CMD_DATA_FRAME, fbuf, flen, -1); // KISS pseudo terminal
|
||||
kissnet_send_rec_packet (chan, KISS_CMD_DATA_FRAME, fbuf, flen, NULL, -1); // KISS TCP
|
||||
kissserial_send_rec_packet (chan, KISS_CMD_DATA_FRAME, fbuf, flen, NULL, -1); // KISS serial port
|
||||
kisspt_send_rec_packet (chan, KISS_CMD_DATA_FRAME, fbuf, flen, NULL, -1); // KISS pseudo terminal
|
||||
|
||||
if (A_opt_ais_to_obj && strlen(ais_obj_packet) != 0) {
|
||||
packet_t ao_pp = ax25_from_text (ais_obj_packet, 1);
|
||||
|
@ -1340,26 +1518,42 @@ void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alev
|
|||
int ao_flen = ax25_pack(ao_pp, ao_fbuf);
|
||||
|
||||
server_send_rec_packet (chan, ao_pp, ao_fbuf, ao_flen);
|
||||
kissnet_send_rec_packet (chan, KISS_CMD_DATA_FRAME, ao_fbuf, ao_flen, -1);
|
||||
kissserial_send_rec_packet (chan, KISS_CMD_DATA_FRAME, ao_fbuf, ao_flen, -1);
|
||||
kisspt_send_rec_packet (chan, KISS_CMD_DATA_FRAME, ao_fbuf, ao_flen, -1);
|
||||
kissnet_send_rec_packet (chan, KISS_CMD_DATA_FRAME, ao_fbuf, ao_flen, NULL, -1);
|
||||
kissserial_send_rec_packet (chan, KISS_CMD_DATA_FRAME, ao_fbuf, ao_flen, NULL, -1);
|
||||
kisspt_send_rec_packet (chan, KISS_CMD_DATA_FRAME, ao_fbuf, ao_flen, NULL, -1);
|
||||
ax25_delete (ao_pp);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If it came from DTMF decoder, send it to APRStt gateway.
|
||||
* If it is from the ICHANNEL, we are done.
|
||||
* Don't digipeat. Don't IGate.
|
||||
* Don't do anything with it after printing and sending to client apps.
|
||||
*/
|
||||
|
||||
if (chan == audio_config.igate_vchannel) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* If it came from DTMF decoder (subchan == -1), send it to APRStt gateway.
|
||||
* Otherwise, it is a candidate for IGate and digipeater.
|
||||
*
|
||||
* TODO: It would be useful to have some way to simulate touch tone
|
||||
* It is also useful to have some way to simulate touch tone
|
||||
* sequences with BEACON sendto=R0 for testing.
|
||||
*/
|
||||
|
||||
if (subchan == -1) {
|
||||
if (subchan == -1) { // from DTMF decoder
|
||||
if (tt_config.gateway_enabled && info_len >= 2) {
|
||||
aprs_tt_sequence (chan, (char*)(pinfo+1));
|
||||
}
|
||||
}
|
||||
else if (*pinfo == 't' && info_len >= 2 && tt_config.gateway_enabled) {
|
||||
// For testing.
|
||||
// Would be nice to verify it was generated locally,
|
||||
// not received over the air.
|
||||
aprs_tt_sequence (chan, (char*)(pinfo+1));
|
||||
}
|
||||
else {
|
||||
|
||||
/* Send to Internet server if option is enabled. */
|
||||
|
@ -1472,7 +1666,9 @@ static void usage (char **argv)
|
|||
dw_printf (" -P xxx Modem Profiles.\n");
|
||||
dw_printf (" -A Convert AIS positions to APRS Object Reports.\n");
|
||||
dw_printf (" -D n Divide audio sample rate by n for channel 0.\n");
|
||||
dw_printf (" -X n 1 to enable FX.25 transmit.\n");
|
||||
dw_printf (" -X n 1 to enable FX.25 transmit. 16, 32, 64 for specific number of check bytes.\n");
|
||||
dw_printf (" -I n Enable IL2P transmit. n=1 is recommended. 0 uses weaker FEC.\n");
|
||||
dw_printf (" -i n Enable IL2P transmit, inverted polarity. n=1 is recommended. 0 uses weaker FEC.\n");
|
||||
dw_printf (" -d Debug options:\n");
|
||||
dw_printf (" a a = AGWPE network protocol client.\n");
|
||||
dw_printf (" k k = KISS serial port or pseudo terminal client.\n");
|
||||
|
@ -1490,6 +1686,8 @@ static void usage (char **argv)
|
|||
dw_printf (" h h = hamlib increase verbose level.\n");
|
||||
#endif
|
||||
dw_printf (" x x = FX.25 increase verbose level.\n");
|
||||
dw_printf (" 2 2 = IL2P.\n");
|
||||
dw_printf (" d d = APRStt (DTMF to APRS object translation).\n");
|
||||
dw_printf (" -q Quiet (suppress output) options:\n");
|
||||
dw_printf (" h h = Heard line with the audio level.\n");
|
||||
dw_printf (" d d = Decoding of APRS packets.\n");
|
||||
|
@ -1502,6 +1700,11 @@ static void usage (char **argv)
|
|||
dw_printf (" -p Enable pseudo terminal for KISS protocol.\n");
|
||||
#endif
|
||||
dw_printf (" -x Send Xmit level calibration tones.\n");
|
||||
dw_printf (" a a = Alternating mark/space tones.\n");
|
||||
dw_printf (" m m = Steady mark tone (e.g. 1200Hz).\n");
|
||||
dw_printf (" s s = Steady space tone (e.g. 2200Hz).\n");
|
||||
dw_printf (" p p = Silence (Set PTT only).\n");
|
||||
dw_printf (" chan Optionally add a number to specify radio channel.\n");
|
||||
dw_printf (" -u Print UTF-8 test string and exit.\n");
|
||||
dw_printf (" -S Print symbol tables and exit.\n");
|
||||
dw_printf (" -T fmt Time stamp format for sent and received frames.\n");
|
||||
|
@ -1509,13 +1712,17 @@ static void usage (char **argv)
|
|||
dw_printf ("\n");
|
||||
|
||||
dw_printf ("After any options, there can be a single command line argument for the source of\n");
|
||||
dw_printf ("received audio. This can overrides the audio input specified in the configuration file.\n");
|
||||
dw_printf ("received audio. This can override the audio input specified in the configuration file.\n");
|
||||
dw_printf ("\n");
|
||||
|
||||
#if __WIN32__
|
||||
dw_printf ("Complete documentation can be found in the 'doc' folder\n");
|
||||
#else
|
||||
dw_printf ("Complete documentation can be found in /usr/local/share/doc/direwolf.\n");
|
||||
// TODO: Could vary by platform and build options.
|
||||
dw_printf ("Complete documentation can be found in /usr/local/share/doc/direwolf\n");
|
||||
#endif
|
||||
dw_printf ("or online at https://github.com/wb2osz/direwolf/tree/master/doc\n");
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Previously, we could handle only a single audio device.
|
||||
* This meant we could have only two radio channels.
|
||||
|
@ -65,7 +64,15 @@
|
|||
* and make sure they handle undefined channels correctly.
|
||||
*/
|
||||
|
||||
#define MAX_CHANS ((MAX_ADEVS) * 2)
|
||||
#define MAX_RADIO_CHANS ((MAX_ADEVS) * 2)
|
||||
|
||||
#define MAX_CHANS MAX_RADIO_CHANS // TODO: Replace all former with latter to avoid confusion with following.
|
||||
|
||||
#define MAX_TOTAL_CHANS 16 // v1.7 allows additional virtual channels which are connected
|
||||
// to something other than radio modems.
|
||||
// Total maximum channels is based on the 4 bit KISS field.
|
||||
// Someone with very unusual requirements could increase this and
|
||||
// use only the AGW network protocol.
|
||||
|
||||
/*
|
||||
* Maximum number of rigs.
|
||||
|
@ -97,7 +104,7 @@
|
|||
* Each one of these can have multiple slicers, at
|
||||
* different levels, to compensate for different
|
||||
* amplitudes of the AFSK tones.
|
||||
* Intially used same number as subchannels but
|
||||
* Initially used same number as subchannels but
|
||||
* we could probably trim this down a little
|
||||
* without impacting performance.
|
||||
*/
|
||||
|
@ -176,6 +183,7 @@
|
|||
#define DW_METERS_TO_FEET(x) ((x) == G_UNKNOWN ? G_UNKNOWN : (x) * 3.2808399)
|
||||
#define DW_FEET_TO_METERS(x) ((x) == G_UNKNOWN ? G_UNKNOWN : (x) * 0.3048)
|
||||
#define DW_KM_TO_MILES(x) ((x) == G_UNKNOWN ? G_UNKNOWN : (x) * 0.621371192)
|
||||
#define DW_MILES_TO_KM(x) ((x) == G_UNKNOWN ? G_UNKNOWN : (x) * 1.609344)
|
||||
|
||||
#define DW_KNOTS_TO_MPH(x) ((x) == G_UNKNOWN ? G_UNKNOWN : (x) * 1.15077945)
|
||||
#define DW_KNOTS_TO_METERS_PER_SEC(x) ((x) == G_UNKNOWN ? G_UNKNOWN : (x) * 0.51444444444)
|
||||
|
@ -278,43 +286,34 @@ char *strsep(char **stringp, const char *delim);
|
|||
char *strtok_r(char *str, const char *delim, char **saveptr);
|
||||
#endif
|
||||
|
||||
// Don't recall why for everyone.
|
||||
// Don't recall why I added this for everyone rather than only for Windows.
|
||||
char *strcasestr(const char *S, const char *FIND);
|
||||
|
||||
|
||||
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__APPLE__)
|
||||
// cmake determines whether strlcpy and strlcat are available
|
||||
// or if we need to supply our own.
|
||||
|
||||
// strlcpy and strlcat should be in string.h and the C library.
|
||||
|
||||
#else // Use our own copy
|
||||
|
||||
|
||||
// These prevent /usr/include/gps.h from providing its own definition.
|
||||
#define HAVE_STRLCAT 1
|
||||
#define HAVE_STRLCPY 1
|
||||
|
||||
|
||||
#define DEBUG_STRL 1
|
||||
#define DEBUG_STRL 1 // Extra Debug version when using our own strlcpy, strlcat.
|
||||
|
||||
#ifndef HAVE_STRLCPY // Need to supply our own.
|
||||
#if DEBUG_STRL
|
||||
|
||||
#define strlcpy(dst,src,siz) strlcpy_debug(dst,src,siz,__FILE__,__func__,__LINE__)
|
||||
#define strlcat(dst,src,siz) strlcat_debug(dst,src,siz,__FILE__,__func__,__LINE__)
|
||||
|
||||
size_t strlcpy_debug(char *__restrict__ dst, const char *__restrict__ src, size_t siz, const char *file, const char *func, int line);
|
||||
size_t strlcat_debug(char *__restrict__ dst, const char *__restrict__ src, size_t siz, const char *file, const char *func, int line);
|
||||
|
||||
#else
|
||||
|
||||
#define strlcpy(dst,src,siz) strlcpy_debug(dst,src,siz)
|
||||
#define strlcat(dst,src,siz) strlcat_debug(dst,src,siz)
|
||||
|
||||
size_t strlcpy_debug(char *__restrict__ dst, const char *__restrict__ src, size_t siz);
|
||||
size_t strlcat_debug(char *__restrict__ dst, const char *__restrict__ src, size_t siz);
|
||||
|
||||
#endif /* DEBUG_STRL */
|
||||
#endif
|
||||
|
||||
#endif /* BSD or Apple */
|
||||
#ifndef HAVE_STRLCAT // Need to supply our own.
|
||||
#if DEBUG_STRL
|
||||
#define strlcat(dst,src,siz) strlcat_debug(dst,src,siz,__FILE__,__func__,__LINE__)
|
||||
size_t strlcat_debug(char *__restrict__ dst, const char *__restrict__ src, size_t siz, const char *file, const char *func, int line);
|
||||
#else
|
||||
#define strlcat(dst,src,siz) strlcat_debug(dst,src,siz)
|
||||
size_t strlcat_debug(char *__restrict__ dst, const char *__restrict__ src, size_t siz);
|
||||
#endif /* DEBUG_STRL */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* ifndef DIREWOLF_H */
|
||||
|
|
67
src/dlq.c
67
src/dlq.c
|
@ -130,12 +130,18 @@ void dlq_init (void)
|
|||
#else
|
||||
int err;
|
||||
err = pthread_mutex_init (&wake_up_mutex, NULL);
|
||||
if (err != 0) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("dlq_init: pthread_mutex_init err=%d", err);
|
||||
perror ("");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
err = pthread_mutex_init (&dlq_mutex, NULL);
|
||||
if (err != 0) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("dlq_init: pthread_mutex_init err=%d", err);
|
||||
perror ("");
|
||||
exit (1);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -233,7 +239,7 @@ void dlq_rec_frame (int chan, int subchan, int slice, packet_t pp, alevel_t alev
|
|||
dw_printf ("dlq_rec_frame (chan=%d, pp=%p, ...)\n", chan, pp);
|
||||
#endif
|
||||
|
||||
assert (chan >= 0 && chan < MAX_CHANS);
|
||||
assert (chan >= 0 && chan < MAX_TOTAL_CHANS); // TOTAL to include virtual channels.
|
||||
|
||||
if (pp == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
|
@ -253,6 +259,11 @@ void dlq_rec_frame (int chan, int subchan, int slice, packet_t pp, alevel_t alev
|
|||
/* Allocate a new queue item. */
|
||||
|
||||
pnew = (struct dlq_item_s *) calloc (sizeof(struct dlq_item_s), 1);
|
||||
if (pnew == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FATAL ERROR: Out of memory.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
s_new_count++;
|
||||
|
||||
if (s_new_count > s_delete_count + 50) {
|
||||
|
@ -492,6 +503,11 @@ void dlq_connect_request (char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LEN], int num
|
|||
/* Allocate a new queue item. */
|
||||
|
||||
pnew = (struct dlq_item_s *) calloc (sizeof(struct dlq_item_s), 1);
|
||||
if (pnew == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FATAL ERROR: Out of memory.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
s_new_count++;
|
||||
|
||||
pnew->type = DLQ_CONNECT_REQUEST;
|
||||
|
@ -545,6 +561,11 @@ void dlq_disconnect_request (char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LEN], int
|
|||
/* Allocate a new queue item. */
|
||||
|
||||
pnew = (struct dlq_item_s *) calloc (sizeof(struct dlq_item_s), 1);
|
||||
if (pnew == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FATAL ERROR: Out of memory.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
s_new_count++;
|
||||
|
||||
pnew->type = DLQ_DISCONNECT_REQUEST;
|
||||
|
@ -603,6 +624,11 @@ void dlq_outstanding_frames_request (char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LE
|
|||
/* Allocate a new queue item. */
|
||||
|
||||
pnew = (struct dlq_item_s *) calloc (sizeof(struct dlq_item_s), 1);
|
||||
if (pnew == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FATAL ERROR: Out of memory.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
s_new_count++;
|
||||
|
||||
pnew->type = DLQ_OUTSTANDING_FRAMES_REQUEST;
|
||||
|
@ -670,6 +696,11 @@ void dlq_xmit_data_request (char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LEN], int n
|
|||
/* Allocate a new queue item. */
|
||||
|
||||
pnew = (struct dlq_item_s *) calloc (sizeof(struct dlq_item_s), 1);
|
||||
if (pnew == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FATAL ERROR: Out of memory.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
s_new_count++;
|
||||
|
||||
pnew->type = DLQ_XMIT_DATA_REQUEST;
|
||||
|
@ -733,6 +764,11 @@ void dlq_register_callsign (char addr[AX25_MAX_ADDR_LEN], int chan, int client)
|
|||
/* Allocate a new queue item. */
|
||||
|
||||
pnew = (struct dlq_item_s *) calloc (sizeof(struct dlq_item_s), 1);
|
||||
if (pnew == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FATAL ERROR: Out of memory.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
s_new_count++;
|
||||
|
||||
pnew->type = DLQ_REGISTER_CALLSIGN;
|
||||
|
@ -763,6 +799,11 @@ void dlq_unregister_callsign (char addr[AX25_MAX_ADDR_LEN], int chan, int client
|
|||
/* Allocate a new queue item. */
|
||||
|
||||
pnew = (struct dlq_item_s *) calloc (sizeof(struct dlq_item_s), 1);
|
||||
if (pnew == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FATAL ERROR: Out of memory.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
s_new_count++;
|
||||
|
||||
pnew->type = DLQ_UNREGISTER_CALLSIGN;
|
||||
|
@ -817,6 +858,11 @@ void dlq_channel_busy (int chan, int activity, int status)
|
|||
/* Allocate a new queue item. */
|
||||
|
||||
pnew = (struct dlq_item_s *) calloc (sizeof(struct dlq_item_s), 1);
|
||||
if (pnew == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FATAL ERROR: Out of memory.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
s_new_count++;
|
||||
|
||||
pnew->type = DLQ_CHANNEL_BUSY;
|
||||
|
@ -840,7 +886,7 @@ void dlq_channel_busy (int chan, int activity, int status)
|
|||
* Name: dlq_seize_confirm
|
||||
*
|
||||
* Purpose: Inform data link state machine that the transmitter is on.
|
||||
* This is in reponse to lm_seize_request.
|
||||
* This is in response to lm_seize_request.
|
||||
*
|
||||
* Inputs: chan - Radio channel number.
|
||||
*
|
||||
|
@ -865,6 +911,11 @@ void dlq_seize_confirm (int chan)
|
|||
/* Allocate a new queue item. */
|
||||
|
||||
pnew = (struct dlq_item_s *) calloc (sizeof(struct dlq_item_s), 1);
|
||||
if (pnew == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FATAL ERROR: Out of memory.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
s_new_count++;
|
||||
|
||||
pnew->type = DLQ_SEIZE_CONFIRM;
|
||||
|
@ -910,6 +961,11 @@ void dlq_client_cleanup (int client)
|
|||
/* Allocate a new queue item. */
|
||||
|
||||
pnew = (struct dlq_item_s *) calloc (sizeof(struct dlq_item_s), 1);
|
||||
if (pnew == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FATAL ERROR: Out of memory.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
s_new_count++;
|
||||
|
||||
// All we care about is the client number.
|
||||
|
@ -1192,6 +1248,11 @@ cdata_t *cdata_new (int pid, char *data, int len)
|
|||
size = ( len + 127 ) & ~0x7f;
|
||||
|
||||
cdata = malloc ( sizeof(cdata_t) + size );
|
||||
if (cdata == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FATAL ERROR: Out of memory.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
cdata->magic = TXDATA_MAGIC;
|
||||
cdata->next = NULL;
|
||||
|
|
|
@ -0,0 +1,260 @@
|
|||
//
|
||||
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
||||
//
|
||||
// Copyright (C) 2020 Heikki Hannikainen, OH7LZB
|
||||
//
|
||||
//
|
||||
// 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
*
|
||||
* Module: dns_sd_avahi.c
|
||||
*
|
||||
* Purpose: Announce the KISS over TCP service using DNS-SD via Avahi
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Most people have typed in enough IP addresses and ports by now, and
|
||||
* would rather just select an available TNC that is automatically
|
||||
* discovered on the local network. Even more so on a mobile device
|
||||
* such an Android or iOS phone or tablet.
|
||||
*
|
||||
* On Linux, the announcement can be made through Avahi, the mDNS
|
||||
* framework commonly deployed on Linux systems.
|
||||
*
|
||||
* This is largely based on the publishing example of the Avahi library.
|
||||
*/
|
||||
|
||||
#ifdef USE_AVAHI_CLIENT
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <avahi-client/client.h>
|
||||
#include <avahi-client/publish.h>
|
||||
#include <avahi-common/simple-watch.h>
|
||||
#include <avahi-common/alternative.h>
|
||||
#include <avahi-common/malloc.h>
|
||||
#include <avahi-common/error.h>
|
||||
|
||||
#include "dns_sd_dw.h"
|
||||
#include "dns_sd_common.h"
|
||||
#include "textcolor.h"
|
||||
|
||||
static AvahiEntryGroup *group = NULL;
|
||||
static AvahiSimplePoll *simple_poll = NULL;
|
||||
static AvahiClient *client = NULL;
|
||||
static char *name = NULL;
|
||||
static int kiss_port = 0;
|
||||
|
||||
pthread_t avahi_thread;
|
||||
|
||||
static void create_services(AvahiClient *c);
|
||||
|
||||
#define PRINT_PREFIX "DNS-SD: Avahi: "
|
||||
|
||||
static void entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void *userdata)
|
||||
{
|
||||
assert(g == group || group == NULL);
|
||||
group = g;
|
||||
|
||||
/* Called whenever the entry group state changes */
|
||||
switch (state) {
|
||||
case AVAHI_ENTRY_GROUP_ESTABLISHED :
|
||||
/* The entry group has been established successfully */
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf(PRINT_PREFIX "Service '%s' successfully registered.\n", name);
|
||||
break;
|
||||
case AVAHI_ENTRY_GROUP_COLLISION: {
|
||||
char *n;
|
||||
/* A service name collision with a remote service
|
||||
* happened. Let's pick a new name. */
|
||||
n = avahi_alternative_service_name(name);
|
||||
avahi_free(name);
|
||||
name = n;
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf(PRINT_PREFIX "Service name collision, renaming service to '%s'\n", name);
|
||||
/* And recreate the services */
|
||||
create_services(avahi_entry_group_get_client(g));
|
||||
break;
|
||||
}
|
||||
case AVAHI_ENTRY_GROUP_FAILURE:
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf(PRINT_PREFIX "Entry group failure: %s\n", avahi_strerror(avahi_client_errno(avahi_entry_group_get_client(g))));
|
||||
/* Some kind of failure happened while we were registering our services */
|
||||
avahi_simple_poll_quit(simple_poll);
|
||||
break;
|
||||
case AVAHI_ENTRY_GROUP_UNCOMMITED:
|
||||
case AVAHI_ENTRY_GROUP_REGISTERING:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
static void create_services(AvahiClient *c)
|
||||
{
|
||||
char *n;
|
||||
int ret;
|
||||
assert(c);
|
||||
/* If this is the first time we're called, let's create a new
|
||||
* entry group if necessary */
|
||||
if (!group) {
|
||||
if (!(group = avahi_entry_group_new(c, entry_group_callback, NULL))) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf(PRINT_PREFIX "avahi_entry_group_new() failed: %s\n", avahi_strerror(avahi_client_errno(c)));
|
||||
goto fail;
|
||||
}
|
||||
} else {
|
||||
avahi_entry_group_reset(group);
|
||||
}
|
||||
|
||||
/* If the group is empty (either because it was just created, or
|
||||
* because it was reset previously, add our entries. */
|
||||
if (avahi_entry_group_is_empty(group)) {
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf(PRINT_PREFIX "Announcing KISS TCP on port %d as '%s'\n", kiss_port, name);
|
||||
|
||||
/* Announce with AVAHI_PROTO_INET instead of AVAHI_PROTO_UNSPEC, since Dire Wolf currently
|
||||
* only listens on IPv4.
|
||||
*/
|
||||
|
||||
if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_INET, 0, name, DNS_SD_SERVICE, NULL, NULL, kiss_port, NULL)) < 0) {
|
||||
if (ret == AVAHI_ERR_COLLISION)
|
||||
goto collision;
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf(PRINT_PREFIX "Failed to add _kiss-tnc._tcp service: %s\n", avahi_strerror(ret));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Tell the server to register the service */
|
||||
if ((ret = avahi_entry_group_commit(group)) < 0) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf(PRINT_PREFIX "Failed to commit entry group: %s\n", avahi_strerror(ret));
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
collision:
|
||||
/* A service name collision with a local service happened. Let's
|
||||
* pick a new name */
|
||||
n = avahi_alternative_service_name(name);
|
||||
avahi_free(name);
|
||||
name = n;
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf(PRINT_PREFIX "Service name collision, renaming service to '%s'\n", name);
|
||||
avahi_entry_group_reset(group);
|
||||
create_services(c);
|
||||
return;
|
||||
|
||||
fail:
|
||||
avahi_simple_poll_quit(simple_poll);
|
||||
}
|
||||
|
||||
static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata)
|
||||
{
|
||||
assert(c);
|
||||
/* Called whenever the client or server state changes */
|
||||
switch (state) {
|
||||
case AVAHI_CLIENT_S_RUNNING:
|
||||
/* The server has startup successfully and registered its host
|
||||
* name on the network, so it's time to create our services */
|
||||
create_services(c);
|
||||
break;
|
||||
case AVAHI_CLIENT_FAILURE:
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf(PRINT_PREFIX "Client failure: %s\n", avahi_strerror(avahi_client_errno(c)));
|
||||
avahi_simple_poll_quit(simple_poll);
|
||||
break;
|
||||
case AVAHI_CLIENT_S_COLLISION:
|
||||
/* Let's drop our registered services. When the server is back
|
||||
* in AVAHI_SERVER_RUNNING state we will register them
|
||||
* again with the new host name. */
|
||||
case AVAHI_CLIENT_S_REGISTERING:
|
||||
/* The server records are now being established. This
|
||||
* might be caused by a host name change. We need to wait
|
||||
* for our own records to register until the host name is
|
||||
* properly esatblished. */
|
||||
if (group)
|
||||
avahi_entry_group_reset(group);
|
||||
break;
|
||||
case AVAHI_CLIENT_CONNECTING:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
static void cleanup(void)
|
||||
{
|
||||
/* Cleanup things */
|
||||
if (client)
|
||||
avahi_client_free(client);
|
||||
|
||||
if (simple_poll)
|
||||
avahi_simple_poll_free(simple_poll);
|
||||
|
||||
avahi_free(name);
|
||||
}
|
||||
|
||||
|
||||
static void *avahi_mainloop(void *arg)
|
||||
{
|
||||
/* Run the main loop */
|
||||
avahi_simple_poll_loop(simple_poll);
|
||||
|
||||
cleanup();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void dns_sd_announce (struct misc_config_s *mc)
|
||||
{
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
//kiss_port = mc->kiss_port; // now an array.
|
||||
kiss_port = mc->kiss_port[0]; // FIXME: Quick hack until I can handle multiple TCP ports properly.
|
||||
|
||||
int error;
|
||||
|
||||
/* Allocate main loop object */
|
||||
if (!(simple_poll = avahi_simple_poll_new())) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf(PRINT_PREFIX "Failed to create Avahi simple poll object.\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (mc->dns_sd_name[0]) {
|
||||
name = avahi_strdup(mc->dns_sd_name);
|
||||
} else {
|
||||
name = dns_sd_default_service_name();
|
||||
}
|
||||
|
||||
/* Allocate a new client */
|
||||
client = avahi_client_new(avahi_simple_poll_get(simple_poll), 0, client_callback, NULL, &error);
|
||||
|
||||
/* Check whether creating the client object succeeded */
|
||||
if (!client) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf(PRINT_PREFIX "Failed to create Avahi client: %s\n", avahi_strerror(error));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pthread_create(&avahi_thread, NULL, &avahi_mainloop, NULL);
|
||||
|
||||
return;
|
||||
|
||||
fail:
|
||||
cleanup();
|
||||
}
|
||||
|
||||
#endif // USE_AVAHI_CLIENT
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
//
|
||||
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
||||
//
|
||||
// Copyright (C) 2020 Heikki Hannikainen, OH7LZB
|
||||
//
|
||||
//
|
||||
// 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
*
|
||||
* Module: dns_sd_common.c
|
||||
*
|
||||
* Purpose: Announce the KISS over TCP service using DNS-SD, common functions
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Most people have typed in enough IP addresses and ports by now, and
|
||||
* would rather just select an available TNC that is automatically
|
||||
* discovered on the local network. Even more so on a mobile device
|
||||
* such an Android or iOS phone or tablet.
|
||||
*
|
||||
* This module contains common functions needed on Linux and MacOS.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Get a default service name to publish. By default,
|
||||
* "Dire Wolf on <hostname>", or just "Dire Wolf" if hostname cannot
|
||||
* be obtained.
|
||||
*/
|
||||
char *dns_sd_default_service_name(void)
|
||||
{
|
||||
char hostname[51];
|
||||
char sname[64];
|
||||
|
||||
int i = gethostname(hostname, sizeof(hostname));
|
||||
if (i == 0) {
|
||||
hostname[sizeof(hostname)-1] = 0;
|
||||
|
||||
// on some systems, an FQDN is returned; remove domain part
|
||||
char *dot = strchr(hostname, '.');
|
||||
if (dot)
|
||||
*dot = 0;
|
||||
|
||||
snprintf(sname, sizeof(sname), "Dire Wolf on %s", hostname);
|
||||
return strdup(sname);
|
||||
}
|
||||
|
||||
return strdup("Dire Wolf");
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
#if (USE_AVAHI_CLIENT|USE_MACOS_DNSSD)
|
||||
|
||||
char *dns_sd_default_service_name(void);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
#if (USE_AVAHI_CLIENT|USE_MACOS_DNSSD)
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define DNS_SD_SERVICE "_kiss-tnc._tcp"
|
||||
|
||||
void dns_sd_announce (struct misc_config_s *mc);
|
||||
|
||||
#endif // USE_AVAHI_CLIENT
|
|
@ -0,0 +1,89 @@
|
|||
//
|
||||
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
||||
//
|
||||
// Copyright (C) 2020 Heikki Hannikainen, OH7LZB
|
||||
//
|
||||
//
|
||||
// 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
*
|
||||
* Module: dns_sd_macos.c
|
||||
*
|
||||
* Purpose: Announce the KISS over TCP service using MacOS dns-sd
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Most people have typed in enough IP addresses and ports by now, and
|
||||
* would rather just select an available TNC that is automatically
|
||||
* discovered on the local network. Even more so on a mobile device
|
||||
* such an Android or iOS phone or tablet.
|
||||
*
|
||||
* On MacOs, the announcement can be made through dns-sd.
|
||||
*/
|
||||
|
||||
#ifdef USE_MACOS_DNSSD
|
||||
|
||||
#include <string.h>
|
||||
#include <dns_sd.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "dns_sd_dw.h"
|
||||
#include "dns_sd_common.h"
|
||||
#include "textcolor.h"
|
||||
|
||||
static char *name = NULL;
|
||||
|
||||
static void registerServiceCallBack(DNSServiceRef sdRef, DNSServiceFlags flags, DNSServiceErrorType errorCode,
|
||||
const char* name, const char* regType, const char* domain, void* context)
|
||||
{
|
||||
if (errorCode == kDNSServiceErr_NoError) {
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf("DNS-SD: Successfully registered '%s'\n", name);
|
||||
} else {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf("DNS-SD: Failed to register '%s': %d\n", name, errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
void dns_sd_announce (struct misc_config_s *mc)
|
||||
{
|
||||
//int kiss_port = mc->kiss_port; // now an array.
|
||||
int kiss_port = mc->kiss_port[0]; // FIXME: Quick hack until I can handle multiple TCP ports properly.
|
||||
|
||||
if (mc->dns_sd_name[0]) {
|
||||
name = strdup(mc->dns_sd_name);
|
||||
} else {
|
||||
name = dns_sd_default_service_name();
|
||||
}
|
||||
|
||||
uint16_t port_nw = htons(kiss_port);
|
||||
|
||||
DNSServiceRef registerRef;
|
||||
DNSServiceErrorType err = DNSServiceRegister(
|
||||
®isterRef, 0, 0, name, DNS_SD_SERVICE, NULL, NULL,
|
||||
port_nw, 0, NULL, registerServiceCallBack, NULL);
|
||||
|
||||
if (err == kDNSServiceErr_NoError) {
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf("DNS-SD: Announcing KISS TCP on port %d as '%s'\n", kiss_port, name);
|
||||
} else {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf("DNS-SD: Failed to announce '%s': %d\n", name, err);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // USE_MACOS_DNSSD
|
||||
|
||||
|
134
src/dsp.c
134
src/dsp.c
|
@ -43,7 +43,6 @@
|
|||
#include "dsp.h"
|
||||
|
||||
|
||||
//#include "fsk_demod_agc.h" /* for M_FILTER_SIZE, etc. */
|
||||
|
||||
#define MIN(a,b) ((a)<(b)?(a):(b))
|
||||
#define MAX(a,b) ((a)>(b)?(a):(b))
|
||||
|
@ -127,7 +126,7 @@ float window (bp_window_t type, int size, int j)
|
|||
*----------------------------------------------------------------*/
|
||||
|
||||
|
||||
int gen_lowpass (float fc, float *lp_filter, int filter_size, bp_window_t wtype, float lp_delay_fract)
|
||||
void gen_lowpass (float fc, float *lp_filter, int filter_size, bp_window_t wtype)
|
||||
{
|
||||
int j;
|
||||
float G;
|
||||
|
@ -175,54 +174,7 @@ int gen_lowpass (float fc, float *lp_filter, int filter_size, bp_window_t wtype,
|
|||
lp_filter[j] = lp_filter[j] / G;
|
||||
}
|
||||
|
||||
|
||||
// Calculate the signal delay.
|
||||
// If a signal at level 0 steps to level 1, this is the time that it would
|
||||
// take for the output to reach 0.5.
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// Filter has one tap with value of 1.0.
|
||||
// Output is immediate so I would call this delay of 0.
|
||||
//
|
||||
// Filter coefficients: 0.2, 0.2, 0.2, 0.2, 0.2
|
||||
// "1" inputs Out
|
||||
// 1 0.2
|
||||
// 2 0.4
|
||||
// 3 0.6
|
||||
//
|
||||
// In this case, the output does not change immediately.
|
||||
// It takes two more samples to reach the half way point
|
||||
// so it has a delay of 2.
|
||||
|
||||
float sum = 0;
|
||||
int delay = 0;
|
||||
|
||||
if (lp_delay_fract == 0) lp_delay_fract = 0.5;
|
||||
|
||||
for (j=0; j<filter_size; j++) {
|
||||
sum += lp_filter[j];
|
||||
#if DEBUG1
|
||||
dw_printf ("lp_filter[%d] = %.3f sum = %.3f lp_delay_fract = %.3f\n", j, lp_filter[j], sum, lp_delay_fract);
|
||||
#endif
|
||||
if (sum > lp_delay_fract) {
|
||||
delay = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG1
|
||||
dw_printf ("Low Pass Delay = %d samples\n", delay) ;
|
||||
#endif
|
||||
|
||||
// Hmmm. This might have been wasted effort. The result is always half the number of taps.
|
||||
|
||||
if (delay < 2 || delay > filter_size - 2) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Internal error, %s %d, delay %d for size %d\n", __func__, __LINE__, delay, filter_size);
|
||||
}
|
||||
|
||||
return (delay);
|
||||
return;
|
||||
|
||||
} /* end gen_lowpass */
|
||||
|
||||
|
@ -369,4 +321,86 @@ void gen_ms (int fc, int sps, float *sin_table, float *cos_table, int filter_siz
|
|||
} /* end gen_ms */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
*
|
||||
* Name: rrc
|
||||
*
|
||||
* Purpose: Root Raised Cosine function.
|
||||
* Why do they call it that?
|
||||
* It's mostly the sinc function with cos windowing to taper off edges faster.
|
||||
*
|
||||
* Inputs: t - Time in units of symbol duration.
|
||||
* i.e. The centers of two adjacent symbols would differ by 1.
|
||||
*
|
||||
* a - Roll off factor, between 0 and 1.
|
||||
*
|
||||
* Returns: Basically the sinc (sin(x)/x) function with edges decreasing faster.
|
||||
* Should be 1 for t = 0 and 0 at all other integer values of t.
|
||||
*
|
||||
*----------------------------------------------------------------*/
|
||||
|
||||
__attribute__((const))
|
||||
float rrc (float t, float a)
|
||||
{
|
||||
float sinc, window, result;
|
||||
|
||||
if (t > -0.001 && t < 0.001) {
|
||||
sinc = 1;
|
||||
}
|
||||
else {
|
||||
sinc = sinf(M_PI * t) / (M_PI * t);
|
||||
}
|
||||
|
||||
if (fabsf(a * t) > 0.499 && fabsf(a * t) < 0.501) {
|
||||
window = M_PI / 4;
|
||||
}
|
||||
else {
|
||||
window = cos(M_PI * a * t) / ( 1 - powf(2 * a * t, 2));
|
||||
// This made nicer looking waveforms for generating signal.
|
||||
//window = cos(M_PI * a * t);
|
||||
// Do we want to let it go negative?
|
||||
// I think this would happen when a > 0.5 / (filter width in symbol times)
|
||||
if (window < 0) {
|
||||
//printf ("'a' is too large for range of 't'.\n");
|
||||
//window = 0;
|
||||
}
|
||||
}
|
||||
|
||||
result = sinc * window;
|
||||
|
||||
#if DEBUGRRC
|
||||
// t should vary from - to + half of filter size in symbols.
|
||||
// Result should be 1 at t=0 and 0 at all other integer values of t.
|
||||
|
||||
printf ("%.3f, %.3f, %.3f, %.3f\n", t, sinc, window, result);
|
||||
#endif
|
||||
return (result);
|
||||
}
|
||||
|
||||
// The Root Raised Cosine (RRC) low pass filter is suppposed to minimize Intersymbol Interference (ISI).
|
||||
|
||||
void gen_rrc_lowpass (float *pfilter, int filter_taps, float rolloff, float samples_per_symbol)
|
||||
{
|
||||
int k;
|
||||
float t;
|
||||
|
||||
for (k = 0; k < filter_taps; k++) {
|
||||
t = (k - ((filter_taps - 1.0) / 2.0)) / samples_per_symbol;
|
||||
pfilter[k] = rrc (t, rolloff);
|
||||
}
|
||||
|
||||
// Scale it for unity gain.
|
||||
|
||||
t = 0;
|
||||
for (k = 0; k < filter_taps; k++) {
|
||||
t += pfilter[k];
|
||||
}
|
||||
for (k = 0; k < filter_taps; k++) {
|
||||
pfilter[k] = pfilter[k] / t;
|
||||
}
|
||||
}
|
||||
|
||||
/* end dsp.c */
|
||||
|
|
|
@ -5,9 +5,13 @@
|
|||
|
||||
float window (bp_window_t type, int size, int j);
|
||||
|
||||
int gen_lowpass (float fc, float *lp_filter, int filter_size, bp_window_t wtype, float lp_delay_fract);
|
||||
void gen_lowpass (float fc, float *lp_filter, int filter_size, bp_window_t wtype);
|
||||
|
||||
void gen_bandpass (float f1, float f2, float *bp_filter, int filter_size, bp_window_t wtype);
|
||||
|
||||
void gen_ms (int fc, int samples_per_sec, float *sin_table, float *cos_table, int filter_size, int wtype);
|
||||
|
||||
|
||||
__attribute__((const)) float rrc (float t, float a);
|
||||
|
||||
void gen_rrc_lowpass (float *pfilter, int filter_taps, float rolloff, float samples_per_symbol);
|
||||
|
|
|
@ -245,7 +245,7 @@ char dtmf_sample (int c, float input)
|
|||
* others in the same group multiplied by some factor.
|
||||
*
|
||||
* For perfect synthetic signals this needs to be in
|
||||
* the range of about 1.33 (very senstive) to 2.15 (very fussy).
|
||||
* the range of about 1.33 (very sensitive) to 2.15 (very fussy).
|
||||
*
|
||||
* Too low will cause false triggers on random noise.
|
||||
* Too high will won't decode less than perfect signals.
|
||||
|
@ -529,7 +529,7 @@ int main ()
|
|||
memset (&my_audio_config, 0, sizeof(my_audio_config));
|
||||
my_audio_config.adev[ACHAN2ADEV(c)].defined = 1;
|
||||
my_audio_config.adev[ACHAN2ADEV(c)].samples_per_sec = 44100;
|
||||
my_audio_config.achan[c].medium = MEDIUM_RADIO;
|
||||
my_audio_config.chan_medium[c] = MEDIUM_RADIO;
|
||||
my_audio_config.achan[c].dtmf_decode = DTMF_DECODE_ON;
|
||||
|
||||
dtmf_init(&my_audio_config, 50);
|
||||
|
|
|
@ -90,7 +90,7 @@ static dw_mutex_t s_gps_mutex;
|
|||
*
|
||||
* Name: dwgps_init
|
||||
*
|
||||
* Purpose: Intialize the GPS interface.
|
||||
* Purpose: Initialize the GPS interface.
|
||||
*
|
||||
* Inputs: pconfig Configuration settings. This might include
|
||||
* serial port name for direct connect and host
|
||||
|
|
136
src/dwgpsd.c
136
src/dwgpsd.c
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
||||
//
|
||||
// Copyright (C) 2013, 2014, 2015 John Langner, WB2OSZ
|
||||
// Copyright (C) 2013, 2014, 2015, 2020, 2022 John Langner, WB2OSZ
|
||||
//
|
||||
// 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
|
||||
|
@ -20,7 +20,7 @@
|
|||
|
||||
/*------------------------------------------------------------------
|
||||
*
|
||||
* Module: dwgps.c
|
||||
* Module: dwgpsd.c
|
||||
*
|
||||
* Purpose: Interface to location data, i.e. GPS receiver.
|
||||
*
|
||||
|
@ -55,13 +55,16 @@
|
|||
|
||||
#include <gps.h>
|
||||
|
||||
// Debian bug report: direwolf (1.2-1) FTBFS with libgps22 as part of the gpsd transition (#803605):
|
||||
// dwgps.c claims to only support GPSD_API_MAJOR_VERSION 5, but also builds successfully with
|
||||
// GPSD_API_MAJOR_VERSION 6 provided by libgps22 when the attached patch is applied.
|
||||
|
||||
// Also compatible with API 7 & 8 with conditional compilation later.
|
||||
|
||||
#if GPSD_API_MAJOR_VERSION < 5 || GPSD_API_MAJOR_VERSION > 8
|
||||
// An incompatibility was introduced with version 7
|
||||
// and again with 9 and again with 10.
|
||||
|
||||
// release lib version API Raspberry Pi OS
|
||||
// 3.22 28 11 bullseye
|
||||
// 3.23 29 12
|
||||
|
||||
#if GPSD_API_MAJOR_VERSION < 5 || GPSD_API_MAJOR_VERSION > 12
|
||||
#error libgps API version might be incompatible.
|
||||
#endif
|
||||
|
||||
|
@ -95,7 +98,7 @@ static void * read_gpsd_thread (void *arg);
|
|||
*
|
||||
* Name: dwgpsd_init
|
||||
*
|
||||
* Purpose: Intialize the GPS interface.
|
||||
* Purpose: Initialize the GPS interface.
|
||||
*
|
||||
* Inputs: pconfig Configuration settings. This includes
|
||||
* host name or address for network connection.
|
||||
|
@ -116,7 +119,7 @@ static void * read_gpsd_thread (void *arg);
|
|||
* shared region via dwgps_put_data.
|
||||
*
|
||||
* The application calls dwgps_read to get the most
|
||||
8 recent information.
|
||||
* recent information.
|
||||
*
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
@ -126,7 +129,7 @@ static void * read_gpsd_thread (void *arg);
|
|||
* Originally, I wanted to use the shared memory interface to gpsd
|
||||
* because it is simpler and more efficient. Just access it when we
|
||||
* actually need the data and we don't have a lot of extra unnecessary
|
||||
* busy work going on.
|
||||
* busy work going on constantly polling it when we don't need the information.
|
||||
*
|
||||
* The current version of gpsd, supplied with Raspian (Wheezy), is 3.6 from back in
|
||||
* May 2012, is missing support for the shared memory interface.
|
||||
|
@ -149,6 +152,21 @@ static void * read_gpsd_thread (void *arg);
|
|||
*
|
||||
* I'm told that the shared memory interface might work in Raspian, Jessie version.
|
||||
* Haven't tried it yet.
|
||||
*
|
||||
* June 2020: This is how to build the most recent.
|
||||
*
|
||||
* Based on https://www.satsignal.eu/raspberry-pi/UpdatingGPSD.html
|
||||
*
|
||||
* git clone https://gitlab.com/gpsd/gpsd.git gpsd-gitlab
|
||||
* cd gpsd-gitlab
|
||||
* scons --config=force
|
||||
* scons
|
||||
* sudo scons install
|
||||
*
|
||||
* The problem we have here is that the library is put in /usr/local/lib and direwolf
|
||||
* can't find it there. Solution is to define environment variable:
|
||||
*
|
||||
* export LD_LIBRARY_PATH=/use/local/lib
|
||||
*/
|
||||
|
||||
|
||||
|
@ -177,7 +195,7 @@ int dwgpsd_init (struct misc_config_s *pconfig, int debug)
|
|||
|
||||
if (strlen(pconfig->gpsd_host) == 0) {
|
||||
|
||||
/* Nothing to do. Leave initial fix value of errror. */
|
||||
/* Nothing to do. Leave initial fix value of error. */
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -232,7 +250,7 @@ int dwgpsd_init (struct misc_config_s *pconfig, int debug)
|
|||
*
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#define TIMEOUT 30
|
||||
#define TIMEOUT 15
|
||||
|
||||
#if ENABLE_GPSD
|
||||
|
||||
|
@ -255,10 +273,19 @@ static void * read_gpsd_thread (void *arg)
|
|||
|
||||
while (1) {
|
||||
|
||||
// Example code found here:
|
||||
// https://lists.nongnu.org/archive/html/gpsd-dev/2017-11/msg00001.html
|
||||
|
||||
if ( ! gps_waiting(&gpsdata, TIMEOUT * 1000000)) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("GPSD: Timeout waiting for GPS data.\n");
|
||||
/* Fall thru to read which should get error and bail out. */
|
||||
dw_printf ("------------------------------------------\n");
|
||||
dw_printf ("dwgpsd: Timeout waiting for GPS data.\n");
|
||||
dw_printf ("Is GPSD daemon running?\n");
|
||||
dw_printf ("Troubleshooting tip: Try running cgps or xgps.\n");
|
||||
dw_printf ("------------------------------------------\n");
|
||||
info.fix = DWFIX_ERROR;
|
||||
SLEEP_MS(5000);
|
||||
continue;
|
||||
}
|
||||
|
||||
// https://github.com/wb2osz/direwolf/issues/196
|
||||
|
@ -290,17 +317,61 @@ static void * read_gpsd_thread (void *arg)
|
|||
break; // Jump out of loop and terminate thread.
|
||||
}
|
||||
|
||||
#if GPSD_API_MAJOR_VERSION >= 9
|
||||
|
||||
// The gps.h revision history says:
|
||||
// * mark altitude in gps_fix_t as deprecated and undefined
|
||||
// This seems really stupid to me.
|
||||
// If it is deprecated and undefined then take it out. Someone trying to use
|
||||
// it would get a compile error and know that something needs to be done.
|
||||
// Instead we all just go merrily on our way using a field that is [allegedly] undefined.
|
||||
// Why not simply add more variables with different definitions of altitude
|
||||
// and keep the original variable working as it always did?
|
||||
// If it is truly undefined, as the comment would have us believe, numerous
|
||||
// people will WASTE VAST AMOUNTS OF TIME pondering why altitude is now broken in
|
||||
// their applications.
|
||||
|
||||
#define stupid_altitude altMSL
|
||||
#else
|
||||
#define stupid_altitude altitude
|
||||
#endif
|
||||
|
||||
#if GPSD_API_MAJOR_VERSION >= 10
|
||||
|
||||
// They did it again. Whimsical incompatibilities that cause
|
||||
// pain and aggravation for everyone trying to use this library.
|
||||
//
|
||||
// error: ‘struct gps_data_t’ has no member named ‘status’
|
||||
//
|
||||
// Yes, I can understand that it is a more logical place but it breaks
|
||||
// all existing code that uses this.
|
||||
// I'm really getting annoyed about wasting so much time on keeping up with all
|
||||
// of these incompatibilities that are completely unnecessary.
|
||||
|
||||
#define stupid_status fix.status
|
||||
#else
|
||||
#define stupid_status status
|
||||
#endif
|
||||
|
||||
|
||||
if (s_debug >= 3) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("gpsdata: status=%d, mode=%d, lat=%.6f, lon=%.6f, track=%.1f, speed=%.1f, alt=%.0f\n",
|
||||
gpsdata.stupid_status, gpsdata.fix.mode,
|
||||
gpsdata.fix.latitude, gpsdata.fix.longitude,
|
||||
gpsdata.fix.track, gpsdata.fix.speed, gpsdata.fix.stupid_altitude);
|
||||
}
|
||||
|
||||
// Inform user about change in fix status.
|
||||
|
||||
switch (gpsdata.fix.mode) {
|
||||
default:
|
||||
case MODE_NOT_SEEN:
|
||||
if (info.fix >= DWFIX_2D) {
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("GPSD: Lost location fix.\n");
|
||||
}
|
||||
info.fix = DWFIX_NOT_SEEN;
|
||||
break;
|
||||
|
||||
case MODE_NO_FIX:
|
||||
if (info.fix <= DWFIX_NOT_SEEN) {
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("GPSD: No location fix.\n");
|
||||
}
|
||||
if (info.fix >= DWFIX_2D) {
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("GPSD: Lost location fix.\n");
|
||||
|
@ -325,21 +396,27 @@ static void * read_gpsd_thread (void *arg)
|
|||
break;
|
||||
}
|
||||
|
||||
/* Data is available. */
|
||||
// TODO: what is gpsdata.status?
|
||||
|
||||
// Oct. 2020 - 'status' is always zero for latest version of libgps so we can't use that anymore.
|
||||
|
||||
if (gpsdata.status >= STATUS_FIX && gpsdata.fix.mode >= MODE_2D) {
|
||||
if (/*gpsdata.stupid_status >= STATUS_FIX &&*/ gpsdata.fix.mode >= MODE_2D) {
|
||||
|
||||
info.dlat = isnan(gpsdata.fix.latitude) ? G_UNKNOWN : gpsdata.fix.latitude;
|
||||
info.dlon = isnan(gpsdata.fix.longitude) ? G_UNKNOWN : gpsdata.fix.longitude;
|
||||
info.track = isnan(gpsdata.fix.track) ? G_UNKNOWN : gpsdata.fix.track;
|
||||
info.speed_knots = isnan(gpsdata.fix.speed) ? G_UNKNOWN : (MPS_TO_KNOTS * gpsdata.fix.speed);
|
||||
#define GOOD(x) (isfinite(x) && ! isnan(x))
|
||||
|
||||
info.dlat = GOOD(gpsdata.fix.latitude) ? gpsdata.fix.latitude : G_UNKNOWN;
|
||||
info.dlon = GOOD(gpsdata.fix.longitude) ? gpsdata.fix.longitude : G_UNKNOWN;
|
||||
// When stationary, track is NaN which is not finite.
|
||||
info.track = GOOD(gpsdata.fix.track) ? gpsdata.fix.track : G_UNKNOWN;
|
||||
info.speed_knots = GOOD(gpsdata.fix.speed) ? (MPS_TO_KNOTS * gpsdata.fix.speed) : G_UNKNOWN;
|
||||
if (gpsdata.fix.mode >= MODE_3D) {
|
||||
info.altitude = isnan(gpsdata.fix.altitude) ? G_UNKNOWN : gpsdata.fix.altitude;
|
||||
info.altitude = GOOD(gpsdata.fix.stupid_altitude) ? gpsdata.fix.stupid_altitude : G_UNKNOWN;
|
||||
}
|
||||
// Otherwise keep last known altitude when we downgrade from 3D to 2D fix.
|
||||
// Caller knows altitude is outdated if info.fix == DWFIX_2D.
|
||||
}
|
||||
// Otherwise keep the last known location which is better than totally lost.
|
||||
// Caller knows location is outdated if info.fix == DWFIX_NO_FIX.
|
||||
|
||||
|
||||
info.timestamp = time(NULL);
|
||||
if (s_debug >= 2) {
|
||||
|
@ -373,6 +450,7 @@ void dwgpsd_term (void) {
|
|||
|
||||
#if ENABLE_GPSD
|
||||
|
||||
gps_stream (&gpsdata, WATCH_DISABLE, NULL);
|
||||
gps_close (&gpsdata);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -144,11 +144,9 @@ int dwgpsnmea_init (struct misc_config_s *pconfig, int debug)
|
|||
|
||||
/*
|
||||
* Open serial port connection.
|
||||
* 4800 baud is standard for GPS.
|
||||
* Should add an option to allow changing someday.
|
||||
*/
|
||||
|
||||
s_gpsnmea_port_fd = serial_port_open (pconfig->gpsnmea_port, 4800);
|
||||
s_gpsnmea_port_fd = serial_port_open (pconfig->gpsnmea_port, pconfig->gpsnmea_speed);
|
||||
|
||||
if (s_gpsnmea_port_fd != MYFDERROR) {
|
||||
#if __WIN32__
|
||||
|
@ -182,12 +180,10 @@ int dwgpsnmea_init (struct misc_config_s *pconfig, int debug)
|
|||
|
||||
|
||||
/* Return fd to share if waypoint wants same device. */
|
||||
/* Currently both are fixed speed at 4800. */
|
||||
/* If that ever becomes configurable, that needs to be compared too. */
|
||||
|
||||
MYFDTYPE dwgpsnmea_get_fd(char *wp_port_name, int speed)
|
||||
{
|
||||
if (strcmp(s_save_configp->gpsnmea_port, wp_port_name) == 0 && speed == 4800) {
|
||||
if (strcmp(s_save_configp->gpsnmea_port, wp_port_name) == 0 && speed == s_save_configp->gpsnmea_speed) {
|
||||
return (s_gpsnmea_port_fd);
|
||||
}
|
||||
return (MYFDERROR);
|
||||
|
@ -266,9 +262,12 @@ static void * read_gpsnmea_thread (void *arg)
|
|||
}
|
||||
dwgps_set_data (&info);
|
||||
|
||||
// TODO: doesn't exist yet - serial_port_close(fd);
|
||||
serial_port_close(s_gpsnmea_port_fd);
|
||||
s_gpsnmea_port_fd = MYFDERROR;
|
||||
|
||||
// TODO: If the open() was in this thread, we could wait a while and
|
||||
// try to open again. That would allow recovery if the USB GPS device
|
||||
// is unplugged and plugged in again.
|
||||
break; /* terminate thread. */
|
||||
}
|
||||
|
||||
|
@ -289,74 +288,54 @@ static void * read_gpsnmea_thread (void *arg)
|
|||
}
|
||||
|
||||
/* Process sentence. */
|
||||
// TODO: More general: Ignore the second letter rather than recognizing only GP... and GN...
|
||||
|
||||
if (strncmp(gps_msg, "$GPRMC", 6) == 0 ||
|
||||
strncmp(gps_msg, "$GNRMC", 6) == 0) {
|
||||
|
||||
f = dwgpsnmea_gprmc (gps_msg, 0, &info.dlat, &info.dlon, &info.speed_knots, &info.track);
|
||||
// Here we just tuck away the course and speed.
|
||||
// Fix and location will be updated by GxGGA.
|
||||
|
||||
double ignore_dlat;
|
||||
double ignore_dlon;
|
||||
|
||||
f = dwgpsnmea_gprmc (gps_msg, 0, &ignore_dlat, &ignore_dlon, &info.speed_knots, &info.track);
|
||||
|
||||
if (f == DWFIX_ERROR) {
|
||||
|
||||
/* Parse error. Shouldn't happen. Better luck next time. */
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("GPSNMEA: Error parsing $GPRMC sentence.\n");
|
||||
dw_printf ("%s\n", gps_msg);
|
||||
}
|
||||
else if (f == DWFIX_2D) {
|
||||
|
||||
if (info.fix != DWFIX_2D && info.fix != DWFIX_3D) {
|
||||
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("GPSNMEA: Location fix is now available.\n");
|
||||
|
||||
info.fix = DWFIX_2D; // Don't know if 2D or 3D. Take minimum.
|
||||
}
|
||||
info.timestamp = time(NULL);
|
||||
if (s_debug >= 2) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dwgps_print ("GPSNMEA: ", &info);
|
||||
}
|
||||
dwgps_set_data (&info);
|
||||
}
|
||||
else {
|
||||
|
||||
if (info.fix == DWFIX_2D || info.fix == DWFIX_3D) {
|
||||
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("GPSNMEA: Lost location fix.\n");
|
||||
}
|
||||
info.fix = f; /* lost it. */
|
||||
info.timestamp = time(NULL);
|
||||
if (s_debug >= 2) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dwgps_print ("GPSNMEA: ", &info);
|
||||
}
|
||||
dwgps_set_data (&info);
|
||||
}
|
||||
|
||||
}
|
||||
else if (strncmp(gps_msg, "$GPGGA", 6) == 0 ||
|
||||
strncmp(gps_msg, "$GNGGA", 6) == 0) {
|
||||
int nsat;
|
||||
|
||||
f = dwgpsnmea_gpgga (gps_msg, 0, &info.dlat, &info.dlon, &info.altitude, &nsat);
|
||||
|
||||
/* Only switch between 2D & 3D. */
|
||||
/* Let GPRMC handle other changes in fix state and data transfer. */
|
||||
|
||||
if (f == DWFIX_ERROR) {
|
||||
|
||||
/* Parse error. Shouldn't happen. Better luck next time. */
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("GPSNMEA: Error parsing $GPGGA sentence.\n");
|
||||
dw_printf ("%s\n", gps_msg);
|
||||
}
|
||||
else if ((f == DWFIX_3D && info.fix == DWFIX_2D) ||
|
||||
(f == DWFIX_2D && info.fix == DWFIX_3D)) {
|
||||
else {
|
||||
if (f != info.fix) { // Print change in location fix.
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("GPSNMEA: Location fix is now %dD.\n", (int)f);
|
||||
if (f == DWFIX_NO_FIX) dw_printf ("GPSNMEA: Location fix has been lost.\n");
|
||||
if (f == DWFIX_2D) dw_printf ("GPSNMEA: Location fix is now 2D.\n");
|
||||
if (f == DWFIX_3D) dw_printf ("GPSNMEA: Location fix is now 3D.\n");
|
||||
info.fix = f;
|
||||
}
|
||||
info.timestamp = time(NULL);
|
||||
if (s_debug >= 2) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dwgps_print ("GPSNMEA: ", &info);
|
||||
}
|
||||
dwgps_set_data (&info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -436,7 +415,7 @@ static int remove_checksum (char *sent, int quiet)
|
|||
*
|
||||
* Name: dwgpsnmea_gprmc
|
||||
*
|
||||
* Purpose: Parse $GPRMC sentence and extract interesing parts.
|
||||
* Purpose: Parse $GPRMC sentence and extract interesting parts.
|
||||
*
|
||||
* Inputs: sentence NMEA sentence.
|
||||
*
|
||||
|
@ -449,6 +428,8 @@ static int remove_checksum (char *sent, int quiet)
|
|||
*
|
||||
* Left undefined if not valid.
|
||||
*
|
||||
* Note: RMC does not contain altitude.
|
||||
*
|
||||
* Returns: DWFIX_ERROR Parse error.
|
||||
* DWFIX_NO_FIX GPS is there but Position unknown. Could be temporary.
|
||||
* DWFIX_2D Valid position. We don't know if it is really 2D or 3D.
|
||||
|
@ -585,7 +566,7 @@ dwfix_t dwgpsnmea_gprmc (char *sentence, int quiet, double *odlat, double *odlon
|
|||
*
|
||||
* Name: dwgpsnmea_gpgga
|
||||
*
|
||||
* Purpose: Parse $GPGGA sentence and extract interesing parts.
|
||||
* Purpose: Parse $GPGGA sentence and extract interesting parts.
|
||||
*
|
||||
* Inputs: sentence NMEA sentence.
|
||||
*
|
||||
|
@ -598,10 +579,13 @@ dwfix_t dwgpsnmea_gprmc (char *sentence, int quiet, double *odlat, double *odlon
|
|||
*
|
||||
* Left undefined if not valid.
|
||||
*
|
||||
* Note: GGA has altitude but not course and speed so we need to use both.
|
||||
*
|
||||
* Returns: DWFIX_ERROR Parse error.
|
||||
* DWFIX_NO_FIX GPS is there but Position unknown. Could be temporary.
|
||||
* DWFIX_2D Valid position. We don't know if it is really 2D or 3D.
|
||||
* Take more cautious value so we don't try using altitude.
|
||||
* DWFIX_3D Valid 3D position.
|
||||
*
|
||||
* Examples: $GPGGA,001429.00,,,,,0,00,99.99,,,,,,*68
|
||||
* $GPGGA,212407.000,4237.1505,N,07120.8602,W,0,00,,,M,,M,,*58
|
||||
|
@ -610,9 +594,6 @@ dwfix_t dwgpsnmea_gprmc (char *sentence, int quiet, double *odlat, double *odlon
|
|||
*
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
// TODO: in progress...
|
||||
|
||||
dwfix_t dwgpsnmea_gpgga (char *sentence, int quiet, double *odlat, double *odlon, float *oalt, int *onsat)
|
||||
{
|
||||
char stemp[NMEA_MAX_LEN]; /* Make copy because parsing is destructive. */
|
||||
|
@ -709,8 +690,7 @@ dwfix_t dwgpsnmea_gpgga (char *sentence, int quiet, double *odlat, double *odlon
|
|||
return (DWFIX_ERROR);
|
||||
}
|
||||
|
||||
|
||||
// TODO: num sat...
|
||||
// TODO: num sat... Why would we care?
|
||||
|
||||
/*
|
||||
* We can distinguish between 2D & 3D fix by presence
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
int dwsock_init (void);
|
||||
|
||||
int dwsock_connect (char *hostname, char *port, char *description, int allow_ipv6, int debug, char *ipaddr_str);
|
||||
int dwsock_connect (char *hostname, char *port, char *description, int allow_ipv6, int debug, char ipaddr_str[DWSOCK_IPADDR_LEN]);
|
||||
/* ipaddr_str needs to be at least SOCK_IPADDR_LEN bytes */
|
||||
|
||||
char *dwsock_ia_to_text (int Family, void * pAddr, char * pStringBuf, size_t StringBufSize);
|
||||
|
|
|
@ -81,8 +81,14 @@ typedef struct position_s {
|
|||
|
||||
static int set_norm_position (char symtab, char symbol, double dlat, double dlong, int ambiguity, position_t *presult)
|
||||
{
|
||||
// An over zealous compiler might complain about l*itude_to_str writing
|
||||
// N characters plus nul to an N character field so we stick it into a
|
||||
// larger temp then copy the desired number of bytes. (Issue 296)
|
||||
|
||||
latitude_to_str (dlat, ambiguity, presult->lat);
|
||||
char stemp[16];
|
||||
|
||||
latitude_to_str (dlat, ambiguity, stemp);
|
||||
memcpy (presult->lat, stemp, sizeof(presult->lat));
|
||||
|
||||
if (symtab != '/' && symtab != '\\' && ! isdigit(symtab) && ! isupper(symtab)) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
|
@ -90,7 +96,8 @@ static int set_norm_position (char symtab, char symbol, double dlat, double dlon
|
|||
}
|
||||
presult->sym_table_id = symtab;
|
||||
|
||||
longitude_to_str (dlong, ambiguity, presult->lon);
|
||||
longitude_to_str (dlong, ambiguity, stemp);
|
||||
memcpy (presult->lon, stemp, sizeof(presult->lon));
|
||||
|
||||
if (symbol < '!' || symbol > '~') {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
|
@ -118,7 +125,7 @@ static int set_norm_position (char symtab, char symbol, double dlat, double dlon
|
|||
* height - Feet.
|
||||
* gain - dBi.
|
||||
*
|
||||
* course - Degress, 0 - 360 (360 equiv. to 0).
|
||||
* course - Degrees, 0 - 360 (360 equiv. to 0).
|
||||
* Use G_UNKNOWN for none or unknown.
|
||||
* speed - knots.
|
||||
*
|
||||
|
@ -336,7 +343,7 @@ static int phg_data_extension (int power, int height, int gain, char *dir, char
|
|||
*
|
||||
* Purpose: Fill in parts of the course & speed data extension.
|
||||
*
|
||||
* Inputs: course - Degress, 0 - 360 (360 equiv. to 0).
|
||||
* Inputs: course - Degrees, 0 - 360 (360 equiv. to 0).
|
||||
* Use G_UNKNOWN for none or unknown.
|
||||
*
|
||||
* speed - knots.
|
||||
|
@ -487,7 +494,7 @@ static int frequency_spec (float freq, float tone, float offset, char *presult)
|
|||
* gain - dB. Not clear if it is dBi or dBd.
|
||||
* dir - Directivity: N, NE, etc., omni.
|
||||
*
|
||||
* course - Degress, 0 - 360 (360 equiv. to 0).
|
||||
* course - Degrees, 0 - 360 (360 equiv. to 0).
|
||||
* Use G_UNKNOWN for none or unknown.
|
||||
* speed - knots. // TODO: should distinguish unknown(not revevant) vs. known zero.
|
||||
*
|
||||
|
@ -497,7 +504,7 @@ static int frequency_spec (float freq, float tone, float offset, char *presult)
|
|||
*
|
||||
* comment - Additional comment text.
|
||||
*
|
||||
* result_size - Ammount of space for result, provideed by
|
||||
* result_size - Amount of space for result, provided by
|
||||
* caller, to avoid buffer overflow.
|
||||
*
|
||||
* Outputs: presult - Stored here. Should be at least ??? bytes.
|
||||
|
@ -512,7 +519,7 @@ static int frequency_spec (float freq, float tone, float offset, char *presult)
|
|||
* Power/height/gain/directivity or
|
||||
* Course/speed.
|
||||
*
|
||||
* Afer that,
|
||||
* After that,
|
||||
*
|
||||
*----------------------------------------------------------------*/
|
||||
|
||||
|
@ -629,7 +636,7 @@ int encode_position (int messaging, int compressed, double lat, double lon, int
|
|||
* gain - dB. Not clear if it is dBi or dBd.
|
||||
* dir - Direction: N, NE, etc., omni.
|
||||
*
|
||||
* course - Degress, 0 - 360 (360 equiv. to 0).
|
||||
* course - Degrees, 0 - 360 (360 equiv. to 0).
|
||||
* Use G_UNKNOWN for none or unknown.
|
||||
* speed - knots.
|
||||
*
|
||||
|
@ -639,7 +646,7 @@ int encode_position (int messaging, int compressed, double lat, double lon, int
|
|||
*
|
||||
* comment - Additional comment text.
|
||||
*
|
||||
* result_size - Ammount of space for result, provideed by
|
||||
* result_size - Amount of space for result, provided by
|
||||
* caller, to avoid buffer overflow.
|
||||
*
|
||||
* Outputs: presult - Stored here. Should be at least ??? bytes.
|
||||
|
@ -769,7 +776,7 @@ int encode_object (char *name, int compressed, time_t thyme, double lat, double
|
|||
* Inputs: addressee - Addressed to, up to 9 characters.
|
||||
* text - Text part of the message.
|
||||
* id - Identifier, 0 to 5 characters.
|
||||
* result_size - Ammount of space for result, provided by
|
||||
* result_size - Amount of space for result, provided by
|
||||
* caller, to avoid buffer overflow.
|
||||
*
|
||||
* Outputs: presult - Stored here.
|
||||
|
@ -853,7 +860,7 @@ int main (int argc, char *argv[])
|
|||
dw_printf ("%s\n", result);
|
||||
if (strcmp(result, "!4234.61ND07126.47W&PHG7368") != 0) { dw_printf ("ERROR! line %d\n", __LINE__); errors++; }
|
||||
|
||||
/* with freq & tone. minus offset, no offset, explict simplex. */
|
||||
/* with freq & tone. minus offset, no offset, explicit simplex. */
|
||||
|
||||
encode_position (0, 0, 42+34.61/60, -(71+26.47/60), 0, G_UNKNOWN, 'D', '&',
|
||||
0, 0, 0, NULL, G_UNKNOWN, 0, 146.955, 74.4, -0.6, NULL, result, sizeof(result));
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
#define TUNE_MS_FILTER_SIZE 140
|
||||
#define TUNE_PRE_BAUD 1.080
|
|
@ -20,6 +20,31 @@ typedef enum bp_window_e { BP_WINDOW_TRUNCATED,
|
|||
BP_WINDOW_BLACKMAN,
|
||||
BP_WINDOW_FLATTOP } bp_window_t;
|
||||
|
||||
// Experimental low pass filter to detect DC bias or low frequency changes.
|
||||
// IIR behaves like an analog R-C filter.
|
||||
// Intuitively, it seems like FIR would be better because it is based on a finite history.
|
||||
// However, it would require MANY taps and a LOT of computation for a low frequency.
|
||||
// We can use a little trick here to keep a running average.
|
||||
// This would be equivalent to convolving with an array of all 1 values.
|
||||
// That would eliminate the need to multiply.
|
||||
// We can also eliminate the need to add them all up each time by keeping a running total.
|
||||
// Add a sample to the total when putting it in our array of recent samples.
|
||||
// Subtract it from the total when it gets pushed off the end.
|
||||
// We can also eliminate the need to shift them all down by using a circular buffer.
|
||||
|
||||
#define CIC_LEN_MAX 4000
|
||||
|
||||
typedef struct cic_s {
|
||||
int len; // Number of elements used.
|
||||
// Might want to dynamically allocate.
|
||||
short in[CIC_LEN_MAX]; // Samples coming in.
|
||||
int sum; // Running sum.
|
||||
int inext; // Next position to fill.
|
||||
} cic_t;
|
||||
|
||||
|
||||
#define MAX_FILTER_SIZE 404 /* 401 is needed for profile A, 300 baud & 44100. Revisit someday. */
|
||||
|
||||
|
||||
struct demodulator_state_s
|
||||
{
|
||||
|
@ -39,30 +64,12 @@ struct demodulator_state_s
|
|||
// Data is sampled when it overflows.
|
||||
|
||||
|
||||
int ms_filter_size; /* Size of mark & space filters, in audio samples. */
|
||||
/* Started off as a guess of one bit length */
|
||||
/* but about 2 bit times turned out to be better. */
|
||||
/* Currently using same size for any prefilter. */
|
||||
|
||||
|
||||
#define MAX_FILTER_SIZE 320 /* 304 is needed for profile C, 300 baud & 44100. */
|
||||
|
||||
/*
|
||||
* Filter length for Mark & Space in bit times.
|
||||
* e.g. 1 means 1/1200 second for 1200 baud.
|
||||
*/
|
||||
float ms_filter_len_bits;
|
||||
float lp_delay_fract;
|
||||
|
||||
/*
|
||||
* Window type for the various filters.
|
||||
*/
|
||||
|
||||
bp_window_t pre_window;
|
||||
bp_window_t ms_window;
|
||||
bp_window_t lp_window;
|
||||
|
||||
|
||||
/*
|
||||
* Alternate Low pass filters.
|
||||
* First is arbitrary number for quick IIR.
|
||||
|
@ -78,16 +85,13 @@ struct demodulator_state_s
|
|||
/* In practice, it turned out a little larger */
|
||||
/* for profiles B, C, D. */
|
||||
|
||||
float lp_filter_len_bits; /* Length in number of bit times. */
|
||||
float lp_filter_width_sym; /* Length in number of symbol times. */
|
||||
|
||||
int lp_filter_size; /* Size of Low Pass filter, in audio samples. */
|
||||
/* Previously it was always the same as the M/S */
|
||||
/* filters but in version 1.2 it's now independent. */
|
||||
#define lp_filter_len_bits lp_filter_width_sym // FIXME: temp hack
|
||||
|
||||
int lp_filter_delay; /* Number of samples that the low pass filter */
|
||||
/* delays the signal. */
|
||||
int lp_filter_taps; /* Size of Low Pass filter, in audio samples. */
|
||||
|
||||
/* New in 1.6. */
|
||||
#define lp_filter_size lp_filter_taps // FIXME: temp hack
|
||||
|
||||
|
||||
/*
|
||||
|
@ -111,6 +115,7 @@ struct demodulator_state_s
|
|||
/*
|
||||
* Phase Locked Loop (PLL) inertia.
|
||||
* Larger number means less influence by signal transitions.
|
||||
* It is more resistant to change when locked on to a signal.
|
||||
*/
|
||||
float pll_locked_inertia;
|
||||
float pll_searching_inertia;
|
||||
|
@ -129,23 +134,17 @@ struct demodulator_state_s
|
|||
/* lower = min(1600,1800) - 0.5 * 300 = 1450 */
|
||||
/* upper = max(1600,1800) + 0.5 * 300 = 1950 */
|
||||
|
||||
float pre_filter_len_bits; /* Length in number of bit times. */
|
||||
float pre_filter_len_sym; // Length in number of symbol times.
|
||||
#define pre_filter_len_bits pre_filter_len_sym // temp until all references changed.
|
||||
|
||||
int pre_filter_size; /* Size of pre filter, in audio samples. */
|
||||
bp_window_t pre_window; // Window type for filter shaping.
|
||||
|
||||
int pre_filter_taps; // Calculated number of filter taps.
|
||||
#define pre_filter_size pre_filter_taps // temp until all references changed.
|
||||
|
||||
float pre_filter[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
|
||||
|
||||
/*
|
||||
* Kernel for the mark and space detection filters.
|
||||
*/
|
||||
|
||||
float m_sin_table[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
float m_cos_table[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
|
||||
float s_sin_table[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
float s_cos_table[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
|
||||
float raw_cb[MAX_FILTER_SIZE] __attribute__((aligned(16))); // audio in, need better name.
|
||||
|
||||
/*
|
||||
* The rest are continuously updated.
|
||||
|
@ -154,11 +153,6 @@ struct demodulator_state_s
|
|||
unsigned int lo_phase; /* Local oscillator for PSK. */
|
||||
|
||||
|
||||
/*
|
||||
* Most recent raw audio samples, before/after prefiltering.
|
||||
*/
|
||||
float raw_cb[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
|
||||
/*
|
||||
* Use half of the AGC code to get a measure of input audio amplitude.
|
||||
* These use "quick" attack and "sluggish" decay while the
|
||||
|
@ -170,24 +164,14 @@ struct demodulator_state_s
|
|||
float alevel_mark_peak;
|
||||
float alevel_space_peak;
|
||||
|
||||
/*
|
||||
* Input to the mark/space detector.
|
||||
* Could be prefiltered or raw audio.
|
||||
*/
|
||||
float ms_in_cb[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
|
||||
/*
|
||||
* Outputs from the mark and space amplitude detection,
|
||||
* used as inputs to the FIR lowpass filters.
|
||||
* Kernel for the lowpass filters.
|
||||
*/
|
||||
|
||||
float m_amp_cb[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
float s_amp_cb[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
|
||||
float lp_filter[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
|
||||
|
||||
float m_peak, s_peak;
|
||||
float m_valley, s_valley;
|
||||
float m_amp_prev, s_amp_prev;
|
||||
|
@ -266,6 +250,122 @@ struct demodulator_state_s
|
|||
|
||||
union {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// AFSK only - new method in 1.7 //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
struct afsk_only_s {
|
||||
|
||||
unsigned int m_osc_phase; // Phase for Mark local oscillator.
|
||||
unsigned int m_osc_delta; // How much to change for each audio sample.
|
||||
|
||||
unsigned int s_osc_phase; // Phase for Space local oscillator.
|
||||
unsigned int s_osc_delta; // How much to change for each audio sample.
|
||||
|
||||
unsigned int c_osc_phase; // Phase for Center frequency local oscillator.
|
||||
unsigned int c_osc_delta; // How much to change for each audio sample.
|
||||
|
||||
// Need two mixers for profile "A".
|
||||
|
||||
float m_I_raw[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
float m_Q_raw[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
|
||||
float s_I_raw[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
float s_Q_raw[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
|
||||
// Only need one mixer for profile "B". Reuse the same storage?
|
||||
|
||||
//#define c_I_raw m_I_raw
|
||||
//#define c_Q_raw m_Q_raw
|
||||
float c_I_raw[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
float c_Q_raw[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
|
||||
int use_rrc; // Use RRC rather than generic low pass.
|
||||
|
||||
float rrc_width_sym; /* Width of RRC filter in number of symbols. */
|
||||
|
||||
float rrc_rolloff; /* Rolloff factor for RRC. Between 0 and 1. */
|
||||
|
||||
float prev_phase; // To see phase shift between samples for FM demod.
|
||||
|
||||
float normalize_rpsam; // Normalize to -1 to +1 for expected tones.
|
||||
|
||||
} afsk;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// Baseband only, AKA G3RUH //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// TODO: Continue experiments with root raised cosine filter.
|
||||
// Either switch to that or take out all the related stuff.
|
||||
|
||||
struct bb_only_s {
|
||||
|
||||
float rrc_width_sym; /* Width of RRC filter in number of symbols. */
|
||||
|
||||
float rrc_rolloff; /* Rolloff factor for RRC. Between 0 and 1. */
|
||||
|
||||
int rrc_filter_taps; // Number of elements used in the next two.
|
||||
|
||||
// FIXME: TODO: reevaluate max size needed.
|
||||
|
||||
float audio_in[MAX_FILTER_SIZE] __attribute__((aligned(16))); // Audio samples in.
|
||||
|
||||
|
||||
float lp_filter[MAX_FILTER_SIZE] __attribute__((aligned(16))); // Low pass filter.
|
||||
|
||||
// New in 1.7 - Polyphase filter to reduce CPU requirements.
|
||||
|
||||
float lp_polyphase_1[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
float lp_polyphase_2[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
float lp_polyphase_3[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
float lp_polyphase_4[MAX_FILTER_SIZE] __attribute__((aligned(16)));
|
||||
|
||||
float lp_1_iir_param; // very low pass filters to get DC offset.
|
||||
float lp_1_out;
|
||||
|
||||
float lp_2_iir_param;
|
||||
float lp_2_out;
|
||||
|
||||
float agc_1_fast_attack; // Signal envelope detection.
|
||||
float agc_1_slow_decay;
|
||||
float agc_1_peak;
|
||||
float agc_1_valley;
|
||||
|
||||
float agc_2_fast_attack;
|
||||
float agc_2_slow_decay;
|
||||
float agc_2_peak;
|
||||
float agc_2_valley;
|
||||
|
||||
float agc_3_fast_attack;
|
||||
float agc_3_slow_decay;
|
||||
float agc_3_peak;
|
||||
float agc_3_valley;
|
||||
|
||||
// CIC low pass filters to detect DC bias or low frequency changes.
|
||||
// IIR behaves like an analog R-C filter.
|
||||
// Intuitively, it seems like FIR would be better because it is based on a finite history.
|
||||
// However, it would require MANY taps and a LOT of computation for a low frequency.
|
||||
// We can use a little trick here to keep a running average.
|
||||
// This would be equivalent to convolving with an array of all 1 values.
|
||||
// That would eliminate the need to multiply.
|
||||
// We can also eliminate the need to add them all up each time by keeping a running total.
|
||||
// Add a sample to the total when putting it in our array of recent samples.
|
||||
// Subtract it from the total when it gets pushed off the end.
|
||||
// We can also eliminate the need to shift them all down by using a circular buffer.
|
||||
// This only works with integers because float would have cummulated round off errors.
|
||||
|
||||
cic_t cic_center1;
|
||||
cic_t cic_above;
|
||||
cic_t cic_below;
|
||||
|
||||
} bb;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// PSK only. //
|
||||
|
|
130
src/fx25_init.c
130
src/fx25_init.c
|
@ -130,6 +130,9 @@ static const struct correlation_tag_s tags[16] = {
|
|||
// 12 got many false matches with random noise.
|
||||
// Even 8 might be too high. We see 2 or 4 bit errors here
|
||||
// at the point where decoding the block is very improbable.
|
||||
// After 2 months of continuous operation as a digipeater/iGate,
|
||||
// no false triggers were observed. So 8 doesn't seem to be too
|
||||
// high for 1200 bps. No study has been done for 9600 bps.
|
||||
|
||||
// Given a 64 bit correlation tag value, find acceptable match in table.
|
||||
// Return index into table or -1 for no match.
|
||||
|
@ -215,14 +218,14 @@ void fx25_init ( int debug_level )
|
|||
assert (tags[j].n_block_rs == FX25_BLOCK_SIZE);
|
||||
}
|
||||
|
||||
assert (fx25_pick_mode (1, 239) == 1);
|
||||
assert (fx25_pick_mode (1, 240) == -1);
|
||||
assert (fx25_pick_mode (100+1, 239) == 1);
|
||||
assert (fx25_pick_mode (100+1, 240) == -1);
|
||||
|
||||
assert (fx25_pick_mode (5, 223) == 5);
|
||||
assert (fx25_pick_mode (5, 224) == -1);
|
||||
assert (fx25_pick_mode (100+5, 223) == 5);
|
||||
assert (fx25_pick_mode (100+5, 224) == -1);
|
||||
|
||||
assert (fx25_pick_mode (9, 191) == 9);
|
||||
assert (fx25_pick_mode (9, 192) == -1);
|
||||
assert (fx25_pick_mode (100+9, 191) == 9);
|
||||
assert (fx25_pick_mode (100+9, 192) == -1);
|
||||
|
||||
assert (fx25_pick_mode (16, 32) == 4);
|
||||
assert (fx25_pick_mode (16, 64) == 3);
|
||||
|
@ -241,6 +244,16 @@ void fx25_init ( int debug_level )
|
|||
assert (fx25_pick_mode (64, 191) == 9);
|
||||
assert (fx25_pick_mode (64, 192) == -1);
|
||||
|
||||
assert (fx25_pick_mode (1, 32) == 4);
|
||||
assert (fx25_pick_mode (1, 33) == 3);
|
||||
assert (fx25_pick_mode (1, 64) == 3);
|
||||
assert (fx25_pick_mode (1, 65) == 6);
|
||||
assert (fx25_pick_mode (1, 128) == 6);
|
||||
assert (fx25_pick_mode (1, 191) == 9);
|
||||
assert (fx25_pick_mode (1, 223) == 5);
|
||||
assert (fx25_pick_mode (1, 239) == 1);
|
||||
assert (fx25_pick_mode (1, 240) == -1);
|
||||
|
||||
} // fx25_init
|
||||
|
||||
|
||||
|
@ -290,12 +303,13 @@ int fx25_get_debug (void)
|
|||
* Purpose: Pick suitable transmission format based on user preference
|
||||
* and size of data part required.
|
||||
*
|
||||
* Inputs: fx_mode - Normally, this would be 16, 32, or 64 for the desired number
|
||||
* of check bytes. The shortest format, adequate for the
|
||||
* required data length will be picked automatically.
|
||||
* 0x01 thru 0x0b may also be specified for a specific format
|
||||
* but this is expected to be mostly for testing, not normal
|
||||
* operation.
|
||||
* Inputs: fx_mode - 0 = none.
|
||||
* 1 = pick a tag automatically.
|
||||
* 16, 32, 64 = use this many check bytes.
|
||||
* 100 + n = use tag n.
|
||||
*
|
||||
* 0 and 1 would be the most common.
|
||||
* Others are mostly for testing.
|
||||
*
|
||||
* dlen - Required size for transmitted "data" part, in bytes.
|
||||
* This includes the AX.25 frame with bit stuffing and a flag
|
||||
|
@ -303,24 +317,29 @@ int fx25_get_debug (void)
|
|||
*
|
||||
* Returns: Correlation tag number in range of CTAG_MIN thru CTAG_MAX.
|
||||
* -1 is returned for failure.
|
||||
*
|
||||
* Future: Might be more accomodating.
|
||||
* For example, if 64 check bytes were specified for 200 data bytes,
|
||||
* we might automatically drop it down to 32 check bytes, print a
|
||||
* warning and continue. Keep it simple at first. Fine tune later.
|
||||
* The caller should fall back to using plain old AX.25.
|
||||
*
|
||||
*--------------------------------------------------------------*/
|
||||
|
||||
int fx25_pick_mode (int fx_mode, int dlen)
|
||||
{
|
||||
if (fx_mode >= CTAG_MIN && fx_mode <= CTAG_MAX) {
|
||||
if (dlen <= fx25_get_k_data_radio(fx_mode)) {
|
||||
return (fx_mode);
|
||||
if (fx_mode <= 0) return (-1);
|
||||
|
||||
// Specify a specific tag by adding 100 to the number.
|
||||
// Fails if data won't fit.
|
||||
|
||||
if (fx_mode - 100 >= CTAG_MIN && fx_mode - 100 <= CTAG_MAX) {
|
||||
if (dlen <= fx25_get_k_data_radio(fx_mode - 100)) {
|
||||
return (fx_mode - 100);
|
||||
}
|
||||
else {
|
||||
return (-1); // Assuming caller prints failure message.
|
||||
}
|
||||
}
|
||||
|
||||
// Specify number of check bytes.
|
||||
// Pick the shortest one that can handle the required data length.
|
||||
|
||||
else if (fx_mode == 16 || fx_mode == 32 || fx_mode == 64) {
|
||||
for (int k = CTAG_MAX; k >= CTAG_MIN; k--) {
|
||||
if (fx_mode == fx25_get_nroots(k) && dlen <= fx25_get_k_data_radio(k)) {
|
||||
|
@ -329,11 +348,41 @@ int fx25_pick_mode (int fx_mode, int dlen)
|
|||
}
|
||||
return (-1);
|
||||
}
|
||||
else {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf("FX.25: Transmission format %d must be 0x00 thru 0x0b, 16, 32, or 64.\n", fx_mode);
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
// For any other number, [[ or if the preference was not possible, ?? ]]
|
||||
// try to come up with something reasonable. For shorter frames,
|
||||
// use smaller overhead. For longer frames, where an error is
|
||||
// more probable, use more check bytes. When the data gets even
|
||||
// larger, check bytes must be reduced to fit in block size.
|
||||
// When all else fails, fall back to normal AX.25.
|
||||
// Some of this is from observing UZ7HO Soundmodem behavior.
|
||||
//
|
||||
// Tag Data Check Max Num
|
||||
// Number Bytes Bytes Repaired
|
||||
// ------ ----- ----- -----
|
||||
// 0x04 32 16 8
|
||||
// 0x03 64 16 8
|
||||
// 0x06 128 32 16
|
||||
// 0x09 191 64 32
|
||||
// 0x05 223 32 16
|
||||
// 0x01 239 16 8
|
||||
// none larger
|
||||
//
|
||||
// The PRUG FX.25 TNC has additional modes that will handle larger frames
|
||||
// by using multiple RS blocks. This is a future possibility but needs
|
||||
// to be coordinated with other FX.25 developers so we maintain compatibility.
|
||||
|
||||
static const int prefer[6] = { 0x04, 0x03, 0x06, 0x09, 0x05, 0x01 };
|
||||
for (int k = 0; k < 6; k++) {
|
||||
int m = prefer[k];
|
||||
if (dlen <= fx25_get_k_data_radio(m)) {
|
||||
return (m);
|
||||
}
|
||||
}
|
||||
return (-1);
|
||||
|
||||
// TODO: revisit error messages, produced by caller, when this returns -1.
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -361,19 +410,25 @@ struct rs *INIT_RS(unsigned int symsize,unsigned int gfpoly,unsigned fcr,unsigne
|
|||
return NULL; /* Can't have more roots than symbol values! */
|
||||
|
||||
rs = (struct rs *)calloc(1,sizeof(struct rs));
|
||||
if (rs == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FATAL ERROR: Out of memory.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
rs->mm = symsize;
|
||||
rs->nn = (1<<symsize)-1;
|
||||
|
||||
rs->alpha_to = (DTYPE *)malloc(sizeof(DTYPE)*(rs->nn+1));
|
||||
rs->alpha_to = (DTYPE *)calloc((rs->nn+1),sizeof(DTYPE));
|
||||
if(rs->alpha_to == NULL){
|
||||
free(rs);
|
||||
return NULL;
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FATAL ERROR: Out of memory.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
rs->index_of = (DTYPE *)malloc(sizeof(DTYPE)*(rs->nn+1));
|
||||
rs->index_of = (DTYPE *)calloc((rs->nn+1),sizeof(DTYPE));
|
||||
if(rs->index_of == NULL){
|
||||
free(rs->alpha_to);
|
||||
free(rs);
|
||||
return NULL;
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FATAL ERROR: Out of memory.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Generate Galois field lookup tables */
|
||||
|
@ -397,12 +452,11 @@ struct rs *INIT_RS(unsigned int symsize,unsigned int gfpoly,unsigned fcr,unsigne
|
|||
}
|
||||
|
||||
/* Form RS code generator polynomial from its roots */
|
||||
rs->genpoly = (DTYPE *)malloc(sizeof(DTYPE)*(nroots+1));
|
||||
rs->genpoly = (DTYPE *)calloc((nroots+1),sizeof(DTYPE));
|
||||
if(rs->genpoly == NULL){
|
||||
free(rs->alpha_to);
|
||||
free(rs->index_of);
|
||||
free(rs);
|
||||
return NULL;
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FATAL ERROR: Out of memory.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
rs->fcr = fcr;
|
||||
rs->prim = prim;
|
||||
|
@ -433,7 +487,7 @@ struct rs *INIT_RS(unsigned int symsize,unsigned int gfpoly,unsigned fcr,unsigne
|
|||
}
|
||||
|
||||
// diagnostic prints
|
||||
/*
|
||||
#if 0
|
||||
printf("Alpha To:\n\r");
|
||||
for (i=0; i < sizeof(DTYPE)*(rs->nn+1); i++)
|
||||
printf("0x%2x,", rs->alpha_to[i]);
|
||||
|
@ -448,7 +502,7 @@ struct rs *INIT_RS(unsigned int symsize,unsigned int gfpoly,unsigned fcr,unsigne
|
|||
for (i = 0; i <= nroots; i++)
|
||||
printf("0x%2x,", rs->genpoly[i]);
|
||||
printf("\n\r");
|
||||
*/
|
||||
#endif
|
||||
return rs;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ static struct fx_context_s *fx_context[MAX_CHANS][MAX_SUBCHANS][MAX_SLICERS];
|
|||
|
||||
static void process_rs_block (int chan, int subchan, int slice, struct fx_context_s *F);
|
||||
|
||||
static int my_unstuff (unsigned char * restrict pin, int ilen, unsigned char * restrict frame_buf);
|
||||
static int my_unstuff (int chan, int subchan, int slice, unsigned char * restrict pin, int ilen, unsigned char * restrict frame_buf);
|
||||
|
||||
//#define FXTEST 1 // Define for standalone test application.
|
||||
// It expects to find files fx01.dat, fx02.dat, ..., fx0b.dat/
|
||||
|
@ -182,7 +182,8 @@ void fx25_rec_bit (int chan, int subchan, int slice, int dbit)
|
|||
|
||||
if (fx25_get_debug() >= 2) {
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("FX.25: Matched correlation tag 0x%02x with %d bit errors. Expecting %d data & %d check bytes.\n",
|
||||
dw_printf ("FX.25[%d.%d]: Matched correlation tag 0x%02x with %d bit errors. Expecting %d data & %d check bytes.\n",
|
||||
chan, slice, // ideally subchan too only if applicable
|
||||
c,
|
||||
__builtin_popcountll(F->accum ^ fx25_get_ctag_value(c)),
|
||||
F->k_data_radio, F->nroots);
|
||||
|
@ -257,7 +258,7 @@ int fx25_rec_busy (int chan)
|
|||
{
|
||||
assert (chan >= 0 && chan < MAX_CHANS);
|
||||
|
||||
// This could be a litle faster if we knew number of
|
||||
// This could be a little faster if we knew number of
|
||||
// subchannels and slicers but it is probably insignificant.
|
||||
|
||||
for (int i = 0; i < MAX_SUBCHANS; i++) {
|
||||
|
@ -308,7 +309,7 @@ static void process_rs_block (int chan, int subchan, int slice, struct fx_contex
|
|||
{
|
||||
if (fx25_get_debug() >= 3) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("FX.25: Received RS codeblock.\n");
|
||||
dw_printf ("FX.25[%d.%d]: Received RS codeblock.\n", chan, slice);
|
||||
fx_hex_dump (F->block, FX25_BLOCK_SIZE);
|
||||
}
|
||||
assert (F->block[FX25_BLOCK_SIZE] == FENCE);
|
||||
|
@ -323,10 +324,10 @@ static void process_rs_block (int chan, int subchan, int slice, struct fx_contex
|
|||
if (fx25_get_debug() >= 2) {
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
if (derrors == 0) {
|
||||
dw_printf ("FX.25: FEC complete with no errors.\n");
|
||||
dw_printf ("FX.25[%d.%d]: FEC complete with no errors.\n", chan, slice);
|
||||
}
|
||||
else {
|
||||
dw_printf ("FX.25: FEC complete, fixed %2d errors in byte positions:",derrors);
|
||||
dw_printf ("FX.25[%d.%d]: FEC complete, fixed %2d errors in byte positions:", chan, slice, derrors);
|
||||
for (int k = 0; k < derrors; k++) {
|
||||
dw_printf (" %d", derrlocs[k]);
|
||||
}
|
||||
|
@ -335,7 +336,7 @@ static void process_rs_block (int chan, int subchan, int slice, struct fx_contex
|
|||
}
|
||||
|
||||
unsigned char frame_buf[FX25_MAX_DATA+1]; // Out must be shorter than input.
|
||||
int frame_len = my_unstuff (F->block, F->dlen, frame_buf);
|
||||
int frame_len = my_unstuff (chan, subchan, slice, F->block, F->dlen, frame_buf);
|
||||
|
||||
if (frame_len >= 14 + 1 + 2) { // Minimum length: Two addresses & control & FCS.
|
||||
|
||||
|
@ -345,7 +346,7 @@ static void process_rs_block (int chan, int subchan, int slice, struct fx_contex
|
|||
|
||||
if (fx25_get_debug() >= 3) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("FX.25: Extracted AX.25 frame:\n");
|
||||
dw_printf ("FX.25[%d.%d]: Extracted AX.25 frame:\n", chan, slice);
|
||||
fx_hex_dump (frame_buf, frame_len);
|
||||
}
|
||||
|
||||
|
@ -360,7 +361,7 @@ static void process_rs_block (int chan, int subchan, int slice, struct fx_contex
|
|||
} else {
|
||||
// Most likely cause is defective sender software.
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FX.25: Bad FCS for AX.25 frame.\n");
|
||||
dw_printf ("FX.25[%d.%d]: Bad FCS for AX.25 frame.\n", chan, slice);
|
||||
fx_hex_dump (F->block, F->dlen);
|
||||
fx_hex_dump (frame_buf, frame_len);
|
||||
}
|
||||
|
@ -368,14 +369,14 @@ static void process_rs_block (int chan, int subchan, int slice, struct fx_contex
|
|||
else {
|
||||
// Most likely cause is defective sender software.
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FX.25: AX.25 frame is shorter than minimum length.\n");
|
||||
dw_printf ("FX.25[%d.%d]: AX.25 frame is shorter than minimum length.\n", chan, slice);
|
||||
fx_hex_dump (F->block, F->dlen);
|
||||
fx_hex_dump (frame_buf, frame_len);
|
||||
}
|
||||
}
|
||||
else if (fx25_get_debug() >= 2) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FX.25: FEC failed. Too many errors.\n");
|
||||
dw_printf ("FX.25[%d.%d]: FEC failed. Too many errors.\n", chan, slice);
|
||||
}
|
||||
|
||||
} // process_rs_block
|
||||
|
@ -387,7 +388,9 @@ static void process_rs_block (int chan, int subchan, int slice, struct fx_contex
|
|||
*
|
||||
* Purpose: Remove HDLC it stuffing and surrounding flag delimiters.
|
||||
*
|
||||
* Inputs: pin - "data" part of RS codeblock.
|
||||
* Inputs: chan, subchan, slice - For error messages.
|
||||
*
|
||||
* pin - "data" part of RS codeblock.
|
||||
* First byte must be HDLC "flag".
|
||||
* May be followed by additional flags.
|
||||
* There must be terminating flag but it might not be byte aligned.
|
||||
|
@ -409,7 +412,7 @@ static void process_rs_block (int chan, int subchan, int slice, struct fx_contex
|
|||
*
|
||||
***********************************************************************************/
|
||||
|
||||
static int my_unstuff (unsigned char * restrict pin, int ilen, unsigned char * restrict frame_buf)
|
||||
static int my_unstuff (int chan, int subchan, int slice, unsigned char * restrict pin, int ilen, unsigned char * restrict frame_buf)
|
||||
{
|
||||
unsigned char pat_det = 0; // Pattern detector.
|
||||
unsigned char oacc = 0; // Accumulator for a byte out.
|
||||
|
@ -418,7 +421,7 @@ static int my_unstuff (unsigned char * restrict pin, int ilen, unsigned char * r
|
|||
|
||||
if (*pin != 0x7e) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FX.25 error: Data section did not start with 0x7e.\n");
|
||||
dw_printf ("FX.25[%d.%d] error: Data section did not start with 0x7e.\n", chan, slice);
|
||||
fx_hex_dump (pin, ilen);
|
||||
return (0);
|
||||
}
|
||||
|
@ -436,7 +439,7 @@ static int my_unstuff (unsigned char * restrict pin, int ilen, unsigned char * r
|
|||
|
||||
if (pat_det == 0xfe) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FX.25: Invalid AX.25 frame - Seven '1' bits in a row.\n");
|
||||
dw_printf ("FX.25[%d.%d]: Invalid AX.25 frame - Seven '1' bits in a row.\n", chan, slice);
|
||||
fx_hex_dump (pin, ilen);
|
||||
return 0;
|
||||
}
|
||||
|
@ -451,7 +454,7 @@ static int my_unstuff (unsigned char * restrict pin, int ilen, unsigned char * r
|
|||
}
|
||||
else {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FX.25: Invalid AX.25 frame - Not a whole number of bytes.\n");
|
||||
dw_printf ("FX.25[%d.%d]: Invalid AX.25 frame - Not a whole number of bytes.\n", chan, slice);
|
||||
fx_hex_dump (pin, ilen);
|
||||
return (0);
|
||||
}
|
||||
|
@ -470,7 +473,7 @@ static int my_unstuff (unsigned char * restrict pin, int ilen, unsigned char * r
|
|||
} /* end of loop on all bits in block */
|
||||
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FX.25: Invalid AX.25 frame - Terminating flag not found.\n");
|
||||
dw_printf ("FX.25[%d.%d]: Invalid AX.25 frame - Terminating flag not found.\n", chan, slice);
|
||||
fx_hex_dump (pin, ilen);
|
||||
|
||||
return (0); // Should never fall off the end.
|
||||
|
|
|
@ -61,7 +61,7 @@ int main ()
|
|||
dw_printf("Run fxrec as second part of test.\n");
|
||||
|
||||
fx25_init (3);
|
||||
for (int i = CTAG_MIN; i <= CTAG_MAX; i++) {
|
||||
for (int i = 100 + CTAG_MIN; i <= 100 + CTAG_MAX; i++) {
|
||||
fx25_send_frame (0, preload, (int)sizeof(preload)-3, i);
|
||||
}
|
||||
exit(EXIT_SUCCESS);
|
||||
|
@ -115,7 +115,7 @@ int fx25_send_frame (int chan, unsigned char *fbuf, int flen, int fx_mode)
|
|||
if (fx25_get_debug() >= 3) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("------\n");
|
||||
dw_printf ("FX.25 send frame: chan = %d, FX.25 mode = %d\n", chan, fx_mode);
|
||||
dw_printf ("FX.25[%d] send frame: FX.25 mode = %d\n", chan, fx_mode);
|
||||
fx_hex_dump (fbuf, flen);
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ int fx25_send_frame (int chan, unsigned char *fbuf, int flen, int fx_mode)
|
|||
assert (data[FX25_MAX_DATA] == fence);
|
||||
if (dlen < 0) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FX.25: Frame length of %d + overhead is too large to encode.\n", flen);
|
||||
dw_printf ("FX.25[%d]: Frame length of %d + overhead is too large to encode.\n", chan, flen);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ int fx25_send_frame (int chan, unsigned char *fbuf, int flen, int fx_mode)
|
|||
|
||||
if (ctag_num < CTAG_MIN || ctag_num > CTAG_MAX) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("FX.25: Could not find suitable format for requested %d and data length %d.\n", fx_mode, dlen);
|
||||
dw_printf ("FX.25[%d]: Could not find suitable format for requested %d and data length %d.\n", chan, fx_mode, dlen);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
@ -179,9 +179,9 @@ int fx25_send_frame (int chan, unsigned char *fbuf, int flen, int fx_mode)
|
|||
|
||||
if (fx25_get_debug() >= 3) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("FX.25: transmit %d data bytes, ctag number 0x%02x\n", k_data_radio, ctag_num);
|
||||
dw_printf ("FX.25[%d]: transmit %d data bytes, ctag number 0x%02x\n", chan, k_data_radio, ctag_num);
|
||||
fx_hex_dump (data, k_data_radio);
|
||||
dw_printf ("FX.25: transmit %d check bytes:\n", NROOTS);
|
||||
dw_printf ("FX.25[%d]: transmit %d check bytes:\n", chan, NROOTS);
|
||||
fx_hex_dump (check, NROOTS);
|
||||
dw_printf ("------\n");
|
||||
}
|
||||
|
@ -212,6 +212,11 @@ int fx25_send_frame (int chan, unsigned char *fbuf, int flen, int fx_mode)
|
|||
#else
|
||||
// Normal usage. Send bits to modulator.
|
||||
|
||||
// Temp hack for testing. Corrupt first 8 bytes.
|
||||
// for (int j = 0; j < 16; j++) {
|
||||
// data[j] = ~ data[j];
|
||||
// }
|
||||
|
||||
for (int k = 0; k < 8; k++) {
|
||||
unsigned char b = (ctag_value >> (k * 8)) & 0xff;
|
||||
send_bytes (chan, &b, 1);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
||||
//
|
||||
// Copyright (C) 2011, 2013, 2014, 2015, 2016, 2019 John Langner, WB2OSZ
|
||||
// Copyright (C) 2011, 2013, 2014, 2015, 2016, 2019, 2021 John Langner, WB2OSZ
|
||||
//
|
||||
// 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
|
||||
|
@ -76,6 +76,7 @@
|
|||
#include "morse.h"
|
||||
#include "dtmf.h"
|
||||
#include "fx25.h"
|
||||
#include "il2p.h"
|
||||
|
||||
|
||||
/* Own random number generator so we can get */
|
||||
|
@ -123,6 +124,7 @@ static void send_packet (char *str)
|
|||
return;
|
||||
}
|
||||
flen = ax25_pack (pp, fbuf);
|
||||
(void)flen;
|
||||
for (c=0; c<modem.adev[0].num_channels; c++)
|
||||
{
|
||||
|
||||
|
@ -151,12 +153,10 @@ static void send_packet (char *str)
|
|||
gen_tone_put_sample (c, 0, 0);
|
||||
}
|
||||
#endif
|
||||
hdlc_send_flags (c, 8, 0);
|
||||
hdlc_send_flags (c, 8, 0);
|
||||
hdlc_send_flags (c, 8, 0);
|
||||
hdlc_send_flags (c, 8, 0);
|
||||
hdlc_send_frame (c, fbuf, flen, 0, modem.fx25_xmit_enable);
|
||||
hdlc_send_flags (c, 2, 1);
|
||||
|
||||
layer2_preamble_postamble (c, 32, 0, &modem);
|
||||
layer2_send_frame (c, pp, 0, &modem);
|
||||
layer2_preamble_postamble (c, 2, 1, &modem);
|
||||
}
|
||||
ax25_delete (pp);
|
||||
}
|
||||
|
@ -176,6 +176,9 @@ int main(int argc, char **argv)
|
|||
int g_opt = 0;
|
||||
int j_opt = 0;
|
||||
int J_opt = 0;
|
||||
int X_opt = 0; // send FX.25
|
||||
int I_opt = -1; // send IL2P rather than AX.25, normal polarity
|
||||
int i_opt = -1; // send IL2P rather than AX.25, inverted polarity
|
||||
|
||||
/*
|
||||
* Set up default values for the modem.
|
||||
|
@ -195,7 +198,7 @@ int main(int argc, char **argv)
|
|||
modem.achan[chan].baud = DEFAULT_BAUD; /* -b option */
|
||||
}
|
||||
|
||||
modem.achan[0].medium = MEDIUM_RADIO;
|
||||
modem.chan_medium[0] = MEDIUM_RADIO;
|
||||
|
||||
|
||||
/*
|
||||
|
@ -227,7 +230,7 @@ int main(int argc, char **argv)
|
|||
|
||||
/* ':' following option character means arg is required. */
|
||||
|
||||
c = getopt_long(argc, argv, "gjJm:s:a:b:B:r:n:N:o:z:82M:X:",
|
||||
c = getopt_long(argc, argv, "gjJm:s:a:b:B:r:n:N:o:z:82M:X:I:i:",
|
||||
long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
@ -424,7 +427,7 @@ int main(int argc, char **argv)
|
|||
case '2': /* -2 for 2 channels of sound */
|
||||
|
||||
modem.adev[0].num_channels = 2;
|
||||
modem.achan[1].medium = MEDIUM_RADIO;
|
||||
modem.chan_medium[1] = MEDIUM_RADIO;
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf("2 channels of sound rather than 1.\n");
|
||||
break;
|
||||
|
@ -453,7 +456,17 @@ int main(int argc, char **argv)
|
|||
|
||||
case 'X':
|
||||
|
||||
modem.fx25_xmit_enable = atoi(optarg);
|
||||
X_opt = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'I': // IL2P, normal polarity
|
||||
|
||||
I_opt = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'i': // IL2P, inverted polarity
|
||||
|
||||
i_opt = atoi(optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
|
@ -507,6 +520,43 @@ int main(int argc, char **argv)
|
|||
exit (1);
|
||||
}
|
||||
|
||||
if (X_opt > 0) {
|
||||
if (I_opt != -1 || i_opt != -1) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Can't mix -X with -I or -i.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
modem.achan[0].fx25_strength = X_opt;
|
||||
modem.achan[0].layer2_xmit = LAYER2_FX25;
|
||||
}
|
||||
|
||||
if (I_opt != -1 && i_opt != -1) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Can't use both -I and -i at the same time.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (I_opt >= 0) {
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("Using IL2P normal polarity.\n");
|
||||
modem.achan[0].layer2_xmit = LAYER2_IL2P;
|
||||
modem.achan[0].il2p_max_fec = (I_opt > 0);
|
||||
modem.achan[0].il2p_invert_polarity = 0; // normal
|
||||
}
|
||||
|
||||
if (i_opt >= 0) {
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("Using IL2P inverted polarity.\n");
|
||||
modem.achan[0].layer2_xmit = LAYER2_IL2P;
|
||||
modem.achan[0].il2p_max_fec = (i_opt > 0);
|
||||
modem.achan[0].il2p_invert_polarity = 1; // invert for transmit
|
||||
if (modem.achan[0].baud == 1200) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Using -i with 1200 bps is a bad idea. Use -I instead.\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Open the output file.
|
||||
*/
|
||||
|
@ -536,6 +586,7 @@ int main(int argc, char **argv)
|
|||
// Just use the default of minimal information.
|
||||
|
||||
fx25_init (1);
|
||||
il2p_init (0); // There are no "-d" options so far but it could be handy here.
|
||||
|
||||
assert (modem.adev[0].bits_per_sample == 8 || modem.adev[0].bits_per_sample == 16);
|
||||
assert (modem.adev[0].num_channels == 1 || modem.adev[0].num_channels == 2);
|
||||
|
@ -669,7 +720,9 @@ static void usage (char **argv)
|
|||
dw_printf (" -g Scrambled baseband rather than AFSK.\n");
|
||||
dw_printf (" -j 2400 bps QPSK compatible with direwolf <= 1.5.\n");
|
||||
dw_printf (" -J 2400 bps QPSK compatible with MFJ-2400.\n");
|
||||
dw_printf (" -X n Generate FX.25 frames. Specify number of check bytes: 16, 32, or 64.\n");
|
||||
dw_printf (" -X n 1 to enable FX.25 transmit. 16, 32, 64 for specific number of check bytes.\n");
|
||||
dw_printf (" -I n Enable IL2P transmit. n=1 is recommended. 0 uses weaker FEC.\n");
|
||||
dw_printf (" -i n Enable IL2P transmit, inverted polarity. n=1 is recommended. 0 uses weaker FEC.\n");
|
||||
dw_printf (" -m <number> Mark frequency. Default is %d.\n", DEFAULT_MARK_FREQ);
|
||||
dw_printf (" -s <number> Space frequency. Default is %d.\n", DEFAULT_SPACE_FREQ);
|
||||
dw_printf (" -r <number> Audio sample Rate. Default is %d.\n", DEFAULT_SAMPLES_PER_SEC);
|
||||
|
|
|
@ -164,7 +164,7 @@ int gen_tone_init (struct audio_s *audio_config_p, int amp, int gen_packets)
|
|||
|
||||
for (chan = 0; chan < MAX_CHANS; chan++) {
|
||||
|
||||
if (audio_config_p->achan[chan].medium == MEDIUM_RADIO) {
|
||||
if (audio_config_p->chan_medium[chan] == MEDIUM_RADIO) {
|
||||
|
||||
int a = ACHAN2ADEV(chan);
|
||||
|
||||
|
@ -295,7 +295,7 @@ void tone_gen_put_bit (int chan, int dat)
|
|||
|
||||
assert (save_audio_config_p != NULL);
|
||||
|
||||
if (save_audio_config_p->achan[chan].medium != MEDIUM_RADIO) {
|
||||
if (save_audio_config_p->chan_medium[chan] != MEDIUM_RADIO) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Invalid channel %d for tone generation.\n", chan);
|
||||
return;
|
||||
|
@ -360,7 +360,10 @@ void tone_gen_put_bit (int chan, int dat)
|
|||
bit_count[chan] = 0;
|
||||
}
|
||||
|
||||
if (save_audio_config_p->achan[chan].modem_type == MODEM_SCRAMBLE) {
|
||||
// Would be logical to have MODEM_BASEBAND for IL2P rather than checking here. But...
|
||||
// That would mean putting in at least 3 places and testing all rather than just one.
|
||||
if (save_audio_config_p->achan[chan].modem_type == MODEM_SCRAMBLE &&
|
||||
save_audio_config_p->achan[chan].layer2_xmit != LAYER2_IL2P) {
|
||||
int x;
|
||||
|
||||
x = (dat ^ (lfsr[chan] >> 16) ^ (lfsr[chan] >> 11)) & 1;
|
||||
|
@ -380,7 +383,14 @@ void tone_gen_put_bit (int chan, int dat)
|
|||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("tone_gen_put_bit %d AFSK\n", __LINE__);
|
||||
#endif
|
||||
tone_phase[chan] += dat ? f2_change_per_sample[chan] : f1_change_per_sample[chan];
|
||||
|
||||
// v1.7 reversed.
|
||||
// Previously a data '1' selected the second (usually higher) tone.
|
||||
// It never really mattered before because we were using NRZI.
|
||||
// With the addition of IL2P, we need to be more careful.
|
||||
// A data '1' should be the mark tone.
|
||||
|
||||
tone_phase[chan] += dat ? f1_change_per_sample[chan] : f2_change_per_sample[chan];
|
||||
sam = sine_table[(tone_phase[chan] >> 24) & 0xff];
|
||||
gen_tone_put_sample (chan, a, sam);
|
||||
break;
|
||||
|
|
|
@ -433,9 +433,9 @@ static const symbol_type_t grm_alternate_symtab[SYMTAB_SIZE] = {
|
|||
sym_park, // ; 27 Park/Picnic area
|
||||
sym_default, // < 28 ADVISORY (one WX flag)
|
||||
sym_rbcn, // = 29 APRStt Touchtone (DTMF users)
|
||||
sym_car, // > 30 OVERLAYED CAR
|
||||
sym_car, // > 30 OVERLAID CAR
|
||||
sym_default, // ? 31 INFO Kiosk (Blue box with ?)
|
||||
sym_default, // @ 32 HURICANE/Trop-Storm
|
||||
sym_default, // @ 32 HURRICANE/Trop-Storm
|
||||
sym_default, // A 33 overlayBOX DTMF & RFID & XO
|
||||
sym_default, // B 34 Blwng Snow (& future codes)
|
||||
sym_coast_guard, // C 35 Coast Guard
|
||||
|
@ -445,7 +445,7 @@ static const symbol_type_t grm_alternate_symtab[SYMTAB_SIZE] = {
|
|||
sym_default, // G 39 Snow Shwr (& future ovrlys)
|
||||
sym_default, // H 40 Haze (& Overlay Hazards)
|
||||
sym_default, // I 41 Rain Shower
|
||||
sym_default, // J 42 Lightening (& future ovrlys)
|
||||
sym_default, // J 42 Lightning (& future ovrlys)
|
||||
sym_rbcn, // K 43 Kenwood HT (W)
|
||||
sym_light, // L 44 Lighthouse
|
||||
sym_default, // M 45 MARS (A=Army,N=Navy,F=AF)
|
||||
|
@ -488,12 +488,12 @@ static const symbol_type_t grm_alternate_symtab[SYMTAB_SIZE] = {
|
|||
sym_restrooms, // r 82 Restrooms
|
||||
sym_default, // s 83 OVERLAY SHIP/boat (top view)
|
||||
sym_default, // t 84 Tornado
|
||||
sym_car, // u 85 OVERLAYED TRUCK
|
||||
sym_car, // v 86 OVERLAYED Van
|
||||
sym_car, // u 85 OVERLAID TRUCK
|
||||
sym_car, // v 86 OVERLAID Van
|
||||
sym_default, // w 87 Flooding
|
||||
sym_wreck, // x 88 Wreck or Obstruction ->X<-
|
||||
sym_default, // y 89 Skywarn
|
||||
sym_default, // z 90 OVERLAYED Shelter
|
||||
sym_default, // z 90 OVERLAID Shelter
|
||||
sym_default, // { 91 Fog (& future ovrly codes)
|
||||
sym_default, // | 92 TNC Stream Switch
|
||||
sym_default, // } 93
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "demod_9600.h" /* for descramble() */
|
||||
#include "ptt.h"
|
||||
#include "fx25.h"
|
||||
#include "il2p.h"
|
||||
|
||||
|
||||
//#define TEST 1 /* Define for unit testing. */
|
||||
|
@ -151,7 +152,7 @@ void hdlc_rec_init (struct audio_s *pa)
|
|||
for (ch = 0; ch < MAX_CHANS; ch++)
|
||||
{
|
||||
|
||||
if (pa->achan[ch].medium == MEDIUM_RADIO) {
|
||||
if (pa->chan_medium[ch] == MEDIUM_RADIO) {
|
||||
|
||||
num_subchan[ch] = pa->achan[ch].num_subchan;
|
||||
|
||||
|
@ -496,6 +497,7 @@ void hdlc_rec_bit (int chan, int subchan, int slice, int raw, int is_scrambled,
|
|||
|
||||
if (g_audio_p->achan[chan].modem_type != MODEM_AIS) {
|
||||
fx25_rec_bit (chan, subchan, slice, dbit);
|
||||
il2p_rec_bit (chan, subchan, slice, raw); // Note: skip NRZI.
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -759,7 +761,7 @@ void dcd_change (int chan, int subchan, int slice, int state)
|
|||
*
|
||||
* Name: hdlc_rec_data_detect_any
|
||||
*
|
||||
* Purpose: Determine if the radio channel is curently busy
|
||||
* Purpose: Determine if the radio channel is currently busy
|
||||
* with packet data.
|
||||
* This version doesn't care about voice or other sounds.
|
||||
* This is used by the transmit logic to transmit only
|
||||
|
@ -774,7 +776,7 @@ void dcd_change (int chan, int subchan, int slice, int state)
|
|||
* Description: We have two different versions here.
|
||||
*
|
||||
* hdlc_rec_data_detect_any sees if ANY of the decoders
|
||||
* for this channel are receving a signal. This is
|
||||
* for this channel are receiving a signal. This is
|
||||
* used to determine whether the channel is clear and
|
||||
* we can transmit. This would apply to the 300 baud
|
||||
* HF SSB case where we have multiple decoders running
|
||||
|
|
|
@ -273,7 +273,7 @@ void hdlc_rec2_block (rrbb_t block)
|
|||
}
|
||||
|
||||
/*
|
||||
* Not successful with frame in orginal form.
|
||||
* Not successful with frame in original form.
|
||||
* See if we can "fix" it.
|
||||
*/
|
||||
if (try_to_fix_quick_now (block, chan, subchan, slice, alevel)) {
|
||||
|
|
134
src/hdlc_send.c
134
src/hdlc_send.c
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
||||
//
|
||||
// Copyright (C) 2011, 2013, 2014, 2019 John Langner, WB2OSZ
|
||||
// Copyright (C) 2011, 2013, 2014, 2019, 2021 John Langner, WB2OSZ
|
||||
//
|
||||
// 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
|
||||
|
@ -27,11 +27,15 @@
|
|||
#include "gen_tone.h"
|
||||
#include "textcolor.h"
|
||||
#include "fcs_calc.h"
|
||||
#include "ax25_pad.h"
|
||||
#include "fx25.h"
|
||||
#include "il2p.h"
|
||||
|
||||
static void send_control (int, int);
|
||||
static void send_data (int, int);
|
||||
static void send_bit (int, int);
|
||||
static void send_byte_msb_first (int chan, int x, int polarity);
|
||||
|
||||
static void send_control_nrzi (int, int);
|
||||
static void send_data_nrzi (int, int);
|
||||
static void send_bit_nrzi (int, int);
|
||||
|
||||
|
||||
|
||||
|
@ -39,25 +43,21 @@ static int number_of_bits_sent[MAX_CHANS]; // Count number of bits sent by "hdl
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------
|
||||
*
|
||||
* Name: hdlc_send
|
||||
* Name: layer2_send_frame
|
||||
*
|
||||
* Purpose: Convert HDLC frames to a stream of bits.
|
||||
* Purpose: Convert frames to a stream of bits.
|
||||
* Originally this was for AX.25 only, hence the file name.
|
||||
* Over time, FX.25 and IL2P were shoehorned in.
|
||||
*
|
||||
* Inputs: chan - Audio channel number, 0 = first.
|
||||
*
|
||||
* fbuf - Frame buffer address.
|
||||
*
|
||||
* flen - Frame length, not including the FCS.
|
||||
* pp - Packet object.
|
||||
*
|
||||
* bad_fcs - Append an invalid FCS for testing purposes.
|
||||
* Applies only to regular AX.25.
|
||||
*
|
||||
* fx25_xmit_enable - Just like the name says.
|
||||
*
|
||||
* Outputs: Bits are shipped out by calling tone_gen_put_bit().
|
||||
*
|
||||
* Returns: Number of bits sent including "flags" and the
|
||||
|
@ -65,12 +65,12 @@ static int number_of_bits_sent[MAX_CHANS]; // Count number of bits sent by "hdl
|
|||
* The required time can be calculated by dividing this
|
||||
* number by the transmit rate of bits/sec.
|
||||
*
|
||||
* Description: Convert to stream of bits including:
|
||||
* Description: For AX.25, send:
|
||||
* start flag
|
||||
* bit stuffed data
|
||||
* calculated FCS
|
||||
* end flag
|
||||
* NRZI encoding
|
||||
* NRZI encoding for all but the "flags."
|
||||
*
|
||||
*
|
||||
* Assumptions: It is assumed that the tone_gen module has been
|
||||
|
@ -81,23 +81,40 @@ static int number_of_bits_sent[MAX_CHANS]; // Count number of bits sent by "hdl
|
|||
|
||||
static int ax25_only_hdlc_send_frame (int chan, unsigned char *fbuf, int flen, int bad_fcs);
|
||||
|
||||
// New in 1.6: Option to encapsulate in FX.25.
|
||||
|
||||
int hdlc_send_frame (int chan, unsigned char *fbuf, int flen, int bad_fcs, int fx25_xmit_enable)
|
||||
int layer2_send_frame (int chan, packet_t pp, int bad_fcs, struct audio_s *audio_config_p)
|
||||
{
|
||||
if (fx25_xmit_enable) {
|
||||
int n = fx25_send_frame (chan, fbuf, flen, fx25_xmit_enable);
|
||||
if (audio_config_p->achan[chan].layer2_xmit == LAYER2_IL2P) {
|
||||
|
||||
int n = il2p_send_frame (chan, pp, audio_config_p->achan[chan].il2p_max_fec,
|
||||
audio_config_p->achan[chan].il2p_invert_polarity);
|
||||
if (n > 0) {
|
||||
return (n);
|
||||
}
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Unable to send IL2p frame. Falling back to regular AX.25.\n");
|
||||
// Not sure if we should fall back to AX.25 or not here.
|
||||
}
|
||||
else if (audio_config_p->achan[chan].layer2_xmit == LAYER2_FX25) {
|
||||
unsigned char fbuf[AX25_MAX_PACKET_LEN+2];
|
||||
int flen = ax25_pack (pp, fbuf);
|
||||
int n = fx25_send_frame (chan, fbuf, flen, audio_config_p->achan[chan].fx25_strength);
|
||||
if (n > 0) {
|
||||
return (n);
|
||||
}
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Unable to send FX.25. Falling back to regular AX.25.\n");
|
||||
// Definitely need to fall back to AX.25 here because
|
||||
// the FX.25 frame length is so limited.
|
||||
}
|
||||
|
||||
unsigned char fbuf[AX25_MAX_PACKET_LEN+2];
|
||||
int flen = ax25_pack (pp, fbuf);
|
||||
return (ax25_only_hdlc_send_frame (chan, fbuf, flen, bad_fcs));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int ax25_only_hdlc_send_frame (int chan, unsigned char *fbuf, int flen, int bad_fcs)
|
||||
{
|
||||
int j, fcs;
|
||||
|
@ -105,33 +122,31 @@ static int ax25_only_hdlc_send_frame (int chan, unsigned char *fbuf, int flen, i
|
|||
|
||||
number_of_bits_sent[chan] = 0;
|
||||
|
||||
|
||||
#if DEBUG
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("hdlc_send_frame ( chan = %d, fbuf = %p, flen = %d, bad_fcs = %d)\n", chan, fbuf, flen, bad_fcs);
|
||||
fflush (stdout);
|
||||
#endif
|
||||
|
||||
|
||||
send_control (chan, 0x7e); /* Start frame */
|
||||
send_control_nrzi (chan, 0x7e); /* Start frame */
|
||||
|
||||
for (j=0; j<flen; j++) {
|
||||
send_data (chan, fbuf[j]);
|
||||
send_data_nrzi (chan, fbuf[j]);
|
||||
}
|
||||
|
||||
fcs = fcs_calc (fbuf, flen);
|
||||
|
||||
if (bad_fcs) {
|
||||
/* For testing only - Simulate a frame getting corrupted along the way. */
|
||||
send_data (chan, (~fcs) & 0xff);
|
||||
send_data (chan, ((~fcs) >> 8) & 0xff);
|
||||
send_data_nrzi (chan, (~fcs) & 0xff);
|
||||
send_data_nrzi (chan, ((~fcs) >> 8) & 0xff);
|
||||
}
|
||||
else {
|
||||
send_data (chan, fcs & 0xff);
|
||||
send_data (chan, (fcs >> 8) & 0xff);
|
||||
send_data_nrzi (chan, fcs & 0xff);
|
||||
send_data_nrzi (chan, (fcs >> 8) & 0xff);
|
||||
}
|
||||
|
||||
send_control (chan, 0x7e); /* End frame */
|
||||
send_control_nrzi (chan, 0x7e); /* End frame */
|
||||
|
||||
return (number_of_bits_sent[chan]);
|
||||
}
|
||||
|
@ -139,22 +154,25 @@ static int ax25_only_hdlc_send_frame (int chan, unsigned char *fbuf, int flen, i
|
|||
|
||||
/*-------------------------------------------------------------
|
||||
*
|
||||
* Name: hdlc_send_flags
|
||||
* Name: layer2_preamble_postamble
|
||||
*
|
||||
* Purpose: Send HDLC flags before and after the frame.
|
||||
* Purpose: Send filler pattern before and after the frame.
|
||||
* For HDLC it is 01111110, for IL2P 01010101.
|
||||
*
|
||||
* Inputs: chan - Audio channel number, 0 = first.
|
||||
*
|
||||
* nflags - Number of flag patterns to send.
|
||||
* nbytes - Number of bytes to send.
|
||||
*
|
||||
* finish - True for end of transmission.
|
||||
* This causes the last audio buffer to be flushed.
|
||||
*
|
||||
* audio_config_p - Configuration for audio and modems.
|
||||
*
|
||||
* Outputs: Bits are shipped out by calling tone_gen_put_bit().
|
||||
*
|
||||
* Returns: Number of bits sent.
|
||||
* There is no bit-stuffing so we would expect this to
|
||||
* be 8 * nflags.
|
||||
* be 8 * nbytes.
|
||||
* The required time can be calculated by dividing this
|
||||
* number by the transmit rate of bits/sec.
|
||||
*
|
||||
|
@ -164,25 +182,30 @@ static int ax25_only_hdlc_send_frame (int chan, unsigned char *fbuf, int flen, i
|
|||
*
|
||||
*--------------------------------------------------------------*/
|
||||
|
||||
int hdlc_send_flags (int chan, int nflags, int finish)
|
||||
int layer2_preamble_postamble (int chan, int nbytes, int finish, struct audio_s *audio_config_p)
|
||||
{
|
||||
int j;
|
||||
|
||||
|
||||
number_of_bits_sent[chan] = 0;
|
||||
|
||||
|
||||
#if DEBUG
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("hdlc_send_flags ( chan = %d, nflags = %d, finish = %d )\n", chan, nflags, finish);
|
||||
fflush (stdout);
|
||||
#endif
|
||||
|
||||
/* The AX.25 spec states that when the transmitter is on but not sending data */
|
||||
/* it should send a continuous stream of "flags." */
|
||||
// When the transmitter is on but not sending data, it should be sending
|
||||
// a stream of a filler pattern.
|
||||
// For AX.25, it is the 01111110 "flag" pattern with NRZI and no bit stuffing.
|
||||
// For IL2P, it is 01010101 without NRZI.
|
||||
|
||||
for (j=0; j<nflags; j++) {
|
||||
send_control (chan, 0x7e);
|
||||
for (j=0; j<nbytes; j++) {
|
||||
if (audio_config_p->achan[chan].layer2_xmit == LAYER2_IL2P) {
|
||||
send_byte_msb_first (chan, IL2P_PREAMBLE, audio_config_p->achan[chan].il2p_invert_polarity);
|
||||
}
|
||||
else {
|
||||
send_control_nrzi (chan, 0x7e);
|
||||
}
|
||||
}
|
||||
|
||||
/* Push out the final partial buffer! */
|
||||
|
@ -196,33 +219,54 @@ int hdlc_send_flags (int chan, int nflags, int finish)
|
|||
|
||||
|
||||
|
||||
// The next one is only for IL2P. No NRZI.
|
||||
// MSB first, opposite of AX.25.
|
||||
|
||||
static void send_byte_msb_first (int chan, int x, int polarity)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<8; i++) {
|
||||
int dbit = (x & 0x80) != 0;
|
||||
tone_gen_put_bit (chan, (dbit ^ polarity) & 1);
|
||||
x <<= 1;
|
||||
number_of_bits_sent[chan]++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// The following are only for HDLC.
|
||||
// All bits are sent NRZI.
|
||||
// Data (non flags) use bit stuffing.
|
||||
|
||||
|
||||
static int stuff[MAX_CHANS]; // Count number of "1" bits to keep track of when we
|
||||
// need to break up a long run by "bit stuffing."
|
||||
// Needs to be array because we could be transmitting
|
||||
// on multiple channels at the same time.
|
||||
|
||||
static void send_control (int chan, int x)
|
||||
static void send_control_nrzi (int chan, int x)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<8; i++) {
|
||||
send_bit (chan, x & 1);
|
||||
send_bit_nrzi (chan, x & 1);
|
||||
x >>= 1;
|
||||
}
|
||||
|
||||
stuff[chan] = 0;
|
||||
}
|
||||
|
||||
static void send_data (int chan, int x)
|
||||
static void send_data_nrzi (int chan, int x)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<8; i++) {
|
||||
send_bit (chan, x & 1);
|
||||
send_bit_nrzi (chan, x & 1);
|
||||
if (x & 1) {
|
||||
stuff[chan]++;
|
||||
if (stuff[chan] == 5) {
|
||||
send_bit (chan, 0);
|
||||
send_bit_nrzi (chan, 0);
|
||||
stuff[chan] = 0;
|
||||
}
|
||||
} else {
|
||||
|
@ -238,7 +282,7 @@ static void send_data (int chan, int x)
|
|||
* data 0 bit -> invert signal.
|
||||
*/
|
||||
|
||||
static void send_bit (int chan, int b)
|
||||
static void send_bit_nrzi (int chan, int b)
|
||||
{
|
||||
static int output[MAX_CHANS];
|
||||
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
|
||||
/* hdlc_send.h */
|
||||
|
||||
int hdlc_send_frame (int chan, unsigned char *fbuf, int flen, int bad_fcs, int fx25_xmit_enable);
|
||||
// In version 1.7 an extra layer of abstraction was added here.
|
||||
// Rather than calling hdlc_send_frame, we now use another function
|
||||
// which sends AX.25, FX.25, or IL2P depending on
|
||||
|
||||
int hdlc_send_flags (int chan, int flags, int finish);
|
||||
#include "ax25_pad.h"
|
||||
#include "audio.h"
|
||||
|
||||
int layer2_send_frame (int chan, packet_t pp, int bad_fcs, struct audio_s *audio_config_p);
|
||||
|
||||
int layer2_preamble_postamble (int chan, int flags, int finish, struct audio_s *audio_config_p);
|
||||
|
||||
/* end hdlc_send.h */
|
||||
|
||||
|
|
65
src/igate.c
65
src/igate.c
|
@ -100,6 +100,7 @@
|
|||
#include "version.h"
|
||||
#include "digipeater.h"
|
||||
#include "tq.h"
|
||||
#include "dlq.h"
|
||||
#include "igate.h"
|
||||
#include "latlong.h"
|
||||
#include "pfilter.h"
|
||||
|
@ -107,6 +108,7 @@
|
|||
#include "mheard.h"
|
||||
|
||||
|
||||
|
||||
#if __WIN32__
|
||||
static unsigned __stdcall connnect_thread (void *arg);
|
||||
static unsigned __stdcall igate_recv_thread (void *arg);
|
||||
|
@ -1469,7 +1471,7 @@ static void * igate_recv_thread (void *arg)
|
|||
*
|
||||
* Future: might have ability to configure multiple transmit
|
||||
* channels, each with own client side filtering and via path.
|
||||
* Loop here over all configured channels.
|
||||
* If so, loop here over all configured channels.
|
||||
*/
|
||||
text_color_set(DW_COLOR_REC);
|
||||
dw_printf ("\n[ig>tx] "); // formerly just [ig]
|
||||
|
@ -1504,6 +1506,60 @@ static void * igate_recv_thread (void *arg)
|
|||
if (to_chan >= 0) {
|
||||
maybe_xmit_packet_from_igate ((char*)message, to_chan);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* New in 1.7: If ICHANNEL was specified, send packet to client app as specified channel.
|
||||
*/
|
||||
if (save_audio_config_p->igate_vchannel >= 0) {
|
||||
|
||||
int ichan = save_audio_config_p->igate_vchannel;
|
||||
|
||||
// Try to parse it into a packet object.
|
||||
// This will contain "q constructs" and we might see an address
|
||||
// with two alphnumeric characters in the SSID so we must use
|
||||
// the non-strict parsing.
|
||||
|
||||
// Possible problem: Up to 8 digipeaters are allowed in radio format.
|
||||
// There is a potential of finding a larger number here.
|
||||
|
||||
packet_t pp3 = ax25_from_text((char*)message, 0); // 0 means not strict
|
||||
if (pp3 != NULL) {
|
||||
|
||||
// Should we remove the VIA path?
|
||||
|
||||
// For example, we might get something like this from the server.
|
||||
// Lower case 'q' and non-numeric SSID are not valid for AX.25 over the air.
|
||||
// K1USN-1>APWW10,TCPIP*,qAC,N5JXS-F1:T#479,100,048,002,500,000,10000000
|
||||
|
||||
// Should we try to retain all information and pass that along, to the best of our ability,
|
||||
// to the client app, or should we remove the via path so it looks like this?
|
||||
// K1USN-1>APWW10:T#479,100,048,002,500,000,10000000
|
||||
|
||||
// For now, keep it intact and see if it causes problems. Easy to remove like this:
|
||||
// while (ax25_get_num_repeaters(pp3) > 0) {
|
||||
// ax25_remove_addr (pp3, AX25_REPEATER_1);
|
||||
// }
|
||||
|
||||
alevel_t alevel;
|
||||
memset (&alevel, 0, sizeof(alevel));
|
||||
alevel.mark = -2; // FIXME: Do we want some other special case?
|
||||
alevel.space = -2;
|
||||
|
||||
int subchan = -2; // FIXME: -1 is special case for APRStt.
|
||||
// See what happens with -2 and follow up on this.
|
||||
// Do we need something else here?
|
||||
int slice = 0;
|
||||
int is_fx25 = 0;
|
||||
char spectrum[] = "APRS-IS";
|
||||
dlq_rec_frame (ichan, subchan, slice, pp3, alevel, is_fx25, RETRY_NONE, spectrum);
|
||||
}
|
||||
else {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("ICHANNEL %d: Could not parse message from APRS-IS server.\n", ichan);
|
||||
dw_printf ("%s\n", message);
|
||||
}
|
||||
} // end ICHANNEL option
|
||||
}
|
||||
|
||||
} /* while (1) */
|
||||
|
@ -1538,9 +1594,14 @@ static void * igate_recv_thread (void *arg)
|
|||
* Duplicate removal will drop the original if there is no
|
||||
* corresponding digipeated version.
|
||||
*
|
||||
*
|
||||
* This was an idea that came up in one of the discussion forums.
|
||||
* I rushed in without thinking about it very much.
|
||||
*
|
||||
* In retrospect, I don't think this was such a good idea.
|
||||
* It would be of value only if there is no other IGate nearby
|
||||
* that would report on the original transmission.
|
||||
* I wonder if anyone would notice if this silently disappeared.
|
||||
*
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
@ -2211,7 +2272,7 @@ static int rx_to_ig_allow (packet_t pp)
|
|||
*
|
||||
* Future:
|
||||
* Should the digipeater function avoid transmitting something if it
|
||||
* was recently transmitted by the IGate funtion?
|
||||
* was recently transmitted by the IGate function?
|
||||
* This code is pretty much the same as dedupe.c. Maybe it could all
|
||||
* be combined into one. Need to ponder this some more.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
|
||||
|
||||
#ifndef IL2P_H
|
||||
#define IL2P_H 1
|
||||
|
||||
|
||||
#define IL2P_PREAMBLE 0x55
|
||||
|
||||
#define IL2P_SYNC_WORD 0xF15E48
|
||||
|
||||
#define IL2P_SYNC_WORD_SIZE 3
|
||||
#define IL2P_HEADER_SIZE 13 // Does not include 2 parity.
|
||||
#define IL2P_HEADER_PARITY 2
|
||||
|
||||
#define IL2P_MAX_PAYLOAD_SIZE 1023
|
||||
#define IL2P_MAX_PAYLOAD_BLOCKS 5
|
||||
#define IL2P_MAX_PARITY_SYMBOLS 16 // For payload only.
|
||||
#define IL2P_MAX_ENCODED_PAYLOAD_SIZE (IL2P_MAX_PAYLOAD_SIZE + IL2P_MAX_PAYLOAD_BLOCKS * IL2P_MAX_PARITY_SYMBOLS)
|
||||
|
||||
#define IL2P_MAX_PACKET_SIZE (IL2P_SYNC_WORD_SIZE + IL2P_HEADER_SIZE + IL2P_HEADER_PARITY + IL2P_MAX_ENCODED_PAYLOAD_SIZE)
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// il2p_init.c
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// Init must be called at start of application.
|
||||
|
||||
extern void il2p_init (int debug);
|
||||
|
||||
#include "fx25.h" // For Reed Solomon stuff. e.g. struct rs
|
||||
// Maybe rearrange someday because RS now used another place.
|
||||
|
||||
extern struct rs *il2p_find_rs(int nparity); // Internal later?
|
||||
|
||||
extern void il2p_encode_rs (unsigned char *tx_data, int data_size, int num_parity, unsigned char *parity_out);
|
||||
|
||||
extern int il2p_decode_rs (unsigned char *rec_block, int data_size, int num_parity, unsigned char *out);
|
||||
|
||||
extern int il2p_get_debug(void);
|
||||
extern void il2p_set_debug(int debug);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// il2p_rec.c
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Receives a bit stream from demodulator.
|
||||
|
||||
extern void il2p_rec_bit (int chan, int subchan, int slice, int dbit);
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// il2p_send.c
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "ax25_pad.h" // For packet object.
|
||||
|
||||
// Send bit stream to modulator.
|
||||
|
||||
int il2p_send_frame (int chan, packet_t pp, int max_fec, int polarity);
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// il2p_codec.c
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "ax25_pad.h"
|
||||
|
||||
extern int il2p_encode_frame (packet_t pp, int max_fec, unsigned char *iout);
|
||||
|
||||
packet_t il2p_decode_frame (unsigned char *irec);
|
||||
|
||||
packet_t il2p_decode_header_payload (unsigned char* uhdr, unsigned char *epayload, int *symbols_corrected);
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// il2p_header.c
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
extern int il2p_type_1_header (packet_t pp, int max_fec, unsigned char *hdr);
|
||||
|
||||
extern packet_t il2p_decode_header_type_1 (unsigned char *hdr, int num_sym_changed);
|
||||
|
||||
|
||||
extern int il2p_type_0_header (packet_t pp, int max_fec, unsigned char *hdr);
|
||||
|
||||
extern int il2p_clarify_header(unsigned char *rec_hdr, unsigned char *corrected_descrambled_hdr);
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// il2p_scramble.c
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern void il2p_scramble_block (unsigned char *in, unsigned char *out, int len);
|
||||
|
||||
extern void il2p_descramble_block (unsigned char *in, unsigned char *out, int len);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// il2p_payload.c
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
typedef struct {
|
||||
int payload_byte_count; // Total size, 0 thru 1023
|
||||
int payload_block_count;
|
||||
int small_block_size;
|
||||
int large_block_size;
|
||||
int large_block_count;
|
||||
int small_block_count;
|
||||
int parity_symbols_per_block; // 2, 4, 6, 8, 16
|
||||
} il2p_payload_properties_t;
|
||||
|
||||
extern int il2p_payload_compute (il2p_payload_properties_t *p, int payload_size, int max_fec);
|
||||
|
||||
extern int il2p_encode_payload (unsigned char *payload, int payload_size, int max_fec, unsigned char *enc);
|
||||
|
||||
extern int il2p_decode_payload (unsigned char *received, int payload_size, int max_fec, unsigned char *payload_out, int *symbols_corrected);
|
||||
|
||||
extern int il2p_get_header_attributes (unsigned char *hdr, int *hdr_type, int *max_fec);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,263 @@
|
|||
//
|
||||
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
||||
//
|
||||
// Copyright (C) 2021 John Langner, WB2OSZ
|
||||
//
|
||||
// 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, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
#include "direwolf.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "il2p.h"
|
||||
#include "textcolor.h"
|
||||
#include "demod.h"
|
||||
|
||||
|
||||
/*-------------------------------------------------------------
|
||||
*
|
||||
* File: il2p_codec.c
|
||||
*
|
||||
* Purpose: Convert IL2P encoded format from and to direwolf internal packet format.
|
||||
*
|
||||
*--------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*-------------------------------------------------------------
|
||||
*
|
||||
* Name: il2p_encode_frame
|
||||
*
|
||||
* Purpose: Convert AX.25 frame to IL2P encoding.
|
||||
*
|
||||
* Inputs: chan - Audio channel number, 0 = first.
|
||||
*
|
||||
* pp - Packet object pointer.
|
||||
*
|
||||
* max_fec - 1 to send maximum FEC size rather than automatic.
|
||||
*
|
||||
* Outputs: iout - Encoded result, excluding the 3 byte sync word.
|
||||
* Caller should provide IL2P_MAX_PACKET_SIZE bytes.
|
||||
*
|
||||
* Returns: Number of bytes for transmission.
|
||||
* -1 is returned for failure.
|
||||
*
|
||||
* Description: Encode into IL2P format.
|
||||
*
|
||||
* Errors: If something goes wrong, return -1.
|
||||
*
|
||||
* Most likely reason is that the frame is too large.
|
||||
* IL2P has a max payload size of 1023 bytes.
|
||||
* For a type 1 header, this is the maximum AX.25 Information part size.
|
||||
* For a type 0 header, this is the entire AX.25 frame.
|
||||
*
|
||||
*--------------------------------------------------------------*/
|
||||
|
||||
int il2p_encode_frame (packet_t pp, int max_fec, unsigned char *iout)
|
||||
{
|
||||
|
||||
// Can a type 1 header be used?
|
||||
|
||||
unsigned char hdr[IL2P_HEADER_SIZE + IL2P_HEADER_PARITY];
|
||||
int e;
|
||||
int out_len = 0;
|
||||
|
||||
e = il2p_type_1_header (pp, max_fec, hdr);
|
||||
if (e >= 0) {
|
||||
il2p_scramble_block (hdr, iout, IL2P_HEADER_SIZE);
|
||||
il2p_encode_rs (iout, IL2P_HEADER_SIZE, IL2P_HEADER_PARITY, iout+IL2P_HEADER_SIZE);
|
||||
out_len = IL2P_HEADER_SIZE + IL2P_HEADER_PARITY;
|
||||
|
||||
if (e == 0) {
|
||||
// Success. No info part.
|
||||
return (out_len);
|
||||
}
|
||||
|
||||
// Payload is AX.25 info part.
|
||||
unsigned char *pinfo;
|
||||
int info_len;
|
||||
info_len = ax25_get_info (pp, &pinfo);
|
||||
|
||||
int k = il2p_encode_payload (pinfo, info_len, max_fec, iout+out_len);
|
||||
if (k > 0) {
|
||||
out_len += k;
|
||||
// Success. Info part was <= 1023 bytes.
|
||||
return (out_len);
|
||||
}
|
||||
|
||||
// Something went wrong with the payload encoding.
|
||||
return (-1);
|
||||
}
|
||||
else if (e == -1) {
|
||||
|
||||
// Could not use type 1 header for some reason.
|
||||
// e.g. More than 2 addresses, extended (mod 128) sequence numbers, etc.
|
||||
|
||||
e = il2p_type_0_header (pp, max_fec, hdr);
|
||||
if (e > 0) {
|
||||
|
||||
il2p_scramble_block (hdr, iout, IL2P_HEADER_SIZE);
|
||||
il2p_encode_rs (iout, IL2P_HEADER_SIZE, IL2P_HEADER_PARITY, iout+IL2P_HEADER_SIZE);
|
||||
out_len = IL2P_HEADER_SIZE + IL2P_HEADER_PARITY;
|
||||
|
||||
// Payload is entire AX.25 frame.
|
||||
|
||||
unsigned char *frame_data_ptr = ax25_get_frame_data_ptr (pp);
|
||||
int frame_len = ax25_get_frame_len (pp);
|
||||
int k = il2p_encode_payload (frame_data_ptr, frame_len, max_fec, iout+out_len);
|
||||
if (k > 0) {
|
||||
out_len += k;
|
||||
// Success. Entire AX.25 frame <= 1023 bytes.
|
||||
return (out_len);
|
||||
}
|
||||
// Something went wrong with the payload encoding.
|
||||
return (-1);
|
||||
}
|
||||
else if (e == 0) {
|
||||
// Impossible condition. Type 0 header must have payload.
|
||||
return (-1);
|
||||
}
|
||||
else {
|
||||
// AX.25 frame is too large.
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
// AX.25 Information part is too large.
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------
|
||||
*
|
||||
* Name: il2p_decode_frame
|
||||
*
|
||||
* Purpose: Convert IL2P encoding to AX.25 frame.
|
||||
* This is only used during testing, with a whole encoded frame.
|
||||
* During reception, the header would have FEC and descrambling
|
||||
* applied first so we would know how much to collect for the payload.
|
||||
*
|
||||
* Inputs: irec - Received IL2P frame excluding the 3 byte sync word.
|
||||
*
|
||||
* Future Out: Number of symbols corrected.
|
||||
*
|
||||
* Returns: Packet pointer or NULL for error.
|
||||
*
|
||||
*--------------------------------------------------------------*/
|
||||
|
||||
packet_t il2p_decode_frame (unsigned char *irec)
|
||||
{
|
||||
unsigned char uhdr[IL2P_HEADER_SIZE]; // After FEC and descrambling.
|
||||
int e = il2p_clarify_header (irec, uhdr);
|
||||
|
||||
// TODO?: for symmetry we might want to clarify the payload before combining.
|
||||
|
||||
return (il2p_decode_header_payload(uhdr, irec + IL2P_HEADER_SIZE + IL2P_HEADER_PARITY, &e));
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------
|
||||
*
|
||||
* Name: il2p_decode_header_payload
|
||||
*
|
||||
* Purpose: Convert IL2P encoding to AX.25 frame
|
||||
*
|
||||
* Inputs: uhdr - Received header after FEC and descrambling.
|
||||
* epayload - Encoded payload.
|
||||
*
|
||||
* In/Out: symbols_corrected - Symbols (bytes) corrected in the header.
|
||||
* Should be 0 or 1 because it has 2 parity symbols.
|
||||
* Here we add number of corrections for the payload.
|
||||
*
|
||||
* Returns: Packet pointer or NULL for error.
|
||||
*
|
||||
*--------------------------------------------------------------*/
|
||||
|
||||
packet_t il2p_decode_header_payload (unsigned char* uhdr, unsigned char *epayload, int *symbols_corrected)
|
||||
{
|
||||
int hdr_type;
|
||||
int max_fec;
|
||||
int payload_len = il2p_get_header_attributes (uhdr, &hdr_type, &max_fec);
|
||||
|
||||
packet_t pp = NULL;
|
||||
|
||||
if (hdr_type == 1) {
|
||||
|
||||
// Header type 1. Any payload is the AX.25 Information part.
|
||||
|
||||
pp = il2p_decode_header_type_1 (uhdr, *symbols_corrected);
|
||||
if (pp == NULL) {
|
||||
// Failed for some reason.
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (payload_len > 0) {
|
||||
// This is the AX.25 Information part.
|
||||
|
||||
unsigned char extracted[IL2P_MAX_PAYLOAD_SIZE];
|
||||
int e = il2p_decode_payload (epayload, payload_len, max_fec, extracted, symbols_corrected);
|
||||
|
||||
// It would be possible to have a good header but too many errors in the payload.
|
||||
|
||||
if (e <= 0) {
|
||||
ax25_delete (pp);
|
||||
pp = NULL;
|
||||
return (pp);
|
||||
}
|
||||
|
||||
if (e != payload_len) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("IL2P Internal Error: %s(): hdr_type=%d, max_fec=%d, payload_len=%d, e=%d.\n", __func__, hdr_type, max_fec, payload_len, e);
|
||||
}
|
||||
|
||||
ax25_set_info (pp, extracted, payload_len);
|
||||
}
|
||||
return (pp);
|
||||
}
|
||||
else {
|
||||
|
||||
// Header type 0. The payload is the entire AX.25 frame.
|
||||
|
||||
unsigned char extracted[IL2P_MAX_PAYLOAD_SIZE];
|
||||
int e = il2p_decode_payload (epayload, payload_len, max_fec, extracted, symbols_corrected);
|
||||
|
||||
if (e <= 0) { // Payload was not received correctly.
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (e != payload_len) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("IL2P Internal Error: %s(): hdr_type=%d, e=%d, payload_len=%d\n", __func__, hdr_type, e, payload_len);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
alevel_t alevel;
|
||||
memset (&alevel, 0, sizeof(alevel));
|
||||
//alevel = demod_get_audio_level (chan, subchan); // What TODO? We don't know channel here.
|
||||
// I think alevel gets filled in somewhere later making
|
||||
// this redundant.
|
||||
|
||||
pp = ax25_from_frame (extracted, payload_len, alevel);
|
||||
return (pp);
|
||||
}
|
||||
|
||||
} // end il2p_decode_header_payload
|
||||
|
||||
// end il2p_codec.c
|
||||
|
||||
|
|
@ -0,0 +1,673 @@
|
|||
//
|
||||
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
||||
//
|
||||
// Copyright (C) 2021 John Langner, WB2OSZ
|
||||
//
|
||||
// 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, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
#include "direwolf.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "textcolor.h"
|
||||
#include "ax25_pad.h"
|
||||
#include "ax25_pad2.h"
|
||||
#include "il2p.h"
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
*
|
||||
* File: il2p_header.c
|
||||
*
|
||||
* Purpose: Functions to deal with the IL2P header.
|
||||
*
|
||||
* Reference: http://tarpn.net/t/il2p/il2p-specification0-4.pdf
|
||||
*
|
||||
*--------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
// Convert ASCII to/from DEC SIXBIT as defined here:
|
||||
// https://en.wikipedia.org/wiki/Six-bit_character_code#DEC_six-bit_code
|
||||
|
||||
static inline int ascii_to_sixbit (int a)
|
||||
{
|
||||
if (a >= ' ' && a <= '_') return (a - ' ');
|
||||
return (31); // '?' for any invalid.
|
||||
}
|
||||
|
||||
static inline int sixbit_to_ascii (int s)
|
||||
{
|
||||
return (s + ' ');
|
||||
}
|
||||
|
||||
// Functions for setting the various header fields.
|
||||
// It is assumed that it was zeroed first so only the '1' bits are set.
|
||||
|
||||
static void set_field (unsigned char *hdr, int bit_num, int lsb_index, int width, int value)
|
||||
{
|
||||
while (width > 0 && value != 0) {
|
||||
assert (lsb_index >= 0 && lsb_index <= 11);
|
||||
if (value & 1) {
|
||||
hdr[lsb_index] |= 1 << bit_num;
|
||||
}
|
||||
value >>= 1;
|
||||
lsb_index--;
|
||||
width--;
|
||||
}
|
||||
assert (value == 0);
|
||||
}
|
||||
|
||||
#define SET_UI(hdr,val) set_field(hdr, 6, 0, 1, val)
|
||||
|
||||
#define SET_PID(hdr,val) set_field(hdr, 6, 4, 4, val)
|
||||
|
||||
#define SET_CONTROL(hdr,val) set_field(hdr, 6, 11, 7, val)
|
||||
|
||||
|
||||
#define SET_FEC_LEVEL(hdr,val) set_field(hdr, 7, 0, 1, val)
|
||||
|
||||
#define SET_HDR_TYPE(hdr,val) set_field(hdr, 7, 1, 1, val)
|
||||
|
||||
#define SET_PAYLOAD_BYTE_COUNT(hdr,val) set_field(hdr, 7, 11, 10, val)
|
||||
|
||||
|
||||
// Extracting the fields.
|
||||
|
||||
static int get_field (unsigned char *hdr, int bit_num, int lsb_index, int width)
|
||||
{
|
||||
int result = 0;
|
||||
lsb_index -= width - 1;
|
||||
while (width > 0) {
|
||||
result <<= 1;
|
||||
assert (lsb_index >= 0 && lsb_index <= 11);
|
||||
if (hdr[lsb_index] & (1 << bit_num)) {
|
||||
result |= 1;
|
||||
}
|
||||
lsb_index++;
|
||||
width--;
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
#define GET_UI(hdr) get_field(hdr, 6, 0, 1)
|
||||
|
||||
#define GET_PID(hdr) get_field(hdr, 6, 4, 4)
|
||||
|
||||
#define GET_CONTROL(hdr) get_field(hdr, 6, 11, 7)
|
||||
|
||||
|
||||
#define GET_FEC_LEVEL(hdr) get_field(hdr, 7, 0, 1)
|
||||
|
||||
#define GET_HDR_TYPE(hdr) get_field(hdr, 7, 1, 1)
|
||||
|
||||
#define GET_PAYLOAD_BYTE_COUNT(hdr) get_field(hdr, 7, 11, 10)
|
||||
|
||||
|
||||
|
||||
// AX.25 'I' and 'UI' frames have a protocol ID which determines how the
|
||||
// information part should be interpreted.
|
||||
// Here we squeeze the most common cases down to 4 bits.
|
||||
// Return -1 if translation is not possible. Fall back to type 0 header in this case.
|
||||
|
||||
static int encode_pid (packet_t pp)
|
||||
{
|
||||
int pid = ax25_get_pid(pp);
|
||||
|
||||
if ((pid & 0x30) == 0x20) return (0x2); // AX.25 Layer 3
|
||||
if ((pid & 0x30) == 0x10) return (0x2); // AX.25 Layer 3
|
||||
if (pid == 0x01) return (0x3); // ISO 8208 / CCIT X.25 PLP
|
||||
if (pid == 0x06) return (0x4); // Compressed TCP/IP
|
||||
if (pid == 0x07) return (0x5); // Uncompressed TCP/IP
|
||||
if (pid == 0x08) return (0x6); // Segmentation fragmen
|
||||
if (pid == 0xcc) return (0xb); // ARPA Internet Protocol
|
||||
if (pid == 0xcd) return (0xc); // ARPA Address Resolution
|
||||
if (pid == 0xce) return (0xd); // FlexNet
|
||||
if (pid == 0xcf) return (0xe); // TheNET
|
||||
if (pid == 0xf0) return (0xf); // No L3
|
||||
return (-1);
|
||||
}
|
||||
|
||||
// Convert IL2P 4 bit PID to AX.25 8 bit PID.
|
||||
|
||||
|
||||
static int decode_pid (int pid)
|
||||
{
|
||||
static const unsigned char axpid[16] = {
|
||||
0xf0, // Should not happen. 0 is for 'S' frames.
|
||||
0xf0, // Should not happen. 1 is for 'U' frames (but not UI).
|
||||
0x20, // AX.25 Layer 3
|
||||
0x01, // ISO 8208 / CCIT X.25 PLP
|
||||
0x06, // Compressed TCP/IP
|
||||
0x07, // Uncompressed TCP/IP
|
||||
0x08, // Segmentation fragment
|
||||
0xf0, // Future
|
||||
0xf0, // Future
|
||||
0xf0, // Future
|
||||
0xf0, // Future
|
||||
0xcc, // ARPA Internet Protocol
|
||||
0xcd, // ARPA Address Resolution
|
||||
0xce, // FlexNet
|
||||
0xcf, // TheNET
|
||||
0xf0 }; // No L3
|
||||
|
||||
assert (pid >= 0 && pid <= 15);
|
||||
return (axpid[pid]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
*
|
||||
* Function: il2p_type_1_header
|
||||
*
|
||||
* Purpose: Attempt to create type 1 header from packet object.
|
||||
*
|
||||
* Inputs: pp - Packet object.
|
||||
*
|
||||
* max_fec - 1 to use maximum FEC symbols , 0 for automatic.
|
||||
*
|
||||
* Outputs: hdr - IL2P header with no scrambling or parity symbols.
|
||||
* Must be large enough to hold IL2P_HEADER_SIZE unsigned bytes.
|
||||
*
|
||||
* Returns: Number of bytes for information part or -1 for failure.
|
||||
* In case of failure, fall back to type 0 transparent encapsulation.
|
||||
*
|
||||
* Description: Type 1 Headers do not support AX.25 repeater callsign addressing,
|
||||
* Modulo-128 extended mode window sequence numbers, nor any callsign
|
||||
* characters that cannot translate to DEC SIXBIT.
|
||||
* If these cases are encountered during IL2P packet encoding,
|
||||
* the encoder switches to Type 0 Transparent Encapsulation.
|
||||
* SABME can't be handled by type 1.
|
||||
*
|
||||
*--------------------------------------------------------------------------------*/
|
||||
|
||||
int il2p_type_1_header (packet_t pp, int max_fec, unsigned char *hdr)
|
||||
{
|
||||
memset (hdr, 0, IL2P_HEADER_SIZE);
|
||||
|
||||
if (ax25_get_num_addr(pp) != 2) {
|
||||
// Only two addresses are allowed for type 1 header.
|
||||
return (-1);
|
||||
}
|
||||
|
||||
// Check does not apply for 'U' frames but put in one place rather than two.
|
||||
|
||||
if (ax25_get_modulo(pp) == 128) return(-1);
|
||||
|
||||
// Destination and source addresses go into low bits 0-5 for bytes 0-11.
|
||||
|
||||
char dst_addr[AX25_MAX_ADDR_LEN];
|
||||
char src_addr[AX25_MAX_ADDR_LEN];
|
||||
|
||||
ax25_get_addr_no_ssid (pp, AX25_DESTINATION, dst_addr);
|
||||
int dst_ssid = ax25_get_ssid (pp, AX25_DESTINATION);
|
||||
|
||||
ax25_get_addr_no_ssid (pp, AX25_SOURCE, src_addr);
|
||||
int src_ssid = ax25_get_ssid (pp, AX25_SOURCE);
|
||||
|
||||
unsigned char *a = (unsigned char *)dst_addr;
|
||||
for (int i = 0; *a != '\0'; i++, a++) {
|
||||
if (*a < ' ' || *a > '_') {
|
||||
// Shouldn't happen but follow the rule.
|
||||
return (-1);
|
||||
}
|
||||
hdr[i] = ascii_to_sixbit(*a);
|
||||
}
|
||||
|
||||
a = (unsigned char *)src_addr;
|
||||
for (int i = 6; *a != '\0'; i++, a++) {
|
||||
if (*a < ' ' || *a > '_') {
|
||||
// Shouldn't happen but follow the rule.
|
||||
return (-1);
|
||||
}
|
||||
hdr[i] = ascii_to_sixbit(*a);
|
||||
}
|
||||
|
||||
// Byte 12 has DEST SSID in upper nybble and SRC SSID in lower nybble and
|
||||
hdr[12] = (dst_ssid << 4) | src_ssid;
|
||||
|
||||
ax25_frame_type_t frame_type;
|
||||
cmdres_t cr; // command or response.
|
||||
char description[64];
|
||||
int pf; // Poll/Final.
|
||||
int nr, ns; // Sequence numbers.
|
||||
|
||||
frame_type = ax25_frame_type (pp, &cr, description, &pf, &nr, &ns);
|
||||
|
||||
//dw_printf ("%s(): %s-%d>%s-%d: %s\n", __func__, src_addr, src_ssid, dst_addr, dst_ssid, description);
|
||||
|
||||
switch (frame_type) {
|
||||
|
||||
case frame_type_S_RR: // Receive Ready - System Ready To Receive
|
||||
case frame_type_S_RNR: // Receive Not Ready - TNC Buffer Full
|
||||
case frame_type_S_REJ: // Reject Frame - Out of Sequence or Duplicate
|
||||
case frame_type_S_SREJ: // Selective Reject - Request single frame repeat
|
||||
|
||||
// S frames (RR, RNR, REJ, SREJ), mod 8, have control N(R) P/F S S 0 1
|
||||
// These are mapped into P/F N(R) C S S
|
||||
// Bit 6 is not mentioned in documentation but it is used for P/F for the other frame types.
|
||||
// C is copied from the C bit in the destination addr.
|
||||
// C from source is not used here. Reception assumes it is the opposite.
|
||||
// PID is set to 0, meaning none, for S frames.
|
||||
|
||||
SET_UI(hdr, 0);
|
||||
SET_PID(hdr, 0);
|
||||
SET_CONTROL(hdr, (pf<<6) | (nr<<3) | (((cr == cr_cmd) | (cr == cr_11))<<2));
|
||||
|
||||
// This gets OR'ed into the above.
|
||||
switch (frame_type) {
|
||||
case frame_type_S_RR: SET_CONTROL(hdr, 0); break;
|
||||
case frame_type_S_RNR: SET_CONTROL(hdr, 1); break;
|
||||
case frame_type_S_REJ: SET_CONTROL(hdr, 2); break;
|
||||
case frame_type_S_SREJ: SET_CONTROL(hdr, 3); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case frame_type_U_SABM: // Set Async Balanced Mode
|
||||
case frame_type_U_DISC: // Disconnect
|
||||
case frame_type_U_DM: // Disconnect Mode
|
||||
case frame_type_U_UA: // Unnumbered Acknowledge
|
||||
case frame_type_U_FRMR: // Frame Reject
|
||||
case frame_type_U_UI: // Unnumbered Information
|
||||
case frame_type_U_XID: // Exchange Identification
|
||||
case frame_type_U_TEST: // Test
|
||||
|
||||
// The encoding allows only 3 bits for frame type and SABME got left out.
|
||||
// Control format: P/F opcode[3] C n/a n/a
|
||||
// The grayed out n/a bits are observed as 00 in the example.
|
||||
// The header UI field must also be set for UI frames.
|
||||
// PID is set to 1 for all U frames other than UI.
|
||||
|
||||
if (frame_type == frame_type_U_UI) {
|
||||
SET_UI(hdr, 1); // I guess this is how we distinguish 'I' and 'UI'
|
||||
// on the receiving end.
|
||||
int pid = encode_pid(pp);
|
||||
if (pid < 0) return (-1);
|
||||
SET_PID(hdr, pid);
|
||||
}
|
||||
else {
|
||||
SET_PID(hdr, 1); // 1 for 'U' other than 'UI'.
|
||||
}
|
||||
|
||||
// Each of the destination and source addresses has a "C" bit.
|
||||
// They should normally have the opposite setting.
|
||||
// IL2P has only a single bit to represent 4 possbilities.
|
||||
//
|
||||
// dst src il2p meaning
|
||||
// --- --- ---- -------
|
||||
// 0 0 0 Not valid (earlier protocol version)
|
||||
// 1 0 1 Command (v2)
|
||||
// 0 1 0 Response (v2)
|
||||
// 1 1 1 Not valid (earlier protocol version)
|
||||
//
|
||||
// APRS does not mention how to set these bits and all 4 combinations
|
||||
// are seen in the wild. Apparently these are ignored on receive and no
|
||||
// one cares. Here we copy from the C bit in the destination address.
|
||||
// It should be noted that the case of both C bits being the same can't
|
||||
// be represented so the il2p encode/decode bit not produce exactly the
|
||||
// same bits. We see this in the second example in the protocol spec.
|
||||
// The original UI frame has both C bits of 0 so it is received as a response.
|
||||
|
||||
SET_CONTROL(hdr, (pf<<6) | (((cr == cr_cmd) | (cr == cr_11))<<2));
|
||||
|
||||
// This gets OR'ed into the above.
|
||||
switch (frame_type) {
|
||||
case frame_type_U_SABM: SET_CONTROL(hdr, 0<<3); break;
|
||||
case frame_type_U_DISC: SET_CONTROL(hdr, 1<<3); break;
|
||||
case frame_type_U_DM: SET_CONTROL(hdr, 2<<3); break;
|
||||
case frame_type_U_UA: SET_CONTROL(hdr, 3<<3); break;
|
||||
case frame_type_U_FRMR: SET_CONTROL(hdr, 4<<3); break;
|
||||
case frame_type_U_UI: SET_CONTROL(hdr, 5<<3); break;
|
||||
case frame_type_U_XID: SET_CONTROL(hdr, 6<<3); break;
|
||||
case frame_type_U_TEST: SET_CONTROL(hdr, 7<<3); break;
|
||||
default: break;
|
||||
}
|
||||
break;
|
||||
|
||||
case frame_type_I: // Information
|
||||
|
||||
// I frames (mod 8 only)
|
||||
// encoded control: P/F N(R) N(S)
|
||||
|
||||
SET_UI(hdr, 0);
|
||||
|
||||
int pid2 = encode_pid(pp);
|
||||
if (pid2 < 0) return (-1);
|
||||
SET_PID(hdr, pid2);
|
||||
|
||||
SET_CONTROL(hdr, (pf<<6) | (nr<<3) | ns);
|
||||
break;
|
||||
|
||||
case frame_type_U_SABME: // Set Async Balanced Mode, Extended
|
||||
case frame_type_U: // other Unnumbered, not used by AX.25.
|
||||
case frame_not_AX25: // Could not get control byte from frame.
|
||||
default:
|
||||
|
||||
// Fall back to the header type 0 for these.
|
||||
return (-1);
|
||||
}
|
||||
|
||||
// Common for all header type 1.
|
||||
|
||||
// Bit 7 has [FEC Level:1], [HDR Type:1], [Payload byte Count:10]
|
||||
|
||||
SET_FEC_LEVEL(hdr, max_fec);
|
||||
SET_HDR_TYPE(hdr, 1);
|
||||
|
||||
unsigned char *pinfo;
|
||||
int info_len;
|
||||
|
||||
info_len = ax25_get_info (pp, &pinfo);
|
||||
if (info_len < 0 || info_len > IL2P_MAX_PAYLOAD_SIZE) {
|
||||
return (-2);
|
||||
}
|
||||
|
||||
SET_PAYLOAD_BYTE_COUNT(hdr, info_len);
|
||||
return (info_len);
|
||||
}
|
||||
|
||||
|
||||
// This should create a packet from the IL2P header.
|
||||
// The information part will not be filled in.
|
||||
|
||||
static void trim (char *stuff)
|
||||
{
|
||||
char *p = stuff + strlen(stuff) - 1;
|
||||
while (strlen(stuff) > 0 && (*p == ' ')) {
|
||||
*p = '\0';
|
||||
p--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
*
|
||||
* Function: il2p_decode_header_type_1
|
||||
*
|
||||
* Purpose: Attempt to convert type 1 header to a packet object.
|
||||
*
|
||||
* Inputs: hdr - IL2P header with no scrambling or parity symbols.
|
||||
*
|
||||
* num_sym_changed - Number of symbols changed by FEC in the header.
|
||||
* Should be 0 or 1.
|
||||
*
|
||||
* Returns: Packet Object or NULL for failure.
|
||||
*
|
||||
* Description: A later step will process the payload for the information part.
|
||||
*
|
||||
*--------------------------------------------------------------------------------*/
|
||||
|
||||
packet_t il2p_decode_header_type_1 (unsigned char *hdr, int num_sym_changed)
|
||||
{
|
||||
|
||||
if (GET_HDR_TYPE(hdr) != 1 ) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("IL2P Internal error. Should not be here: %s, when header type is 0.\n", __func__);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
// First get the addresses including SSID.
|
||||
|
||||
char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LEN];
|
||||
int num_addr = 2;
|
||||
memset (addrs, 0, 2*AX25_MAX_ADDR_LEN);
|
||||
|
||||
// The IL2P header uses 2 parity symbols which means a single corrupted symbol (byte)
|
||||
// can always be corrected.
|
||||
// However, I have seen cases, where the error rate is very high, where the RS decoder
|
||||
// thinks it found a valid code block by changing one symbol but it was the wrong one.
|
||||
// The result is trash. This shows up as address fields like 'R&G4"A' and 'TEW\ !'.
|
||||
// I added a sanity check here to catch characters other than uppper case letters and digits.
|
||||
// The frame should be rejected in this case. The question is whether to discard it
|
||||
// silently or print a message so the user can see that something strange is happening?
|
||||
// My current thinking is that it should be silently ignored if the header has been
|
||||
// modified (correctee or more likely, made worse in this cases).
|
||||
// If no changes were made, something weird is happening. We should mention it for
|
||||
// troubleshooting rather than sweeping it under the rug.
|
||||
|
||||
// The same thing has been observed with the payload, under very high error conditions,
|
||||
// and max_fec==0. Here I don't see a good solution. AX.25 information can contain
|
||||
// "binary" data so I'm not sure what sort of sanity check could be added.
|
||||
// This was not observed with max_fec==1. If we make that the default, same as Nino TNC,
|
||||
// it would be extremely extremely unlikely unless someone explicitly selects weaker FEC.
|
||||
|
||||
// TODO: We could do something similar for header type 0.
|
||||
// The address fields should be all binary zero values.
|
||||
// Someone overly ambitious might check the addresses found in the first payload block.
|
||||
|
||||
for (int i = 0; i <= 5; i++) {
|
||||
addrs[AX25_DESTINATION][i] = sixbit_to_ascii(hdr[i] & 0x3f);
|
||||
}
|
||||
trim (addrs[AX25_DESTINATION]);
|
||||
for (int i = 0; i < strlen(addrs[AX25_DESTINATION]); i++) {
|
||||
if (! isupper(addrs[AX25_DESTINATION][i]) && ! isdigit(addrs[AX25_DESTINATION][i])) {
|
||||
if (num_sym_changed == 0) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("IL2P: Invalid character '%c' in destination address '%s'\n", addrs[AX25_DESTINATION][i], addrs[AX25_DESTINATION]);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
snprintf (addrs[AX25_DESTINATION]+strlen(addrs[AX25_DESTINATION]), 4, "-%d", (hdr[12] >> 4) &0xf);
|
||||
|
||||
for (int i = 0; i <= 5; i++) {
|
||||
addrs[AX25_SOURCE][i] = sixbit_to_ascii(hdr[i+6] & 0x3f);
|
||||
}
|
||||
trim (addrs[AX25_SOURCE]);
|
||||
for (int i = 0; i < strlen(addrs[AX25_SOURCE]); i++) {
|
||||
if (! isupper(addrs[AX25_SOURCE][i]) && ! isdigit(addrs[AX25_SOURCE][i])) {
|
||||
if (num_sym_changed == 0) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("IL2P: Invalid character '%c' in source address '%s'\n", addrs[AX25_SOURCE][i], addrs[AX25_SOURCE]);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
snprintf (addrs[AX25_SOURCE]+strlen(addrs[AX25_SOURCE]), 4, "-%d", hdr[12] &0xf);
|
||||
|
||||
// The PID field gives us the general type.
|
||||
// 0 = 'S' frame.
|
||||
// 1 = 'U' frame other than UI.
|
||||
// others are either 'UI' or 'I' depending on the UI field.
|
||||
|
||||
int pid = GET_PID(hdr);
|
||||
int ui = GET_UI(hdr);
|
||||
|
||||
if (pid == 0) {
|
||||
|
||||
// 'S' frame.
|
||||
// The control field contains: P/F N(R) C S S
|
||||
|
||||
int control = GET_CONTROL(hdr);
|
||||
cmdres_t cr = (control & 0x04) ? cr_cmd : cr_res;
|
||||
ax25_frame_type_t ftype;
|
||||
switch (control & 0x03) {
|
||||
case 0: ftype = frame_type_S_RR; break;
|
||||
case 1: ftype = frame_type_S_RNR; break;
|
||||
case 2: ftype = frame_type_S_REJ; break;
|
||||
default: ftype = frame_type_S_SREJ; break;
|
||||
}
|
||||
int modulo = 8;
|
||||
int nr = (control >> 3) & 0x07;
|
||||
int pf = (control >> 6) & 0x01;
|
||||
unsigned char *pinfo = NULL; // Any info for SREJ will be added later.
|
||||
int info_len = 0;
|
||||
return (ax25_s_frame (addrs, num_addr, cr, ftype, modulo, nr, pf, pinfo, info_len));
|
||||
}
|
||||
else if (pid == 1) {
|
||||
|
||||
// 'U' frame other than 'UI'.
|
||||
// The control field contains: P/F OPCODE{3) C x x
|
||||
|
||||
int control = GET_CONTROL(hdr);
|
||||
cmdres_t cr = (control & 0x04) ? cr_cmd : cr_res;
|
||||
int axpid = 0; // unused for U other than UI.
|
||||
ax25_frame_type_t ftype;
|
||||
switch ((control >> 3) & 0x7) {
|
||||
case 0: ftype = frame_type_U_SABM; break;
|
||||
case 1: ftype = frame_type_U_DISC; break;
|
||||
case 2: ftype = frame_type_U_DM; break;
|
||||
case 3: ftype = frame_type_U_UA; break;
|
||||
case 4: ftype = frame_type_U_FRMR; break;
|
||||
case 5: ftype = frame_type_U_UI; axpid = 0xf0; break; // Should not happen with IL2P pid == 1.
|
||||
case 6: ftype = frame_type_U_XID; break;
|
||||
default: ftype = frame_type_U_TEST; break;
|
||||
}
|
||||
int pf = (control >> 6) & 0x01;
|
||||
unsigned char *pinfo = NULL; // Any info for UI, XID, TEST will be added later.
|
||||
int info_len = 0;
|
||||
return (ax25_u_frame (addrs, num_addr, cr, ftype, pf, axpid, pinfo, info_len));
|
||||
}
|
||||
else if (ui) {
|
||||
|
||||
// 'UI' frame.
|
||||
// The control field contains: P/F OPCODE{3) C x x
|
||||
|
||||
int control = GET_CONTROL(hdr);
|
||||
cmdres_t cr = (control & 0x04) ? cr_cmd : cr_res;
|
||||
ax25_frame_type_t ftype = frame_type_U_UI;
|
||||
int pf = (control >> 6) & 0x01;
|
||||
int axpid = decode_pid(GET_PID(hdr));
|
||||
unsigned char *pinfo = NULL; // Any info for UI, XID, TEST will be added later.
|
||||
int info_len = 0;
|
||||
return (ax25_u_frame (addrs, num_addr, cr, ftype, pf, axpid, pinfo, info_len));
|
||||
}
|
||||
else {
|
||||
|
||||
// 'I' frame.
|
||||
// The control field contains: P/F N(R) N(S)
|
||||
|
||||
int control = GET_CONTROL(hdr);
|
||||
cmdres_t cr = cr_cmd; // Always command.
|
||||
int pf = (control >> 6) & 0x01;
|
||||
int nr = (control >> 3) & 0x7;
|
||||
int ns = control & 0x7;
|
||||
int modulo = 8;
|
||||
int axpid = decode_pid(GET_PID(hdr));
|
||||
unsigned char *pinfo = NULL; // Any info for UI, XID, TEST will be added later.
|
||||
int info_len = 0;
|
||||
return (ax25_i_frame (addrs, num_addr, cr, modulo, nr, ns, pf, axpid, pinfo, info_len));
|
||||
}
|
||||
return (NULL); // unreachable but avoid warning.
|
||||
|
||||
} // end
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
*
|
||||
* Function: il2p_type_0_header
|
||||
*
|
||||
* Purpose: Attempt to create type 0 header from packet object.
|
||||
*
|
||||
* Inputs: pp - Packet object.
|
||||
*
|
||||
* max_fec - 1 to use maximum FEC symbols, 0 for automatic.
|
||||
*
|
||||
* Outputs: hdr - IL2P header with no scrambling or parity symbols.
|
||||
* Must be large enough to hold IL2P_HEADER_SIZE unsigned bytes.
|
||||
*
|
||||
* Returns: Number of bytes for information part or -1 for failure.
|
||||
* In case of failure, fall back to type 0 transparent encapsulation.
|
||||
*
|
||||
* Description: The type 0 header is used when it is not one of the restricted cases
|
||||
* covered by the type 1 header.
|
||||
* The AX.25 frame is put in the payload.
|
||||
* This will cover: more than one address, mod 128 sequences, etc.
|
||||
*
|
||||
*--------------------------------------------------------------------------------*/
|
||||
|
||||
int il2p_type_0_header (packet_t pp, int max_fec, unsigned char *hdr)
|
||||
{
|
||||
memset (hdr, 0, IL2P_HEADER_SIZE);
|
||||
|
||||
// Bit 7 has [FEC Level:1], [HDR Type:1], [Payload byte Count:10]
|
||||
|
||||
SET_FEC_LEVEL(hdr, max_fec);
|
||||
SET_HDR_TYPE(hdr, 0);
|
||||
|
||||
int frame_len = ax25_get_frame_len (pp);
|
||||
|
||||
if (frame_len < 14 || frame_len > IL2P_MAX_PAYLOAD_SIZE) {
|
||||
return (-2);
|
||||
}
|
||||
|
||||
SET_PAYLOAD_BYTE_COUNT(hdr, frame_len);
|
||||
return (frame_len);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************
|
||||
*
|
||||
* Name: il2p_get_header_attributes
|
||||
*
|
||||
* Purpose: Extract a few attributes from an IL2p header.
|
||||
*
|
||||
* Inputs: hdr - IL2P header structure.
|
||||
*
|
||||
* Outputs: hdr_type - 0 or 1.
|
||||
*
|
||||
* max_fec - 0 for automatic or 1 for fixed maximum size.
|
||||
*
|
||||
* Returns: Payload byte count. (actual payload size, not the larger encoded format)
|
||||
*
|
||||
***********************************************************************************/
|
||||
|
||||
|
||||
int il2p_get_header_attributes (unsigned char *hdr, int *hdr_type, int *max_fec)
|
||||
{
|
||||
*hdr_type = GET_HDR_TYPE(hdr);
|
||||
*max_fec = GET_FEC_LEVEL(hdr);
|
||||
return(GET_PAYLOAD_BYTE_COUNT(hdr));
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************
|
||||
*
|
||||
* Name: il2p_clarify_header
|
||||
*
|
||||
* Purpose: Convert received header to usable form.
|
||||
* This involves RS FEC then descrambling.
|
||||
*
|
||||
* Inputs: rec_hdr - Header as received over the radio.
|
||||
*
|
||||
* Outputs: corrected_descrambled_hdr - After RS FEC and unscrambling.
|
||||
*
|
||||
* Returns: Number of symbols that were corrected:
|
||||
* 0 = No errors
|
||||
* 1 = Single symbol corrected.
|
||||
* <0 = Unable to obtain good header.
|
||||
*
|
||||
***********************************************************************************/
|
||||
|
||||
int il2p_clarify_header(unsigned char *rec_hdr, unsigned char *corrected_descrambled_hdr)
|
||||
{
|
||||
unsigned char corrected[IL2P_HEADER_SIZE+IL2P_HEADER_PARITY];
|
||||
|
||||
int e = il2p_decode_rs (rec_hdr, IL2P_HEADER_SIZE, IL2P_HEADER_PARITY, corrected);
|
||||
|
||||
il2p_descramble_block (corrected, corrected_descrambled_hdr, IL2P_HEADER_SIZE);
|
||||
|
||||
return (e);
|
||||
}
|
||||
|
||||
// end il2p_header.c
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue