############################################### #
#
# ############################################### #
# ###############################################
CREDITS This project is based on several other projects:
The base for relayngel.py is reverseapi.py, written by Edouard F4EXB as part of his SDRAngel project: https://github.com/f4exb/sdrangel. Some of the Reverse API code is directly copied from there.
I also was inspired by some code posted on Amazon user "M" who posted some basic Python code for the Sainsmart 1982-USB4CH device. This was very necessary given that the SainSmart documentation is simply wrong, and the FTDI documentation does not really discuss Python much. Link: https://www.amazon.com/gp/customer-reviews/R1H80WYYIJ66JK/ref=cm_cr_dp_d_rvw_ttl?ie=UTF8&ASIN=B009A524Z0
LICENSE This code is free-to-use by anyone for any-purpose, provided credited authors above are given their due.
PURPOSE The purpose of this code is to expand upon F4EXB's code to integrate SDRAngel with USB relay controller boards. This will allow the user to control antenna switches, amplifiers, bandpass filters, etc. via SDRAngel.
SUPPORTED DEVICES
Currently supported relay boards:
Amazon link: https://www.amazon.com/SainSmart-USB-Channel-Relay-Automation/dp/B07CSJ16W4
Amazon link: https://www.amazon.com/SMAKN%C2%AE-LCUS-1-module-intelligent-control/dp/B01CN7E0RQ
REQUIREMENTS To use this you will need:
1.SDRAngel 4.5 or higher (Reverse API was added in 4.4.x but this was built and tested against 4.5). Link: https://github.com/f4exb/sdrangel
3.The "Flask" Python module (pip install Flask).
The FTDI D2XX drivers. Note that the Kernel drivers in Ubuntu don't quite work (I believe they are for VCP).
On Windows -- you will need to get CH340 driver.
The ftd2xx Python module (pip install ftd2xx).
On Windows -- the pywin32 Python module (C:\Python27\python -m pip install pywin32), and the pyserial module (C:\Python27\python -m pip install pyserial).
git (recommended)
NOTE REGARDING LINUX KERNEL DRIVER
CONFIGURATION To configure, you will need to edit config.xml.
The root tag in config.xml is
Each relay board device will need its own node with a
The
Example:
<?xml version="1.0"?>
Note that the first
The first
Suppose you have a low-noise amplifier connected to relay 4. You would want it "on" when device #0 is receiving, and off when it is not. That is why the fourth value in the "on" attribute is "1" for the first
The delay_on and delay_off attributes specify a delay (in milliseconds) before the channel is switched on or off.
For the CH341_LCUS-1, the situation is a bit simpler as there is only one relay. However, you could add more than two devices; for example if you had four different source devices configured in SDRAngel, you could have four
For PROCESS, stdout and stderr are sent to /dev/null. If you require logging of process output, then you should include that in your shell/batch script.
USE
Linux: Once you have hardware connected and the config.xml file prepared, you should start the Flask server by running relayngel.sh.
Windows: Once you have hardware connected and the config.xml file prepared, you should start the Flask server by running relayngel.bat.