diff --git a/gui/daemon.js b/gui/daemon.js
index 0397b191..c866e782 100644
--- a/gui/daemon.js
+++ b/gui/daemon.js
@@ -209,7 +209,7 @@ exports.getDaemonState = function() {
// START TNC
// ` `== multi line string
-exports.startTNC = function(mycall, mygrid, rx_audio, tx_audio, radiocontrol, devicename, deviceport, pttprotocol, pttport, serialspeed, data_bits, stop_bits, handshake, rigctld_ip, rigctld_port, enable_fft, enable_scatter, low_bandwith_mode, tuning_range_fmin, tuning_range_fmax, enable_fsk) {
+exports.startTNC = function(mycall, mygrid, rx_audio, tx_audio, radiocontrol, devicename, deviceport, pttprotocol, pttport, serialspeed, data_bits, stop_bits, handshake, rigctld_ip, rigctld_port, enable_fft, enable_scatter, low_bandwith_mode, tuning_range_fmin, tuning_range_fmax, enable_fsk, tx_audio_level) {
var json_command = JSON.stringify({
type: 'set',
command: 'start_tnc',
@@ -234,7 +234,8 @@ exports.startTNC = function(mycall, mygrid, rx_audio, tx_audio, radiocontrol, de
enable_fsk: enable_fsk,
low_bandwith_mode : low_bandwith_mode,
tuning_range_fmin : tuning_range_fmin,
- tuning_range_fmax : tuning_range_fmax
+ tuning_range_fmax : tuning_range_fmax,
+ tx_audio_level : tx_audio_level
}]
})
diff --git a/gui/preload-main.js b/gui/preload-main.js
index ab231a28..f233873c 100644
--- a/gui/preload-main.js
+++ b/gui/preload-main.js
@@ -161,6 +161,12 @@ document.getElementById('openReceivedFilesFolder').addEventListener('click', ()
document.getElementById("tuning_range_fmin").value = config.tuning_range_fmin;
document.getElementById("tuning_range_fmax").value = config.tuning_range_fmax;
+
+ // Update TX Audio Level
+ document.getElementById("audioLevelTXvalue").innerHTML = config.tx_audio_level;
+ document.getElementById("audioLevelTX").value = config.tx_audio_level;
+
+
if (config.spectrum == 'waterfall') {
document.getElementById("waterfall-scatter-switch1").checked = true;
document.getElementById("waterfall-scatter-switch2").checked = false;
@@ -378,14 +384,35 @@ document.getElementById('openReceivedFilesFolder').addEventListener('click', ()
});
-
+ // on change tnc port
document.getElementById("tnc_port").addEventListener("change", () => {
config.tnc_port = document.getElementById("tnc_port").value;
config.daemon_port = parseInt(document.getElementById("tnc_port").value) + 1;
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
});
+
+ // on change audio TX Level
+ document.getElementById("audioLevelTX").addEventListener("change", () => {
+ var tx_audio_level = document.getElementById("audioLevelTX").value;
+ document.getElementById("audioLevelTXvalue").innerHTML = tx_audio_level;
+ config.tx_audio_level = tx_audio_level;
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
+ let Data = {
+ command: "set_tx_audio_level",
+ tx_audio_level: tx_audio_level
+ };
+ ipcRenderer.send('run-tnc-command', Data);
+
+ });
+ document.getElementById("sendTestFrame").addEventListener("click", () => {
+ let Data = {
+ type: "set",
+ command: "send_test_frame"
+ };
+ ipcRenderer.send('run-tnc-command', Data);
+ });
// saveMyCall button clicked
document.getElementById("saveMyCall").addEventListener("click", () => {
callsign = document.getElementById("myCall").value;
@@ -644,7 +671,7 @@ document.getElementById('openReceivedFilesFolder').addEventListener('click', ()
var radiocontrol = 'disabled';
}
-
+ var tx_audio_level = document.getElementById("audioLevelTX").value;
config.radiocontrol = radiocontrol;
@@ -668,6 +695,7 @@ document.getElementById('openReceivedFilesFolder').addEventListener('click', ()
config.enable_fft = enable_fft;
config.enable_fsk = enable_fsk;
config.low_bandwith_mode = low_bandwith_mode;
+ config.tx_audio_level = tx_audio_level;
@@ -688,7 +716,7 @@ document.getElementById('openReceivedFilesFolder').addEventListener('click', ()
*/
- daemon.startTNC(callsign_ssid, mygrid, rx_audio, tx_audio, radiocontrol, deviceid, deviceport, pttprotocol, pttport, serialspeed, data_bits, stop_bits, handshake, rigctld_ip, rigctld_port, enable_fft, enable_scatter, low_bandwith_mode, tuning_range_fmin, tuning_range_fmax, enable_fsk);
+ daemon.startTNC(callsign_ssid, mygrid, rx_audio, tx_audio, radiocontrol, deviceid, deviceport, pttprotocol, pttport, serialspeed, data_bits, stop_bits, handshake, rigctld_ip, rigctld_port, enable_fft, enable_scatter, low_bandwith_mode, tuning_range_fmin, tuning_range_fmax, enable_fsk, tx_audio_level);
})
@@ -1782,6 +1810,14 @@ ipcRenderer.on('run-tnc-command', (event, arg) => {
if (arg.command == 'stop_transmission') {
sock.stopTransmission();
}
+ if (arg.command == 'set_tx_audio_level') {
+ sock.setTxAudioLevel(arg.tx_audio_level);
+ }
+ if (arg.command == 'send_test_frame') {
+ sock.sendTestFrame();
+ }
+
+
});
diff --git a/gui/sock.js b/gui/sock.js
index 67c04daa..db1f0a34 100644
--- a/gui/sock.js
+++ b/gui/sock.js
@@ -365,6 +365,14 @@ exports.sendCQ = function() {
writeTncCommand(command)
}
+// Set AUDIO Level
+exports.setTxAudioLevel = function(value) {
+ command = '{"type" : "set", "command" : "tx_audio_level", "value" : "'+ value +'"}'
+ writeTncCommand(command)
+}
+
+
+
// Send File
exports.sendFile = function(dxcallsign, mode, frames, filename, filetype, data, checksum) {
@@ -447,3 +455,9 @@ exports.disconnectARQ = function() {
command = '{"type" : "arq", "command" : "disconnect"}'
writeTncCommand(command)
}
+
+// SEND SINE
+exports.sendTestFrame = function() {
+ command = '{"type" : "set", "command" : "send_test_frame"}'
+ writeTncCommand(command)
+}
diff --git a/gui/src/index.html b/gui/src/index.html
index 6f99d31a..b9833980 100644
--- a/gui/src/index.html
+++ b/gui/src/index.html
@@ -802,7 +802,7 @@
@@ -1173,10 +1173,24 @@
- ...
+
+
Test-Frame
+
+
+
+
+
+ TX Level
+ ---
+
+
+
+
+
+
diff --git a/tnc/daemon.py b/tnc/daemon.py
index 0ac573dd..66dc8cb0 100755
--- a/tnc/daemon.py
+++ b/tnc/daemon.py
@@ -218,6 +218,10 @@ class DAEMON():
if data[21] == 'True':
options.append('--fsk')
+
+ options.append('--tx-audio-level')
+ options.append(data[22])
+
# try running tnc from binary, else run from source
diff --git a/tnc/data_handler.py b/tnc/data_handler.py
index 384643be..5c4c5633 100644
--- a/tnc/data_handler.py
+++ b/tnc/data_handler.py
@@ -163,6 +163,9 @@ class DATA():
# [0] DX CALLSIGN
self.close_session()
+ elif data[0] == 'SEND_TEST_FRAME':
+ # [0] DX CALLSIGN
+ self.send_test_frame()
else:
# wrong command
print(f"wrong command {data}")
@@ -1943,3 +1946,8 @@ class DATA():
time.sleep(1)
self.transmit_session_heartbeat()
time.sleep(2)
+
+
+
+ def send_test_frame(self):
+ modem.MODEM_TRANSMIT_QUEUE.put([12,1,0,[bytearray(126)]])
diff --git a/tnc/main.py b/tnc/main.py
index f9464e04..e0cdd41e 100755
--- a/tnc/main.py
+++ b/tnc/main.py
@@ -71,7 +71,8 @@ if __name__ == '__main__':
PARSER.add_argument('--500hz', dest="low_bandwith_mode", action="store_true", help="Enable low bandwith mode ( 500 Hz only )")
PARSER.add_argument('--fsk', dest="enable_fsk", action="store_true", help="Enable FSK mode for ping, beacon and CQ")
PARSER.add_argument('--tuning_range_fmin', dest="tuning_range_fmin", choices=[-50.0, -100.0, -150.0, -200.0, -250.0], default=-50.0, help="Tuning range fmin", type=float)
- PARSER.add_argument('--tuning_range_fmax', dest="tuning_range_fmax", choices=[50.0, 100.0, 150.0, 200.0, 250.0], default=50.0, help="Tuning range fmax", type=float)
+ PARSER.add_argument('--tuning_range_fmax', dest="tuning_range_fmax", choices=[50.0, 100.0, 150.0, 200.0, 250.0], default=50.0, help="Tuning range fmax", type=float)
+ PARSER.add_argument('--tx-audio-level', dest="tx_audio_level", default=50, help="Set the tx audio level at an early stage", type=int)
ARGS = PARSER.parse_args()
@@ -108,7 +109,7 @@ if __name__ == '__main__':
static.LOW_BANDWITH_MODE = ARGS.low_bandwith_mode
static.TUNING_RANGE_FMIN = ARGS.tuning_range_fmin
static.TUNING_RANGE_FMAX = ARGS.tuning_range_fmax
-
+ static.TX_AUDIO_LEVEL = ARGS.tx_audio_level
diff --git a/tnc/modem.py b/tnc/modem.py
index 70562692..4021fb5b 100644
--- a/tnc/modem.py
+++ b/tnc/modem.py
@@ -216,11 +216,12 @@ class RF():
audio_thread_datac3 = threading.Thread(target=self.audio_datac3, name="AUDIO_THREAD DATAC3",daemon=True)
audio_thread_datac3.start()
- audio_thread_fsk_ldpc0 = threading.Thread(target=self.audio_fsk_ldpc_0, name="AUDIO_THREAD FSK LDPC0",daemon=True)
- audio_thread_fsk_ldpc0.start()
+ if static.ENABLE_FSK:
+ audio_thread_fsk_ldpc0 = threading.Thread(target=self.audio_fsk_ldpc_0, name="AUDIO_THREAD FSK LDPC0",daemon=True)
+ audio_thread_fsk_ldpc0.start()
- audio_thread_fsk_ldpc1 = threading.Thread(target=self.audio_fsk_ldpc_1, name="AUDIO_THREAD FSK LDPC1",daemon=True)
- audio_thread_fsk_ldpc1.start()
+ audio_thread_fsk_ldpc1 = threading.Thread(target=self.audio_fsk_ldpc_1, name="AUDIO_THREAD FSK LDPC1",daemon=True)
+ audio_thread_fsk_ldpc1.start()
hamlib_thread = threading.Thread(target=self.update_rig_data, name="HAMLIB_THREAD",daemon=True)
hamlib_thread.start()
@@ -382,6 +383,7 @@ class RF():
codec2.api.freedv_rawdatatx(freedv,mod_out,data) # modulate DATA and save it into mod_out pointer
txbuffer += bytes(mod_out)
+
# append postamble to txbuffer
codec2.api.freedv_rawdatapostambletx(freedv, mod_out_postamble)
@@ -393,6 +395,7 @@ class RF():
# resample up to 48k (resampler works on np.int16)
x = np.frombuffer(txbuffer, dtype=np.int16)
+ x = set_audio_volume(x, static.TX_AUDIO_LEVEL)
txbuffer_48k = self.resampler.resample8_to_48(x)
# explicitly lock our usage of mod_out_queue if needed
@@ -411,6 +414,7 @@ class RF():
#structlog.get_logger("structlog").debug("[TNC] mod out shorter than audio buffer", delta=delta)
self.modoutqueue.append(c)
+
# Release our mod_out_lock so we can use the queue
@@ -516,9 +520,10 @@ class RF():
""" """
while True:
data = self.modem_transmit_queue.get()
+
self.transmit(mode=data[0], repeats=data[1], repeat_delay=data[2], frames=data[3])
#self.modem_transmit_queue.task_done()
-
+
# worker for FIFO queue for processing received frames
@@ -620,7 +625,8 @@ class RF():
static.HAMLIB_FREQUENCY = self.hamlib.get_frequency()
static.HAMLIB_MODE = self.hamlib.get_mode()
static.HAMLIB_BANDWITH = self.hamlib.get_bandwith()
-
+
+
def calculate_fft(self):
""" """
# channel_busy_delay counter
@@ -723,4 +729,10 @@ def get_bytes_per_frame(mode):
# get number of bytes per frame for mode
return int(codec2.api.freedv_get_bits_per_modem_frame(freedv)/8)
+
+
+def set_audio_volume(datalist, volume):
+ data = np.fromstring(datalist, np.int16) * (volume / 100.)
+ return data.astype(np.int16)
+
diff --git a/tnc/sock.py b/tnc/sock.py
index 77aa7da6..44e6542b 100644
--- a/tnc/sock.py
+++ b/tnc/sock.py
@@ -193,6 +193,26 @@ def process_tnc_commands(data):
# convert data to json object
received_json = json.loads(data)
+ # SET TX AUDIO LEVEL -----------------------------------------------------
+ if received_json["type"] == "set" and received_json["command"] == "tx_audio_level":
+ try:
+ static.TX_AUDIO_LEVEL = int(received_json["value"])
+ command_response("tx_audio_level", True)
+
+ except Exception as e:
+ command_response("tx_audio_level", False)
+ structlog.get_logger("structlog").warning("[SCK] command execution error", e=e, command=received_json)
+
+
+ # TRANSMIT SINE WAVE -----------------------------------------------------
+ if received_json["type"] == "set" and received_json["command"] == "send_test_frame":
+ try:
+ data_handler.DATA_QUEUE_TRANSMIT.put(['SEND_TEST_FRAME'])
+ command_response("send_test_frame", True)
+ except Exception as e:
+ command_response("send_test_frame", False)
+ structlog.get_logger("structlog").warning("[SCK] command execution error", e=e, command=received_json)
+
# CQ CQ CQ -----------------------------------------------------
if received_json["command"] == "cqcqcq":
try:
@@ -492,7 +512,7 @@ def process_daemon_commands(data):
low_bandwith_mode = str(received_json["parameter"][0]["low_bandwith_mode"])
tuning_range_fmin = str(received_json["parameter"][0]["tuning_range_fmin"])
tuning_range_fmax = str(received_json["parameter"][0]["tuning_range_fmax"])
-
+ tx_audio_level = str(received_json["parameter"][0]["tx_audio_level"])
DAEMON_QUEUE.put(['STARTTNC', \
mycall, \
@@ -515,7 +535,8 @@ def process_daemon_commands(data):
low_bandwith_mode, \
tuning_range_fmin, \
tuning_range_fmax, \
- enable_fsk \
+ enable_fsk, \
+ tx_audio_level \
])
command_response("start_tnc", True)
diff --git a/tnc/static.py b/tnc/static.py
index 2ef7dbcc..7fcd68fd 100644
--- a/tnc/static.py
+++ b/tnc/static.py
@@ -70,6 +70,7 @@ ENABLE_FSK = False
# ---------------------------------
# Audio Defaults
+TX_AUDIO_LEVEL = 50
AUDIO_INPUT_DEVICES = []
AUDIO_OUTPUT_DEVICES = []
AUDIO_INPUT_DEVICE = -2