added tci gui control field

This commit is contained in:
DJ2LS 2023-05-17 15:23:49 +02:00
parent fe8bb04a04
commit ba7737594d
4 changed files with 207 additions and 19 deletions

View file

@ -444,24 +444,51 @@ window.addEventListener("DOMContentLoaded", () => {
if (config.radiocontrol == "rigctld") {
document.getElementById("radio-control-switch-disabled").checked = false;
document.getElementById("radio-control-switch-rigctld").checked = true;
document.getElementById("radio-control-switch-tci").checked = false;
document.getElementById("radio-control-disabled").style.visibility =
"hidden";
document.getElementById("radio-control-disabled").style.display = "none";
document.getElementById("radio-control-tci").style.display = "none";
document.getElementById("radio-control-tci").style.visibility = "hidden";
document.getElementById("radio-control-help").style.visibility = "hidden";
document.getElementById("radio-control-help").style.display = "none";
document.getElementById("radio-control-rigctld").style.visibility =
"visible";
document.getElementById("radio-control-rigctld").style.display = "block";
} else if(config.radiocontrol == "tci"){
document.getElementById("radio-control-switch-disabled").checked = false;
document.getElementById("radio-control-switch-rigctld").checked = false;
document.getElementById("radio-control-switch-tci").checked = true;
document.getElementById("radio-control-disabled").style.visibility =
"hidden";
document.getElementById("radio-control-disabled").style.display = "none";
document.getElementById("radio-control-help").style.visibility = "hidden";
document.getElementById("radio-control-help").style.display = "none";
document.getElementById("radio-control-rigctld").style.visibility = "hidden";
document.getElementById("radio-control-rigctld").style.display = "none";
document.getElementById("radio-control-tci").style.visibility =
"visible";
document.getElementById("radio-control-tci").style.display = "block";
} else {
document.getElementById("radio-control-switch-disabled").checked = true;
document.getElementById("radio-control-switch-rigctld").checked = false;
document.getElementById("radio-control-switch-tci").checked = false;
document.getElementById("radio-control-help").style.display = "none";
document.getElementById("radio-control-help").style.visibility = "hidden";
document.getElementById("radio-control-tci").style.display = "none";
document.getElementById("radio-control-tci").style.visibility = "hidden";
document.getElementById("radio-control-rigctld").style.visibility =
"hidden";
document.getElementById("radio-control-rigctld").style.display = "none";
@ -536,6 +563,8 @@ window.addEventListener("DOMContentLoaded", () => {
document.getElementById("radio-control-disabled").style.display = "block";
document.getElementById("radio-control-disabled").style.visibility =
"visible";
document.getElementById("radio-control-tci").style.display = "none";
document.getElementById("radio-control-tci").style.visibility = "hidden";
document.getElementById("radio-control-help").style.display = "none";
document.getElementById("radio-control-help").style.visibility = "hidden";
@ -563,6 +592,9 @@ window.addEventListener("DOMContentLoaded", () => {
document.getElementById("radio-control-help").style.display = "none";
document.getElementById("radio-control-help").style.visibility = "hidden";
document.getElementById("radio-control-tci").style.display = "none";
document.getElementById("radio-control-tci").style.visibility = "hidden";
document.getElementById("radio-control-rigctld").style.visibility =
"visible";
document.getElementById("radio-control-rigctld").style.display = "block";
@ -572,6 +604,32 @@ window.addEventListener("DOMContentLoaded", () => {
FD.saveConfig(config, configPath);
});
// // radio settings 'rigctld' event listener
document
.getElementById("radio-control-switch-tci")
.addEventListener("click", () => {
//document.getElementById("hamlib_info_field").innerHTML =
// "Edit your rigctld settings and start and stop rigctld .";
document.getElementById("radio-control-disabled").style.display = "none";
document.getElementById("radio-control-disabled").style.visibility =
"hidden";
document.getElementById("radio-control-rigctld").style.display = "none";
document.getElementById("radio-control-rigctld").style.visibility = "hidden";
document.getElementById("radio-control-help").style.display = "none";
document.getElementById("radio-control-help").style.visibility = "hidden";
document.getElementById("radio-control-tci").style.visibility =
"visible";
document.getElementById("radio-control-tci").style.display = "block";
config.radiocontrol = "tci";
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
FD.saveConfig(config, configPath);
});
document
.getElementById("btnHamlibCopyCommand")
.addEventListener("click", () => {

View file

@ -407,6 +407,25 @@
Hamlib
</label>
</div>
<div
class="btn-group btn-group-sm"
role="group"
aria-label="radio-control-switch-tci"
>
<input
type="radio"
class="btn-check"
name="radio-control-switch"
id="radio-control-switch-tci"
autocomplete="off"
/>
<label
class="btn btn-sm btn-outline-secondary"
for="radio-control-switch-tci"
>
TCI
</label>
</div>
</div>
</div>
@ -437,7 +456,7 @@
</p>
</div>
<!-- RADIO CONTROL RIGCTLD INFO-->
<!-- RADIO CONTROL RIGCTLD -->
<div id="radio-control-rigctld">
<div class="input-group input-group-sm mb-1">
<div class="input-group input-group-sm mb-1">
@ -502,7 +521,36 @@
</div>
</div>
</div>
<!-- RADIO CONTROL TCI-->
<div id="radio-control-tci">
<div class="input-group input-group-sm mb-1">
<div class="input-group input-group-sm mb-1">
<span class="input-group-text">TCI</span>
<span class="input-group-text">Address</span>
<input
type="text"
class="form-control"
placeholder="tci IP"
id="tci_ip"
aria-label="Device IP"
aria-describedby="basic-addon1"
/>
</div>
<div class="input-group input-group-sm mb-1">
<span class="input-group-text">Port</span>
<input
type="text"
class="form-control"
placeholder="tci port"
id="tci_port"
aria-label="Device Port"
aria-describedby="basic-addon1"
/>
</div>
</div>
</div>
<!-- RADIO CONTROL HELP -->
<div id="radio-control-help">
<strong>VOX:</strong> Use rig control mode 'none'

View file

@ -2855,7 +2855,9 @@ class DATA:
self.log.info("[TNC] ENABLE FSK", state=TNC.enable_fsk)
self.enqueue_frame_for_tx([cq_frame], c2_mode=FREEDV_MODE.fsk_ldpc_0.value)
else:
self.enqueue_frame_for_tx([cq_frame], c2_mode=FREEDV_MODE.sig0.value, copies=1, repeat_delay=0)
#self.enqueue_frame_for_tx([cq_frame], c2_mode=FREEDV_MODE.sig0.value, copies=1, repeat_delay=0)
TNC.transmitting = True
modem.MODEM_TRANSMIT_QUEUE.put(["morse", 1, 0, "123"])
def received_cq(self, data_in: bytes) -> None:
"""

View file

@ -28,6 +28,7 @@ from static import FRAME_TYPE
import structlog
import ujson as json
import tci
import cw
from queues import DATA_QUEUE_RECEIVED, MODEM_RECEIVED_QUEUE, MODEM_TRANSMIT_QUEUE, RIGCTLD_COMMAND_QUEUE, \
AUDIO_RECEIVED_QUEUE, AUDIO_TRANSMIT_QUEUE
@ -686,19 +687,8 @@ class RF:
self.mod_out_locked = True
# -------------------------------
chunk_length = self.AUDIO_FRAMES_PER_BUFFER_TX # 4800
chunk = [
txbuffer_out[i: i + chunk_length]
for i in range(0, len(txbuffer_out), chunk_length)
]
for c in chunk:
# Pad the chunk, if needed
if len(c) < chunk_length:
delta = chunk_length - len(c)
delta_zeros = np.zeros(delta, dtype=np.int16)
c = np.append(c, delta_zeros)
# self.log.debug("[MDM] mod out shorter than audio buffer", delta=delta)
self.modoutqueue.append(c)
# add modulation to modout_queue
self.enqueue_modulation(txbuffer_out)
# Release our mod_out_lock, so we can use the queue
self.mod_out_locked = False
@ -745,6 +735,93 @@ class RF:
transmission_time = end_of_transmission - start_of_transmission
self.log.debug("[MDM] ON AIR TIME", time=transmission_time)
def transmit_morse(self, repeats, repeat_delay, frames):
TNC.transmitting = True
# if we're transmitting FreeDATA signals, reset channel busy state
ModemParam.channel_busy = False
self.log.debug(
"[MDM] TRANSMIT", mode="MORSE"
)
start_of_transmission = time.time()
txbuffer = cw.MorseCodePlayer().text_to_signal("DJ2LS-1")
print(txbuffer)
print(type(txbuffer))
x = np.frombuffer(txbuffer, dtype=np.int16)
print(type(x))
txbuffer_out = x
print(txbuffer_out)
#if not AudioParam.audio_enable_tci:
# txbuffer_out = self.resampler.resample8_to_48(x)
#else:
# txbuffer_out = x
self.mod_out_locked = True
self.enqueue_modulation(txbuffer_out)
self.mod_out_locked = False
# we need to wait manually for tci processing
if AudioParam.audio_enable_tci:
duration = len(txbuffer_out) / 8000
timestamp_to_sleep = time.time() + duration
self.log.debug("[MDM] TCI calculated duration", duration=duration)
tci_timeout_reached = False
#while time.time() < timestamp_to_sleep:
# threading.Event().wait(0.01)
else:
timestamp_to_sleep = time.time()
# set tci timeout reached to True for overriding if not used
tci_timeout_reached = True
while self.modoutqueue or not tci_timeout_reached:
if AudioParam.audio_enable_tci:
if time.time() < timestamp_to_sleep:
tci_timeout_reached = False
else:
tci_timeout_reached = True
threading.Event().wait(0.01)
# if we're transmitting FreeDATA signals, reset channel busy state
ModemParam.channel_busy = False
HamlibParam.ptt_state = self.radio.set_ptt(False)
# Push ptt state to socket stream
jsondata = {"ptt": "False"}
data_out = json.dumps(jsondata)
sock.SOCKET_QUEUE.put(data_out)
# After processing, set the locking state back to true to be prepared for next transmission
self.mod_out_locked = True
self.modem_transmit_queue.task_done()
TNC.transmitting = False
threading.Event().set()
end_of_transmission = time.time()
transmission_time = end_of_transmission - start_of_transmission
self.log.debug("[MDM] ON AIR TIME", time=transmission_time)
def enqueue_modulation(self, txbuffer_out):
chunk_length = self.AUDIO_FRAMES_PER_BUFFER_TX # 4800
chunk = [
txbuffer_out[i: i + chunk_length]
for i in range(0, len(txbuffer_out), chunk_length)
]
for c in chunk:
# Pad the chunk, if needed
if len(c) < chunk_length:
delta = chunk_length - len(c)
delta_zeros = np.zeros(delta, dtype=np.int16)
c = np.append(c, delta_zeros)
# self.log.debug("[MDM] mod out shorter than audio buffer", delta=delta)
self.modoutqueue.append(c)
def demodulate_audio(
self,
audiobuffer: codec2.audio_buffer,
@ -1009,10 +1086,12 @@ class RF:
self.log.debug("[MDM] self.modem_transmit_queue", qsize=queuesize)
data = self.modem_transmit_queue.get()
# self.log.debug("[MDM] worker_transmit", mode=data[0])
self.transmit(
mode=data[0], repeats=data[1], repeat_delay=data[2], frames=data[3]
)
if data[0] in ["morse"]:
self.transmit_morse(repeats=data[1], repeat_delay=data[2], frames=data[3])
else:
self.transmit(
mode=data[0], repeats=data[1], repeat_delay=data[2], frames=data[3]
)
# self.modem_transmit_queue.task_done()
def worker_received(self) -> None:
@ -1399,3 +1478,4 @@ def get_modem_error_state():
return True
return False