added tci control option

This commit is contained in:
DJ2LS 2023-05-20 09:53:57 +02:00
parent 9c6df07ef5
commit e5bd339357
8 changed files with 55 additions and 45 deletions

View file

@ -225,7 +225,9 @@ exports.startTNC = function (
enable_explorer,
explorer_stats,
auto_tune,
tx_delay
tx_delay,
tci_ip,
tci_port
) {
var json_command = JSON.stringify({
type: "set",
@ -260,6 +262,8 @@ exports.startTNC = function (
enable_stats: explorer_stats,
enable_auto_tune: auto_tune,
tx_delay: tx_delay,
tci_ip: tci_ip,
tci_port: tci_port
},
],
});

View file

@ -10,14 +10,14 @@ ssid_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[AUDIO]
#audio settings
rx = 0
tx = 0
rx = 6
tx = 6
txaudiolevel = 250
auto_tune = False
[RADIO]
#radio settings
radiocontrol = disabled
radiocontrol = tci
rigctld_ip = 127.0.0.1
rigctld_port = 4532

View file

@ -79,6 +79,11 @@ class CONFIG:
'fsk': data[13],
'tx_delay': data[21]
}
self.config['TCI'] = {'#TCI settings': None,
'ip': data[22],
'port': data[23]
}
try:
with open(self.config_name, 'w') as configfile:
self.config.write(configfile)

View file

@ -236,6 +236,12 @@ class DAEMON:
options.extend((data[6], "--rigctld_port"))
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":
options.append("--scatter")

View file

@ -127,7 +127,7 @@ if __name__ == "__main__":
PARSER.add_argument(
"--radiocontrol",
dest="hamlib_radiocontrol",
choices=["disabled", "direct", "rigctl", "rigctld"],
choices=["disabled", "rigctld", "tci"],
default="disabled",
help="Set how you want to control your radio",
)
@ -222,13 +222,6 @@ if __name__ == "__main__":
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(
"--tci-ip",
dest="tci_ip",
@ -303,7 +296,6 @@ if __name__ == "__main__":
TNC.enable_explorer = ARGS.enable_explorer
AudioParam.audio_auto_tune = ARGS.enable_audio_auto_tune
TNC.enable_stats = ARGS.enable_stats
AudioParam.audio_enable_tci = ARGS.audio_enable_tci
TCIParam.ip = ARGS.tci_ip
TCIParam.port = ARGS.tci_port
ModemParam.tx_delay = ARGS.tx_delay
@ -339,7 +331,7 @@ if __name__ == "__main__":
AudioParam.audio_output_device = conf.get('AUDIO', 'tx', '0')
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_port = str(conf.get('RADIO', 'rigctld_port', '4532'))
ModemParam.enable_scatter = conf.get('TNC', 'scatter', 'True')
@ -354,7 +346,6 @@ if __name__ == "__main__":
TNC.enable_explorer = conf.get('TNC', 'explorer', 'False')
AudioParam.audio_auto_tune = conf.get('AUDIO', 'auto_tune', '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.port = int(conf.get('TCI', 'tci_port', '50001'))
ModemParam.tx_delay = int(conf.get('TNC', 'tx_delay', '0'))

View file

@ -74,7 +74,7 @@ class RF:
self.AUDIO_FRAMES_PER_BUFFER_RX = 2400 * 2 # 8192
# 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
self.AUDIO_CHANNELS = 1
self.MODE = 0
@ -179,7 +179,7 @@ class RF:
self.freedv_ldpc1_tx = open_codec2_instance(codec2.FREEDV_MODE.fsk_ldpc_1.value)
# --------------------------------------------CREATE PORTAUDIO INSTANCE
if not TESTMODE and not AudioParam.audio_enable_tci:
if not TESTMODE and not HamlibParam.hamlib_radiocontrol in ["tci"]:
try:
self.stream = sd.RawStream(
channels=1,
@ -267,12 +267,12 @@ class RF:
# Check how we want to control the radio
if HamlibParam.hamlib_radiocontrol == "rigctld":
import rigctld as rig
elif AudioParam.audio_enable_tci:
elif HamlibParam.hamlib_radiocontrol == "tci":
self.radio = self.tci_module
else:
import rigdummy as rig
if not AudioParam.audio_enable_tci:
if not HamlibParam.hamlib_radiocontrol in ["tci"]:
self.radio = rig.radio()
self.radio.open_rig(
rigctld_ip=HamlibParam.hamlib_rigctld_ip,
@ -675,7 +675,7 @@ class RF:
alc_level=str(HamlibParam.alc))
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)
else:
txbuffer_out = x
@ -694,7 +694,7 @@ class RF:
self.mod_out_locked = False
# we need to wait manually for tci processing
if AudioParam.audio_enable_tci:
if HamlibParam.hamlib_radiocontrol in ["tci"]:
duration = len(txbuffer_out) / 8000
timestamp_to_sleep = time.time() + duration
self.log.debug("[MDM] TCI calculated duration", duration=duration)
@ -707,7 +707,7 @@ class RF:
tci_timeout_reached = True
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:
tci_timeout_reached = False
else:
@ -752,7 +752,7 @@ class RF:
txbuffer_out = x
print(txbuffer_out)
#if not AudioParam.audio_enable_tci:
#if not HamlibParam.hamlib_radiocontrol in ["tci"]:
# txbuffer_out = self.resampler.resample8_to_48(x)
#else:
# txbuffer_out = x
@ -762,7 +762,7 @@ class RF:
self.mod_out_locked = False
# we need to wait manually for tci processing
if AudioParam.audio_enable_tci:
if HamlibParam.hamlib_radiocontrol in ["tci"]:
duration = len(txbuffer_out) / 8000
timestamp_to_sleep = time.time() + duration
self.log.debug("[MDM] TCI calculated duration", duration=duration)
@ -775,7 +775,7 @@ class RF:
tci_timeout_reached = True
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:
tci_timeout_reached = False
else:
@ -1218,25 +1218,31 @@ class RF:
- HamlibParam.hamlib_bandwidth
"""
while True:
# this looks weird, but is necessary for avoiding rigctld packet colission sock
threading.Event().wait(0.25)
HamlibParam.hamlib_frequency = self.radio.get_frequency()
threading.Event().wait(0.1)
HamlibParam.hamlib_mode = self.radio.get_mode()
threading.Event().wait(0.1)
HamlibParam.hamlib_bandwidth = self.radio.get_bandwidth()
threading.Event().wait(0.1)
HamlibParam.hamlib_status = self.radio.get_status()
threading.Event().wait(0.1)
if TNC.transmitting:
HamlibParam.alc = self.radio.get_alc()
try:
# this looks weird, but is necessary for avoiding rigctld packet colission sock
threading.Event().wait(0.25)
HamlibParam.hamlib_frequency = self.radio.get_frequency()
threading.Event().wait(0.1)
# HamlibParam.hamlib_rf = self.radio.get_level()
# threading.Event().wait(0.1)
HamlibParam.hamlib_strength = self.radio.get_strength()
# print(f"ALC: {HamlibParam.alc}, RF: {HamlibParam.hamlib_rf}, STRENGTH: {HamlibParam.hamlib_strength}")
HamlibParam.hamlib_mode = self.radio.get_mode()
threading.Event().wait(0.1)
HamlibParam.hamlib_bandwidth = self.radio.get_bandwidth()
threading.Event().wait(0.1)
HamlibParam.hamlib_status = self.radio.get_status()
threading.Event().wait(0.1)
if TNC.transmitting:
HamlibParam.alc = self.radio.get_alc()
threading.Event().wait(0.1)
# HamlibParam.hamlib_rf = self.radio.get_level()
# threading.Event().wait(0.1)
HamlibParam.hamlib_strength = self.radio.get_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:
"""
Calculate an average signal strength of the channel to assess

View file

@ -55,8 +55,6 @@ class AudioParam:
audio_record_file = ''
buffer_overflow_counter = [0, 0, 0, 0, 0]
audio_auto_tune: bool = False
# Audio TCI Support
audio_enable_tci: bool = False
audio_dbfs: int = 0
fft = []
enable_fft: bool = True

View file

@ -155,7 +155,7 @@ class TCICtrl:
def on_error(self, error):
def on_error(self, ws, error):
self.log.error(
"[TCI] Error FreeDATA to TCI rig!", ip=self.hostname, port=self.port, e=error
)