mirror of https://github.com/wb2osz/direwolf.git
Merge remote-tracking branch 'origin/dev'
This commit is contained in:
commit
de293a1f25
|
@ -0,0 +1,162 @@
|
|||
name: 'build direwolf'
|
||||
|
||||
on:
|
||||
# permit to manually trigger the CI
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
cmake_flags:
|
||||
description: 'Custom CMAKE flags'
|
||||
required: false
|
||||
push:
|
||||
paths-ignore:
|
||||
- '.github/**'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '.github/**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: ${{ matrix.config.name }}
|
||||
runs-on: ${{ matrix.config.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config:
|
||||
- {
|
||||
name: 'Windows Latest MinGW 64bit',
|
||||
os: windows-latest,
|
||||
cc: 'x86_64-w64-mingw32-gcc',
|
||||
cxx: 'x86_64-w64-mingw32-g++',
|
||||
ar: 'x86_64-w64-mingw32-ar',
|
||||
windres: 'x86_64-w64-mingw32-windres',
|
||||
arch: 'x86_64',
|
||||
build_type: 'Release',
|
||||
cmake_extra_flags: '-G "MinGW Makefiles"'
|
||||
}
|
||||
- {
|
||||
name: 'Windows 2019 MinGW 32bit',
|
||||
os: windows-2019,
|
||||
cc: 'i686-w64-mingw32-gcc',
|
||||
cxx: 'i686-w64-mingw32-g++',
|
||||
ar: 'i686-w64-mingw32-ar',
|
||||
windres: 'i686-w64-mingw32-windres',
|
||||
arch: 'i686',
|
||||
build_type: 'Release',
|
||||
cmake_extra_flags: '-G "MinGW Makefiles"'
|
||||
}
|
||||
- {
|
||||
name: 'macOS latest',
|
||||
os: macos-latest,
|
||||
cc: 'clang',
|
||||
cxx: 'clang++',
|
||||
arch: 'x86_64',
|
||||
build_type: 'Release',
|
||||
cmake_extra_flags: ''
|
||||
}
|
||||
- {
|
||||
name: 'Ubuntu latest Debug',
|
||||
os: ubuntu-latest,
|
||||
cc: 'gcc',
|
||||
cxx: 'g++',
|
||||
arch: 'x86_64',
|
||||
build_type: 'Debug',
|
||||
cmake_extra_flags: ''
|
||||
}
|
||||
- {
|
||||
name: 'Ubuntu 22.04',
|
||||
os: ubuntu-22.04,
|
||||
cc: 'gcc',
|
||||
cxx: 'g++',
|
||||
arch: 'x86_64',
|
||||
build_type: 'Release',
|
||||
cmake_extra_flags: ''
|
||||
}
|
||||
- {
|
||||
name: 'Ubuntu 20.04',
|
||||
os: ubuntu-20.04,
|
||||
cc: 'gcc',
|
||||
cxx: 'g++',
|
||||
arch: 'x86_64',
|
||||
build_type: 'Release',
|
||||
cmake_extra_flags: ''
|
||||
}
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 8
|
||||
- name: dependency
|
||||
shell: bash
|
||||
run: |
|
||||
# this is not perfect but enought for now
|
||||
if [ "$RUNNER_OS" == "Linux" ]; then
|
||||
sudo apt-get update
|
||||
sudo apt-get install libasound2-dev libudev-dev libhamlib-dev gpsd
|
||||
elif [ "$RUNNER_OS" == "macOS" ]; then
|
||||
# just to simplify I use homebrew but
|
||||
# we can use macports (latest direwolf is already available as port)
|
||||
brew install portaudio hamlib gpsd
|
||||
elif [ "$RUNNER_OS" == "Windows" ]; then
|
||||
# add the folder to PATH
|
||||
echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH
|
||||
fi
|
||||
- name: create build environment
|
||||
run: |
|
||||
cmake -E make_directory ${{github.workspace}}/build
|
||||
- name: configure
|
||||
shell: bash
|
||||
working-directory: ${{github.workspace}}/build
|
||||
run: |
|
||||
if [ "$RUNNER_OS" == "Windows" ]; then
|
||||
export CC=${{ matrix.config.cc }}
|
||||
export CXX=${{ matrix.config.cxx }}
|
||||
export AR=${{ matrix.config.ar }}
|
||||
export WINDRES=${{ matrix.config.windres }}
|
||||
fi
|
||||
cmake $GITHUB_WORKSPACE \
|
||||
-DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \
|
||||
-DCMAKE_C_COMPILER=${{ matrix.config.cc }} \
|
||||
-DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} \
|
||||
-DCMAKE_CXX_FLAGS="-Werror" -DUNITTEST=1 \
|
||||
${{ matrix.config.cmake_extra_flags }} \
|
||||
${{ github.event.inputs.cmake_flags }}
|
||||
- name: build
|
||||
shell: bash
|
||||
working-directory: ${{github.workspace}}/build
|
||||
run: |
|
||||
if [ "$RUNNER_OS" == "Windows" ]; then
|
||||
export CC=${{ matrix.config.cc }}
|
||||
export CXX=${{ matrix.config.cxx }}
|
||||
export AR=${{ matrix.config.ar }}
|
||||
export WINDRES=${{ matrix.config.windres }}
|
||||
fi
|
||||
cmake --build . --config ${{ matrix.config.build_type }} \
|
||||
${{ github.event.inputs.cmake_flags }}
|
||||
- name: test
|
||||
continue-on-error: true
|
||||
shell: bash
|
||||
working-directory: ${{github.workspace}}/build
|
||||
run: |
|
||||
ctest -C ${{ matrix.config.build_type }} \
|
||||
--parallel 2 --output-on-failure \
|
||||
${{ github.event.inputs.cmake_flags }}
|
||||
- name: package
|
||||
shell: bash
|
||||
working-directory: ${{github.workspace}}/build
|
||||
run: |
|
||||
if [ "$RUNNER_OS" == "Windows" ] || [ "$RUNNER_OS" == "macOS" ]; then
|
||||
make package
|
||||
fi
|
||||
- name: archive binary
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: direwolf_${{ matrix.config.os }}_${{ matrix.config.arch }}_${{ github.sha }}
|
||||
path: |
|
||||
${{github.workspace}}/build/direwolf-*.zip
|
||||
${{github.workspace}}/build/direwolf.conf
|
||||
${{github.workspace}}/build/src/*
|
||||
${{github.workspace}}/build/CMakeCache.txt
|
||||
!${{github.workspace}}/build/src/cmake_install.cmake
|
||||
!${{github.workspace}}/build/src/CMakeFiles
|
||||
!${{github.workspace}}/build/src/Makefile
|
63
CHANGES.md
63
CHANGES.md
|
@ -2,9 +2,70 @@
|
|||
# Revision History #
|
||||
|
||||
|
||||
## Version 1.6 -- October 2020 ##
|
||||
## Version 1.7 -- October 2023 ##
|
||||
|
||||
|
||||
### New Documentation: ###
|
||||
|
||||
Additional documentation location to slow down growth of main repository. [https://github.com/wb2osz/direwolf-doc](https://github.com/wb2osz/direwolf-doc) . These are more oriented toward achieving a goal and understanding, as opposed to the User Guide which describes the functionality.
|
||||
|
||||
- ***APRS Digipeaters***
|
||||
|
||||
- ***Internal Packet Routing***
|
||||
|
||||
- ***Radio Interface Guide***
|
||||
|
||||
- ***Successful IGate Operation***
|
||||
|
||||
- ***Understanding APRS Packets***
|
||||
|
||||
|
||||
### New Features: ###
|
||||
|
||||
|
||||
|
||||
- New ICHANNEL configuration option to map a KISS client application channel to APRS-IS. Packets from APRS-IS will be presented to client applications as the specified channel. Packets sent, by client applications, to that channel will go to APRS-IS rather than a radio channel. Details in ***Internal-Packet-Routing.pdf***.
|
||||
|
||||
- New variable speed option for gen_packets. For example, "-v 5,0.1" would generate packets from 5% too slow to 5% too fast with increments of 0.1. Some implementations might have imprecise timing. Use this to test how well TNCs tolerate sloppy timing.
|
||||
|
||||
- Improved Layer 2 Protocol [(IL2P)](https://en.wikipedia.org/wiki/FX.25_Forward_Error_Correction). Compatible with Nino TNC for 1200 and 9600 bps. Use "-I 1" on command line to enable transmit for first channel. For more general case, add to config file (simplified version, see User Guide for more details):
|
||||
|
||||
> After: "CHANNEL 1" (or other channel)
|
||||
>
|
||||
> Add: "IL2PTX 1"
|
||||
|
||||
- Limited support for CM108/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. You can specify a specific number of parity bytes (16, 32, 64) or 1 to choose automatically based on packet size.
|
||||
|
||||
> After: "CHANNEL 1" (or other channel)
|
||||
>
|
||||
> Add: "FX25TX 1" (or 16 or 32 or 64)
|
||||
|
||||
|
||||
|
||||
### Bugs Fixed: ###
|
||||
|
||||
- The t/m packet filter incorrectly included bulletins. It now allows only "messages" to specific stations. Use of t/m is discouraged. i/180 is the preferred filter for messages to users recently heard locally.
|
||||
|
||||
- Packet filtering now skips over any third party header before classifying packet types.
|
||||
|
||||
- Fixed build for Alpine Linux.
|
||||
|
||||
### Notes: ###
|
||||
|
||||
The Windows binary distribution now uses gcc (MinGW) version 11.3.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.
|
||||
|
||||
## Version 1.6 -- October 2020 ##
|
||||
|
||||
### New Build Procedure: ###
|
||||
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
@ -131,7 +133,7 @@ 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)
|
||||
|
||||
|
@ -143,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")
|
||||
|
@ -156,17 +162,22 @@ elseif(APPLE)
|
|||
set(CMAKE_MACOSX_RPATH ON)
|
||||
message(STATUS "RPATH support: ${CMAKE_MACOSX_RPATH}")
|
||||
|
||||
elseif (WIN32)
|
||||
if(NOT VS2015 AND NOT VS2017)
|
||||
message(FATAL_ERROR "You must use Microsoft Visual Studio 2015 or 2017 as compiler")
|
||||
endif()
|
||||
# just blindly enable dns-sd
|
||||
set(USE_MACOS_DNSSD ON)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_MACOS_DNSSD")
|
||||
|
||||
elseif (WIN32)
|
||||
if(C_MSVC)
|
||||
if (NOT VS2015 AND NOT VS2017 AND NOT VS2019)
|
||||
message(FATAL_ERROR "You must use Microsoft Visual Studio 2015, 2017 or 2019 as compiler")
|
||||
else()
|
||||
# compile with full multicore
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
||||
|
||||
set(CUSTOM_SHELL_BIN "")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (C_CLANG OR C_GCC)
|
||||
# _BSD_SOURCE is deprecated we need to use _DEFAULT_SOURCE.
|
||||
|
@ -195,10 +206,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()
|
||||
#
|
||||
|
@ -246,6 +263,44 @@ 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. (Windows, most, but not all Linux)
|
||||
# Here we detect whether these are provided by the OS and set a symbol
|
||||
# so that:
|
||||
# (1) libgps does not supply its own version.
|
||||
# (2) we know whether we need to supply our own copy.
|
||||
#
|
||||
# This was all working fine until these were added to the gnu c library 2.38.
|
||||
# References:
|
||||
# - https://www.gnu.org/software/libc/sources.html
|
||||
# - https://sourceware.org/git/?p=glibc.git;a=blob_plain;f=NEWS;hb=HEAD
|
||||
#
|
||||
# This test is not detecting them for glibc 2.38 resulting in a conflict.
|
||||
# Why? Are they declared in a different file or in some strange way?
|
||||
#
|
||||
# This is how they are declared in include/string.h:
|
||||
#
|
||||
# extern __typeof (strlcpy) __strlcpy;
|
||||
# libc_hidden_proto (__strlcpy)
|
||||
# extern __typeof (strlcat) __strlcat;
|
||||
# libc_hidden_proto (__strlcat)
|
||||
#
|
||||
# Apparently cmake does not recognize this style.
|
||||
# Keep this here for BSD type systems where it behaves as expected.
|
||||
# We will need to add a hack in direwolf.h to define these if glibc version >= 2.38.
|
||||
|
||||
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)
|
||||
|
||||
|
@ -276,6 +331,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)
|
||||
|
@ -287,8 +353,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
|
||||
|
@ -297,6 +367,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
|
||||
|
|
39
README.md
39
README.md
|
@ -1,4 +1,4 @@
|
|||
|
||||
|
||||
# Dire Wolf #
|
||||
|
||||
### Decoded Information from Radio Emissions for Windows Or Linux Fans ###
|
||||
|
@ -9,11 +9,15 @@ Why waste $200 and settle for mediocre receive performance from a 1980's technol
|
|||
|
||||
![](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 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. This was originally developed for satellites and is now seeing widespread use on HF.
|
||||
|
||||
![](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 but it is not compatible with AX.25.
|
||||
|
||||
|
||||
|
||||
### 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:
|
||||
|
||||
|
@ -76,7 +80,21 @@ It can also be used as a virtual TNC for other applications such as [APRSIS32](h
|
|||
|
||||
|
||||
|
||||
- **Standard 300, 1200 & 9600 bps modems and more.**
|
||||
- **Modems:**
|
||||
|
||||
300 bps AFSK for HF
|
||||
|
||||
1200 bps AFSK most common for VHF/UHF
|
||||
|
||||
2400 & 4800 bps PSK
|
||||
|
||||
9600 bps GMSK/G3RUH
|
||||
|
||||
AIS reception
|
||||
|
||||
EAS SAME reception
|
||||
|
||||
|
||||
|
||||
- **DTMF ("Touch Tone") Decoding and Encoding.**
|
||||
|
||||
|
@ -96,12 +114,16 @@ It can also be used as a virtual TNC for other applications such as [APRSIS32](h
|
|||
|
||||
## Documentation ##
|
||||
|
||||
|
||||
[Stable Version](https://github.com/wb2osz/direwolf/tree/master/doc)
|
||||
|
||||
[Latest Development Version](https://github.com/wb2osz/direwolf/tree/dev/doc)
|
||||
[Latest Development Version ("dev" branch)](https://github.com/wb2osz/direwolf/tree/dev/doc)
|
||||
|
||||
[Power Point presentation](https://github.com/wb2osz/direwolf-presentation) -- Why not give a talk at a local club meeting?
|
||||
[Additional Topics](https://github.com/wb2osz/direwolf-doc)
|
||||
|
||||
[Power Point presentations](https://github.com/wb2osz/direwolf-presentation) -- Why not give a talk at a local club meeting?
|
||||
|
||||
Youtube has many interesting and helpful videos. Searching for [direwolf tnc](https://www.youtube.com/results?search_query=direwolf+tnc) or [direwolf aprs](https://www.youtube.com/results?search_query=direwolf+aprs) will produce the most relevant results.
|
||||
|
||||
## Installation ##
|
||||
|
||||
|
@ -131,6 +153,7 @@ On Debian / Ubuntu / Raspbian / Raspberry Pi OS:
|
|||
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:
|
||||
|
||||
|
@ -140,6 +163,7 @@ Or on Red Hat / Fedora / CentOS:
|
|||
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 don't already have the older version and want to type cmake rather than cmake3.
|
||||
|
@ -190,6 +214,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")
|
||||
|
|
|
@ -5,7 +5,9 @@ elseif(NOT DEFINED C_GCC AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|||
set(C_GCC 1)
|
||||
elseif(NOT DEFINED C_MSVC AND CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
set(C_MSVC 1)
|
||||
if(MSVC_VERSION GREATER 1910 AND MSVC_VERSION LESS 1919)
|
||||
if(MSVC_VERSION GREATER_EQUAL 1920 AND MSVC_VERSION LESS_EQUAL 1929)
|
||||
set(VS2019 ON)
|
||||
elseif(MSVC_VERSION GREATER_EQUAL 1910 AND MSVC_VERSION LESS_EQUAL 1919)
|
||||
set(VS2017 ON)
|
||||
elseif(MSVC_VERSION GREATER 1899 AND MSVC_VERSION LESS 1910)
|
||||
set(VS2015 ON)
|
||||
|
|
|
@ -52,7 +52,7 @@ find_library(HAMLIB_LIBRARY
|
|||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(HAMLIB
|
||||
find_package_handle_standard_args(hamlib
|
||||
DEFAULT_MSG
|
||||
HAMLIB_LIBRARY
|
||||
HAMLIB_INCLUDE_DIR
|
||||
|
|
|
@ -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)
|
|
@ -65,7 +65,7 @@ find_path(UDEV_INCLUDE_DIR
|
|||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(UDEV
|
||||
find_package_handle_standard_args(udev
|
||||
DEFAULT_MSG
|
||||
UDEV_LIBRARY
|
||||
UDEV_INCLUDE_DIR
|
||||
|
|
|
@ -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.
|
||||
|
@ -28,3 +28,9 @@ SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0d8c", GROUP="audio", MODE="0660"
|
|||
#
|
||||
# Read the User Guide and run the "cm108" application for more information.
|
||||
#
|
||||
|
||||
#
|
||||
# Same thing for the "All In One Cable."
|
||||
#
|
||||
|
||||
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="7388", GROUP="audio", MODE="0660"
|
||||
|
|
|
@ -29,16 +29,21 @@
|
|||
%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%# Additional topics - https://github.com/wb2osz/direwolf-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
|
||||
%W%# The basic documentation set can also be found in the doc folder.
|
||||
%L%# The basic 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%# Questions??? Join the discussion forum: https://groups.io/g/direwolf
|
||||
%C%#
|
||||
%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%# Consult the User Guide for more details on configuration options
|
||||
%C%# and other documents for more details for different uses.
|
||||
%C%#
|
||||
%C%# These are the most likely settings you might change:
|
||||
%C%#
|
||||
|
@ -93,6 +98,11 @@
|
|||
%C%# Many people will simply use the default sound device.
|
||||
%C%# Some might want to use an alternative device by choosing it here.
|
||||
%C%#
|
||||
%C%#
|
||||
%C%# Many examples of radio interfaces and PTT options can be found in:
|
||||
%C%# https://github.com/wb2osz/direwolf-doc/blob/main/Radio-Interface-Guide.pdf
|
||||
%C%#
|
||||
%C%#
|
||||
%R% ---------- Windows ----------
|
||||
%R%
|
||||
%W%# When the Windows version starts up, it displays something like
|
||||
|
@ -238,7 +248,7 @@
|
|||
%C%
|
||||
%C%#
|
||||
%C%# Pick a suitable modem speed based on your situation.
|
||||
%C%# 1200 Most common for VHF/UHF. Default if not specified.
|
||||
%C%# 1200 Most common for VHF/UHF. This is the default if not specified.
|
||||
%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).
|
||||
|
@ -263,10 +273,26 @@
|
|||
%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%# Push to Talk (PTT) can be confusing because there are so many different cases.
|
||||
%C%# Radio-Interface-Guide.pdf in https://github.com/wb2osz/direwolf-doc
|
||||
%C%# goes into detail about the various options.
|
||||
%C%
|
||||
%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.
|
||||
|
@ -278,6 +304,7 @@
|
|||
%C%#PTT COM1 RTS
|
||||
%C%#PTT COM1 RTS -DTR
|
||||
%L%#PTT /dev/ttyUSB0 RTS
|
||||
%L%#PTT /dev/ttyUSB0 RTS -DTR
|
||||
%C%
|
||||
%L%#
|
||||
%L%# On Linux, you can also use general purpose I/O pins if
|
||||
|
@ -289,7 +316,7 @@
|
|||
%L%
|
||||
%L%#PTT GPIO 25
|
||||
%L%
|
||||
%C%# The Data Carrier Detect (DCD) signal can be sent to the same places
|
||||
%C%# The Data Carrier Detect (DCD) signal can be sent to most of 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
|
||||
|
@ -357,11 +384,11 @@
|
|||
%W%
|
||||
%C%#
|
||||
%C%# It is sometimes possible to recover frames with a bad FCS.
|
||||
%C%# This applies to all channels.
|
||||
%C%# This is not a global setting.
|
||||
%C%# It applies only the the most recent CHANNEL specified.
|
||||
%C%#
|
||||
%C%# 0 [NONE] - Don't try to repair.
|
||||
%C%# 1 [SINGLE] - Attempt to fix single bit error. (default)
|
||||
%C%# ... see User Guide for more values and in-depth discussion.
|
||||
%C%# 0 - Don't try to repair. (default)
|
||||
%C%# 1 - Attempt to fix single bit error.
|
||||
%C%#
|
||||
%C%
|
||||
%C%#FIX_BITS 0
|
||||
|
@ -386,15 +413,21 @@
|
|||
%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%# Every half hour, it can travel via one digipeater hop.
|
||||
%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=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
|
||||
%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%#
|
||||
%C%# Did you know that APRS comments and messages can contain UTF-8 characters, not only plain ASCII?
|
||||
%C%#
|
||||
%C%#PBEACON delay=1 every=30 overlay=S symbol="digi" lat=42^37.14N long=071^20.83W comment=" Did you know that APRS comments and messages can contain UTF-8 characters? \xe0\xb8\xa7\xe0\xb8\xb4\xe0\xb8\x97\xe0\xb8\xa2\xe0\xb8\xb8\xe0\xb8\xaa\xe0\xb8\xa1\xe0\xb8\xb1\xe0\xb8\x84\xe0\xb8\xa3\xe0\xb9\x80\xe0\xb8\xa5\xe0\xb9\x88\xe0\xb8\x99"
|
||||
%C%#PBEACON delay=11 every=30 overlay=S symbol="digi" lat=42^37.14N long=071^20.83W comment=" Did you know that APRS comments and messages can contain UTF-8 characters? \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"
|
||||
%C%#PBEACON delay=21 every=30 overlay=S symbol="digi" lat=42^37.14N long=071^20.83W comment=" Did you know that APRS comments and messages can contain UTF-8 characters? \xe3\x82\xa2\xe3\x83\x9e\xe3\x83\x81\xe3\x83\xa5\xe3\x82\xa2\xe7\x84\xa1\xe7\xb7\x9a"
|
||||
%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
|
||||
|
@ -430,17 +463,11 @@
|
|||
%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%#DIGIPEAT 0 0 ^WIDE[3-7]-[1-7]$|^TEST$ ^WIDE[12]-[12]$
|
||||
%C%
|
||||
%C%# See User Guide for more explanation of what this means and how
|
||||
%C%# it can be customized for your particular needs.
|
||||
%C%# See User Guide and "APRS-Digipeaters.pdf" for more explanation of what
|
||||
%C%# this means and how 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%# Traditional connected mode packet radio uses a different
|
||||
%C%# type of digipeating. See User Guide for details.
|
||||
|
@ -474,6 +501,7 @@
|
|||
%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%# There is no need to send it as often as you would over the radio.
|
||||
%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
|
||||
|
@ -482,13 +510,14 @@
|
|||
%C%# To relay messages from the Internet to radio, you need to add
|
||||
%C%# one more option with the transmit channel number and a VIA path.
|
||||
%C%
|
||||
%C%#IGTXVIA 0 WIDE1-1
|
||||
%C%#IGTXVIA 0 WIDE1-1,WIDE2-1
|
||||
%C%
|
||||
%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%# This might be low for APRS Thursday when there is abnormally high activity.
|
||||
%C%
|
||||
%C%IGTXLIMIT 6 10
|
||||
%C%
|
||||
|
@ -505,82 +534,4 @@
|
|||
%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%
|
||||
%C%TTPOINT B01 37^55.37N 81^7.86W
|
||||
%C%TTPOINT B7495088 42.605237 -71.34456
|
||||
%C%TTPOINT B934 42.605237 -71.34456
|
||||
%C%
|
||||
%C%TTPOINT B901 42.661279 -71.364452
|
||||
%C%TTPOINT B902 42.660411 -71.364419
|
||||
%C%TTPOINT B903 42.659046 -71.364452
|
||||
%C%TTPOINT B904 42.657578 -71.364602
|
||||
%C%
|
||||
%C%
|
||||
%C%# For location at given bearing and distance from starting point.
|
||||
%C%
|
||||
%C%TTVECTOR B5bbbddd 37^55.37N 81^7.86W 0.01 mi
|
||||
%C%
|
||||
%C%# For location specified by x, y coordinates.
|
||||
%C%
|
||||
%C%TTGRID Byyyxxx 37^50.00N 81^00.00W 37^59.99N 81^09.99W
|
||||
%C%
|
||||
%C%# UTM location for Lowell-Dracut-Tyngsborough State Forest.
|
||||
%C%
|
||||
%C%TTUTM B6xxxyyy 19T 10 300000 4720000
|
||||
%C%
|
||||
%C%
|
||||
%C%
|
||||
%C%# Location for the corral.
|
||||
%C%
|
||||
%C%TTCORRAL 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%
|
||||
%C%TTMACRO xx1yy B9xx*AB166*AA2B4C5B3B0A1yy
|
||||
%C%TTMACRO xx2yy B9xx*AB170*AA3C4C7C3B0A2yy
|
||||
%C%TTMACRO xxyyy B9xx*AB180*AA3A6C4A0Ayyy
|
||||
%C%
|
||||
%C%TTMACRO z Cz
|
||||
%C%
|
||||
%C%# Receive on channel 0, Transmit object reports on channel 1 with optional via path.
|
||||
%C%# You probably want to put in a transmit delay on the APRStt channel so it
|
||||
%C%# it doesn't start sending a response before the user releases PTT.
|
||||
%C%# This is in 10 ms units so 100 means 1000 ms = 1 second.
|
||||
%C%
|
||||
%C%#TTOBJ 0 1 WIDE1-1
|
||||
%C%#CHANNEL 0
|
||||
%C%#DWAIT 100
|
||||
%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%
|
||||
%C%# Sample speech responses.
|
||||
%C%# Default is Morse code "R" for received OK and "?" for all errors.
|
||||
%C%
|
||||
%C%#TTERR OK SPEECH Message Received.
|
||||
%C%#TTERR D_MSG SPEECH D not implemented.
|
||||
%C%#TTERR INTERNAL SPEECH Internal error.
|
||||
%C%#TTERR MACRO_NOMATCH SPEECH No definition for digit sequence.
|
||||
%C%#TTERR BAD_CHECKSUM SPEECH Bad checksum on call.
|
||||
%C%#TTERR INVALID_CALL SPEECH Invalid callsign.
|
||||
%C%#TTERR INVALID_OBJNAME SPEECH Invalid object name.
|
||||
%C%#TTERR INVALID_SYMBOL SPEECH Invalid symbol.
|
||||
%C%#TTERR INVALID_LOC SPEECH Invalid location.
|
||||
%C%#TTERR NO_CALL SPEECH No call or object name.
|
||||
%C%#TTERR SATSQ SPEECH Satellite square must be 4 digits.
|
||||
%C%#TTERR SUFFIX_NO_CALL SPEECH Send full call before using suffix.
|
||||
%C%
|
||||
|
||||
|
|
|
@ -1,4 +1,19 @@
|
|||
#
|
||||
# Update: 1 May 2023 (still 1.7 dev version)
|
||||
#
|
||||
# The original intention was to allow an easy way to download the most
|
||||
# recent versions of some files.
|
||||
#
|
||||
# "update-data" would only work once.
|
||||
#
|
||||
# These locations are no longer being maintained:
|
||||
# http://www.aprs.org/aprs11/tocalls.txt -- 14 Dec 2021
|
||||
# http://www.aprs.org/symbols/symbols-new.txt -- 17 Mar 2021
|
||||
# http://www.aprs.org/symbols/symbolsX.txt -- 25 Nov 2015
|
||||
# so there is no reason to provide a capability grab the latest version.
|
||||
#
|
||||
# Rather than fixing an obsolete capability, it will just be removed.
|
||||
#
|
||||
# The destination field is often used to identify the manufacturer/model.
|
||||
# These are not hardcoded into Dire Wolf. Instead they are read from
|
||||
# a file called tocalls.txt at application start up time.
|
||||
|
@ -6,24 +21,13 @@
|
|||
# The original permanent symbols are built in but the "new" symbols,
|
||||
# using overlays, are often updated. These are also read from files.
|
||||
#
|
||||
# You can obtain an updated copy by typing "make data-update".
|
||||
# This is not part of the normal build process. You have to do this explicitly.
|
||||
#
|
||||
# The locations below appear to be the most recent.
|
||||
# The copy at http://www.aprs.org/tocalls.txt is out of date.
|
||||
#
|
||||
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
set(TOCALLS_TXT "tocalls.txt")
|
||||
set(TOCALLS_TXT_BKP "tocalls.txt.old")
|
||||
set(TOCALLS_URL "http://www.aprs.org/aprs11/tocalls.txt")
|
||||
set(SYMBOLS-NEW_TXT "symbols-new.txt")
|
||||
set(SYMBOLS-NEW_TXT_BKP "symbols-new.txt.old")
|
||||
set(SYMBOLS-NEW_URL "http://www.aprs.org/symbols/symbols-new.txt")
|
||||
set(SYMBOLSX_TXT "symbolsX.txt")
|
||||
set(SYMBOLSX_TXT_BKP "symbolsX.txt.old")
|
||||
set(SYMBOLSX_URL "http://www.aprs.org/symbols/symbolsX.txt")
|
||||
set(CUSTOM_BINARY_DATA_DIR "${CMAKE_BINARY_DIR}/data")
|
||||
|
||||
# we can also move to a separate cmake file and use file(download)
|
||||
|
@ -32,63 +36,6 @@ file(COPY "${CUSTOM_DATA_DIR}/${TOCALLS_TXT}" DESTINATION "${CUSTOM_BINARY_DATA_
|
|||
file(COPY "${CUSTOM_DATA_DIR}/${SYMBOLS-NEW_TXT}" DESTINATION "${CUSTOM_BINARY_DATA_DIR}")
|
||||
file(COPY "${CUSTOM_DATA_DIR}/${SYMBOLSX_TXT}" DESTINATION "${CUSTOM_BINARY_DATA_DIR}")
|
||||
|
||||
add_custom_target(data_rename
|
||||
COMMAND ${CMAKE_COMMAND} -E rename "${CUSTOM_BINARY_DATA_DIR}/${TOCALLS_TXT}" "${CUSTOM_BINARY_DATA_DIR}/${TOCALLS_TXT_BKP}"
|
||||
COMMAND ${CMAKE_COMMAND} -E rename "${CUSTOM_BINARY_DATA_DIR}/${SYMBOLS-NEW_TXT}" "${CUSTOM_BINARY_DATA_DIR}/${SYMBOLS-NEW_TXT_BKP}"
|
||||
COMMAND ${CMAKE_COMMAND} -E rename "${CUSTOM_BINARY_DATA_DIR}/${SYMBOLSX_TXT}" "${CUSTOM_BINARY_DATA_DIR}/${SYMBOLSX_TXT_BKP}"
|
||||
)
|
||||
|
||||
ExternalProject_Add(download_tocalls
|
||||
DEPENDS data_rename
|
||||
URL ${TOCALLS_URL}
|
||||
PREFIX ""
|
||||
DOWNLOAD_DIR "${CUSTOM_BINARY_DATA_DIR}"
|
||||
DOWNLOAD_NAME "${TOCALLS_TXT}"
|
||||
DOWNLOAD_NO_EXTRACT 0
|
||||
EXCLUDE_FROM_ALL 1
|
||||
UPDATE_COMMAND ""
|
||||
PATCH_COMMAND ""
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
|
||||
ExternalProject_Add(download_symbols-new
|
||||
DEPENDS data_rename
|
||||
URL ${SYMBOLS-NEW_URL}
|
||||
PREFIX ""
|
||||
DOWNLOAD_DIR "${CUSTOM_BINARY_DATA_DIR}"
|
||||
DOWNLOAD_NAME "${SYMBOLS-NEW_TXT}"
|
||||
DOWNLOAD_NO_EXTRACT 0
|
||||
EXCLUDE_FROM_ALL 1
|
||||
UPDATE_COMMAND ""
|
||||
PATCH_COMMAND ""
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
|
||||
ExternalProject_Add(download_symbolsx
|
||||
DEPENDS data_rename
|
||||
URL ${SYMBOLSX_URL}
|
||||
PREFIX ""
|
||||
DOWNLOAD_DIR "${CUSTOM_BINARY_DATA_DIR}"
|
||||
DOWNLOAD_NAME "${SYMBOLSX_TXT}"
|
||||
DOWNLOAD_NO_EXTRACT 0
|
||||
EXCLUDE_FROM_ALL 1
|
||||
UPDATE_COMMAND ""
|
||||
PATCH_COMMAND ""
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
|
||||
add_custom_target(update-data)
|
||||
add_dependencies(update-data data_rename download_tocalls download_symbols-new download_symbolsx)
|
||||
|
||||
install(FILES "${CUSTOM_BINARY_DATA_DIR}/${TOCALLS_TXT}" DESTINATION ${INSTALL_DATA_DIR})
|
||||
install(FILES "${CUSTOM_BINARY_DATA_DIR}/${SYMBOLS-NEW_TXT}" DESTINATION ${INSTALL_DATA_DIR})
|
||||
install(FILES "${CUSTOM_BINARY_DATA_DIR}/${SYMBOLSX_TXT}" DESTINATION ${INSTALL_DATA_DIR})
|
||||
|
|
|
@ -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: #=
|
||||
|
|
|
@ -1,38 +1,31 @@
|
|||
<title>
|
||||
APRS TO-CALL VERSION NUMBERS 13 Oct 2020
|
||||
-------------------------------------------------------------------
|
||||
APRS TO-CALL VERSION NUMBERS 14 Dec 2021
|
||||
---------------------------------------------------------------------
|
||||
WB4APR
|
||||
</title>
|
||||
<version_notes>
|
||||
07 Jun 23 Added APK005 for Kenwood TH-D75
|
||||
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
|
||||
|
||||
13 Oct 20 Added APIZCI hymTR IZCI Tracker by TA7W/OH2UDS and TA6AEU
|
||||
13 Aug 20 Added APLGxx for LoRa Gateway/Digipeater
|
||||
APLTxx for LoRa Tracker - OE5BPA
|
||||
02 Aug 20 Added APNVxx for SQ8L's VP digi and Nodes
|
||||
26 May 20 Added APY300 for Yaesu
|
||||
5 May 20 added APESPG ESP SmartBeacon APRS-IS Client
|
||||
APESPW ESP Weather Station APRS-IS Client
|
||||
17 Apr 20 Added APGDTx for VK4FAST's Graphic Data Terminal
|
||||
19 Mar 20 Added APOSW and APOSB for OpenSPOT2 and 3
|
||||
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
|
||||
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
|
||||
|
@ -52,6 +45,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>
|
||||
|
||||
|
@ -69,7 +66,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
|
||||
|
@ -89,7 +87,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
|
||||
|
@ -112,6 +112,7 @@ 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
|
||||
|
@ -128,9 +129,21 @@ a TOCALL number series:
|
|||
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
|
||||
|
@ -144,20 +157,26 @@ a TOCALL number series:
|
|||
APK APK0xx Kenwood TH-D7's
|
||||
APK003 Kenwood TH-D72
|
||||
APK004 Kenwood TH-D74
|
||||
APK005 Kenwood TH-D75
|
||||
APK1xx Kenwood D700's
|
||||
APK102 Kenwood D710
|
||||
APKRAM KRAMstuff.com - Mark. G7LEU
|
||||
APL APLGxx LoRa Gateway/Digipeater OE5BPA
|
||||
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
|
||||
|
@ -234,10 +253,12 @@ 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
|
||||
|
@ -249,14 +270,17 @@ a TOCALL number 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
|
||||
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
|
||||
APZMDM github/codec2_talkie - product code not registered
|
||||
APZMDR for HaMDR trackers - hessu * hes.iki.fi]
|
||||
APZPAD Smart Palm
|
||||
APZTKP TrackPoint, Nick N0LP (Balloon tracking)(depricated)
|
||||
|
@ -265,15 +289,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
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
@ -154,6 +154,14 @@ and a couple things that can be done about it.
|
|||
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.
|
||||
|
||||
|
||||
## Additional Documentation for Dire Wolf Software TNC #
|
||||
|
||||
|
||||
When there was little documentation, it was all added to the source code repository [https://github.com/wb2osz/direwolf/tree/master/doc](https://github.com/wb2osz/direwolf/tree/master/doc)
|
||||
|
||||
The growing number of documentation files and revisions are making the source code repository very large which means long download times. Additional documentation, not tied to a specific release, is now being added to [https://github.com/wb2osz/direwolf-doc](https://github.com/wb2osz/direwolf-doc)
|
||||
|
||||
## Questions? Experiences to share? ##
|
||||
|
||||
Here are some good places to ask questions and share your experiences:
|
||||
|
|
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,16 +6,48 @@ 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 doesn't like to get an empty source file list.
|
||||
# I tried several variations on this theme to test whether the list
|
||||
# was not empty and was not successful in getting it to work
|
||||
# on both Alpine and RPi.
|
||||
#if("${misc_SOURCES}")
|
||||
# This is less elegant and less maintainable but it works.
|
||||
|
||||
if ((NOT HAVE_STRLCPY) OR (NOT HAVE_STRLCAT))
|
||||
add_library(misc STATIC
|
||||
${misc_SOURCES}
|
||||
)
|
||||
else()
|
||||
set(MISC_LIBRARIES "" CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
elseif(WIN32 OR CYGWIN) # windows
|
||||
|
||||
|
|
|
@ -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,8 @@ 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;
|
||||
extern 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
|
||||
|
|
|
@ -37,6 +37,10 @@ Data rate in bits/sec. Standard values are 300, 1200, 2400, 4800, 9600.
|
|||
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
|
||||
|
|
|
@ -87,7 +87,15 @@ Divide audio sample by n for first channel.
|
|||
|
||||
.TP
|
||||
.BI "-X " "n"
|
||||
1 to enable FX.25 transmit.
|
||||
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"
|
||||
|
@ -122,6 +130,8 @@ m = Monitor heard station list.
|
|||
f = Packet filtering.
|
||||
.P
|
||||
x = FX.25 increase verbose level.
|
||||
.P
|
||||
d = APRStt (DTMF to APRS object conversion).
|
||||
.RE
|
||||
.RE
|
||||
.PD
|
||||
|
@ -135,6 +145,8 @@ 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
|
||||
|
@ -149,11 +161,26 @@ Text colors. 0=disabled. 1=default. 2,3,4,... alternatives. Use 9 to test com
|
|||
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
|
||||
|
|
|
@ -46,6 +46,8 @@ 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
|
||||
EAS for Emergency Alert System (EAS) Specific Area Message Encoding (SAME).
|
||||
.RE
|
||||
.RE
|
||||
.PD
|
||||
|
@ -62,6 +64,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"
|
||||
|
@ -88,9 +102,13 @@ Send output to .wav file.
|
|||
8 bit audio rather than 16.
|
||||
|
||||
.TP
|
||||
.B "-2"
|
||||
.BI "-2"
|
||||
2 channels of audio rather than 1.
|
||||
|
||||
.TP
|
||||
.BI "-v" "max[,incr]"
|
||||
Variable speed with specified maximum error and optional increment.
|
||||
|
||||
|
||||
.SH EXAMPLES
|
||||
.P
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
# global includes
|
||||
# not ideal but not so slow
|
||||
# otherwise use target_include_directories
|
||||
|
@ -7,7 +8,9 @@ include_directories(
|
|||
${ALSA_INCLUDE_DIRS}
|
||||
${UDEV_INCLUDE_DIRS}
|
||||
${PORTAUDIO_INCLUDE_DIRS}
|
||||
${SNDIO_INCLUDE_DIRS}
|
||||
${CUSTOM_GEOTRANZ_DIR}
|
||||
${CUSTOM_HIDAPI_DIR}
|
||||
)
|
||||
|
||||
if(WIN32 OR CYGWIN)
|
||||
|
@ -57,6 +60,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
|
||||
|
@ -96,9 +106,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
|
||||
|
@ -107,10 +124,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
|
||||
|
@ -121,19 +148,22 @@ target_link_libraries(direwolf
|
|||
${GEOTRANZ_LIBRARIES}
|
||||
${MISC_LIBRARIES}
|
||||
${REGEX_LIBRARIES}
|
||||
${HIDAPI_LIBRARIES}
|
||||
Threads::Threads
|
||||
${GPSD_LIBRARIES}
|
||||
${HAMLIB_LIBRARIES}
|
||||
${ALSA_LIBRARIES}
|
||||
${UDEV_LIBRARIES}
|
||||
${PORTAUDIO_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
|
||||
|
@ -266,12 +296,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
|
||||
|
@ -298,14 +336,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
|
||||
|
@ -398,9 +444,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
|
||||
|
@ -416,10 +488,23 @@ 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()
|
||||
|
||||
|
||||
# Touch Tone to Speech sample application.
|
||||
# ttcalc
|
||||
|
@ -481,7 +566,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()
|
||||
|
|
14
src/agwlib.c
14
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.
|
||||
|
@ -365,7 +365,7 @@ static void * tnc_listen_thread (void *arg)
|
|||
}
|
||||
|
||||
/*
|
||||
* Call to/from fields are 10 bytes but contents must not exceeed 9 characters.
|
||||
* Call to/from fields are 10 bytes but contents must not exceed 9 characters.
|
||||
* It's not guaranteed that unused bytes will contain 0 so we
|
||||
* don't issue error message in this case.
|
||||
*/
|
||||
|
@ -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);
|
||||
|
||||
|
|
114
src/atest.c
114
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, 2022, 2023 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
|
||||
|
@ -23,12 +23,12 @@
|
|||
*
|
||||
* Name: atest.c
|
||||
*
|
||||
* Purpose: Test fixture for the AFSK demodulator.
|
||||
* Purpose: Test fixture for the Dire Wolf demodulators.
|
||||
*
|
||||
* 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.
|
||||
* Description: This can be used to test the demodulators under
|
||||
* controlled and reproducible conditions for tweaking.
|
||||
*
|
||||
* For example
|
||||
*
|
||||
|
@ -68,6 +68,7 @@
|
|||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <getopt.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
#define ATEST_C 1
|
||||
|
@ -82,6 +83,7 @@
|
|||
#include "ptt.h"
|
||||
#include "dtime_now.h"
|
||||
#include "fx25.h"
|
||||
#include "il2p.h"
|
||||
#include "hdlc_rec.h"
|
||||
|
||||
|
||||
|
@ -106,7 +108,7 @@ struct wav_header { /* .WAV file header. */
|
|||
/* 8 bit samples are unsigned bytes */
|
||||
/* in range of 0 .. 255. */
|
||||
|
||||
/* 16 bit samples are signed short */
|
||||
/* 16 bit samples are little endian signed short */
|
||||
/* in range of -32768 .. +32767. */
|
||||
|
||||
static struct {
|
||||
|
@ -189,6 +191,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 +239,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;
|
||||
|
@ -273,12 +276,12 @@ int main (int argc, char *argv[])
|
|||
|
||||
case 'B': /* -B for data Bit rate */
|
||||
/* Also implies modem type based on speed. */
|
||||
/* Special case "AIS" rather than number. */
|
||||
/* Special cases AIS, EAS rather than number. */
|
||||
if (strcasecmp(optarg, "AIS") == 0) {
|
||||
B_opt = 12345; // See special case below.
|
||||
B_opt = 0xA15A15; // See special case below.
|
||||
}
|
||||
else if (strcasecmp(optarg, "EAS") == 0) {
|
||||
B_opt = 23456; // See special case below.
|
||||
B_opt = 0xEA5EA5; // See special case below.
|
||||
}
|
||||
else {
|
||||
B_opt = atoi(optarg);
|
||||
|
@ -389,6 +392,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;
|
||||
}
|
||||
}
|
||||
|
@ -421,32 +425,26 @@ int main (int argc, char *argv[])
|
|||
|
||||
my_audio_config.achan[0].baud = B_opt;
|
||||
|
||||
if (my_audio_config.achan[0].baud < MIN_BAUD || my_audio_config.achan[0].baud > MAX_BAUD) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Use a more reasonable bit rate in range of %d - %d.\n", MIN_BAUD, MAX_BAUD);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* 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));
|
||||
}
|
||||
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".
|
||||
}
|
||||
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;
|
||||
// Should default to E+ or something similar later.
|
||||
}
|
||||
else if (my_audio_config.achan[0].baud < 3600) {
|
||||
my_audio_config.achan[0].modem_type = MODEM_QPSK;
|
||||
|
@ -460,20 +458,20 @@ 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 == 0xA15A15) { // 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;
|
||||
my_audio_config.achan[0].space_freq = 0;
|
||||
strlcpy (my_audio_config.achan[0].profiles, " ", sizeof(my_audio_config.achan[0].profiles)); // avoid getting default later.
|
||||
}
|
||||
else if (my_audio_config.achan[0].baud == 23456) {
|
||||
else if (my_audio_config.achan[0].baud == 0xEA5EA5) {
|
||||
my_audio_config.achan[0].modem_type = MODEM_EAS;
|
||||
my_audio_config.achan[0].baud = 521; // Actually 520.83 but we have an integer field here.
|
||||
// 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;
|
||||
|
@ -482,6 +480,12 @@ int main (int argc, char *argv[])
|
|||
strlcpy (my_audio_config.achan[0].profiles, " ", sizeof(my_audio_config.achan[0].profiles)); // avoid getting default later.
|
||||
}
|
||||
|
||||
if (my_audio_config.achan[0].baud < MIN_BAUD || my_audio_config.achan[0].baud > MAX_BAUD) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Use a more reasonable bit rate in range of %d - %d.\n", MIN_BAUD, MAX_BAUD);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/*
|
||||
* -g option means force g3RUH regardless of speed.
|
||||
*/
|
||||
|
@ -537,6 +541,7 @@ int main (int argc, char *argv[])
|
|||
}
|
||||
|
||||
fx25_init (d_x_opt);
|
||||
il2p_init (d_2_opt);
|
||||
|
||||
start_time = dtime_now();
|
||||
|
||||
|
@ -614,9 +619,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 +708,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) {
|
||||
|
@ -752,14 +757,14 @@ int audio_get (int a)
|
|||
* This is called when we have a good frame.
|
||||
*/
|
||||
|
||||
void dlq_rec_frame (int chan, int subchan, int slice, packet_t pp, alevel_t alevel, int is_fx25, retry_t retries, char *spectrum)
|
||||
void dlq_rec_frame (int chan, int subchan, int slice, packet_t pp, alevel_t alevel, fec_type_t fec_type, retry_t retries, char *spectrum)
|
||||
{
|
||||
|
||||
char stemp[500];
|
||||
unsigned char *pinfo;
|
||||
int info_len;
|
||||
int h;
|
||||
char heard[AX25_MAX_ADDR_LEN];
|
||||
char heard[2 * AX25_MAX_ADDR_LEN + 20];
|
||||
char alevel_text[AX25_ALEVEL_TO_TEXT_SIZE];
|
||||
|
||||
packets_decoded_one++;
|
||||
|
@ -804,29 +809,48 @@ void dlq_rec_frame (int chan, int subchan, int slice, packet_t pp, alevel_t alev
|
|||
}
|
||||
ax25_alevel_to_text (alevel, alevel_text);
|
||||
|
||||
if (my_audio_config.achan[chan].fix_bits == RETRY_NONE && my_audio_config.achan[chan].passall == 0) {
|
||||
dw_printf ("%s audio level = %s %s\n", heard, alevel_text, spectrum);
|
||||
/* As suggested by KJ4ERJ, if we are receiving from */
|
||||
/* WIDEn-0, it is quite likely (but not guaranteed), that */
|
||||
/* we are actually hearing the preceding station in the path. */
|
||||
|
||||
if (h >= AX25_REPEATER_2 &&
|
||||
strncmp(heard, "WIDE", 4) == 0 &&
|
||||
isdigit(heard[4]) &&
|
||||
heard[5] == '\0') {
|
||||
|
||||
char probably_really[AX25_MAX_ADDR_LEN];
|
||||
ax25_get_addr_with_ssid(pp, h-1, probably_really);
|
||||
|
||||
strlcat (heard, " (probably ", sizeof(heard));
|
||||
strlcat (heard, probably_really, sizeof(heard));
|
||||
strlcat (heard, ")", sizeof(heard));
|
||||
}
|
||||
else if (is_fx25) {
|
||||
|
||||
switch (fec_type) {
|
||||
|
||||
case fec_type_fx25:
|
||||
dw_printf ("%s audio level = %s FX.25 %s\n", heard, alevel_text, spectrum);
|
||||
break;
|
||||
|
||||
case fec_type_il2p:
|
||||
dw_printf ("%s audio level = %s IL2P %s\n", heard, alevel_text, spectrum);
|
||||
break;
|
||||
|
||||
case fec_type_none:
|
||||
default:
|
||||
if (my_audio_config.achan[chan].fix_bits == RETRY_NONE && my_audio_config.achan[chan].passall == 0) {
|
||||
// No fix_bits or passall specified.
|
||||
dw_printf ("%s audio level = %s %s\n", heard, alevel_text, spectrum);
|
||||
}
|
||||
else {
|
||||
assert (retries >= RETRY_NONE && retries <= RETRY_MAX);
|
||||
assert (retries >= RETRY_NONE && retries <= RETRY_MAX); // validate array index.
|
||||
dw_printf ("%s audio level = %s [%s] %s\n", heard, alevel_text, retry_text[(int)retries], spectrum);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//#if defined(EXPERIMENT_G) || defined(EXPERIMENT_H)
|
||||
// int j;
|
||||
//
|
||||
// for (j=0; j<MAX_SUBCHANS; j++) {
|
||||
// if (spectrum[j] == '|') {
|
||||
// count[j]++;
|
||||
// }
|
||||
// }
|
||||
//#endif
|
||||
|
||||
|
||||
// Display non-APRS packets in a different color.
|
||||
|
||||
|
@ -871,7 +895,7 @@ void dlq_rec_frame (int chan, int subchan, int slice, packet_t pp, alevel_t alev
|
|||
|
||||
|
||||
|
||||
#if 1 // temp experiment TODO: remove this.
|
||||
#if 0 // temp experiment
|
||||
|
||||
#include "decode_aprs.h"
|
||||
#include "log.h"
|
||||
|
@ -880,7 +904,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, NULL);
|
||||
|
||||
// Temp experiment to see how different systems set the RR bits in the source and destination.
|
||||
// log_rr_bits (&A, pp);
|
||||
|
|
259
src/audio.c
259
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;
|
||||
|
@ -343,11 +354,33 @@ int audio_open (struct audio_s *pa)
|
|||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Could not open audio device %s for input\n%s\n",
|
||||
audio_in_name, snd_strerror(err));
|
||||
if (err == -EBUSY) {
|
||||
dw_printf ("This means that some other application is using that device.\n");
|
||||
dw_printf ("The solution is to identify that other application and stop it.\n");
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -430,6 +463,10 @@ int audio_open (struct audio_s *pa)
|
|||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Could not open audio device %s for output\n%s\n",
|
||||
audio_out_name, snd_strerror(err));
|
||||
if (err == -EBUSY) {
|
||||
dw_printf ("This means that some other application is using that device.\n");
|
||||
dw_printf ("The solution is to identify that other application and stop it.\n");
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
@ -439,6 +476,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 +733,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 +933,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 +1006,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 +1102,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 +1138,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 +1439,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;
|
||||
|
@ -1320,7 +1540,7 @@ int audio_flush (int a)
|
|||
* (3) Call this function, which might or might not wait long enough.
|
||||
* (4) Add (1) and (2) resulting in when PTT should be turned off.
|
||||
* (5) Take difference between current time and desired PPT off time
|
||||
* and wait for additoinal time if required.
|
||||
* and wait for additional time if required.
|
||||
*
|
||||
*----------------------------------------------------------------*/
|
||||
|
||||
|
@ -1351,6 +1571,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 +1621,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) {
|
||||
|
|
95
src/audio.h
95
src/audio.h
|
@ -72,7 +72,7 @@ struct audio_s {
|
|||
|
||||
struct adev_param_s {
|
||||
|
||||
/* Properites of the sound device. */
|
||||
/* Properties of the sound device. */
|
||||
|
||||
int defined; /* Was device defined? */
|
||||
/* First one defaults to yes. */
|
||||
|
@ -102,15 +102,16 @@ struct audio_s {
|
|||
/* This is the probability, in per cent, of randomly corrupting it. */
|
||||
/* Normally this is 0. 25 would mean corrupt it 25% of the time. */
|
||||
|
||||
int recv_error_rate; /* Similar but the % probablity of dropping a received frame. */
|
||||
int recv_error_rate; /* Similar but the % probability of dropping a received frame. */
|
||||
|
||||
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. */
|
||||
|
@ -118,32 +119,50 @@ 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.
|
||||
|
||||
// Currently, we have a fixed mapping from audio sources to channel.
|
||||
//
|
||||
// ADEVICE CHANNEL (mono) (stereo)
|
||||
// 0 0 0, 1
|
||||
// 1 2 2, 3
|
||||
// 2 4 4, 5
|
||||
//
|
||||
// A future feauture might allow the user to specify a different audio source.
|
||||
// This would allow multiple modems (with associated channel) to share an audio source.
|
||||
// int audio_source; // Default would be [0,1,2,3,4,5]
|
||||
|
||||
// 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. */
|
||||
|
||||
|
@ -156,9 +175,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
|
||||
|
@ -240,15 +276,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. */
|
||||
|
@ -256,12 +294,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 */
|
||||
|
@ -298,7 +336,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 +350,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 +388,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
|
||||
|
@ -388,7 +426,8 @@ struct audio_s {
|
|||
|
||||
#define DEFAULT_BITS_PER_SAMPLE 16
|
||||
|
||||
#define DEFAULT_FIX_BITS RETRY_INVERT_SINGLE
|
||||
#define DEFAULT_FIX_BITS RETRY_NONE // Interesting research project but even a single bit fix up
|
||||
// will occasionally let corrupted packets through.
|
||||
|
||||
/*
|
||||
* Standard for AFSK on VHF FM.
|
||||
|
@ -418,11 +457,11 @@ struct audio_s {
|
|||
*/
|
||||
|
||||
#define DEFAULT_DWAIT 0
|
||||
#define DEFAULT_SLOTTIME 10
|
||||
#define DEFAULT_SLOTTIME 10 // *10mS = 100mS
|
||||
#define DEFAULT_PERSIST 63
|
||||
#define DEFAULT_TXDELAY 30
|
||||
#define DEFAULT_TXTAIL 10
|
||||
#define DEFAULT_FULLDUP 0
|
||||
#define DEFAULT_TXDELAY 30 // *10mS = 300mS
|
||||
#define DEFAULT_TXTAIL 10 // *10mS = 100mS
|
||||
#define DEFAULT_FULLDUP 0 // false = half duplex
|
||||
|
||||
/*
|
||||
* Note that we have two versions of these in audio.c and audio_win.c.
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
@ -213,7 +213,21 @@ static int pa_devNN(char *deviceStr, char *_devName, size_t length, int *_devNo)
|
|||
while(*cPtr) {
|
||||
cVal = *cPtr++;
|
||||
if(cVal == ':') break;
|
||||
if(((cVal >= ' ') && (cVal <= '~')) && (count < length)) {
|
||||
|
||||
// See Issue 417.
|
||||
// Originally this copied only printable ASCII characters (space thru ~).
|
||||
// That is a problem for some locales that use UTF-8 characters in the device name.
|
||||
// original: if(((cVal >= ' ') && (cVal <= '~')) && (count < length)) {
|
||||
|
||||
// At first I was thinking we should keep the test for < ' ' but then I
|
||||
// remembered that char type can be signed or unsigned depending on implementation.
|
||||
// If characters are signed then a value above 0x7f would be considered negative.
|
||||
|
||||
// It seems to me that the test for buffer full is off by one.
|
||||
// count could reach length, leaving no room for a nul terminator.
|
||||
// Compare has been changed so count is limited to length minus 1.
|
||||
|
||||
if(count < length - 1) {
|
||||
_devName[count++] = cVal;
|
||||
}
|
||||
|
||||
|
@ -513,7 +527,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.
|
||||
*
|
||||
|
@ -1149,7 +1163,7 @@ int audio_put (int a, int c)
|
|||
static double start = 0, end = 0, diff = 0;
|
||||
|
||||
if(adev[a].outbuf_len == 0)
|
||||
start = dtime_now();
|
||||
start = dtime_monotonic();
|
||||
#endif
|
||||
|
||||
if(c >= 0) {
|
||||
|
@ -1178,7 +1192,7 @@ int audio_put (int a, int c)
|
|||
#ifdef __TIMED__
|
||||
count += frames;
|
||||
if(c < 0) { // When the Ax25 frames are flushed.
|
||||
end = dtime_now();
|
||||
end = dtime_monotonic();
|
||||
diff = end - start;
|
||||
if(count)
|
||||
dw_printf ("Transfer Time:%3.9f No of Frames:%d Per frame:%3.9f speed:%f\n",
|
||||
|
@ -1246,7 +1260,7 @@ int audio_flush (int a)
|
|||
* (3) Call this function, which might or might not wait long enough.
|
||||
* (4) Add (1) and (2) resulting in when PTT should be turned off.
|
||||
* (5) Take difference between current time and desired PPT off time
|
||||
* and wait for additoinal time if required.
|
||||
* and wait for additional time if required.
|
||||
*
|
||||
*----------------------------------------------------------------*/
|
||||
|
||||
|
|
|
@ -65,7 +65,6 @@
|
|||
|
||||
#include "audio_stats.h"
|
||||
#include "textcolor.h"
|
||||
#include "dtime_now.h"
|
||||
#include "demod.h" /* for alevel_t & demod_get_audio_level() */
|
||||
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ static struct audio_s *save_audio_config_p;
|
|||
*/
|
||||
|
||||
/*
|
||||
* Originally, we had an abitrary buf time of 40 mS.
|
||||
* Originally, we had an arbitrary buf time of 40 mS.
|
||||
*
|
||||
* For mono, the buffer size was rounded up from 3528 to 4k so
|
||||
* it was really about 50 mS per buffer or about 20 per second.
|
||||
|
@ -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.
|
||||
|
@ -1072,7 +1074,7 @@ int audio_flush (int a)
|
|||
* (3) Call this function, which might or might not wait long enough.
|
||||
* (4) Add (1) and (2) resulting in when PTT should be turned off.
|
||||
* (5) Take difference between current time and desired PPT off time
|
||||
* and wait for additoinal time if required.
|
||||
* and wait for additional time if required.
|
||||
*
|
||||
*----------------------------------------------------------------*/
|
||||
|
||||
|
|
179
src/ax25_link.c
179
src/ax25_link.c
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
||||
//
|
||||
// Copyright (C) 2016, 2017, 2018 John Langner, WB2OSZ
|
||||
// Copyright (C) 2016, 2017, 2018, 2023 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
|
||||
|
@ -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
|
||||
|
@ -190,14 +194,16 @@
|
|||
// Debug switches for different types of information.
|
||||
// Should have command line options instead of changing source and recompiling.
|
||||
|
||||
static int s_debug_protocol_errors = 1; // Less serious Protocol errors.
|
||||
static int s_debug_protocol_errors = 0; // Less serious Protocol errors.
|
||||
// Useful for debugging but unnecessarily alarming other times.
|
||||
// Was it intentially left on for release 1.6?
|
||||
|
||||
static int s_debug_client_app = 0; // Interaction with client application.
|
||||
// dl_connect_request, dl_data_request, dl_data_indication, etc.
|
||||
|
||||
static int s_debug_radio = 0; // Received frames and channel busy status.
|
||||
// lm_data_indication, lm_channel_busy
|
||||
|
||||
static int s_debug_variables = 0; // Variables, state changes.
|
||||
|
||||
static int s_debug_retry = 0; // Related to lost I frames, REJ, SREJ, timeout, resending.
|
||||
|
@ -246,7 +252,7 @@ typedef struct ax25_dlsm_s {
|
|||
// notifications about state changes.
|
||||
|
||||
|
||||
char addrs[AX25_MAX_REPEATERS][AX25_MAX_ADDR_LEN];
|
||||
char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LEN];
|
||||
// Up to 10 addresses, same order as in frame.
|
||||
|
||||
int num_addr; // Number of addresses. Should be in range 2 .. 10.
|
||||
|
@ -255,7 +261,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 +325,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
|
||||
|
@ -343,7 +349,7 @@ typedef struct ax25_dlsm_s {
|
|||
// Sometimes the flow chart has SAT instead of SRT.
|
||||
// I think that is a typographical error.
|
||||
|
||||
float t1v; // How long to wait for an acknowlegement before resending.
|
||||
float t1v; // How long to wait for an acknowledgement before resending.
|
||||
// Value used when starting timer T1, in seconds.
|
||||
// "FRACK" parameter in some implementations.
|
||||
// Typically it might be 3 seconds after frame has been
|
||||
|
@ -590,6 +596,8 @@ static int AX25MODULO(int n, int m, const char *file, const char *func, int line
|
|||
#define PAUSE_TM201 pause_tm201(S, __func__, __LINE__)
|
||||
#define RESUME_TM201 resume_tm201(S, __func__, __LINE__)
|
||||
|
||||
// TODO: add SELECT_T1_VALUE for debugging.
|
||||
|
||||
|
||||
static void dl_data_indication (ax25_dlsm_t *S, int pid, char *data, int len);
|
||||
|
||||
|
@ -824,6 +832,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++;
|
||||
|
@ -1066,10 +1079,29 @@ void dl_disconnect_request (dlq_item_t *E)
|
|||
case state_1_awaiting_connection:
|
||||
case state_5_awaiting_v22_connection:
|
||||
|
||||
// TODO: "requeue." Not sure what to do here.
|
||||
// If we put it back in the queue we will get it back again probably still in same state.
|
||||
// Need a way to defer it until the next state change.
|
||||
// Erratum: The protocol spec says "requeue." If we put disconnect req back in the
|
||||
// queue we will probably get it back again here while still in same state.
|
||||
// I don't think we would want to delay it until the next state transition.
|
||||
|
||||
// Suppose someone tried to connect to another station, which is not responding, and decided to cancel
|
||||
// before all of the SABMe retries were used up. I think we would want to transmit a DISC, send a disc
|
||||
// notice to the user, and go directly into disconnected state, rather than into awaiting release.
|
||||
|
||||
// New code v1.7 dev, May 6 2023
|
||||
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("Stream %d: In progress connection attempt to %s terminated by user.\n", S->stream_id, S->addrs[PEERCALL]);
|
||||
discard_i_queue (S);
|
||||
SET_RC(0);
|
||||
int p1 = 1;
|
||||
int nopid0 = 0;
|
||||
packet_t pp15 = ax25_u_frame (S->addrs, S->num_addr, cr_cmd, frame_type_U_DISC, p1, nopid0, NULL, 0);
|
||||
lm_data_request (S->chan, TQ_PRIO_1_LO, pp15);
|
||||
|
||||
STOP_T1; // started in establish_data_link.
|
||||
STOP_T3; // probably don't need.
|
||||
enter_new_state (S, state_0_disconnected, __func__, __LINE__);
|
||||
server_link_terminated (S->chan, S->client, S->addrs[PEERCALL], S->addrs[OWNCALL], 0);
|
||||
break;
|
||||
|
||||
case state_2_awaiting_release:
|
||||
|
@ -1157,7 +1189,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 +1525,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,15 +1601,51 @@ 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.
|
||||
*
|
||||
* Confusion: https://github.com/wb2osz/direwolf/issues/427
|
||||
*
|
||||
* There are different, inconsistent versions of the protocol spec.
|
||||
*
|
||||
* One of them simply has:
|
||||
*
|
||||
* CallFrom is our call
|
||||
* CallTo is the call of the other station
|
||||
*
|
||||
* A more detailed version has the same thing in the table of fields:
|
||||
*
|
||||
* CallFrom 10 bytes Our CallSign
|
||||
* CallTo 10 bytes Other CallSign
|
||||
*
|
||||
* (My first implementation went with that.)
|
||||
*
|
||||
* HOWEVER, shortly after that, is contradictory information:
|
||||
*
|
||||
* Careful must be exercised to fill correctly both the CallFrom
|
||||
* and CallTo fields to match the ones of an existing connection,
|
||||
* otherwise AGWPE won’t return any information at all from this query.
|
||||
*
|
||||
* The order of the CallFrom and CallTo is not trivial, it should
|
||||
* reflect the order used to start the connection, so
|
||||
*
|
||||
* * If we started the connection CallFrom=US and CallTo=THEM
|
||||
* * If the other end started the connection CallFrom=THEM and CallTo=US
|
||||
*
|
||||
* This seems to make everything unnecessarily more complicated.
|
||||
* We should only care about the stream going from the local station to the
|
||||
* remote station. Why would it matter who reqested the link? The state
|
||||
* machine doesn't even contain this information so the TNC doesn't know.
|
||||
* The client app interface needs to behave differently for the two cases.
|
||||
*
|
||||
* The new code, below, May 2023, should handle both of those cases.
|
||||
*
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
void dl_outstanding_frames_request (dlq_item_t *E)
|
||||
{
|
||||
ax25_dlsm_t *S;
|
||||
int ok_to_create = 0; // must exist already.
|
||||
|
||||
const int ok_to_create = 0; // must exist already.
|
||||
int reversed_addrs = 0;
|
||||
|
||||
if (s_debug_client_app) {
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
|
@ -1580,13 +1653,29 @@ void dl_outstanding_frames_request (dlq_item_t *E)
|
|||
}
|
||||
|
||||
S = get_link_handle (E->addrs, E->num_addr, E->chan, E->client, ok_to_create);
|
||||
if (S != NULL) {
|
||||
reversed_addrs = 0;
|
||||
}
|
||||
else {
|
||||
// Try swapping the addresses.
|
||||
// this is communicating with the client app, not over the air,
|
||||
// so we don't need to worry about digipeaters.
|
||||
|
||||
if (S == NULL) {
|
||||
char swapped[AX25_MAX_ADDRS][AX25_MAX_ADDR_LEN];
|
||||
memset (swapped, 0, sizeof(swapped));
|
||||
strlcpy (swapped[PEERCALL], E->addrs[OWNCALL], sizeof(swapped[PEERCALL]));
|
||||
strlcpy (swapped[OWNCALL], E->addrs[PEERCALL], sizeof(swapped[OWNCALL]));
|
||||
S = get_link_handle (swapped, E->num_addr, E->chan, E->client, ok_to_create);
|
||||
if (S != NULL) {
|
||||
reversed_addrs = 1;
|
||||
}
|
||||
else {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Can't get outstanding frames for %s -> %s, chan %d\n", E->addrs[OWNCALL], E->addrs[PEERCALL], E->chan);
|
||||
server_outstanding_frames_reply (E->chan, E->client, E->addrs[OWNCALL], E->addrs[PEERCALL], 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Add up these
|
||||
//
|
||||
|
@ -1614,7 +1703,13 @@ void dl_outstanding_frames_request (dlq_item_t *E)
|
|||
}
|
||||
}
|
||||
|
||||
if (reversed_addrs) {
|
||||
// Other end initiated the link.
|
||||
server_outstanding_frames_reply (S->chan, S->client, S->addrs[PEERCALL], S->addrs[OWNCALL], count1 + count2);
|
||||
}
|
||||
else {
|
||||
server_outstanding_frames_reply (S->chan, S->client, S->addrs[OWNCALL], S->addrs[PEERCALL], count1 + count2);
|
||||
}
|
||||
|
||||
} // end dl_outstanding_frames_request
|
||||
|
||||
|
@ -1633,7 +1728,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 +2296,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 +2319,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 +2796,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 +2881,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 +2891,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 +2955,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 +2985,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 +3088,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 +3241,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 +3542,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 +3854,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 +4504,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 +4731,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 +5710,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.)
|
||||
*
|
||||
|
@ -6035,7 +6130,7 @@ static void check_need_for_response (ax25_dlsm_t *S, ax25_frame_type_t frame_typ
|
|||
*
|
||||
* Outputs: S->srt New smoothed roundtrip time.
|
||||
*
|
||||
* S->t1v How long to wait for an acknowlegement before resending.
|
||||
* S->t1v How long to wait for an acknowledgement before resending.
|
||||
* Value used when starting timer T1, in seconds.
|
||||
* Here it is dynamically adjusted.
|
||||
*
|
||||
|
@ -6134,7 +6229,7 @@ static void select_t1_value (ax25_dlsm_t *S)
|
|||
|
||||
// This goes up exponentially if implemented as documented!
|
||||
// For example, if we were trying to connect to a station which is not there, we
|
||||
// would retry after 3, the 8, 16, 32, ... and not time out for over an hour.
|
||||
// would retry after 3, then 8, 16, 32, ... and not time out for over an hour.
|
||||
// That's ridiculous. Let's try increasing it by a quarter second each time.
|
||||
// We now give up after about a minute.
|
||||
|
||||
|
@ -6151,12 +6246,30 @@ static void select_t1_value (ax25_dlsm_t *S)
|
|||
}
|
||||
|
||||
|
||||
// See https://groups.io/g/direwolf/topic/100782658#8542
|
||||
// Perhaps the demands of file transfer lead to this problem.
|
||||
|
||||
// "Temporary" hack.
|
||||
// Automatic fine tuning of t1v generally works well, but on very rare occasions, it gets wildly out of control.
|
||||
// Until I have more time to properly diagnose this, add some guardrails so it does not go flying off a cliff.
|
||||
|
||||
// The initial value of t1v is frack + frack * 2 (number of digipeateers in path)
|
||||
// If anything, it should automatically be adjusted down.
|
||||
// Let's say, something smells fishy if it exceeds twice that initial value.
|
||||
|
||||
// TODO: Add some instrumentation to record where this was called from and all the values in the printf below.
|
||||
|
||||
#if 1
|
||||
if (S->t1v < 0.25 || S->t1v > 2 * (g_misc_config_p->frack * (2 * (S->num_addr - 2) + 1)) ) {
|
||||
INIT_T1V_SRT;
|
||||
}
|
||||
#else
|
||||
if (S->t1v < 0.99 || S->t1v > 30) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("INTERNAL ERROR? Stream %d: select_t1_value, rc = %d, t1 remaining = %.3f, old srt = %.3f, new srt = %.3f, Extreme new t1v = %.3f\n",
|
||||
S->stream_id, S->rc, S->t1_remaining_when_last_stopped, old_srt, S->srt, S->t1v);
|
||||
}
|
||||
|
||||
#endif
|
||||
} /* end select_t1_value */
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -1844,7 +1866,7 @@ packet_t ax25_get_nextp (packet_t this_p)
|
|||
*
|
||||
* Inputs: this_p - Current packet object.
|
||||
*
|
||||
* release_time - Time as returned by dtime_now().
|
||||
* release_time - Time as returned by dtime_monotonic().
|
||||
*
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -2870,7 +2923,9 @@ int ax25_alevel_to_text (alevel_t alevel, char text[AX25_ALEVEL_TO_TEXT_SIZE])
|
|||
|
||||
snprintf (text, AX25_ALEVEL_TO_TEXT_SIZE, "%d(%+d/%+d)", alevel.rec, alevel.mark, alevel.space);
|
||||
}
|
||||
else if (alevel.mark == -1 && alevel.space == -1) { /* PSK - single number. */
|
||||
else if ((alevel.mark == -1 && alevel.space == -1) || /* PSK */
|
||||
(alevel.mark == -99 && alevel.space == -99)) { /* v. 1.7 "B" FM demodulator. */
|
||||
// ?? Where does -99 come from?
|
||||
|
||||
snprintf (text, AX25_ALEVEL_TO_TEXT_SIZE, "%d", alevel.rec);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
36
src/beacon.c
36
src/beacon.c
|
@ -162,9 +162,10 @@ void beacon_init (struct audio_s *pmodem, struct misc_config_s *pconfig, struct
|
|||
int chan = g_misc_config_p->beacon[j].sendto_chan;
|
||||
|
||||
if (chan < 0) chan = 0; /* For IGate, use channel 0 call. */
|
||||
if (chan >= MAX_CHANS) chan = 0; // For ICHANNEL, 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 +615,22 @@ 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.
|
||||
// TODO: The correct fix will be using monotonic, rather than clock, time.
|
||||
|
||||
/* 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 */
|
||||
|
@ -790,11 +807,17 @@ static void beacon_send (int j, dwgps_info_t *gpsinfo)
|
|||
|
||||
assert (bp->sendto_chan >= 0);
|
||||
|
||||
if (g_modem_config_p->chan_medium[bp->sendto_chan] == MEDIUM_IGATE) { // ICHANNEL uses chan 0 mycall.
|
||||
// TODO: Maybe it should be allowed to have own.
|
||||
strlcpy (mycall, g_modem_config_p->achan[0].mycall, sizeof(mycall));
|
||||
}
|
||||
else {
|
||||
strlcpy (mycall, g_modem_config_p->achan[bp->sendto_chan].mycall, sizeof(mycall));
|
||||
}
|
||||
|
||||
if (strlen(mycall) == 0 || strcmp(mycall, "NOCALL") == 0) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("MYCALL not set for beacon in config file line %d.\n", bp->lineno);
|
||||
dw_printf ("MYCALL not set for beacon to chan %d in config file line %d.\n", bp->sendto_chan, bp->lineno);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -804,7 +827,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) {
|
||||
|
@ -1026,7 +1054,7 @@ static void beacon_send (int j, dwgps_info_t *gpsinfo)
|
|||
text_color_set(DW_COLOR_XMIT);
|
||||
dw_printf ("[ig] %s\n", beacon_text);
|
||||
|
||||
igate_send_rec_packet (0, pp);
|
||||
igate_send_rec_packet (-1, pp); // Channel -1 to avoid RF>IS filtering.
|
||||
ax25_delete (pp);
|
||||
break;
|
||||
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
*------------------------------------------------------------------*/
|
||||
|
@ -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.
|
||||
*
|
||||
|
|
353
src/cm108.c
353
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,11 @@
|
|||
*
|
||||
* 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/
|
||||
* PAUL https://hamprojects.info/paul/
|
||||
* 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 +46,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 +90,34 @@
|
|||
* 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.
|
||||
*
|
||||
* Here is something new and interesting. The All in One cable (AIOC).
|
||||
* https://github.com/skuep/AIOC/tree/master
|
||||
*
|
||||
* A microcontroller is used to emulate a CM108-compatible soundcard
|
||||
* and a serial port. It fits right on the side of a Bao Feng or similar.
|
||||
*
|
||||
*---------------------------------------------------------------*/
|
||||
|
||||
#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 +126,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 +135,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"
|
||||
|
@ -168,6 +185,11 @@ static int cm108_write (char *name, int iomask, int iodata);
|
|||
#define SSS_PID2 0x1607
|
||||
#define SSS_PID3 0x160b
|
||||
|
||||
// https://github.com/skuep/AIOC/blob/master/stm32/aioc-fw/Src/usb_descriptors.h
|
||||
|
||||
#define AIOC_VID 0x1209
|
||||
#define AIOC_PID 0x7388
|
||||
|
||||
|
||||
// Device VID PID Number of GPIO
|
||||
// ------ --- --- --------------
|
||||
|
@ -207,7 +229,9 @@ static int cm108_write (char *name, int iomask, int iodata);
|
|||
|| p == CMEDIA_PID_CM119A \
|
||||
|| p == CMEDIA_PID_CM119B )) \
|
||||
|| \
|
||||
(v == SSS_VID && (p == SSS_PID1 || p == SSS_PID2 || p == SSS_PID3)) )
|
||||
(v == SSS_VID && (p == SSS_PID1 || p == SSS_PID2 || p == SSS_PID3)) \
|
||||
|| \
|
||||
(v == AIOC_VID && p == AIOC_PID) )
|
||||
|
||||
// Look out for null source pointer, and avoid buffer overflow on destination.
|
||||
|
||||
|
@ -216,6 +240,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 +255,13 @@ static void substr_se (char *dest, const char *src, int start, int endp1)
|
|||
|
||||
} /* end substr_se */
|
||||
|
||||
#endif
|
||||
|
||||
// Maximum length of name for PTT HID.
|
||||
// For Linux, this was originally 17 to handle names like /dev/hidraw3.
|
||||
// Windows has more complicated names. The longest I saw was 95 but longer have been reported.
|
||||
|
||||
#define MAXX_HIDRAW_NAME_LEN 128
|
||||
|
||||
/*
|
||||
* Result of taking inventory of USB soundcards and USB HIDs.
|
||||
|
@ -237,15 +270,18 @@ 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[MAXX_HIDRAW_NAME_LEN];
|
||||
// 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 +295,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 +310,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 +423,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 +437,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 +455,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 +508,7 @@ int main (void)
|
|||
}
|
||||
dw_printf ("LABEL=\"my_usb_audio_end\"\n");
|
||||
dw_printf ("\n");
|
||||
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -400,6 +536,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 +587,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 +736,8 @@ int cm108_inventory (struct thing_s *things, int max_things)
|
|||
}
|
||||
}
|
||||
|
||||
#endif // end Linux
|
||||
|
||||
return (num_things);
|
||||
|
||||
} /* end cm108_inventory */
|
||||
|
@ -584,7 +761,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 +771,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 +837,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 +850,7 @@ void cm108_find_ptt (char *output_audio_device, char *ptt_device, int ptt_devic
|
|||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} /* end cm108_find_ptt */
|
||||
|
||||
|
@ -649,7 +862,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.
|
||||
*
|
||||
|
@ -659,9 +873,9 @@ void cm108_find_ptt (char *output_audio_device, char *ptt_device, int ptt_devic
|
|||
*
|
||||
* Errors: A descriptive error message will be printed for any problem.
|
||||
*
|
||||
* Future: For our initial implementation we are making the simplifying
|
||||
* Shortcut: 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 +883,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)
|
||||
{
|
||||
|
@ -727,7 +903,6 @@ int cm108_set_gpio_pin (char *name, int num, int state)
|
|||
|
||||
iomask = 1 << (num - 1); // 0=input, 1=output
|
||||
iodata = state << (num - 1); // 0=low, 1=high
|
||||
|
||||
return (cm108_write (name, iomask, iodata));
|
||||
|
||||
} /* end cm108_set_gpio_pin */
|
||||
|
@ -758,6 +933,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 +1067,8 @@ static int cm108_write (char *name, int iomask, int iodata)
|
|||
}
|
||||
|
||||
close (fd);
|
||||
|
||||
#endif
|
||||
return (0);
|
||||
|
||||
} /* end cm108_write */
|
||||
|
|
542
src/config.c
542
src/config.c
File diff suppressed because it is too large
Load Diff
45
src/config.h
45
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. */
|
||||
|
||||
|
@ -187,7 +214,7 @@ struct misc_config_s {
|
|||
char symbol; /* Symbol code. */
|
||||
|
||||
float power; /* For PHG. */
|
||||
float height;
|
||||
float height; /* HAAT in feet */
|
||||
float gain; /* Original protocol spec was unclear. */
|
||||
/* Addendum 1.1 clarifies it is dBi not dBd. */
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -24,11 +24,12 @@ typedef struct decode_aprs_s {
|
|||
|
||||
int g_quiet; /* Suppress error messages when decoding. */
|
||||
|
||||
char g_src[AX25_MAX_ADDR_LEN];
|
||||
char g_src[AX25_MAX_ADDR_LEN]; // In the case of a packet encapsulated by a 3rd party
|
||||
// header, this is the encapsulated source.
|
||||
|
||||
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 */
|
||||
|
@ -66,10 +67,30 @@ typedef struct decode_aprs_s {
|
|||
/* Also for Directed Station Query which is a */
|
||||
/* special case of message. */
|
||||
|
||||
// This is so pfilter.c:filt_t does not need to duplicate the same work.
|
||||
|
||||
int g_has_thirdparty_header;
|
||||
enum packet_type_e {
|
||||
packet_type_none=0,
|
||||
packet_type_position,
|
||||
packet_type_weather,
|
||||
packet_type_object,
|
||||
packet_type_item,
|
||||
packet_type_message,
|
||||
packet_type_query,
|
||||
packet_type_capabilities,
|
||||
packet_type_status,
|
||||
packet_type_telemetry,
|
||||
packet_type_userdefined,
|
||||
packet_type_nws
|
||||
} g_packet_type;
|
||||
|
||||
enum message_subtype_e { message_subtype_invalid = 0,
|
||||
message_subtype_message,
|
||||
message_subtype_ack,
|
||||
message_subtype_rej,
|
||||
message_subtype_bulletin,
|
||||
message_subtype_nws,
|
||||
message_subtype_telem_parm,
|
||||
message_subtype_telem_unit,
|
||||
message_subtype_telem_eqns,
|
||||
|
@ -77,23 +98,31 @@ 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[12]; /* 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. */
|
||||
|
||||
int g_power; /* Transmitter power in watts. */
|
||||
|
||||
int g_height; /* Antenna height above average terrain, feet. */
|
||||
// TODO: rename to g_height_ft
|
||||
|
||||
int g_gain; /* Antenna gain in dB. */
|
||||
int g_gain; /* Antenna gain in dBi. */
|
||||
|
||||
char g_directivity[12]; /* Direction of max signal strength */
|
||||
|
||||
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 altitude. Meters would be */
|
||||
/* more natural to the other 96% of the world. */
|
||||
|
||||
char g_mfr[80]; /* Manufacturer or application. */
|
||||
|
||||
|
@ -135,7 +164,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, char *third_party_src);
|
||||
|
||||
extern void decode_aprs_print (decode_aprs_t *A);
|
||||
|
||||
|
|
192
src/demod.c
192
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);
|
||||
|
||||
|
@ -811,7 +832,7 @@ int demod_init (struct audio_s *pa)
|
|||
*
|
||||
* Name: demod_get_sample
|
||||
*
|
||||
* Purpose: Get one audio sample fromt the specified sound input source.
|
||||
* Purpose: Get one audio sample from the specified sound input source.
|
||||
*
|
||||
* Inputs: a - Index for audio device. 0 = first.
|
||||
*
|
||||
|
@ -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
|
||||
|
@ -831,17 +852,15 @@ int demod_init (struct audio_s *pa)
|
|||
|
||||
#define FSK_READ_ERR (256*256)
|
||||
|
||||
|
||||
__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);
|
||||
|
||||
|
||||
if (save_audio_config_p->adev[a].bits_per_sample == 8) {
|
||||
|
||||
x1 = audio_get(a);
|
||||
|
@ -908,12 +927,27 @@ int demod_get_sample (int a)
|
|||
*
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
static volatile int mute_input[MAX_CHANS];
|
||||
|
||||
// New in 1.7.
|
||||
// A few people have a really bad audio cross talk situation where they receive their own transmissions.
|
||||
// It usually doesn't cause a problem but it is confusing to look at.
|
||||
// "half duplex" setting applied only to the transmit logic. i.e. wait for clear channel before sending.
|
||||
// Receiving was still active.
|
||||
// I think the simplest solution is to mute/unmute the audio input at this point if not full duplex.
|
||||
// This is called from ptt_set for half duplex.
|
||||
|
||||
void demod_mute_input (int chan, int mute_during_xmit)
|
||||
{
|
||||
assert (chan >= 0 && chan < MAX_CHANS);
|
||||
mute_input[chan] = mute_during_xmit;
|
||||
}
|
||||
|
||||
__attribute__((hot))
|
||||
void demod_process_sample (int chan, int subchan, int sam)
|
||||
{
|
||||
float fsam;
|
||||
int k;
|
||||
//int k;
|
||||
|
||||
|
||||
struct demodulator_state_s *D;
|
||||
|
@ -921,6 +955,10 @@ void demod_process_sample (int chan, int subchan, int sam)
|
|||
assert (chan >= 0 && chan < MAX_CHANS);
|
||||
assert (subchan >= 0 && subchan < MAX_SUBCHANS);
|
||||
|
||||
if (mute_input[chan]) {
|
||||
sam = 0;
|
||||
};
|
||||
|
||||
D = &demodulator_state[chan][subchan];
|
||||
|
||||
|
||||
|
@ -1005,47 +1043,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 */
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
int demod_init (struct audio_s *pa);
|
||||
|
||||
void demod_mute_input (int chan, int mute);
|
||||
|
||||
int demod_get_sample (int a);
|
||||
|
||||
void demod_process_sample (int chan, int subchan, int sam);
|
||||
|
@ -15,3 +17,4 @@ void demod_process_sample (int chan, int subchan, int sam);
|
|||
void demod_print_agc (int chan, int subchan);
|
||||
|
||||
alevel_t demod_get_audio_level (int chan, int subchan);
|
||||
|
||||
|
|
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);
|
||||
|
||||
|
||||
|
||||
|
|
955
src/demod_afsk.c
955
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.
|
||||
|
@ -501,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.
|
||||
|
@ -781,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.
|
||||
*/
|
||||
|
|
211
src/digipeater.c
211
src/digipeater.c
|
@ -49,6 +49,7 @@
|
|||
* Preemptive Digipeating (new in version 0.8)
|
||||
*
|
||||
* http://www.aprs.org/aprs12/preemptive-digipeating.txt
|
||||
* I ignored the part about the RR bits.
|
||||
*
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
|
@ -73,7 +74,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 +155,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);
|
||||
}
|
||||
|
@ -164,7 +165,34 @@ void digipeater (int from_chan, packet_t pp)
|
|||
/*
|
||||
* First pass: Look at packets being digipeated to same channel.
|
||||
*
|
||||
* We want these to get out quickly.
|
||||
* We want these to get out quickly, bypassing the usual random wait time.
|
||||
*
|
||||
* Some may disagree but I followed what WB4APR had to say about it.
|
||||
*
|
||||
* http://www.aprs.org/balloons.html
|
||||
*
|
||||
* APRS NETWORK FRATRICIDE: Generally, all APRS digipeaters are supposed to transmit
|
||||
* immediately and all at the same time. They should NOT wait long enough for each
|
||||
* one to QRM the channel with the same copy of each packet. NO, APRS digipeaters
|
||||
* are all supposed to STEP ON EACH OTHER with every packet. This makes sure that
|
||||
* everyone in range of a digi will hear one and only one copy of each packet.
|
||||
* and that the packet will digipeat OUTWARD and not backward. The goal is that a
|
||||
* digipeated packet is cleared out of the local area in ONE packet time and not
|
||||
* N packet times for every N digipeaters that heard the packet. This means no
|
||||
* PERSIST times, no DWAIT times and no UIDWAIT times. Notice, this is contrary
|
||||
* to other packet systems that might want to guarantee delivery (but at the
|
||||
* expense of throughput). APRS wants to clear the channel quickly to maximize throughput.
|
||||
*
|
||||
* http://www.aprs.org/kpc3/kpc3+WIDEn.txt
|
||||
*
|
||||
* THIRD: Eliminate the settings that are detrimental to the network.
|
||||
*
|
||||
* * UIDWAIT should be OFF. (the default). With it on, your digi is not doing the
|
||||
* fundamental APRS fratricide that is the primary mechanism for minimizing channel
|
||||
* loading. All digis that hear the same packet are supposed to DIGI it at the SAME
|
||||
* time so that all those copies only take up one additional time slot. (but outward
|
||||
* located digs will hear it without collision (and continue outward propagation)
|
||||
*
|
||||
*/
|
||||
|
||||
for (to_chan=0; to_chan<MAX_CHANS; to_chan++) {
|
||||
|
@ -176,10 +204,11 @@ 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);
|
||||
tq_append (to_chan, TQ_PRIO_0_HI, result);
|
||||
tq_append (to_chan, TQ_PRIO_0_HI, result); // High priority queue.
|
||||
digi_count[from_chan][to_chan]++;
|
||||
}
|
||||
}
|
||||
|
@ -202,10 +231,11 @@ 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);
|
||||
tq_append (to_chan, TQ_PRIO_1_LO, result);
|
||||
tq_append (to_chan, TQ_PRIO_1_LO, result); // Low priority queue.
|
||||
digi_count[from_chan][to_chan]++;
|
||||
}
|
||||
}
|
||||
|
@ -244,6 +274,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 +293,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 +333,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.
|
||||
|
@ -440,6 +441,10 @@ static packet_t digipeat_match (int from_chan, packet_t pp, char *mycall_rec, ch
|
|||
/*
|
||||
* If preemptive digipeating is enabled, try matching my call
|
||||
* and aliases against all remaining unused digipeaters.
|
||||
*
|
||||
* Bob says: "GENERIC XXXXn-N DIGIPEATING should not do preemptive digipeating."
|
||||
*
|
||||
* But consider this case: https://github.com/wb2osz/direwolf/issues/488
|
||||
*/
|
||||
|
||||
if (preempt != PREEMPT_OFF) {
|
||||
|
@ -465,13 +470,22 @@ static packet_t digipeat_match (int from_chan, packet_t pp, char *mycall_rec, ch
|
|||
|
||||
switch (preempt) {
|
||||
case PREEMPT_DROP: /* remove all prior */
|
||||
// TODO: deprecate this option. Result is misleading.
|
||||
|
||||
text_color_set (DW_COLOR_ERROR);
|
||||
dw_printf ("The digipeat DROP option will be removed in a future release. Use PREEMPT for preemptive digipeating.\n");
|
||||
|
||||
while (r2 > AX25_REPEATER_1) {
|
||||
ax25_remove_addr (result, r2-1);
|
||||
r2--;
|
||||
}
|
||||
break;
|
||||
|
||||
case PREEMPT_MARK:
|
||||
case PREEMPT_MARK: // TODO: deprecate this option. Result is misleading.
|
||||
|
||||
text_color_set (DW_COLOR_ERROR);
|
||||
dw_printf ("The digipeat MARK option will be removed in a future release. Use PREEMPT for preemptive digipeating.\n");
|
||||
|
||||
r2--;
|
||||
while (r2 >= AX25_REPEATER_1 && ax25_get_h(result,r2) == 0) {
|
||||
ax25_set_h (result, r2);
|
||||
|
@ -479,7 +493,12 @@ static packet_t digipeat_match (int from_chan, packet_t pp, char *mycall_rec, ch
|
|||
}
|
||||
break;
|
||||
|
||||
case PREEMPT_TRACE: /* remove prior unused */
|
||||
case PREEMPT_TRACE: /* My enhancement - remove prior unused digis. */
|
||||
/* this provides an accurate path of where packet traveled. */
|
||||
|
||||
// Uh oh. It looks like sample config files went out
|
||||
// with this option. Should it be renamed as
|
||||
// PREEMPT which is more descriptive?
|
||||
default:
|
||||
while (r2 > AX25_REPEATER_1 && ax25_get_h(result,r2-1) == 0) {
|
||||
ax25_remove_addr (result, r2-1);
|
||||
|
@ -510,6 +529,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 +661,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 +670,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 +680,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 +694,7 @@ static void test (char *in, char *out)
|
|||
int frame_len;
|
||||
alevel_t alevel;
|
||||
|
||||
|
||||
dw_printf ("\n");
|
||||
|
||||
/*
|
||||
|
@ -691,7 +746,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 +781,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 +796,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 +886,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 +897,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 +984,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.
|
||||
|
|
365
src/direwolf.c
365
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, 2023 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,10 @@
|
|||
#include "ax25_link.h"
|
||||
#include "dtime_now.h"
|
||||
#include "fx25.h"
|
||||
#include "il2p.h"
|
||||
#include "dwsock.h"
|
||||
#include "dns_sd_dw.h"
|
||||
#include "dlq.h" // for fec_type_t definition.
|
||||
|
||||
|
||||
//static int idx_decoded = 0;
|
||||
|
@ -135,7 +139,7 @@ static BOOL cleanup_win (int);
|
|||
static void cleanup_linux (int);
|
||||
#endif
|
||||
|
||||
static void usage (char **argv);
|
||||
static void usage ();
|
||||
|
||||
#if defined(__SSE__) && !defined(__APPLE__)
|
||||
|
||||
|
@ -193,7 +197,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 +226,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));
|
||||
|
@ -272,6 +284,8 @@ int main (int argc, char *argv[])
|
|||
/* 1 = normal, 0 = no text colors. */
|
||||
/* 2, 3, ... alternate escape sequences for different terminals. */
|
||||
|
||||
// FIXME: consider case of no space between t and number.
|
||||
|
||||
for (j=1; j<argc-1; j++) {
|
||||
if (strcmp(argv[j], "-t") == 0) {
|
||||
t_opt = atoi (argv[j+1]);
|
||||
|
@ -287,12 +301,12 @@ 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 version %d.%d (%s) BETA TEST 7\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 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");
|
||||
|
@ -302,12 +316,16 @@ int main (int argc, char *argv[])
|
|||
#endif
|
||||
#if defined(USE_CM108)
|
||||
dw_printf (" cm108-ptt");
|
||||
#endif
|
||||
#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);
|
||||
|
@ -357,7 +375,23 @@ 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.
|
||||
// Ordinary users can access audio, gpio, etc. if they are in the correct groups.
|
||||
// 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);
|
||||
for (int n=0; n<15; n++) {
|
||||
dw_printf ("\n");
|
||||
dw_printf ("Dire Wolf requires only privileges available to ordinary users.\n");
|
||||
dw_printf ("Running this as root is an unnecessary security risk.\n");
|
||||
//SLEEP_SEC(1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default location of configuration file is current directory.
|
||||
|
@ -387,7 +421,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;
|
||||
|
@ -489,9 +523,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 */
|
||||
|
@ -531,7 +599,7 @@ int main (int argc, char *argv[])
|
|||
case '?':
|
||||
|
||||
/* For '?' unknown option message was already printed. */
|
||||
usage (argv);
|
||||
usage ();
|
||||
break;
|
||||
|
||||
case 'd': /* Set debug option. */
|
||||
|
@ -566,6 +634,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;
|
||||
}
|
||||
}
|
||||
|
@ -653,6 +723,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;
|
||||
|
@ -663,7 +743,7 @@ int main (int argc, char *argv[])
|
|||
/* Should not be here. */
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf("?? getopt returned character code 0%o ??\n", c);
|
||||
usage (argv);
|
||||
usage ();
|
||||
}
|
||||
} /* end while(1) for options */
|
||||
|
||||
|
@ -703,7 +783,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -758,7 +838,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;
|
||||
|
@ -853,7 +933,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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -870,20 +988,22 @@ int main (int argc, char *argv[])
|
|||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Pointless to continue without audio device.\n");
|
||||
SLEEP_SEC(5);
|
||||
usage ();
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
/*
|
||||
|
@ -905,29 +1025,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, 1);
|
||||
}
|
||||
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, 0);
|
||||
}
|
||||
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.
|
||||
|
@ -944,6 +1111,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.
|
||||
*/
|
||||
|
@ -1008,7 +1180,7 @@ int main (int argc, char *argv[])
|
|||
|
||||
// TODO: Use only one printf per line so output doesn't get jumbled up with stuff from other threads.
|
||||
|
||||
void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alevel_t alevel, int is_fx25, retry_t retries, char *spectrum)
|
||||
void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alevel_t alevel, fec_type_t fec_type, retry_t retries, char *spectrum)
|
||||
{
|
||||
|
||||
char stemp[500];
|
||||
|
@ -1017,22 +1189,32 @@ void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alev
|
|||
char heard[AX25_MAX_ADDR_LEN];
|
||||
//int j;
|
||||
int h;
|
||||
char display_retries[32];
|
||||
char display_retries[32]; // Extra stuff before slice indicators.
|
||||
// Can indicate FX.25/IL2P or fix_bits.
|
||||
|
||||
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+
|
||||
|
||||
strlcpy (display_retries, "", sizeof(display_retries));
|
||||
|
||||
if (is_fx25) {
|
||||
;
|
||||
}
|
||||
else if (audio_config.achan[chan].fix_bits != RETRY_NONE || audio_config.achan[chan].passall) {
|
||||
switch (fec_type) {
|
||||
case fec_type_fx25:
|
||||
strlcpy (display_retries, " FX.25 ", sizeof(display_retries));
|
||||
break;
|
||||
case fec_type_il2p:
|
||||
strlcpy (display_retries, " IL2P ", sizeof(display_retries));
|
||||
break;
|
||||
case fec_type_none:
|
||||
default:
|
||||
// Possible fix_bits indication.
|
||||
if (audio_config.achan[chan].fix_bits != RETRY_NONE || audio_config.achan[chan].passall) {
|
||||
assert (retries >= RETRY_NONE && retries <= RETRY_MAX);
|
||||
snprintf (display_retries, sizeof(display_retries), " [%s] ", retry_text[(int)retries]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ax25_format_addrs (pp, stemp);
|
||||
|
||||
|
@ -1056,8 +1238,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 ");
|
||||
}
|
||||
|
@ -1101,6 +1286,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. */
|
||||
|
@ -1113,6 +1299,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.
|
||||
|
@ -1137,6 +1329,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);
|
||||
|
@ -1247,7 +1443,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, NULL);
|
||||
|
||||
if ( ! q_d_opt ) {
|
||||
|
||||
|
@ -1326,9 +1522,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);
|
||||
|
@ -1337,32 +1533,52 @@ 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. */
|
||||
/* Consider only those with correct CRC. */
|
||||
|
||||
if (ax25_is_aprs(pp) && retries == RETRY_NONE) {
|
||||
/*
|
||||
* Send to the IGate processing.
|
||||
* Use only those with correct CRC; We don't want to spread corrupted data!
|
||||
* Our earlier "fix bits" hack could allow corrupted information to get thru.
|
||||
* However, if it used FEC mode (FX.25. IL2P), we have much higher level of
|
||||
* confidence that it is correct.
|
||||
*/
|
||||
if (ax25_is_aprs(pp) && ( retries == RETRY_NONE || fec_type == fec_type_fx25 || fec_type == fec_type_il2p) ) {
|
||||
|
||||
igate_send_rec_packet (chan, pp);
|
||||
}
|
||||
|
@ -1377,24 +1593,23 @@ void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alev
|
|||
|
||||
|
||||
/*
|
||||
* APRS digipeater.
|
||||
* Send to APRS digipeater.
|
||||
* Use only those with correct CRC; We don't want to spread corrupted data!
|
||||
* Our earlier "fix bits" hack could allow corrupted information to get thru.
|
||||
* However, if it used FEC mode (FX.25. IL2P), we have much higher level of
|
||||
* confidence that it is correct.
|
||||
*/
|
||||
|
||||
// TODO: Should also use anything received with FX.25 because it is known to be good.
|
||||
// Our earlier "fix bits" hack could allow corrupted information to get thru.
|
||||
|
||||
if (ax25_is_aprs(pp) && retries == RETRY_NONE) {
|
||||
if (ax25_is_aprs(pp) && ( retries == RETRY_NONE || fec_type == fec_type_fx25 || fec_type == fec_type_il2p) ) {
|
||||
|
||||
digipeater (chan, pp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Connected mode digipeater.
|
||||
* Use only those with correct CRC.
|
||||
* Use only those with correct CRC (or using FEC.)
|
||||
*/
|
||||
|
||||
if (retries == RETRY_NONE) {
|
||||
if (retries == RETRY_NONE || fec_type == fec_type_fx25 || fec_type == fec_type_il2p) {
|
||||
|
||||
cdigipeater (chan, pp);
|
||||
}
|
||||
|
@ -1469,7 +1684,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");
|
||||
|
@ -1487,6 +1704,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");
|
||||
|
@ -1499,6 +1718,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");
|
||||
|
@ -1506,19 +1730,20 @@ 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");
|
||||
dw_printf ("Documentation can be found in the 'doc' folder\n");
|
||||
#else
|
||||
// TODO: Could vary by platform and build options.
|
||||
dw_printf ("Complete documentation can be found in /usr/local/share/doc/direwolf\n");
|
||||
dw_printf ("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");
|
||||
dw_printf ("additional topics: https://github.com/wb2osz/direwolf-doc\n");
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* end direwolf.c */
|
||||
|
|
|
@ -37,11 +37,8 @@
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Previously, we could handle only a single audio device.
|
||||
* This meant we could have only two radio channels.
|
||||
* In version 1.2, we relax this restriction and allow more audio devices.
|
||||
* Maximum number of audio devices.
|
||||
* Three is probably adequate for standard version.
|
||||
* Larger reasonable numbers should also be fine.
|
||||
*
|
||||
|
@ -65,7 +62,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 +102,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 +181,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)
|
||||
|
@ -272,49 +278,78 @@ typedef pthread_mutex_t dw_mutex_t;
|
|||
/* Platform differences for string functions. */
|
||||
|
||||
|
||||
// Windows is missing a few which are available on Unix/Linux platforms.
|
||||
// We provide our own copies when building on Windows.
|
||||
|
||||
#if __WIN32__
|
||||
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.
|
||||
// Potential problem if some C library declares it a little differently.
|
||||
char *strcasestr(const char *S, const char *FIND);
|
||||
|
||||
|
||||
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__APPLE__)
|
||||
// cmake tries to determine whether strlcpy and strlcat are provided by the C runtime library.
|
||||
//
|
||||
// ../CMakeLists.txt:check_symbol_exists(strlcpy string.h HAVE_STRLCPY)
|
||||
//
|
||||
// It sets HAVE_STRLCPY and HAVE_STRLCAT if the corresponding functions are declared.
|
||||
// Unfortunately this does not work right for glibc 2.38 which declares the functions
|
||||
// like this:
|
||||
//
|
||||
// extern __typeof (strlcpy) __strlcpy;
|
||||
// libc_hidden_proto (__strlcpy)
|
||||
// extern __typeof (strlcat) __strlcat;
|
||||
// libc_hidden_proto (__strlcat)
|
||||
//
|
||||
// Rather than the normal way found in earlier versions:
|
||||
//
|
||||
// extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
|
||||
//
|
||||
// Perhaps a later version of cmake will recognize this form but the version I'm
|
||||
// using does not.
|
||||
// So, our work around is to assume these functions are available for glibc >= 2.38.
|
||||
//
|
||||
// In theory, cmake should be able to find the version of the C runtime library,
|
||||
// but I could not get it to work. So we have the test here. We will still build
|
||||
// own library with the strl... functions but this does not cause a problem
|
||||
// because they have special debug names which will not cause a conflict.
|
||||
|
||||
// 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
|
||||
#ifdef __GLIBC__
|
||||
#if (__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 38))
|
||||
// These functions first added in 2.38.
|
||||
//#warning "DEBUG - glibc >= 2.38"
|
||||
#define HAVE_STRLCPY 1
|
||||
|
||||
|
||||
#define DEBUG_STRL 1
|
||||
|
||||
#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);
|
||||
|
||||
#define HAVE_STRLCAT 1
|
||||
#else
|
||||
//#warning "DEBUG - glibc < 2.38"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define DEBUG_STRL 1 // Extra Debug version when using our own strlcpy, strlcat.
|
||||
// Should be ignored if not supplying our own.
|
||||
|
||||
#ifndef HAVE_STRLCPY // Need to supply our own.
|
||||
#if DEBUG_STRL
|
||||
#define strlcpy(dst,src,siz) strlcpy_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);
|
||||
#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 */
|
||||
|
|
86
src/dlq.c
86
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
|
||||
|
||||
|
@ -209,10 +215,10 @@ void dlq_init (void)
|
|||
* display of audio level line.
|
||||
* Use -2 to indicate DTMF message.)
|
||||
*
|
||||
* is_fx25 - Was it from FX.25? Need to know because
|
||||
* fec_type - Was it from FX.25 or IL2P? Need to know because
|
||||
* meaning of retries is different.
|
||||
*
|
||||
* retries - Level of bit correction used.
|
||||
* retries - Level of correction used.
|
||||
*
|
||||
* spectrum - Display of how well multiple decoders did.
|
||||
*
|
||||
|
@ -222,7 +228,7 @@ void dlq_init (void)
|
|||
*
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
void dlq_rec_frame (int chan, int subchan, int slice, packet_t pp, alevel_t alevel, int is_fx25, retry_t retries, char *spectrum)
|
||||
void dlq_rec_frame (int chan, int subchan, int slice, packet_t pp, alevel_t alevel, fec_type_t fec_type, retry_t retries, char *spectrum)
|
||||
{
|
||||
|
||||
struct dlq_item_s *pnew;
|
||||
|
@ -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) {
|
||||
|
@ -267,7 +278,7 @@ void dlq_rec_frame (int chan, int subchan, int slice, packet_t pp, alevel_t alev
|
|||
pnew->subchan = subchan;
|
||||
pnew->pp = pp;
|
||||
pnew->alevel = alevel;
|
||||
pnew->is_fx25 = is_fx25;
|
||||
pnew->fec_type = fec_type;
|
||||
pnew->retries = retries;
|
||||
if (spectrum == NULL)
|
||||
strlcpy(pnew->spectrum, "", sizeof(pnew->spectrum));
|
||||
|
@ -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;
|
||||
|
@ -697,8 +728,7 @@ void dlq_xmit_data_request (char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LEN], int n
|
|||
*
|
||||
* Purpose: Register callsigns that we will recognize for incoming connection requests.
|
||||
*
|
||||
* Inputs: addrs - Source (owncall), destination (peercall),
|
||||
* and possibly digipeaters.
|
||||
* Inputs: addr - Callsign to [un]register.
|
||||
*
|
||||
* chan - Channel, 0 is first.
|
||||
*
|
||||
|
@ -718,7 +748,7 @@ void dlq_xmit_data_request (char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LEN], int n
|
|||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
void dlq_register_callsign (char addr[AX25_MAX_ADDR_LEN], int chan, int client)
|
||||
void dlq_register_callsign (char *addr, int chan, int client)
|
||||
{
|
||||
struct dlq_item_s *pnew;
|
||||
|
||||
|
@ -733,11 +763,16 @@ 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;
|
||||
pnew->chan = chan;
|
||||
strlcpy (pnew->addrs[0], addr, AX25_MAX_ADDR_LEN);
|
||||
strlcpy (pnew->addrs[0], addr, sizeof(pnew->addrs[0]));
|
||||
pnew->num_addr = 1;
|
||||
pnew->client = client;
|
||||
|
||||
|
@ -748,7 +783,7 @@ void dlq_register_callsign (char addr[AX25_MAX_ADDR_LEN], int chan, int client)
|
|||
} /* end dlq_register_callsign */
|
||||
|
||||
|
||||
void dlq_unregister_callsign (char addr[AX25_MAX_ADDR_LEN], int chan, int client)
|
||||
void dlq_unregister_callsign (char *addr, int chan, int client)
|
||||
{
|
||||
struct dlq_item_s *pnew;
|
||||
|
||||
|
@ -763,11 +798,16 @@ 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;
|
||||
pnew->chan = chan;
|
||||
strlcpy (pnew->addrs[0], addr, AX25_MAX_ADDR_LEN);
|
||||
strlcpy (pnew->addrs[0], addr, sizeof(pnew->addrs[0]));
|
||||
pnew->num_addr = 1;
|
||||
pnew->client = client;
|
||||
|
||||
|
@ -817,6 +857,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 +885,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 +910,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 +960,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 +1247,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;
|
||||
|
|
11
src/dlq.h
11
src/dlq.h
|
@ -33,10 +33,13 @@ typedef struct cdata_s {
|
|||
|
||||
|
||||
|
||||
|
||||
/* Types of things that can be in queue. */
|
||||
|
||||
typedef enum dlq_type_e {DLQ_REC_FRAME, DLQ_CONNECT_REQUEST, DLQ_DISCONNECT_REQUEST, DLQ_XMIT_DATA_REQUEST, DLQ_REGISTER_CALLSIGN, DLQ_UNREGISTER_CALLSIGN, DLQ_OUTSTANDING_FRAMES_REQUEST, DLQ_CHANNEL_BUSY, DLQ_SEIZE_CONFIRM, DLQ_CLIENT_CLEANUP} dlq_type_t;
|
||||
|
||||
typedef enum fec_type_e {fec_type_none=0, fec_type_fx25=1, fec_type_il2p=2} fec_type_t;
|
||||
|
||||
|
||||
/* A queue item. */
|
||||
|
||||
|
@ -68,7 +71,7 @@ typedef struct dlq_item_s {
|
|||
|
||||
alevel_t alevel; /* Audio level. */
|
||||
|
||||
int is_fx25; /* Was it from FX.25? */
|
||||
fec_type_t fec_type; // Type of FEC for received signal: none, FX.25, or IL2P.
|
||||
|
||||
retry_t retries; /* Effort expended to get a valid CRC. */
|
||||
/* Bits changed for regular AX.25. */
|
||||
|
@ -106,7 +109,7 @@ void dlq_init (void);
|
|||
|
||||
|
||||
|
||||
void dlq_rec_frame (int chan, int subchan, int slice, packet_t pp, alevel_t alevel, int is_fx25, retry_t retries, char *spectrum);
|
||||
void dlq_rec_frame (int chan, int subchan, int slice, packet_t pp, alevel_t alevel, fec_type_t fec_type, retry_t retries, char *spectrum);
|
||||
|
||||
void dlq_connect_request (char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LEN], int num_addr, int chan, int client, int pid);
|
||||
|
||||
|
@ -116,9 +119,9 @@ void dlq_outstanding_frames_request (char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LE
|
|||
|
||||
void dlq_xmit_data_request (char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LEN], int num_addr, int chan, int client, int pid, char *xdata_ptr, int xdata_len);
|
||||
|
||||
void dlq_register_callsign (char addr[AX25_MAX_ADDR_LEN], int chan, int client);
|
||||
void dlq_register_callsign (char *addr, int chan, int client);
|
||||
|
||||
void dlq_unregister_callsign (char addr[AX25_MAX_ADDR_LEN], int chan, int client);
|
||||
void dlq_unregister_callsign (char *addr, int chan, int client);
|
||||
|
||||
void dlq_channel_busy (int chan, int activity, int status);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
109
src/dtime_now.c
109
src/dtime_now.c
|
@ -25,9 +25,9 @@
|
|||
|
||||
/*------------------------------------------------------------------
|
||||
*
|
||||
* Name: dtime_now
|
||||
* Name: dtime_realtime
|
||||
*
|
||||
* Purpose: Return current time as double precision.
|
||||
* Purpose: Return current wall clock time as double precision.
|
||||
*
|
||||
* Input: none
|
||||
*
|
||||
|
@ -41,10 +41,23 @@
|
|||
* simply use double precision floating point to make usage
|
||||
* easier.
|
||||
*
|
||||
* NOTE: This is not a good way to calculate elapsed time because
|
||||
* it can jump forward or backware via NTP or other manual setting.
|
||||
*
|
||||
* Use the monotonic version for measuring elapsed time.
|
||||
*
|
||||
* History: Originally I called this dtime_now. We ran into issues where
|
||||
* we really cared about elapsed time, rather than wall clock time.
|
||||
* The wall clock time could be wrong at start up time if there
|
||||
* is no realtime clock or Internet access. It can then jump
|
||||
* when GPS time or Internet access becomes available.
|
||||
* All instances of dtime_now should be replaced by dtime_realtime
|
||||
* if we want wall clock time, or dtime_monotonic if it is to be
|
||||
* used for measuring elapsed time, such as between becons.
|
||||
*
|
||||
*---------------------------------------------------------------*/
|
||||
|
||||
|
||||
double dtime_now (void)
|
||||
double dtime_realtime (void)
|
||||
{
|
||||
double result;
|
||||
|
||||
|
@ -63,6 +76,10 @@ double dtime_now (void)
|
|||
struct timespec ts;
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
// Why didn't I use clock_gettime?
|
||||
// Not available before Max OSX 10.12? https://github.com/gambit/gambit/issues/293
|
||||
|
||||
struct timeval tp;
|
||||
gettimeofday(&tp, NULL);
|
||||
ts.tv_nsec = tp.tv_usec * 1000;
|
||||
|
@ -75,6 +92,83 @@ double dtime_now (void)
|
|||
|
||||
#endif
|
||||
|
||||
#if DEBUG
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("dtime_realtime() returns %.3f\n", result );
|
||||
#endif
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
*
|
||||
* Name: dtime_monotonic
|
||||
*
|
||||
* Purpose: Return montonically increasing time, which is not influenced
|
||||
* by the wall clock changing. e.g. leap seconds, NTP adjustments.
|
||||
*
|
||||
* Input: none
|
||||
*
|
||||
* Returns: Time as double precision, so we can get resolution
|
||||
* finer than one second.
|
||||
*
|
||||
* Description: Use this when calculating elapsed time.
|
||||
*
|
||||
*---------------------------------------------------------------*/
|
||||
|
||||
double dtime_monotonic (void)
|
||||
{
|
||||
double result;
|
||||
|
||||
#if __WIN32__
|
||||
|
||||
// FIXME:
|
||||
// This is still returning wall clock time.
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-gettickcount64
|
||||
// GetTickCount64 would be ideal but it requires Vista or Server 2008.
|
||||
// As far as I know, the current version of direwolf still works on XP.
|
||||
//
|
||||
// As a work-around, GetTickCount could be used if we add extra code to deal
|
||||
// with the wrap around after about 49.7 days.
|
||||
// Resolution is only about 10 or 16 milliseconds. Is that good enough?
|
||||
|
||||
/* 64 bit integer is number of 100 nanosecond intervals from Jan 1, 1601. */
|
||||
|
||||
FILETIME ft;
|
||||
|
||||
GetSystemTimeAsFileTime (&ft);
|
||||
|
||||
result = ((( (double)ft.dwHighDateTime * (256. * 256. * 256. * 256.) +
|
||||
(double)ft.dwLowDateTime ) / 10000000.) - 11644473600.);
|
||||
#else
|
||||
/* tv_sec is seconds from Jan 1, 1970. */
|
||||
|
||||
struct timespec ts;
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
// FIXME: Does MacOS have a monotonically increasing time?
|
||||
// https://stackoverflow.com/questions/41509505/clock-gettime-on-macos
|
||||
|
||||
struct timeval tp;
|
||||
gettimeofday(&tp, NULL);
|
||||
ts.tv_nsec = tp.tv_usec * 1000;
|
||||
ts.tv_sec = tp.tv_sec;
|
||||
#else
|
||||
|
||||
// This is the only case handled properly.
|
||||
// Probably the only one that matters.
|
||||
// It is common to have a Raspberry Pi, without Internet,
|
||||
// starting up direwolf before GPS/NTP adjusts the time.
|
||||
|
||||
clock_gettime (CLOCK_MONOTONIC, &ts);
|
||||
#endif
|
||||
|
||||
result = ((double)(ts.tv_sec) + (double)(ts.tv_nsec) * 0.000000001);
|
||||
|
||||
#endif
|
||||
|
||||
#if DEBUG
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("dtime_now() returns %.3f\n", result );
|
||||
|
@ -84,6 +178,7 @@ double dtime_now (void)
|
|||
}
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
*
|
||||
* Name: timestamp_now
|
||||
|
@ -104,7 +199,7 @@ double dtime_now (void)
|
|||
|
||||
void timestamp_now (char *result, int result_size, int show_ms)
|
||||
{
|
||||
double now = dtime_now();
|
||||
double now = dtime_realtime();
|
||||
time_t t = (int)now;
|
||||
struct tm tm;
|
||||
|
||||
|
@ -150,7 +245,7 @@ void timestamp_now (char *result, int result_size, int show_ms)
|
|||
|
||||
void timestamp_user_format (char *result, int result_size, char *user_format)
|
||||
{
|
||||
double now = dtime_now();
|
||||
double now = dtime_realtime();
|
||||
time_t t = (int)now;
|
||||
struct tm tm;
|
||||
|
||||
|
@ -191,7 +286,7 @@ void timestamp_user_format (char *result, int result_size, char *user_format)
|
|||
|
||||
void timestamp_filename (char *result, int result_size)
|
||||
{
|
||||
double now = dtime_now();
|
||||
double now = dtime_realtime();
|
||||
time_t t = (int)now;
|
||||
struct tm tm;
|
||||
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
|
||||
|
||||
extern double dtime_now (void);
|
||||
extern double dtime_realtime (void);
|
||||
|
||||
extern double dtime_monotonic (void);
|
||||
|
||||
|
||||
void timestamp_now (char *result, int result_size, int show_ms);
|
||||
|
||||
void timestamp_user_format (char *result, int result_size, char *user_format);
|
||||
|
||||
void timestamp_filename (char *result, int result_size);
|
||||
|
||||
|
||||
// FIXME: remove temp workaround.
|
||||
// Needs many scattered updates.
|
||||
|
||||
#define dtime_now dtime_realtime
|
||||
|
|
|
@ -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
|
||||
|
|
71
src/dwgpsd.c
71
src/dwgpsd.c
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
||||
//
|
||||
// Copyright (C) 2013, 2014, 2015, 2020 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.
|
||||
*
|
||||
|
@ -57,13 +57,36 @@
|
|||
|
||||
|
||||
|
||||
// An incompatibility was introduced with version 7
|
||||
// and again with 9 and again with 10.
|
||||
// An API incompatibility was introduced with API version 7.
|
||||
// and again with 9.
|
||||
// and again with 10.
|
||||
// We deal with it by using a bunch of conditional code such as:
|
||||
// #if GPSD_API_MAJOR_VERSION >= 9
|
||||
|
||||
#if GPSD_API_MAJOR_VERSION < 5 || GPSD_API_MAJOR_VERSION > 11
|
||||
#error libgps API version might be incompatible.
|
||||
|
||||
// release lib version API Raspberry Pi OS Testing status
|
||||
// 3.22 28 11 bullseye OK.
|
||||
// 3.23 29 12 OK.
|
||||
// 3.25 30 14 OK, Jan. 2023
|
||||
|
||||
|
||||
// Previously the compilation would fail if the API version was later
|
||||
// than the last one tested. Now it is just a warning because it changes so
|
||||
// often but more recent versions have not broken backward compatibility.
|
||||
|
||||
#define MAX_TESTED_VERSION 14
|
||||
|
||||
#if (GPSD_API_MAJOR_VERSION < 5) || (GPSD_API_MAJOR_VERSION > MAX_TESTED_VERSION)
|
||||
#pragma message "Your version of gpsd might be incompatible with this application."
|
||||
#pragma message "The libgps application program interface (API) often"
|
||||
#pragma message "changes to be incompatible with earlier versions."
|
||||
// I could not figure out how to do value substitution here.
|
||||
#pragma message "You have libgpsd API version GPSD_API_MAJOR_VERSION."
|
||||
#pragma message "The last that has been tested is MAX_TESTED_VERSION."
|
||||
#pragma message "Even if this builds successfully, it might not run properly."
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Information for interface to gpsd daemon.
|
||||
*/
|
||||
|
@ -94,7 +117,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.
|
||||
|
@ -163,6 +186,22 @@ static void * read_gpsd_thread (void *arg);
|
|||
* can't find it there. Solution is to define environment variable:
|
||||
*
|
||||
* export LD_LIBRARY_PATH=/use/local/lib
|
||||
*
|
||||
* January 2023: Now using 64 bit Raspberry Pi OS, bullseye.
|
||||
* See https://gitlab.com/gpsd/gpsd/-/blob/master/build.adoc
|
||||
* Try to install in proper library place so we don't have to mess with LD_LIBRARY_PATH.
|
||||
*
|
||||
* (Remove any existing gpsd first so we are not mixing mismatched pieces.)
|
||||
*
|
||||
* sudo apt-get install libncurses5-dev
|
||||
* sudo apt-get install gtk+-3.0
|
||||
*
|
||||
* git clone https://gitlab.com/gpsd/gpsd.git gpsd-gitlab
|
||||
* cd gpsd-gitlab
|
||||
* scons prefix=/usr libdir=lib/aarch64-linux-gnu
|
||||
* [ scons check ]
|
||||
* sudo scons udev-install
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
@ -191,7 +230,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);
|
||||
}
|
||||
|
||||
|
@ -364,6 +403,10 @@ static void * read_gpsd_thread (void *arg)
|
|||
default:
|
||||
case MODE_NOT_SEEN:
|
||||
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");
|
||||
|
@ -393,13 +436,15 @@ static void * read_gpsd_thread (void *arg)
|
|||
|
||||
if (/*gpsdata.stupid_status >= STATUS_FIX &&*/ gpsdata.fix.mode >= MODE_2D) {
|
||||
|
||||
info.dlat = isfinite(gpsdata.fix.latitude) ? gpsdata.fix.latitude : G_UNKNOWN;
|
||||
info.dlon = isfinite(gpsdata.fix.longitude) ? gpsdata.fix.longitude : G_UNKNOWN;
|
||||
#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 = isfinite(gpsdata.fix.track) ? gpsdata.fix.track : G_UNKNOWN;
|
||||
info.speed_knots = isfinite(gpsdata.fix.speed) ? (MPS_TO_KNOTS * gpsdata.fix.speed) : G_UNKNOWN;
|
||||
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 = isfinite(gpsdata.fix.stupid_altitude) ? gpsdata.fix.stupid_altitude : G_UNKNOWN;
|
||||
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.
|
||||
|
|
|
@ -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,
|
||||
*
|
||||
*----------------------------------------------------------------*/
|
||||
|
||||
|
@ -544,6 +551,15 @@ int encode_position (int messaging, int compressed, double lat, double lon, int
|
|||
int result_len = 0;
|
||||
|
||||
if (compressed) {
|
||||
|
||||
// Thought:
|
||||
// https://groups.io/g/direwolf/topic/92718535#6886
|
||||
// When speed is zero, we could put the altitude in the compressed
|
||||
// position rather than having /A=999999.
|
||||
// However, the resolution would be decreased and that could be important
|
||||
// when hiking in hilly terrain. It would also be confusing to
|
||||
// flip back and forth between two different representations.
|
||||
|
||||
aprs_compressed_pos_t *p = (aprs_compressed_pos_t *)presult;
|
||||
|
||||
p->dti = messaging ? '=' : '!';
|
||||
|
@ -629,7 +645,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 +655,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 +785,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 +869,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
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#ifndef FSK_DEMOD_STATE_H
|
||||
|
||||
#include <stdint.h> // int64_t
|
||||
|
||||
#include "rpack.h"
|
||||
|
||||
#include "audio.h" // for enum modem_t
|
||||
|
@ -20,6 +22,32 @@ 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 480 /* 401 is needed for profile A, 300 baud & 44100. Revisit someday. */
|
||||
// Size comes out to 417 for 1200 bps with 48000 sample rate
|
||||
// v1.7 - Was 404. Bump up to 480.
|
||||
|
||||
struct demodulator_state_s
|
||||
{
|
||||
|
@ -39,30 +67,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 +88,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 +118,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 +137,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 +156,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 +167,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;
|
||||
|
@ -232,6 +219,12 @@ struct demodulator_state_s
|
|||
signed int prev_d_c_pll; // Previous value of above, before
|
||||
// incrementing, to detect overflows.
|
||||
|
||||
int pll_symbol_count; // Number symbols during time nudge_total is accumulated.
|
||||
int64_t pll_nudge_total; // Sum of DPLL nudge amounts.
|
||||
// Both of these are cleared at start of frame.
|
||||
// At end of frame, we can see if incoming
|
||||
// baud rate is a little off.
|
||||
|
||||
int prev_demod_data; // Previous data bit detected.
|
||||
// Used to look for transitions.
|
||||
float prev_demod_out_f;
|
||||
|
@ -266,6 +259,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 cumulated round off errors.
|
||||
|
||||
cic_t cic_center1;
|
||||
cic_t cic_above;
|
||||
cic_t cic_below;
|
||||
|
||||
} bb;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// PSK only. //
|
||||
|
|
|
@ -371,6 +371,7 @@ int fx25_pick_mode (int fx_mode, int dlen)
|
|||
// 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.
|
||||
// See https://web.tapr.org/meetings/DCC_2020/JE1WAZ/DCC-2020-PRUG-FINAL.pptx
|
||||
|
||||
static const int prefer[6] = { 0x04, 0x03, 0x06, 0x09, 0x05, 0x01 };
|
||||
for (int k = 0; k < 6; k++) {
|
||||
|
@ -410,19 +411,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 */
|
||||
|
@ -446,12 +453,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;
|
||||
|
@ -482,7 +488,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]);
|
||||
|
@ -497,7 +503,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;
|
||||
}
|
||||
|
||||
|
|
|
@ -258,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++) {
|
||||
|
|
|
@ -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, 2023 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
|
||||
|
@ -56,6 +56,14 @@
|
|||
* gen_packets -n 100 -o z2.wav
|
||||
* atest z2.wav
|
||||
*
|
||||
* Variable speed. e.g. 95% to 105% of normal speed.
|
||||
* Required parameter is max % below and above normal.
|
||||
* Optionally specify step other than 0.1%.
|
||||
* Used to test how tolerant TNCs are to senders not
|
||||
* not using exactly the right baud rate.
|
||||
*
|
||||
* gen_packets -v 5
|
||||
* gen_packets -v 5,0.5
|
||||
*
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
|
@ -67,6 +75,7 @@
|
|||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "audio.h"
|
||||
#include "ax25_pad.h"
|
||||
|
@ -76,6 +85,7 @@
|
|||
#include "morse.h"
|
||||
#include "dtmf.h"
|
||||
#include "fx25.h"
|
||||
#include "il2p.h"
|
||||
|
||||
|
||||
/* Own random number generator so we can get */
|
||||
|
@ -99,6 +109,7 @@ static float g_noise_level = 0;
|
|||
static int g_morse_wpm = 0; /* Send morse code at this speed. */
|
||||
|
||||
|
||||
|
||||
static struct audio_s modem;
|
||||
|
||||
|
||||
|
@ -107,13 +118,48 @@ static void send_packet (char *str)
|
|||
packet_t pp;
|
||||
unsigned char fbuf[AX25_MAX_PACKET_LEN+2];
|
||||
int flen;
|
||||
int c;
|
||||
int c = 0; // channel number.
|
||||
|
||||
if (g_morse_wpm > 0) {
|
||||
|
||||
// TODO: Why not use the destination field instead of command line option?
|
||||
// Why not use the destination field instead of command line option?
|
||||
// For one thing, this is not in TNC-2 monitor format.
|
||||
|
||||
morse_send (0, str, g_morse_wpm, 100, 100);
|
||||
morse_send (c, str, g_morse_wpm, 100, 100);
|
||||
}
|
||||
else if (modem.achan[0].modem_type == MODEM_EAS) {
|
||||
|
||||
// Generate EAS SAME signal FOR RESEARCH AND TESTING ONLY!!!
|
||||
// There could be legal consequences for sending unauhorized SAME
|
||||
// over the radio so don't do it!
|
||||
|
||||
// I'm expecting to see TNC 2 monitor format.
|
||||
// The source and destination are ignored.
|
||||
// The optional destination SSID is the number of times to repeat.
|
||||
// The user defined data type indicator can optionally be used
|
||||
// for compatibility with how it is received and presented to client apps.
|
||||
// Examples:
|
||||
// X>X-3:{DEZCZC-WXR-RWT-033019-033017-033015-033013-033011-025011-025017-033007-033005-033003-033001-025009-025027-033009+0015-1691525-KGYX/NWS-
|
||||
// X>X:NNNN
|
||||
|
||||
pp = ax25_from_text (str, 1);
|
||||
if (pp == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("\"%s\" is not valid TNC2 monitoring format.\n", str);
|
||||
return;
|
||||
}
|
||||
unsigned char *pinfo;
|
||||
int info_len = ax25_get_info (pp, &pinfo);
|
||||
if (info_len >= 3 && strncmp((char*)pinfo, "{DE", 3) == 0) {
|
||||
pinfo += 3;
|
||||
info_len -= 3;
|
||||
}
|
||||
|
||||
int repeat = ax25_get_ssid (pp, AX25_DESTINATION);
|
||||
if (repeat == 0) repeat = 1;
|
||||
|
||||
eas_send (c, pinfo, repeat, 500, 500);
|
||||
ax25_delete (pp);
|
||||
}
|
||||
else {
|
||||
pp = ax25_from_text (str, 1);
|
||||
|
@ -123,6 +169,10 @@ static void send_packet (char *str)
|
|||
return;
|
||||
}
|
||||
flen = ax25_pack (pp, fbuf);
|
||||
(void)flen;
|
||||
|
||||
// If stereo, put same thing in each channel.
|
||||
|
||||
for (c=0; c<modem.adev[0].num_channels; c++)
|
||||
{
|
||||
|
||||
|
@ -151,12 +201,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 +224,12 @@ 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
|
||||
double variable_speed_max_error = 0; // both in percent
|
||||
double variable_speed_increment = 0.1;
|
||||
|
||||
|
||||
/*
|
||||
* Set up default values for the modem.
|
||||
|
@ -195,7 +249,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 +281,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:v:",
|
||||
long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
@ -266,23 +320,31 @@ int main(int argc, char **argv)
|
|||
|
||||
// FIXME: options should not be order dependent.
|
||||
|
||||
if (strcasecmp(optarg, "EAS") == 0) {
|
||||
modem.achan[0].baud = 0xEA5EA5; // See special case below.
|
||||
}
|
||||
else {
|
||||
modem.achan[0].baud = atoi(optarg);
|
||||
}
|
||||
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("Data rate set to %d bits / second.\n", modem.achan[0].baud);
|
||||
if (modem.achan[0].baud != 100 && (modem.achan[0].baud < MIN_BAUD || modem.achan[0].baud > MAX_BAUD)) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Use a more reasonable bit rate in range of %d - %d.\n", MIN_BAUD, MAX_BAUD);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* 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 (modem.achan[0].baud == 100) {
|
||||
if (modem.achan[0].baud == 100) { // What was this for?
|
||||
modem.achan[0].modem_type = MODEM_AFSK;
|
||||
modem.achan[0].mark_freq = 1615;
|
||||
modem.achan[0].space_freq = 1785;
|
||||
}
|
||||
else if (modem.achan[0].baud == 0xEA5EA5) {
|
||||
modem.achan[0].baud = 521; // Fine tuned later. 520.83333
|
||||
// Proper fix is to make this float.
|
||||
modem.achan[0].modem_type = MODEM_EAS;
|
||||
modem.achan[0].mark_freq = 2083.3333; // Ideally these should be floating point.
|
||||
modem.achan[0].space_freq = 1562.5000 ;
|
||||
}
|
||||
else if (modem.achan[0].baud < 600) {
|
||||
modem.achan[0].modem_type = MODEM_AFSK;
|
||||
modem.achan[0].mark_freq = 1600; // Typical for HF SSB
|
||||
|
@ -318,6 +380,11 @@ int main(int argc, char **argv)
|
|||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("Using scrambled baseband signal rather than AFSK.\n");
|
||||
}
|
||||
if (modem.achan[0].baud != 100 && (modem.achan[0].baud < MIN_BAUD || modem.achan[0].baud > MAX_BAUD)) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Use a more reasonable bit rate in range of %d - %d.\n", MIN_BAUD, MAX_BAUD);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'g': /* -g for g3ruh scrambling */
|
||||
|
@ -424,7 +491,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 +520,27 @@ 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 'v': // Variable speed data + an - this percentage
|
||||
// optional comma and increment.
|
||||
|
||||
variable_speed_max_error = fabs(atof(optarg));
|
||||
char *q = strchr(optarg, ',');
|
||||
if (q != NULL) {
|
||||
variable_speed_increment = fabs(atof(q+1));
|
||||
}
|
||||
break;
|
||||
|
||||
case '?':
|
||||
|
@ -466,7 +553,7 @@ int main(int argc, char **argv)
|
|||
|
||||
/* Should not be here. */
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf("?? getopt returned character code 0%o ??\n", c);
|
||||
dw_printf("?? getopt returned character code 0%o ??\n", (unsigned)c);
|
||||
usage (argv);
|
||||
}
|
||||
}
|
||||
|
@ -507,6 +594,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 +660,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);
|
||||
|
@ -597,8 +722,34 @@ int main(int argc, char **argv)
|
|||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("built in message...\n");
|
||||
|
||||
//
|
||||
// Generate packets with variable speed.
|
||||
// This overrides any other number of packets or adding noise.
|
||||
//
|
||||
|
||||
if (packet_count > 0) {
|
||||
|
||||
if (variable_speed_max_error != 0) {
|
||||
|
||||
int normal_speed = modem.achan[0].baud;
|
||||
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("Variable speed.\n");
|
||||
|
||||
for (double speed_error = - variable_speed_max_error;
|
||||
speed_error <= variable_speed_max_error + 0.001;
|
||||
speed_error += variable_speed_increment) {
|
||||
|
||||
// Baud is int so we get some roundoff. Make it real?
|
||||
modem.achan[0].baud = (int)round(normal_speed * (1. + speed_error / 100.));
|
||||
gen_tone_init (&modem, amplitude/2, 1);
|
||||
|
||||
char stemp[256];
|
||||
snprintf (stemp, sizeof(stemp), "WB2OSZ-15>TEST:, speed %+0.1f%% The quick brown fox jumps over the lazy dog!", speed_error);
|
||||
send_packet (stemp);
|
||||
}
|
||||
}
|
||||
|
||||
else if (packet_count > 0) {
|
||||
|
||||
/*
|
||||
* Generate packets with increasing noise level.
|
||||
|
@ -640,15 +791,24 @@ int main(int argc, char **argv)
|
|||
}
|
||||
else {
|
||||
|
||||
// This should send a total of 6.
|
||||
// Note that sticking in the user defined type {DE is optional.
|
||||
|
||||
if (modem.achan[0].modem_type == MODEM_EAS) {
|
||||
send_packet ("X>X-3:{DEZCZC-WXR-RWT-033019-033017-033015-033013-033011-025011-025017-033007-033005-033003-033001-025009-025027-033009+0015-1691525-KGYX/NWS-");
|
||||
send_packet ("X>X-2:{DENNNN");
|
||||
send_packet ("X>X:NNNN");
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* Builtin default 4 packets.
|
||||
*/
|
||||
|
||||
send_packet ("WB2OSZ-15>TEST:,The quick brown fox jumps over the lazy dog! 1 of 4");
|
||||
send_packet ("WB2OSZ-15>TEST:,The quick brown fox jumps over the lazy dog! 2 of 4");
|
||||
send_packet ("WB2OSZ-15>TEST:,The quick brown fox jumps over the lazy dog! 3 of 4");
|
||||
send_packet ("WB2OSZ-15>TEST:,The quick brown fox jumps over the lazy dog! 4 of 4");
|
||||
}
|
||||
}
|
||||
|
||||
audio_file_close();
|
||||
|
||||
|
@ -665,11 +825,13 @@ static void usage (char **argv)
|
|||
dw_printf ("Options:\n");
|
||||
dw_printf (" -a <number> Signal amplitude in range of 0 - 200%%. Default 50.\n");
|
||||
dw_printf (" -b <number> Bits / second for data. Default is %d.\n", DEFAULT_BAUD);
|
||||
dw_printf (" -B <number> Bits / second for data. Proper modem selected for 300, 1200, 2400, 4800, 9600.\n");
|
||||
dw_printf (" -B <number> Bits / second for data. Proper modem selected for 300, 1200, 2400, 4800, 9600, EAS.\n");
|
||||
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);
|
||||
|
@ -677,6 +839,7 @@ static void usage (char **argv)
|
|||
dw_printf (" -o <file> Send output to .wav file.\n");
|
||||
dw_printf (" -8 8 bit audio rather than 16.\n");
|
||||
dw_printf (" -2 2 channels (stereo) audio rather than one channel.\n");
|
||||
dw_printf (" -v max[,incr] Variable speed with specified maximum error and increment.\n");
|
||||
// dw_printf (" -z <number> Number of leading zero bits before frame.\n");
|
||||
// dw_printf (" Default is 12 which is .01 seconds at 1200 bits/sec.\n");
|
||||
|
||||
|
@ -685,6 +848,7 @@ static void usage (char **argv)
|
|||
dw_printf ("the default built-in message. The format should correspond to\n");
|
||||
dw_printf ("the standard packet monitoring representation such as,\n\n");
|
||||
dw_printf (" WB2OSZ-1>APDW12,WIDE2-2:!4237.14NS07120.83W#\n");
|
||||
dw_printf ("User defined content can't be used with -n option.\n");
|
||||
dw_printf ("\n");
|
||||
dw_printf ("Example: gen_packets -o x.wav \n");
|
||||
dw_printf ("\n");
|
||||
|
|
177
src/gen_tone.c
177
src/gen_tone.c
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
||||
//
|
||||
// Copyright (C) 2011, 2014, 2015, 2016, 2019 John Langner, WB2OSZ
|
||||
// Copyright (C) 2011, 2014, 2015, 2016, 2019, 2023 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
|
||||
|
@ -70,6 +70,7 @@ static int ticks_per_sample[MAX_CHANS]; /* Same for both channels of same soundc
|
|||
static int ticks_per_bit[MAX_CHANS];
|
||||
static int f1_change_per_sample[MAX_CHANS];
|
||||
static int f2_change_per_sample[MAX_CHANS];
|
||||
static float samples_per_symbol[MAX_CHANS];
|
||||
|
||||
|
||||
static short sine_table[256];
|
||||
|
@ -164,7 +165,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);
|
||||
|
||||
|
@ -198,8 +199,11 @@ int gen_tone_init (struct audio_s *audio_config_p, int amp, int gen_packets)
|
|||
ticks_per_bit[chan] = (int) ((TICKS_PER_CYCLE / ((double)audio_config_p->achan[chan].baud * 0.5)) + 0.5);
|
||||
f1_change_per_sample[chan] = (int) (((double)audio_config_p->achan[chan].mark_freq * TICKS_PER_CYCLE / (double)audio_config_p->adev[a].samples_per_sec ) + 0.5);
|
||||
f2_change_per_sample[chan] = f1_change_per_sample[chan]; // Not used.
|
||||
samples_per_symbol[chan] = 2. * (float)audio_config_p->adev[a].samples_per_sec / (float)audio_config_p->achan[chan].baud;
|
||||
|
||||
tone_phase[chan] = PHASE_SHIFT_45; // Just to mimic first attempt.
|
||||
// ??? Why? We are only concerned with the difference
|
||||
// from one symbol to the next.
|
||||
break;
|
||||
|
||||
case MODEM_8PSK:
|
||||
|
@ -211,6 +215,7 @@ int gen_tone_init (struct audio_s *audio_config_p, int amp, int gen_packets)
|
|||
ticks_per_bit[chan] = (int) ((TICKS_PER_CYCLE / ((double)audio_config_p->achan[chan].baud / 3.)) + 0.5);
|
||||
f1_change_per_sample[chan] = (int) (((double)audio_config_p->achan[chan].mark_freq * TICKS_PER_CYCLE / (double)audio_config_p->adev[a].samples_per_sec ) + 0.5);
|
||||
f2_change_per_sample[chan] = f1_change_per_sample[chan]; // Not used.
|
||||
samples_per_symbol[chan] = 3. * (float)audio_config_p->adev[a].samples_per_sec / (float)audio_config_p->achan[chan].baud;
|
||||
break;
|
||||
|
||||
case MODEM_BASEBAND:
|
||||
|
@ -220,11 +225,23 @@ int gen_tone_init (struct audio_s *audio_config_p, int amp, int gen_packets)
|
|||
// Tone is half baud.
|
||||
ticks_per_bit[chan] = (int) ((TICKS_PER_CYCLE / (double)audio_config_p->achan[chan].baud ) + 0.5);
|
||||
f1_change_per_sample[chan] = (int) (((double)audio_config_p->achan[chan].baud * 0.5 * TICKS_PER_CYCLE / (double)audio_config_p->adev[a].samples_per_sec ) + 0.5);
|
||||
samples_per_symbol[chan] = (float)audio_config_p->adev[a].samples_per_sec / (float)audio_config_p->achan[chan].baud;
|
||||
break;
|
||||
|
||||
case MODEM_EAS: // EAS.
|
||||
|
||||
// TODO: Proper fix would be to use float for baud, mark, space.
|
||||
|
||||
ticks_per_bit[chan] = (int) ((TICKS_PER_CYCLE / 520.833333333333 ) + 0.5);
|
||||
samples_per_symbol[chan] = (int)((audio_config_p->adev[a].samples_per_sec / 520.83333) + 0.5);
|
||||
f1_change_per_sample[chan] = (int) ((2083.33333333333 * TICKS_PER_CYCLE / (double)audio_config_p->adev[a].samples_per_sec ) + 0.5);
|
||||
f2_change_per_sample[chan] = (int) ((1562.5000000 * TICKS_PER_CYCLE / (double)audio_config_p->adev[a].samples_per_sec ) + 0.5);
|
||||
break;
|
||||
|
||||
default: // AFSK
|
||||
|
||||
ticks_per_bit[chan] = (int) ((TICKS_PER_CYCLE / (double)audio_config_p->achan[chan].baud ) + 0.5);
|
||||
samples_per_symbol[chan] = (float)audio_config_p->adev[a].samples_per_sec / (float)audio_config_p->achan[chan].baud;
|
||||
f1_change_per_sample[chan] = (int) (((double)audio_config_p->achan[chan].mark_freq * TICKS_PER_CYCLE / (double)audio_config_p->adev[a].samples_per_sec ) + 0.5);
|
||||
f2_change_per_sample[chan] = (int) (((double)audio_config_p->achan[chan].space_freq * TICKS_PER_CYCLE / (double)audio_config_p->adev[a].samples_per_sec ) + 0.5);
|
||||
break;
|
||||
|
@ -285,9 +302,64 @@ int gen_tone_init (struct audio_s *audio_config_p, int amp, int gen_packets)
|
|||
*
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
// Interpolate between two values.
|
||||
// My original approximation simply jumped between phases, producing a discontinuity,
|
||||
// and increasing bandwidth.
|
||||
// According to multiple sources, we should transition more gently.
|
||||
// Below see see a rough approximation of:
|
||||
// * A step function, immediately going to new value.
|
||||
// * Linear interpoation.
|
||||
// * Raised cosine. Square root of cosine is also mentioned.
|
||||
//
|
||||
// new - / --
|
||||
// | / /
|
||||
// | / |
|
||||
// | / /
|
||||
// old ------- / --
|
||||
// step linear raised cosine
|
||||
//
|
||||
// Inputs are the old (previous value), new value, and a blending control
|
||||
// 0 -> take old value
|
||||
// 1 -> take new value.
|
||||
// inbetween some sort of weighted average.
|
||||
|
||||
static inline float interpol8 (float oldv, float newv, float bc)
|
||||
{
|
||||
// Step function.
|
||||
//return (newv); // 78 on 11/7
|
||||
|
||||
assert (bc >= 0);
|
||||
assert (bc <= 1.1);
|
||||
|
||||
if (bc < 0) return (oldv);
|
||||
if (bc > 1) return (newv);
|
||||
|
||||
// Linear interpolation, just for comparison.
|
||||
//return (bc * newv + (1.0f - bc) * oldv); // 39 on 11/7
|
||||
|
||||
float rc = 0.5f * (cosf(bc * M_PI - M_PI) + 1.0f);
|
||||
float rrc = bc >= 0.5f
|
||||
? 0.5f * (sqrtf(fabsf(cosf(bc * M_PI - M_PI))) + 1.0f)
|
||||
: 0.5f * (-sqrtf(fabsf(cosf(bc * M_PI - M_PI))) + 1.0f);
|
||||
|
||||
(void)rrc;
|
||||
return (rc * newv + (1.0f - bc) * oldv); // 49 on 11/7
|
||||
//return (rrc * newv + (1.0f - bc) * oldv); // 55 on 11/7
|
||||
}
|
||||
|
||||
static const int gray2phase_v26[4] = {0, 1, 3, 2};
|
||||
static const int gray2phase_v27[8] = {1, 0, 2, 3, 6, 7, 5, 4};
|
||||
|
||||
// #define PSKIQ 1 // not ready for prime time yet.
|
||||
#if PSKIQ
|
||||
static int xmit_octant[MAX_CHANS]; // absolute phase in 45 degree units.
|
||||
static int xmit_prev_octant[MAX_CHANS]; // from previous symbol.
|
||||
|
||||
// For PSK, we generate the final signal by combining fixed frequency cosine and
|
||||
// sine by the following weights.
|
||||
static const float ci[8] = { 1, .7071, 0, -.7071, -1, -.7071, 0, .7071 };
|
||||
static const float sq[8] = { 0, .7071, 1, .7071, 0, -.7071, -1, -.7071 };
|
||||
#endif
|
||||
|
||||
void tone_gen_put_bit (int chan, int dat)
|
||||
{
|
||||
|
@ -295,7 +367,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;
|
||||
|
@ -324,14 +396,28 @@ void tone_gen_put_bit (int chan, int dat)
|
|||
|
||||
// All zero bits should give us steady 1800 Hz.
|
||||
// All one bits should flip phase by 180 degrees each time.
|
||||
// For V.26B, add another 45 degrees.
|
||||
// This seems to work a little better.
|
||||
|
||||
dibit = (save_bit[chan] << 1) | dat;
|
||||
|
||||
symbol = gray2phase_v26[dibit];
|
||||
symbol = gray2phase_v26[dibit]; // 0 .. 3 for QPSK.
|
||||
#if PSKIQ
|
||||
// One phase shift unit is 45 degrees.
|
||||
// Remember what it was last time and calculate new.
|
||||
// values 0 .. 7.
|
||||
xmit_prev_octant[chan] = xmit_octant[chan];
|
||||
xmit_octant[chan] += symbol * 2;
|
||||
if (save_audio_config_p->achan[chan].v26_alternative == V26_B) {
|
||||
xmit_octant[chan] += 1;
|
||||
}
|
||||
xmit_octant[chan] &= 0x7;
|
||||
#else
|
||||
tone_phase[chan] += symbol * PHASE_SHIFT_90;
|
||||
if (save_audio_config_p->achan[chan].v26_alternative == V26_B) {
|
||||
tone_phase[chan] += PHASE_SHIFT_45;
|
||||
}
|
||||
#endif
|
||||
bit_count[chan]++;
|
||||
}
|
||||
|
||||
|
@ -360,14 +446,19 @@ 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;
|
||||
lfsr[chan] = (lfsr[chan] << 1) | (x & 1);
|
||||
dat = x;
|
||||
}
|
||||
|
||||
#if PSKIQ
|
||||
int blend = 1;
|
||||
#endif
|
||||
do { /* until enough audio samples for this symbol. */
|
||||
|
||||
int sam;
|
||||
|
@ -380,14 +471,70 @@ 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;
|
||||
|
||||
case MODEM_EAS:
|
||||
|
||||
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;
|
||||
|
||||
case MODEM_QPSK:
|
||||
case MODEM_8PSK:
|
||||
|
||||
#if DEBUG2
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("tone_gen_put_bit %d PSK\n", __LINE__);
|
||||
#endif
|
||||
tone_phase[chan] += f1_change_per_sample[chan];
|
||||
#if PSKIQ
|
||||
#if 1 // blend JWL
|
||||
// remove loop invariant
|
||||
float old_i = ci[xmit_prev_octant[chan]];
|
||||
float old_q = sq[xmit_prev_octant[chan]];
|
||||
|
||||
float new_i = ci[xmit_octant[chan]];
|
||||
float new_q = sq[xmit_octant[chan]];
|
||||
|
||||
float b = blend / samples_per_symbol[chan]; // roughly 0 to 1
|
||||
blend++;
|
||||
// b = (b - 0.5) * 20 + 0.5;
|
||||
// if (b < 0) b = 0;
|
||||
// if (b > 1) b = 1;
|
||||
// b = b > 0.5;
|
||||
//b = 1; // 78 decoded with this.
|
||||
// only 39 without.
|
||||
|
||||
|
||||
//float blended_i = new_i * b + old_i * (1.0f - b);
|
||||
//float blended_q = new_q * b + old_q * (1.0f - b);
|
||||
|
||||
float blended_i = interpol8 (old_i, new_i, b);
|
||||
float blended_q = interpol8 (old_q, new_q, b);
|
||||
|
||||
sam = blended_i * sine_table[((tone_phase[chan] - PHASE_SHIFT_90) >> 24) & 0xff] +
|
||||
blended_q * sine_table[(tone_phase[chan] >> 24) & 0xff];
|
||||
#else // jump
|
||||
sam = ci[xmit_octant[chan]] * sine_table[((tone_phase[chan] - PHASE_SHIFT_90) >> 24) & 0xff] +
|
||||
sq[xmit_octant[chan]] * sine_table[(tone_phase[chan] >> 24) & 0xff];
|
||||
#endif
|
||||
#else
|
||||
sam = sine_table[(tone_phase[chan] >> 24) & 0xff];
|
||||
#endif
|
||||
gen_tone_put_sample (chan, a, sam);
|
||||
break;
|
||||
|
||||
case MODEM_8PSK:
|
||||
#if DEBUG2
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("tone_gen_put_bit %d PSK\n", __LINE__);
|
||||
|
@ -511,6 +658,20 @@ void gen_tone_put_sample (int chan, int a, int sam) {
|
|||
}
|
||||
}
|
||||
|
||||
void gen_tone_put_quiet_ms (int chan, int time_ms) {
|
||||
|
||||
int a = ACHAN2ADEV(chan); /* device for channel. */
|
||||
int sam = 0;
|
||||
|
||||
int nsamples = (int) ((time_ms * (float)save_audio_config_p->adev[a].samples_per_sec / 1000.) + 0.5);
|
||||
|
||||
for (int j=0; j<nsamples; j++) {
|
||||
gen_tone_put_sample (chan, a, sam);
|
||||
};
|
||||
|
||||
// Avoid abrupt change when it starts up again.
|
||||
tone_phase[chan] = 0;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------
|
||||
|
|
|
@ -15,3 +15,5 @@ int gen_tone_init (struct audio_s *pp, int amp, int gen_packets);
|
|||
void tone_gen_put_bit (int chan, int dat);
|
||||
|
||||
void gen_tone_put_sample (int chan, int a, int sam);
|
||||
|
||||
void gen_tone_put_quiet_ms (int chan, int time_ms);
|
|
@ -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)) {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "ax25_pad.h" /* for packet_t, alevel_t */
|
||||
#include "rrbb.h"
|
||||
#include "audio.h" /* for struct audio_s */
|
||||
#include "dlq.h" // for fec_type_t definition.
|
||||
|
||||
|
||||
|
||||
|
@ -62,6 +63,6 @@ int hdlc_rec2_try_to_fix_later (rrbb_t block, int chan, int subchan, int slice,
|
|||
|
||||
/* Provided by the top level application to process a complete frame. */
|
||||
|
||||
void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alevel_t level, int is_fx25, retry_t retries, char *spectrum);
|
||||
void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alevel_t level, fec_type_t fec_type, retry_t retries, char *spectrum);
|
||||
|
||||
#endif
|
||||
|
|
212
src/hdlc_send.c
212
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];
|
||||
|
||||
|
@ -251,4 +295,82 @@ static void send_bit (int chan, int b)
|
|||
number_of_bits_sent[chan]++;
|
||||
}
|
||||
|
||||
|
||||
// The rest of this is for EAS SAME.
|
||||
// This is sort of a logical place because it serializes a frame, but not in HDLC.
|
||||
// We have a parallel where SAME deserialization is in hdlc_rec.
|
||||
// Maybe both should be pulled out and moved to a same.c.
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------
|
||||
*
|
||||
* Name: eas_send
|
||||
*
|
||||
* Purpose: Serialize EAS SAME for transmission.
|
||||
*
|
||||
* Inputs: chan - Radio channel number.
|
||||
* str - Character string to send.
|
||||
* repeat - Number of times to repeat with 1 sec quiet between.
|
||||
* txdelay - Delay (ms) from PTT to first preamble bit.
|
||||
* txtail - Delay (ms) from last data bit to PTT off.
|
||||
*
|
||||
*
|
||||
* Returns: Total number of milliseconds to activate PTT.
|
||||
* This includes delays before the first character
|
||||
* and after the last to avoid chopping off part of it.
|
||||
*
|
||||
* Description: xmit_thread calls this instead of the usual hdlc_send
|
||||
* when we have a special packet that means send EAS SAME
|
||||
* code.
|
||||
*
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
static inline void eas_put_byte (int chan, unsigned char b)
|
||||
{
|
||||
for (int n=0; n<8; n++) {
|
||||
tone_gen_put_bit (chan, (b & 1));
|
||||
b >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
int eas_send (int chan, unsigned char *str, int repeat, int txdelay, int txtail)
|
||||
{
|
||||
int bytes_sent = 0;
|
||||
const int gap = 1000;
|
||||
int gaps_sent = 0;
|
||||
|
||||
gen_tone_put_quiet_ms (chan, txdelay);
|
||||
|
||||
for (int r=0; r<repeat; r++ ) {
|
||||
for (int j=0; j<16; j++) {
|
||||
eas_put_byte (chan, 0xAB);
|
||||
bytes_sent++;
|
||||
}
|
||||
|
||||
for (unsigned char *p = str; *p != '\0'; p++) {
|
||||
eas_put_byte (chan, *p);
|
||||
bytes_sent++;
|
||||
}
|
||||
|
||||
if (r < repeat-1) {
|
||||
gen_tone_put_quiet_ms (chan, gap);
|
||||
gaps_sent++;
|
||||
}
|
||||
}
|
||||
|
||||
gen_tone_put_quiet_ms (chan, txtail);
|
||||
|
||||
audio_flush(ACHAN2ADEV(chan));
|
||||
|
||||
int elapsed = txdelay + (int) (bytes_sent * 8 * 1.92) + (gaps_sent * gap) + txtail;
|
||||
|
||||
// dw_printf ("DEBUG: EAS total time = %d ms\n", elapsed);
|
||||
|
||||
return (elapsed);
|
||||
|
||||
} /* end eas_send */
|
||||
|
||||
|
||||
|
||||
|
||||
/* end hdlc_send.c */
|
|
@ -1,9 +1,21 @@
|
|||
|
||||
/* 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 mode.
|
||||
|
||||
int hdlc_send_flags (int chan, int flags, int finish);
|
||||
// eas_send fits here logically because it also serializes a packet.
|
||||
|
||||
|
||||
#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);
|
||||
|
||||
int eas_send (int chan, unsigned char *str, int repeat, int txdelay, int txtail);
|
||||
|
||||
/* end hdlc_send.h */
|
||||
|
||||
|
|
255
src/igate.c
255
src/igate.c
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
||||
//
|
||||
// Copyright (C) 2013, 2014, 2015, 2016 John Langner, WB2OSZ
|
||||
// Copyright (C) 2013, 2014, 2015, 2016, 2023 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
|
||||
|
@ -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);
|
||||
|
@ -201,6 +203,8 @@ static char * ia_to_text (int Family, void * pAddr, char * pStringBuf, size_t S
|
|||
|
||||
#if ITEST
|
||||
|
||||
// TODO: Add to automated tests.
|
||||
|
||||
/* For unit testing. */
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
|
@ -324,7 +328,7 @@ static int stats_uplink_packets; /* Number of packets passed along to the IGate
|
|||
/* server after filtering. */
|
||||
|
||||
static int stats_uplink_bytes; /* Total number of bytes sent to IGate server */
|
||||
/* including login, packets, and hearbeats. */
|
||||
/* including login, packets, and heartbeats. */
|
||||
|
||||
static int stats_downlink_bytes; /* Total number of bytes from IGate server including */
|
||||
/* packets, heartbeats, other messages. */
|
||||
|
@ -851,6 +855,9 @@ static void * connnect_thread (void *arg)
|
|||
* Purpose: Send a packet to the IGate server
|
||||
*
|
||||
* Inputs: chan - Radio channel it was received on.
|
||||
* This is required for the RF>IS filtering.
|
||||
* Beaconing (sendto=ig, chan=-1) and a client app sending
|
||||
* to ICHANNEL should bypass the filtering.
|
||||
*
|
||||
* recv_pp - Pointer to packet object.
|
||||
* *** CALLER IS RESPONSIBLE FOR DELETING IT! **
|
||||
|
@ -898,7 +905,12 @@ void igate_send_rec_packet (int chan, packet_t recv_pp)
|
|||
* In that case, the payload will have TCPIP in the path and it will be dropped.
|
||||
*/
|
||||
|
||||
if (save_digi_config_p->filter_str[chan][MAX_CHANS] != NULL) {
|
||||
// Apply RF>IS filtering only if it same from a radio channel.
|
||||
// Beacon will be channel -1.
|
||||
// Client app to ICHANNEL is outside of radio channel range.
|
||||
|
||||
if (chan >= 0 && chan < MAX_CHANS && // in radio channel range
|
||||
save_digi_config_p->filter_str[chan][MAX_CHANS] != NULL) {
|
||||
|
||||
if (pfilter(chan, MAX_CHANS, save_digi_config_p->filter_str[chan][MAX_CHANS], recv_pp, 1) != 1) {
|
||||
|
||||
|
@ -1217,7 +1229,7 @@ static void send_packet_to_server (packet_t pp, int chan)
|
|||
* Name: send_msg_to_server
|
||||
*
|
||||
* Purpose: Send something to the IGate server.
|
||||
* This one function should be used for login, hearbeats,
|
||||
* This one function should be used for login, heartbeats,
|
||||
* and packets.
|
||||
*
|
||||
* Inputs: imsg - Message. We will add CR/LF here.
|
||||
|
@ -1469,7 +1481,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 +1516,64 @@ 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;
|
||||
|
||||
// My original poorly thoughtout idea was to parse it into a packet object,
|
||||
// using the non-strict option, and send to the client app.
|
||||
//
|
||||
// A lot of things can go wrong with that approach.
|
||||
|
||||
// (1) Up to 8 digipeaters are allowed in radio format.
|
||||
// There is a potential of finding a larger number here.
|
||||
//
|
||||
// (2) The via path can have names that are not valid in the radio format.
|
||||
// e.g. qAC, T2HAKATA, N5JXS-F1.
|
||||
// Non-strict parsing would force uppercase, truncate names too long,
|
||||
// and drop unacceptable SSIDs.
|
||||
//
|
||||
// (3) The source address could be invalid for the RF address format.
|
||||
// e.g. WHO-IS>APJIW4,TCPIP*,qAC,AE5PL-JF::ZL1JSH-9 :Charles Beadfield/New Zealand{583
|
||||
// That is essential information that we absolutely need to preserve.
|
||||
//
|
||||
// I think the only correct solution is to apply a third party header
|
||||
// wrapper so the original contents are preserved. This will be a little
|
||||
// more work for the application developer. Search for ":}" and use only
|
||||
// the part after that. At this point, I don't see any value in encoding
|
||||
// information in the source/destination so I will just use "X>X:}" as a prefix
|
||||
|
||||
char stemp[AX25_MAX_INFO_LEN];
|
||||
strlcpy (stemp, "X>X:}", sizeof(stemp));
|
||||
strlcat (stemp, (char*)message, sizeof(stemp));
|
||||
|
||||
packet_t pp3 = ax25_from_text(stemp, 0); // 0 means not strict
|
||||
if (pp3 != NULL) {
|
||||
|
||||
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;
|
||||
fec_type_t fec_type = fec_type_none;
|
||||
char spectrum[] = "APRS-IS";
|
||||
dlq_rec_frame (ichan, subchan, slice, pp3, alevel, fec_type, 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 +1608,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.
|
||||
*
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
@ -1652,7 +1727,14 @@ static void * satgate_delay_thread (void *arg)
|
|||
* K1RI-2>APWW10,WIDE1-1,WIDE2-1,qAS,K1RI:/221700h/9AmA<Ct3_ sT010/002g005t045r000p023P020h97b10148
|
||||
* KC1BOS-2>T3PQ3S,WIDE1-1,WIDE2-1,qAR,W1TG-1:`c)@qh\>/"50}TinyTrak4 Mobile
|
||||
*
|
||||
* Notice how the final address in the header might not
|
||||
* This is interesting because the source is not a valid AX.25 address.
|
||||
* Non-RF stations can have 2 alphanumeric characters for SSID.
|
||||
* In this example, the WHO-IS server is responding to a message.
|
||||
*
|
||||
* WHO-IS>APJIW4,TCPIP*,qAC,AE5PL-JF::ZL1JSH-9 :Charles Beadfield/New Zealand{583
|
||||
*
|
||||
*
|
||||
* Notice how the final digipeater address, in the header, might not
|
||||
* be a valid AX.25 address. We see a 9 character address
|
||||
* (with no ssid) and an ssid of two letters.
|
||||
* We don't care because we end up discarding them before
|
||||
|
@ -1667,29 +1749,61 @@ static void * satgate_delay_thread (void *arg)
|
|||
*
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
// It is unforunate that the : data type indicator (DTI) was overloaded with
|
||||
// so many different meanings. Simply looking at the DTI is not adequate for
|
||||
// determining whether a packet is a message.
|
||||
// We need to exclude the other special cases of telemetry metadata,
|
||||
// bulletins, and weather bulletins.
|
||||
|
||||
static int is_message_message (char *infop)
|
||||
{
|
||||
if (*infop != ':') return (0);
|
||||
if (strlen(infop) < 11) return (0); // too short for : addressee :
|
||||
if (strlen(infop) >= 16) {
|
||||
if (strncmp(infop+10, ":PARM.", 6) == 0) return (0);
|
||||
if (strncmp(infop+10, ":UNIT.", 6) == 0) return (0);
|
||||
if (strncmp(infop+10, ":EQNS.", 6) == 0) return (0);
|
||||
if (strncmp(infop+10, ":BITS.", 6) == 0) return (0);
|
||||
}
|
||||
if (strlen(infop) >= 4) {
|
||||
if (strncmp(infop+1, "BLN", 3) == 0) return (0);
|
||||
if (strncmp(infop+1, "NWS", 3) == 0) return (0);
|
||||
if (strncmp(infop+1, "SKY", 3) == 0) return (0);
|
||||
if (strncmp(infop+1, "CWA", 3) == 0) return (0);
|
||||
if (strncmp(infop+1, "BOM", 3) == 0) return (0);
|
||||
}
|
||||
return (1); // message, including ack, rej
|
||||
}
|
||||
|
||||
|
||||
static void maybe_xmit_packet_from_igate (char *message, int to_chan)
|
||||
{
|
||||
packet_t pp3;
|
||||
char payload[AX25_MAX_PACKET_LEN]; /* what is max len? */
|
||||
char src[AX25_MAX_ADDR_LEN]; /* Source address. */
|
||||
|
||||
char *pinfo = NULL;
|
||||
int info_len;
|
||||
int n;
|
||||
|
||||
assert (to_chan >= 0 && to_chan < MAX_CHANS);
|
||||
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* Try to parse it into a packet object; we need this for the packet filtering.
|
||||
*
|
||||
* Bug: Up to 8 digipeaters are allowed in radio format.
|
||||
* There is a potential of finding a larger number here.
|
||||
* We use the non-strict option because there the via path can have:
|
||||
* - station names longer than 6.
|
||||
* - alphanumeric SSID.
|
||||
* - lower case for "q constructs.
|
||||
* We don't care about any of those because the via path will be discarded anyhow.
|
||||
*
|
||||
* The other issue, that I did not think of originally, is that the "source"
|
||||
* address might not conform to AX.25 restrictions when it originally came
|
||||
* from a non-RF source. For example an APRS "message" might be sent to the
|
||||
* "WHO-IS" server, and the reply message would have that for the source address.
|
||||
*
|
||||
* Originally, I used the source address from the packet object but that was
|
||||
* missing the alphanumeric SSID. This needs to be done differently.
|
||||
*
|
||||
* Potential Bug: Up to 8 digipeaters are allowed in radio format.
|
||||
* Is there a possibility of finding a larger number here?
|
||||
*/
|
||||
pp3 = ax25_from_text(message, 0);
|
||||
packet_t pp3 = ax25_from_text(message, 0);
|
||||
if (pp3 == NULL) {
|
||||
text_color_set(DW_COLOR_ERROR);
|
||||
dw_printf ("Tx IGate: Could not parse message from server.\n");
|
||||
|
@ -1697,7 +1811,18 @@ static void maybe_xmit_packet_from_igate (char *message, int to_chan)
|
|||
return;
|
||||
}
|
||||
|
||||
ax25_get_addr_with_ssid (pp3, AX25_SOURCE, src);
|
||||
// Issue 408: The source address might not be valid AX.25 because it
|
||||
// came from a non-RF station. e.g. some server responding to a message.
|
||||
// We need to take source address from original rather than extracting it
|
||||
// from the packet object.
|
||||
|
||||
char src[AX25_MAX_ADDR_LEN]; /* Source address. */
|
||||
memset (src, 0, sizeof(src));
|
||||
memcpy (src, message, sizeof(src)-1);
|
||||
char *gt = strchr(src, '>');
|
||||
if (gt != NULL) {
|
||||
*gt = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
* Drop if path contains:
|
||||
|
@ -1709,8 +1834,8 @@ static void maybe_xmit_packet_from_igate (char *message, int to_chan)
|
|||
|
||||
ax25_get_addr_with_ssid (pp3, n + AX25_REPEATER_1, via);
|
||||
|
||||
if (strcmp(via, "qAX") == 0 ||
|
||||
strcmp(via, "TCPXX") == 0 ||
|
||||
if (strcmp(via, "qAX") == 0 || // qAX deprecated. http://www.aprs-is.net/q.aspx
|
||||
strcmp(via, "TCPXX") == 0 || // TCPXX deprecated.
|
||||
strcmp(via, "RFONLY") == 0 ||
|
||||
strcmp(via, "NOGATE") == 0) {
|
||||
|
||||
|
@ -1739,14 +1864,26 @@ static void maybe_xmit_packet_from_igate (char *message, int to_chan)
|
|||
* If we recently transmitted a 'message' from some station,
|
||||
* send the position of the message sender when it comes along later.
|
||||
*
|
||||
* Some refer to this as a "courtesy posit report" but I don't
|
||||
* think that is an official term.
|
||||
*
|
||||
* If we have a position report, look up the sender and see if we should
|
||||
* bypass the normal filtering.
|
||||
*
|
||||
* Reference: https://www.aprs-is.net/IGating.aspx
|
||||
*
|
||||
* "Passing all message packets also includes passing the sending station's position
|
||||
* along with the message. When APRS-IS was small, we did this using historical position
|
||||
* packets. This has become problematic as it introduces historical data on to RF.
|
||||
* The IGate should note the station(s) it has gated messages to RF for and pass
|
||||
* the next position packet seen for that station(s) to RF."
|
||||
*/
|
||||
|
||||
// TODO: Not quite this simple. Should have a function to check for position.
|
||||
// $ raw gps could be a position. @ could be weather data depending on symbol.
|
||||
|
||||
info_len = ax25_get_info (pp3, (unsigned char **)(&pinfo));
|
||||
char *pinfo = NULL;
|
||||
int info_len = ax25_get_info (pp3, (unsigned char **)(&pinfo));
|
||||
|
||||
int msp_special_case = 0;
|
||||
|
||||
|
@ -1776,12 +1913,6 @@ static void maybe_xmit_packet_from_igate (char *message, int to_chan)
|
|||
// Previously there was a debug message here about the packet being dropped by filtering.
|
||||
// This is now handled better by the "-df" command line option for filtering details.
|
||||
|
||||
// TODO: clean up - remove these lines.
|
||||
//if (s_debug >= 1) {
|
||||
// text_color_set(DW_COLOR_INFO);
|
||||
// dw_printf ("Packet from IGate to channel %d was rejected by filter: %s\n", to_chan, save_digi_config_p->filter_str[MAX_CHANS][to_chan]);
|
||||
//}
|
||||
|
||||
ax25_delete (pp3);
|
||||
return;
|
||||
}
|
||||
|
@ -1790,13 +1921,15 @@ static void maybe_xmit_packet_from_igate (char *message, int to_chan)
|
|||
|
||||
|
||||
/*
|
||||
* Remove the VIA path.
|
||||
* We want to discard the via path, as received from the APRS-IS, then
|
||||
* replace it with TCPIP and our own call, marked as used.
|
||||
*
|
||||
*
|
||||
* For example, we might get something like this from the server.
|
||||
* K1USN-1>APWW10,TCPIP*,qAC,N5JXS-F1:T#479,100,048,002,500,000,10000000<0x0d><0x0a>
|
||||
* K1USN-1>APWW10,TCPIP*,qAC,N5JXS-F1:T#479,100,048,002,500,000,10000000
|
||||
*
|
||||
* We want to reduce it to this before wrapping it as third party traffic.
|
||||
* K1USN-1>APWW10:T#479,100,048,002,500,000,10000000<0x0d><0x0a>
|
||||
* We want to transform it to this before wrapping it as third party traffic.
|
||||
* K1USN-1>APWW10,TCPIP,mycall*:T#479,100,048,002,500,000,10000000
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -1824,37 +1957,24 @@ static void maybe_xmit_packet_from_igate (char *message, int to_chan)
|
|||
*
|
||||
* What is the ",I" construct?
|
||||
* Do we care here?
|
||||
* Is is something new and improved that we should be using in the other direction?
|
||||
* Is it something new and improved that we should be using in the other direction?
|
||||
*/
|
||||
|
||||
while (ax25_get_num_repeaters(pp3) > 0) {
|
||||
ax25_remove_addr (pp3, AX25_REPEATER_1);
|
||||
}
|
||||
char payload[AX25_MAX_PACKET_LEN];
|
||||
|
||||
char dest[AX25_MAX_ADDR_LEN]; /* Destination field. */
|
||||
ax25_get_addr_with_ssid (pp3, AX25_DESTINATION, dest);
|
||||
snprintf (payload, sizeof(payload), "%s>%s,TCPIP,%s*:%s",
|
||||
src, dest, save_audio_config_p->achan[to_chan].mycall, pinfo);
|
||||
|
||||
|
||||
/*
|
||||
* Replace the VIA path with TCPIP and my call.
|
||||
* Mark my call as having been used.
|
||||
*/
|
||||
ax25_set_addr (pp3, AX25_REPEATER_1, "TCPIP");
|
||||
ax25_set_h (pp3, AX25_REPEATER_1);
|
||||
ax25_set_addr (pp3, AX25_REPEATER_2, save_audio_config_p->achan[to_chan].mycall);
|
||||
ax25_set_h (pp3, AX25_REPEATER_2);
|
||||
|
||||
/*
|
||||
* Convert to text representation.
|
||||
*/
|
||||
memset (payload, 0, sizeof(payload));
|
||||
|
||||
ax25_format_addrs (pp3, payload);
|
||||
info_len = ax25_get_info (pp3, (unsigned char **)(&pinfo));
|
||||
(void)(info_len);
|
||||
strlcat (payload, pinfo, sizeof(payload));
|
||||
#if DEBUGx
|
||||
text_color_set(DW_COLOR_DEBUG);
|
||||
dw_printf ("Tx IGate: payload=%s\n", payload);
|
||||
dw_printf ("Tx IGate: DEBUG payload=%s\n", payload);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Encapsulate for sending over radio if no reason to drop it.
|
||||
*/
|
||||
|
@ -1870,19 +1990,13 @@ static void maybe_xmit_packet_from_igate (char *message, int to_chan)
|
|||
*/
|
||||
if (ig_to_tx_allow (pp3, to_chan)) {
|
||||
char radio [2400];
|
||||
packet_t pradio;
|
||||
|
||||
snprintf (radio, sizeof(radio), "%s>%s%d%d%s:}%s",
|
||||
save_audio_config_p->achan[to_chan].mycall,
|
||||
APP_TOCALL, MAJOR_VERSION, MINOR_VERSION,
|
||||
save_igate_config_p->tx_via,
|
||||
payload);
|
||||
|
||||
pradio = ax25_from_text (radio, 1);
|
||||
|
||||
/* Oops. Didn't have a check for NULL here. */
|
||||
/* Could this be the cause of rare and elusive crashes in 1.2? */
|
||||
|
||||
packet_t pradio = ax25_from_text (radio, 1);
|
||||
if (pradio != NULL) {
|
||||
|
||||
#if ITEST
|
||||
|
@ -1895,10 +2009,7 @@ static void maybe_xmit_packet_from_igate (char *message, int to_chan)
|
|||
#endif
|
||||
stats_rf_xmit_packets++; // Any type of packet.
|
||||
|
||||
// TEMP TEST: metadata temporarily allowed during testing.
|
||||
|
||||
if (*pinfo == ':' && ! is_telem_metadata(pinfo)) {
|
||||
// temp test // if (*pinfo == ':') {
|
||||
if (is_message_message(pinfo)) {
|
||||
|
||||
// We transmitted a "message." Telemetry metadata is excluded.
|
||||
// Remember to pass along address of the sender later.
|
||||
|
@ -2211,7 +2322,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.
|
||||
*
|
||||
|
@ -2356,6 +2467,8 @@ void ig_to_tx_remember (packet_t pp, int chan, int bydigi)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int ig_to_tx_allow (packet_t pp, int chan)
|
||||
{
|
||||
unsigned short crc = ax25_dedupe_crc(pp);
|
||||
|
@ -2388,7 +2501,7 @@ static int ig_to_tx_allow (packet_t pp, int chan)
|
|||
|
||||
/* We have a duplicate within some time period. */
|
||||
|
||||
if (*pinfo == ':' && ! is_telem_metadata((char*)pinfo)) {
|
||||
if (is_message_message((char*)pinfo)) {
|
||||
|
||||
/* I think I want to avoid the duplicate suppression for "messages." */
|
||||
/* Suppose we transmit a message from station X and it doesn't get an ack back. */
|
||||
|
@ -2437,7 +2550,7 @@ static int ig_to_tx_allow (packet_t pp, int chan)
|
|||
/* the normal limit for them. */
|
||||
|
||||
increase_limit = 1;
|
||||
if (*pinfo == ':' && ! is_telem_metadata((char*)pinfo)) {
|
||||
if (is_message_message((char*)pinfo)) {
|
||||
increase_limit = 3;
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue