mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
added tci control option
This commit is contained in:
parent
9c6df07ef5
commit
e5bd339357
|
@ -225,7 +225,9 @@ exports.startTNC = function (
|
||||||
enable_explorer,
|
enable_explorer,
|
||||||
explorer_stats,
|
explorer_stats,
|
||||||
auto_tune,
|
auto_tune,
|
||||||
tx_delay
|
tx_delay,
|
||||||
|
tci_ip,
|
||||||
|
tci_port
|
||||||
) {
|
) {
|
||||||
var json_command = JSON.stringify({
|
var json_command = JSON.stringify({
|
||||||
type: "set",
|
type: "set",
|
||||||
|
@ -260,6 +262,8 @@ exports.startTNC = function (
|
||||||
enable_stats: explorer_stats,
|
enable_stats: explorer_stats,
|
||||||
enable_auto_tune: auto_tune,
|
enable_auto_tune: auto_tune,
|
||||||
tx_delay: tx_delay,
|
tx_delay: tx_delay,
|
||||||
|
tci_ip: tci_ip,
|
||||||
|
tci_port: tci_port
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,14 +10,14 @@ ssid_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||||
|
|
||||||
[AUDIO]
|
[AUDIO]
|
||||||
#audio settings
|
#audio settings
|
||||||
rx = 0
|
rx = 6
|
||||||
tx = 0
|
tx = 6
|
||||||
txaudiolevel = 250
|
txaudiolevel = 250
|
||||||
auto_tune = False
|
auto_tune = False
|
||||||
|
|
||||||
[RADIO]
|
[RADIO]
|
||||||
#radio settings
|
#radio settings
|
||||||
radiocontrol = disabled
|
radiocontrol = tci
|
||||||
rigctld_ip = 127.0.0.1
|
rigctld_ip = 127.0.0.1
|
||||||
rigctld_port = 4532
|
rigctld_port = 4532
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,11 @@ class CONFIG:
|
||||||
'fsk': data[13],
|
'fsk': data[13],
|
||||||
'tx_delay': data[21]
|
'tx_delay': data[21]
|
||||||
}
|
}
|
||||||
|
self.config['TCI'] = {'#TCI settings': None,
|
||||||
|
'ip': data[22],
|
||||||
|
'port': data[23]
|
||||||
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(self.config_name, 'w') as configfile:
|
with open(self.config_name, 'w') as configfile:
|
||||||
self.config.write(configfile)
|
self.config.write(configfile)
|
||||||
|
|
|
@ -236,6 +236,12 @@ class DAEMON:
|
||||||
options.extend((data[6], "--rigctld_port"))
|
options.extend((data[6], "--rigctld_port"))
|
||||||
options.append(data[7])
|
options.append(data[7])
|
||||||
|
|
||||||
|
if data[5] == "tci":
|
||||||
|
options.append("--tci_ip")
|
||||||
|
options.extend((data[22], "--tci_port"))
|
||||||
|
options.append(data[23])
|
||||||
|
|
||||||
|
|
||||||
if data[8] == "True":
|
if data[8] == "True":
|
||||||
options.append("--scatter")
|
options.append("--scatter")
|
||||||
|
|
||||||
|
|
13
tnc/main.py
13
tnc/main.py
|
@ -127,7 +127,7 @@ if __name__ == "__main__":
|
||||||
PARSER.add_argument(
|
PARSER.add_argument(
|
||||||
"--radiocontrol",
|
"--radiocontrol",
|
||||||
dest="hamlib_radiocontrol",
|
dest="hamlib_radiocontrol",
|
||||||
choices=["disabled", "direct", "rigctl", "rigctld"],
|
choices=["disabled", "rigctld", "tci"],
|
||||||
default="disabled",
|
default="disabled",
|
||||||
help="Set how you want to control your radio",
|
help="Set how you want to control your radio",
|
||||||
)
|
)
|
||||||
|
@ -222,13 +222,6 @@ if __name__ == "__main__":
|
||||||
help="Enable publishing stats to https://freedata.app",
|
help="Enable publishing stats to https://freedata.app",
|
||||||
)
|
)
|
||||||
|
|
||||||
PARSER.add_argument(
|
|
||||||
"--tci",
|
|
||||||
dest="audio_enable_tci",
|
|
||||||
action="store_true",
|
|
||||||
help="Enable TCI as audio source",
|
|
||||||
)
|
|
||||||
|
|
||||||
PARSER.add_argument(
|
PARSER.add_argument(
|
||||||
"--tci-ip",
|
"--tci-ip",
|
||||||
dest="tci_ip",
|
dest="tci_ip",
|
||||||
|
@ -303,7 +296,6 @@ if __name__ == "__main__":
|
||||||
TNC.enable_explorer = ARGS.enable_explorer
|
TNC.enable_explorer = ARGS.enable_explorer
|
||||||
AudioParam.audio_auto_tune = ARGS.enable_audio_auto_tune
|
AudioParam.audio_auto_tune = ARGS.enable_audio_auto_tune
|
||||||
TNC.enable_stats = ARGS.enable_stats
|
TNC.enable_stats = ARGS.enable_stats
|
||||||
AudioParam.audio_enable_tci = ARGS.audio_enable_tci
|
|
||||||
TCIParam.ip = ARGS.tci_ip
|
TCIParam.ip = ARGS.tci_ip
|
||||||
TCIParam.port = ARGS.tci_port
|
TCIParam.port = ARGS.tci_port
|
||||||
ModemParam.tx_delay = ARGS.tx_delay
|
ModemParam.tx_delay = ARGS.tx_delay
|
||||||
|
@ -339,7 +331,7 @@ if __name__ == "__main__":
|
||||||
AudioParam.audio_output_device = conf.get('AUDIO', 'tx', '0')
|
AudioParam.audio_output_device = conf.get('AUDIO', 'tx', '0')
|
||||||
|
|
||||||
TNC.port = int(conf.get('NETWORK', 'tncport', '3000'))
|
TNC.port = int(conf.get('NETWORK', 'tncport', '3000'))
|
||||||
HamlibParam.hamlib_radiocontrol = conf.get('RADIO', 'radiocontrol', 'rigctld')
|
HamlibParam.hamlib_radiocontrol = conf.get('RADIO', 'radiocontrol', 'disabled')
|
||||||
HamlibParam.hamlib_rigctld_ip = conf.get('RADIO', 'rigctld_ip', '127.0.0.1')
|
HamlibParam.hamlib_rigctld_ip = conf.get('RADIO', 'rigctld_ip', '127.0.0.1')
|
||||||
HamlibParam.hamlib_rigctld_port = str(conf.get('RADIO', 'rigctld_port', '4532'))
|
HamlibParam.hamlib_rigctld_port = str(conf.get('RADIO', 'rigctld_port', '4532'))
|
||||||
ModemParam.enable_scatter = conf.get('TNC', 'scatter', 'True')
|
ModemParam.enable_scatter = conf.get('TNC', 'scatter', 'True')
|
||||||
|
@ -354,7 +346,6 @@ if __name__ == "__main__":
|
||||||
TNC.enable_explorer = conf.get('TNC', 'explorer', 'False')
|
TNC.enable_explorer = conf.get('TNC', 'explorer', 'False')
|
||||||
AudioParam.audio_auto_tune = conf.get('AUDIO', 'auto_tune', 'False')
|
AudioParam.audio_auto_tune = conf.get('AUDIO', 'auto_tune', 'False')
|
||||||
TNC.enable_stats = conf.get('TNC', 'stats', 'False')
|
TNC.enable_stats = conf.get('TNC', 'stats', 'False')
|
||||||
AudioParam.audio_enable_tci = conf.get('AUDIO', 'enable_tci', 'False')
|
|
||||||
TCIParam.ip = str(conf.get('TCI', 'tci_ip', 'localhost'))
|
TCIParam.ip = str(conf.get('TCI', 'tci_ip', 'localhost'))
|
||||||
TCIParam.port = int(conf.get('TCI', 'tci_port', '50001'))
|
TCIParam.port = int(conf.get('TCI', 'tci_port', '50001'))
|
||||||
ModemParam.tx_delay = int(conf.get('TNC', 'tx_delay', '0'))
|
ModemParam.tx_delay = int(conf.get('TNC', 'tx_delay', '0'))
|
||||||
|
|
28
tnc/modem.py
28
tnc/modem.py
|
@ -74,7 +74,7 @@ class RF:
|
||||||
|
|
||||||
self.AUDIO_FRAMES_PER_BUFFER_RX = 2400 * 2 # 8192
|
self.AUDIO_FRAMES_PER_BUFFER_RX = 2400 * 2 # 8192
|
||||||
# 8192 Let's do some tests with very small chunks for TX
|
# 8192 Let's do some tests with very small chunks for TX
|
||||||
self.AUDIO_FRAMES_PER_BUFFER_TX = 1200 if AudioParam.audio_enable_tci else 2400 * 2
|
self.AUDIO_FRAMES_PER_BUFFER_TX = 1200 if HamlibParam.hamlib_radiocontrol in ["tci"] else 2400 * 2
|
||||||
# 8 * (self.AUDIO_SAMPLE_RATE_RX/self.MODEM_SAMPLE_RATE) == 48
|
# 8 * (self.AUDIO_SAMPLE_RATE_RX/self.MODEM_SAMPLE_RATE) == 48
|
||||||
self.AUDIO_CHANNELS = 1
|
self.AUDIO_CHANNELS = 1
|
||||||
self.MODE = 0
|
self.MODE = 0
|
||||||
|
@ -179,7 +179,7 @@ class RF:
|
||||||
self.freedv_ldpc1_tx = open_codec2_instance(codec2.FREEDV_MODE.fsk_ldpc_1.value)
|
self.freedv_ldpc1_tx = open_codec2_instance(codec2.FREEDV_MODE.fsk_ldpc_1.value)
|
||||||
|
|
||||||
# --------------------------------------------CREATE PORTAUDIO INSTANCE
|
# --------------------------------------------CREATE PORTAUDIO INSTANCE
|
||||||
if not TESTMODE and not AudioParam.audio_enable_tci:
|
if not TESTMODE and not HamlibParam.hamlib_radiocontrol in ["tci"]:
|
||||||
try:
|
try:
|
||||||
self.stream = sd.RawStream(
|
self.stream = sd.RawStream(
|
||||||
channels=1,
|
channels=1,
|
||||||
|
@ -267,12 +267,12 @@ class RF:
|
||||||
# Check how we want to control the radio
|
# Check how we want to control the radio
|
||||||
if HamlibParam.hamlib_radiocontrol == "rigctld":
|
if HamlibParam.hamlib_radiocontrol == "rigctld":
|
||||||
import rigctld as rig
|
import rigctld as rig
|
||||||
elif AudioParam.audio_enable_tci:
|
elif HamlibParam.hamlib_radiocontrol == "tci":
|
||||||
self.radio = self.tci_module
|
self.radio = self.tci_module
|
||||||
else:
|
else:
|
||||||
import rigdummy as rig
|
import rigdummy as rig
|
||||||
|
|
||||||
if not AudioParam.audio_enable_tci:
|
if not HamlibParam.hamlib_radiocontrol in ["tci"]:
|
||||||
self.radio = rig.radio()
|
self.radio = rig.radio()
|
||||||
self.radio.open_rig(
|
self.radio.open_rig(
|
||||||
rigctld_ip=HamlibParam.hamlib_rigctld_ip,
|
rigctld_ip=HamlibParam.hamlib_rigctld_ip,
|
||||||
|
@ -675,7 +675,7 @@ class RF:
|
||||||
alc_level=str(HamlibParam.alc))
|
alc_level=str(HamlibParam.alc))
|
||||||
x = set_audio_volume(x, AudioParam.tx_audio_level)
|
x = set_audio_volume(x, AudioParam.tx_audio_level)
|
||||||
|
|
||||||
if not AudioParam.audio_enable_tci:
|
if not HamlibParam.hamlib_radiocontrol in ["tci"]:
|
||||||
txbuffer_out = self.resampler.resample8_to_48(x)
|
txbuffer_out = self.resampler.resample8_to_48(x)
|
||||||
else:
|
else:
|
||||||
txbuffer_out = x
|
txbuffer_out = x
|
||||||
|
@ -694,7 +694,7 @@ class RF:
|
||||||
self.mod_out_locked = False
|
self.mod_out_locked = False
|
||||||
|
|
||||||
# we need to wait manually for tci processing
|
# we need to wait manually for tci processing
|
||||||
if AudioParam.audio_enable_tci:
|
if HamlibParam.hamlib_radiocontrol in ["tci"]:
|
||||||
duration = len(txbuffer_out) / 8000
|
duration = len(txbuffer_out) / 8000
|
||||||
timestamp_to_sleep = time.time() + duration
|
timestamp_to_sleep = time.time() + duration
|
||||||
self.log.debug("[MDM] TCI calculated duration", duration=duration)
|
self.log.debug("[MDM] TCI calculated duration", duration=duration)
|
||||||
|
@ -707,7 +707,7 @@ class RF:
|
||||||
tci_timeout_reached = True
|
tci_timeout_reached = True
|
||||||
|
|
||||||
while self.modoutqueue or not tci_timeout_reached:
|
while self.modoutqueue or not tci_timeout_reached:
|
||||||
if AudioParam.audio_enable_tci:
|
if HamlibParam.hamlib_radiocontrol in ["tci"]:
|
||||||
if time.time() < timestamp_to_sleep:
|
if time.time() < timestamp_to_sleep:
|
||||||
tci_timeout_reached = False
|
tci_timeout_reached = False
|
||||||
else:
|
else:
|
||||||
|
@ -752,7 +752,7 @@ class RF:
|
||||||
txbuffer_out = x
|
txbuffer_out = x
|
||||||
print(txbuffer_out)
|
print(txbuffer_out)
|
||||||
|
|
||||||
#if not AudioParam.audio_enable_tci:
|
#if not HamlibParam.hamlib_radiocontrol in ["tci"]:
|
||||||
# txbuffer_out = self.resampler.resample8_to_48(x)
|
# txbuffer_out = self.resampler.resample8_to_48(x)
|
||||||
#else:
|
#else:
|
||||||
# txbuffer_out = x
|
# txbuffer_out = x
|
||||||
|
@ -762,7 +762,7 @@ class RF:
|
||||||
self.mod_out_locked = False
|
self.mod_out_locked = False
|
||||||
|
|
||||||
# we need to wait manually for tci processing
|
# we need to wait manually for tci processing
|
||||||
if AudioParam.audio_enable_tci:
|
if HamlibParam.hamlib_radiocontrol in ["tci"]:
|
||||||
duration = len(txbuffer_out) / 8000
|
duration = len(txbuffer_out) / 8000
|
||||||
timestamp_to_sleep = time.time() + duration
|
timestamp_to_sleep = time.time() + duration
|
||||||
self.log.debug("[MDM] TCI calculated duration", duration=duration)
|
self.log.debug("[MDM] TCI calculated duration", duration=duration)
|
||||||
|
@ -775,7 +775,7 @@ class RF:
|
||||||
tci_timeout_reached = True
|
tci_timeout_reached = True
|
||||||
|
|
||||||
while self.modoutqueue or not tci_timeout_reached:
|
while self.modoutqueue or not tci_timeout_reached:
|
||||||
if AudioParam.audio_enable_tci:
|
if HamlibParam.hamlib_radiocontrol in ["tci"]:
|
||||||
if time.time() < timestamp_to_sleep:
|
if time.time() < timestamp_to_sleep:
|
||||||
tci_timeout_reached = False
|
tci_timeout_reached = False
|
||||||
else:
|
else:
|
||||||
|
@ -1218,6 +1218,7 @@ class RF:
|
||||||
- HamlibParam.hamlib_bandwidth
|
- HamlibParam.hamlib_bandwidth
|
||||||
"""
|
"""
|
||||||
while True:
|
while True:
|
||||||
|
try:
|
||||||
# this looks weird, but is necessary for avoiding rigctld packet colission sock
|
# this looks weird, but is necessary for avoiding rigctld packet colission sock
|
||||||
threading.Event().wait(0.25)
|
threading.Event().wait(0.25)
|
||||||
HamlibParam.hamlib_frequency = self.radio.get_frequency()
|
HamlibParam.hamlib_frequency = self.radio.get_frequency()
|
||||||
|
@ -1236,7 +1237,12 @@ class RF:
|
||||||
HamlibParam.hamlib_strength = self.radio.get_strength()
|
HamlibParam.hamlib_strength = self.radio.get_strength()
|
||||||
|
|
||||||
# print(f"ALC: {HamlibParam.alc}, RF: {HamlibParam.hamlib_rf}, STRENGTH: {HamlibParam.hamlib_strength}")
|
# print(f"ALC: {HamlibParam.alc}, RF: {HamlibParam.hamlib_rf}, STRENGTH: {HamlibParam.hamlib_strength}")
|
||||||
|
except Exception as e:
|
||||||
|
self.log.warning(
|
||||||
|
"[MDM] error getting radio data",
|
||||||
|
e=e,
|
||||||
|
)
|
||||||
|
threading.Event().wait(1)
|
||||||
def calculate_fft(self) -> None:
|
def calculate_fft(self) -> None:
|
||||||
"""
|
"""
|
||||||
Calculate an average signal strength of the channel to assess
|
Calculate an average signal strength of the channel to assess
|
||||||
|
|
|
@ -55,8 +55,6 @@ class AudioParam:
|
||||||
audio_record_file = ''
|
audio_record_file = ''
|
||||||
buffer_overflow_counter = [0, 0, 0, 0, 0]
|
buffer_overflow_counter = [0, 0, 0, 0, 0]
|
||||||
audio_auto_tune: bool = False
|
audio_auto_tune: bool = False
|
||||||
# Audio TCI Support
|
|
||||||
audio_enable_tci: bool = False
|
|
||||||
audio_dbfs: int = 0
|
audio_dbfs: int = 0
|
||||||
fft = []
|
fft = []
|
||||||
enable_fft: bool = True
|
enable_fft: bool = True
|
||||||
|
|
|
@ -155,7 +155,7 @@ class TCICtrl:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def on_error(self, error):
|
def on_error(self, ws, error):
|
||||||
self.log.error(
|
self.log.error(
|
||||||
"[TCI] Error FreeDATA to TCI rig!", ip=self.hostname, port=self.port, e=error
|
"[TCI] Error FreeDATA to TCI rig!", ip=self.hostname, port=self.port, e=error
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue