mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
advanced hamlib settings
added support for more settings
This commit is contained in:
parent
5365a411ff
commit
ddc949c7ac
7 changed files with 59 additions and 25 deletions
|
@ -140,7 +140,7 @@ exports.getDaemonState = function() {
|
|||
// START TNC
|
||||
// ` `== multi line string
|
||||
|
||||
exports.startTNC = function(rx_audio, tx_audio, devicename, deviceport, pttprotocol, pttport, serialspeed, pttspeed, data_bits, stop_bits, handshake) {
|
||||
exports.startTNC = function(rx_audio, tx_audio, devicename, deviceport, pttprotocol, pttport, serialspeed, data_bits, stop_bits, handshake) {
|
||||
var json_command = JSON.stringify({
|
||||
type: 'SET',
|
||||
command: 'STARTTNC',
|
||||
|
@ -152,7 +152,6 @@ exports.startTNC = function(rx_audio, tx_audio, devicename, deviceport, pttproto
|
|||
pttprotocol: pttprotocol,
|
||||
pttport: pttport,
|
||||
serialspeed: serialspeed,
|
||||
pttspeed: pttspeed,
|
||||
data_bits: data_bits,
|
||||
stop_bits: stop_bits,
|
||||
handshake: handshake
|
||||
|
@ -172,7 +171,7 @@ exports.stopTNC = function() {
|
|||
}
|
||||
|
||||
// TEST HAMLIB
|
||||
exports.testHamlib = function(devicename, deviceport, serialspeed, pttprotocol, pttport, pttspeed, data_bits, stop_bits, handshake) {
|
||||
exports.testHamlib = function(devicename, deviceport, serialspeed, pttprotocol, pttport, data_bits, stop_bits, handshake) {
|
||||
|
||||
var json_command = JSON.stringify({
|
||||
type: 'GET',
|
||||
|
@ -183,7 +182,6 @@ exports.testHamlib = function(devicename, deviceport, serialspeed, pttprotocol,
|
|||
pttprotocol: pttprotocol,
|
||||
pttport: pttport,
|
||||
serialspeed: serialspeed,
|
||||
pttspeed: pttspeed,
|
||||
data_bits: data_bits,
|
||||
stop_bits: stop_bits,
|
||||
handshake: handshake
|
||||
|
|
|
@ -76,7 +76,6 @@ window.addEventListener('DOMContentLoaded', () => {
|
|||
document.getElementById('hamlib_deviceport_advanced').value = config.deviceport
|
||||
document.getElementById('hamlib_serialspeed_advanced').value = config.serialspeed
|
||||
document.getElementById('hamlib_ptt_protocol_advanced').value = config.pttprotocol
|
||||
document.getElementById('hamlib_pttspeed_advanced').value = config.pttspeed
|
||||
document.getElementById('hamlib_ptt_port_advanced').value = config.pttport
|
||||
document.getElementById('hamlib_databits_advanced').value = config.data_bits
|
||||
document.getElementById('hamlib_stopbits_advanced').value = config.stop_bits
|
||||
|
@ -300,7 +299,6 @@ advancedHamlibSettingsModal
|
|||
var serialspeed = document.getElementById("hamlib_serialspeed").value
|
||||
var pttprotocol = document.getElementById("hamlib_ptt_protocol").value
|
||||
var pttport = document.getElementById("hamlib_ptt_port_advanced").value
|
||||
var pttspeed = document.getElementById('hamlib_pttspeed_advanced').value
|
||||
var data_bits = document.getElementById('hamlib_databits_advanced').value
|
||||
var stop_bits = document.getElementById('hamlib_stopbits_advanced').value
|
||||
var handshake = document.getElementById('hamlib_handshake_advanced').value
|
||||
|
@ -310,7 +308,6 @@ advancedHamlibSettingsModal
|
|||
config.serialspeed = serialspeed
|
||||
config.pttprotocol = pttprotocol
|
||||
config.pttport = pttport
|
||||
config.pttspeed = pttspeed
|
||||
config.data_bits = data_bits
|
||||
config.stop_bits = stop_bits
|
||||
config.handshake = handshake
|
||||
|
@ -328,7 +325,7 @@ advancedHamlibSettingsModal
|
|||
var collapseFourthRow = new bootstrap.Collapse(document.getElementById('collapseFourthRow'), {toggle: false})
|
||||
collapseFourthRow.show()
|
||||
|
||||
daemon.startTNC(rx_audio, tx_audio, deviceid, deviceport, pttprotocol, pttport, serialspeed, pttspeed, data_bits, stop_bits, handshake)
|
||||
daemon.startTNC(rx_audio, tx_audio, deviceid, deviceport, pttprotocol, pttport, serialspeed, data_bits, stop_bits, handshake)
|
||||
|
||||
|
||||
|
||||
|
@ -389,14 +386,13 @@ advancedHamlibSettingsModal
|
|||
var pttprotocol = document.getElementById("hamlib_ptt_protocol").value
|
||||
|
||||
var pttport = deviceport
|
||||
var pttspeed = serialspeed
|
||||
|
||||
var data_bits = "8"
|
||||
var stop_bits = "1"
|
||||
var handshake = "None"
|
||||
|
||||
|
||||
daemon.testHamlib(deviceid, deviceport, serialspeed, pttprotocol, pttport, pttspeed, data_bits, stop_bits, handshake)
|
||||
daemon.testHamlib(deviceid, deviceport, serialspeed, pttprotocol, pttport, data_bits, stop_bits, handshake)
|
||||
})
|
||||
|
||||
// TEST HAMLIB ADVANCED
|
||||
|
@ -414,12 +410,11 @@ advancedHamlibSettingsModal
|
|||
|
||||
var pttport = document.getElementById("hamlib_deviceport").value
|
||||
|
||||
var pttspeed = document.getElementById("hamlib_serialspeed_advanced").value
|
||||
var data_bits = document.getElementById("hamlib_databits_advanced").value
|
||||
var stop_bits = document.getElementById("hamlib_stopbits_advanced").value
|
||||
var handshake = document.getElementById("hamlib_handshake_advanced").value
|
||||
|
||||
daemon.testHamlib(deviceid, deviceport, serialspeed, pttprotocol, pttport, pttspeed, data_bits, stop_bits, handshake)
|
||||
daemon.testHamlib(deviceid, deviceport, serialspeed, pttprotocol, pttport, data_bits, stop_bits, handshake)
|
||||
})
|
||||
|
||||
|
||||
|
|
|
@ -529,6 +529,7 @@
|
|||
</span>
|
||||
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_ptt_protocol" style="width: 0.5rem">
|
||||
<option value="RIG">RIG</option>
|
||||
<option value="USB">USB</option>
|
||||
<option value="RTS">Serial RTS</option>
|
||||
<option value="DTR-H">Serial DTR-High</option>
|
||||
<option value="DTR-H">Serial DTR-Low</option>
|
||||
|
@ -1037,6 +1038,7 @@
|
|||
<div class="input-group input-group-sm mb-1"> <span class="input-group-text" id="basic-addon1">PTT</span>
|
||||
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_ptt_protocol_advanced" style="width: 0.5rem">
|
||||
<option value="RIG">RIG</option>
|
||||
<option value="USB">USB</option>
|
||||
<option value="RTS">Serial RTS</option>
|
||||
<option value="DTR-H">Serial DTR-High</option>
|
||||
<option value="DTR-H">Serial DTR-Low</option>
|
||||
|
@ -1066,6 +1068,7 @@
|
|||
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_ptt_port_advanced">
|
||||
<!--<option selected value="/dev/ttyUSB0">/dev/ttyUSB0</option>
|
||||
<option value="/dev/ttyUSB1">/dev/ttyUSB1</option>-->
|
||||
<!--
|
||||
</select> <span class="input-group-text" id="basic-addon1">PTT Speed</span>
|
||||
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_pttspeed_advanced">
|
||||
<option value="1200">1200</option>
|
||||
|
@ -1079,6 +1082,7 @@
|
|||
<option value="57600">57600</option>
|
||||
<option value="115200">115200</option>
|
||||
</select>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
|
|
@ -158,6 +158,11 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
serialspeed = str(received_json["parameter"][0]["serialspeed"])
|
||||
pttprotocol = str(received_json["parameter"][0]["pttprotocol"])
|
||||
pttport = str(received_json["parameter"][0]["pttport"])
|
||||
data_bits = str(received_json["parameter"][0]["data_bits"])
|
||||
stop_bits = str(received_json["parameter"][0]["stop_bits"])
|
||||
handshake = str(received_json["parameter"][0]["handshake"])
|
||||
|
||||
|
||||
|
||||
structlog.get_logger("structlog").warning("[DMN] Starting TNC", rig=devicename, port=deviceport)
|
||||
#print(received_json["parameter"][0])
|
||||
|
@ -186,6 +191,13 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
options.append(pttprotocol)
|
||||
options.append('--pttport')
|
||||
options.append(pttport)
|
||||
options.append('--data_bits')
|
||||
options.append(data_bits)
|
||||
options.append('--stop_bits')
|
||||
options.append(stop_bits)
|
||||
options.append('--handshake')
|
||||
options.append(handshake)
|
||||
|
||||
|
||||
# try running tnc from binary, else run from source
|
||||
# this helps running the tnc in a developer environment
|
||||
|
@ -284,14 +296,12 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
serialspeed = str(received_json["parameter"][0]["serialspeed"])
|
||||
pttprotocol = str(received_json["parameter"][0]["pttprotocol"])
|
||||
pttport = str(received_json["parameter"][0]["pttport"])
|
||||
|
||||
pttspeed = str(received_json["parameter"][0]["pttspeed"])
|
||||
data_bits = str(received_json["parameter"][0]["data_bits"])
|
||||
stop_bits = str(received_json["parameter"][0]["stop_bits"])
|
||||
handshake = str(received_json["parameter"][0]["handshake"])
|
||||
|
||||
hamlib = rig.radio()
|
||||
hamlib.open_rig(devicename=devicename, deviceport=deviceport, hamlib_ptt_type=pttprotocol, serialspeed=serialspeed)
|
||||
hamlib.open_rig(devicename=devicename, deviceport=deviceport, hamlib_ptt_type=pttprotocol, serialspeed=serialspeed, pttport=pttport, data_bits=data_bits, stop_bits=stop_bits, handshake=handshake)
|
||||
|
||||
hamlib.set_ptt(True)
|
||||
pttstate = hamlib.get_ptt()
|
||||
|
|
|
@ -33,6 +33,12 @@ if __name__ == '__main__':
|
|||
PARSER.add_argument('--serialspeed', dest="hamlib_serialspeed", default=9600, help="Serialspeed", type=str)
|
||||
PARSER.add_argument('--pttprotocol', dest="hamlib_ptt_type", default='RTS', help="PTT Type", type=str)
|
||||
PARSER.add_argument('--pttport', dest="hamlib_ptt_port", default="/dev/ttyUSB0", help="PTT Port", type=str)
|
||||
PARSER.add_argument('--data_bits', dest="hamlib_data_bits", default="8", help="Hamlib data bits", type=str)
|
||||
PARSER.add_argument('--stop_bits', dest="hamlib_stop_bits", default="1", help="Hamlib stop bits", type=str)
|
||||
PARSER.add_argument('--handshake', dest="hamlib_handshake", default="None", help="Hamlib handshake", type=str)
|
||||
|
||||
|
||||
|
||||
|
||||
ARGS = PARSER.parse_args()
|
||||
|
||||
|
@ -44,6 +50,9 @@ if __name__ == '__main__':
|
|||
static.HAMLIB_PTT_TYPE = ARGS.hamlib_ptt_type
|
||||
static.HAMLIB_PTT_PORT = ARGS.hamlib_ptt_port
|
||||
static.HAMLIB_SERIAL_SPEED = ARGS.hamlib_serialspeed
|
||||
static.HAMLIB_DATA_BITS = ARGS.hamlib_data_bits
|
||||
static.HAMLIB_STOP_BITS = ARGS.hamlib_stop_bits
|
||||
static.HAMLIB_HANDSHAKE = ARGS.hamlib_handshake
|
||||
|
||||
# we need to wait until we got all parameters from argparse first before we can load the other modules
|
||||
import sock
|
||||
|
|
27
tnc/rig.py
27
tnc/rig.py
|
@ -37,17 +37,25 @@ class radio:
|
|||
self.devicename = ''
|
||||
self.devicenumber = ''
|
||||
self.deviceport = ''
|
||||
self.serialspeed = 0
|
||||
self.serialspeed = ''
|
||||
self.hamlib_ptt_type = ''
|
||||
self.my_rig = ''
|
||||
self.pttport = ''
|
||||
self.data_bits = ''
|
||||
self.stop_bits = ''
|
||||
self.handshake = ''
|
||||
|
||||
|
||||
def open_rig(self, devicename, deviceport, hamlib_ptt_type, serialspeed):
|
||||
def open_rig(self, devicename, deviceport, hamlib_ptt_type, serialspeed, pttport, data_bits, stop_bits, handshake):
|
||||
|
||||
self.devicename = devicename
|
||||
self.deviceport = deviceport
|
||||
self.serialspeed = str(serialspeed) # we need to ensure this is a str, otherwise set_conf functions are crashing
|
||||
self.hamlib_ptt_type = hamlib_ptt_type
|
||||
self.pttport = pttport
|
||||
self.data_bits = data_bits
|
||||
self.stop_bits = stop_bits
|
||||
self.handshake = handshake
|
||||
|
||||
|
||||
# try to init hamlib
|
||||
try:
|
||||
|
@ -65,14 +73,21 @@ class radio:
|
|||
self.my_rig.set_conf("rig_pathname", self.deviceport)
|
||||
self.my_rig.set_conf("retry", "5")
|
||||
self.my_rig.set_conf("serial_speed", self.serialspeed)
|
||||
self.my_rig.set_conf("serial_handshake", "None")
|
||||
self.my_rig.set_conf("stop_bits", "1")
|
||||
self.my_rig.set_conf("data_bits", "8")
|
||||
self.my_rig.set_conf("serial_handshake", self.handshake)
|
||||
self.my_rig.set_conf("stop_bits", self.stop_bits)
|
||||
self.my_rig.set_conf("data_bits", self.data_bits)
|
||||
self.my_rig.set_conf("ptt_pathname", self.pttport)
|
||||
|
||||
|
||||
if self.hamlib_ptt_type == 'RIG':
|
||||
self.hamlib_ptt_type = Hamlib.RIG_PTT_RIG
|
||||
self.my_rig.set_conf("ptt_type", 'RIG')
|
||||
|
||||
elif self.hamlib_ptt_type == 'USB':
|
||||
self.hamlib_ptt_type = Hamlib.RIG_PORT_USB
|
||||
self.my_rig.set_conf("ptt_type", 'USB')
|
||||
|
||||
|
||||
elif self.hamlib_ptt_type == 'DTR-H':
|
||||
self.hamlib_ptt_type = Hamlib.RIG_PTT_SERIAL_DTR
|
||||
self.my_rig.set_conf("dtr_state", "HIGH")
|
||||
|
|
|
@ -33,13 +33,17 @@ SOCKET_TIMEOUT = 3 # seconds
|
|||
# ---------------------------------
|
||||
|
||||
|
||||
HAMLIB_PTT_TYPE = 'RTS'
|
||||
|
||||
PTT_STATE = False
|
||||
|
||||
HAMLIB_PTT_TYPE = 'RTS'
|
||||
HAMLIB_DEVICE_NAME = 'RIG_MODEL_DUMMY_NOVFO'
|
||||
HAMLIB_DEVICE_PORT = '/dev/ttyUSB0'
|
||||
HAMLIB_SERIAL_SPEED = '9600'
|
||||
HAMLIB_PTT_PORT = '/dev/ttyUSB0'
|
||||
HAMLIB_STOP_BITS = '1'
|
||||
HAMLIB_DATA_BITS = '8'
|
||||
HANLIB_HANDSHAKE = 'None'
|
||||
|
||||
HAMLIB_FREQUENCY = 0
|
||||
HAMLIB_MODE = ''
|
||||
|
@ -47,7 +51,6 @@ HAMLIB_BANDWITH = 0
|
|||
# -------------------------
|
||||
# FreeDV Defaults
|
||||
|
||||
BER = 0
|
||||
SNR = 0
|
||||
FREQ_OFFSET = 0
|
||||
SCATTER = []
|
||||
|
|
Loading…
Reference in a new issue