mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
fixed ctest
This commit is contained in:
parent
1e270114fd
commit
7d6256ba6a
3 changed files with 13 additions and 158 deletions
|
@ -1,104 +0,0 @@
|
||||||
const {
|
|
||||||
ipcRenderer
|
|
||||||
} = require('electron');
|
|
||||||
var config = require('./config.json');
|
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', () => {
|
|
||||||
const replaceText = (selector, text) => {
|
|
||||||
const element = document.getElementById(selector)
|
|
||||||
if (element) element.innerText = text
|
|
||||||
}
|
|
||||||
|
|
||||||
// sendPing button clicked
|
|
||||||
document.getElementById("sendPing").addEventListener("click", () => {
|
|
||||||
dxcallsign = document.getElementById("dxCall").value
|
|
||||||
//sock.sendPing(dxcallsign)
|
|
||||||
|
|
||||||
let Data = {
|
|
||||||
command: "ping",
|
|
||||||
dxcallsign: document.getElementById("dxCall").value
|
|
||||||
};
|
|
||||||
ipcRenderer.send('run-tnc-command', Data);
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
document.getElementById("startTransmission").addEventListener("click", () => {
|
|
||||||
let Data = {
|
|
||||||
command: "sendFile",
|
|
||||||
dxcallsign: document.getElementById("dxCall").value,
|
|
||||||
mode: document.getElementById("datamode").value,
|
|
||||||
frames: document.getElementById("framesperburst").value,
|
|
||||||
filetype: 'txt',
|
|
||||||
filename: 'testfile',
|
|
||||||
data: '1234567',
|
|
||||||
checksum: '123123123',
|
|
||||||
};
|
|
||||||
ipcRenderer.send('run-tnc-command', Data);
|
|
||||||
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ipcRenderer.on('action-update-tnc-state', (event, arg) => {
|
|
||||||
|
|
||||||
// PTT STATE
|
|
||||||
if (arg.ptt_state == 'True') {
|
|
||||||
document.getElementById("ptt_state").className = "btn btn-danger";
|
|
||||||
} else if (arg.ptt_state == 'False') {
|
|
||||||
document.getElementById("ptt_state").className = "btn btn-success";
|
|
||||||
} else {
|
|
||||||
document.getElementById("ptt_state").className = "btn btn-secondary"
|
|
||||||
}
|
|
||||||
|
|
||||||
// BUSY STATE
|
|
||||||
if (arg.busy_state == 'BUSY') {
|
|
||||||
document.getElementById("busy_state").className = "btn btn-danger";
|
|
||||||
} else if (arg.busy_state == 'IDLE') {
|
|
||||||
document.getElementById("busy_state").className = "btn btn-success";
|
|
||||||
} else {
|
|
||||||
document.getElementById("busy_state").className = "btn btn-secondary"
|
|
||||||
}
|
|
||||||
|
|
||||||
// ARQ STATE
|
|
||||||
if (arg.arq_state == 'DATA') {
|
|
||||||
document.getElementById("arq_state").className = "btn btn-warning";
|
|
||||||
} else if (arg.arq_state == 'IDLE') {
|
|
||||||
document.getElementById("arq_state").className = "btn btn-secondary";
|
|
||||||
} else {
|
|
||||||
document.getElementById("arq_state").className = "btn btn-secondary"
|
|
||||||
}
|
|
||||||
|
|
||||||
// CHANNEL STATE
|
|
||||||
if (arg.channel_state == 'RECEIVING_SIGNALLING') {
|
|
||||||
document.getElementById("signalling_state").className = "btn btn-success";
|
|
||||||
document.getElementById("data_state").className = "btn btn-secondary";
|
|
||||||
|
|
||||||
} else if (arg.channel_state == 'SENDING_SIGNALLING') {
|
|
||||||
document.getElementById("signalling_state").className = "btn btn-danger";
|
|
||||||
document.getElementById("data_state").className = "btn btn-secondary";
|
|
||||||
|
|
||||||
} else if (arg.channel_state == 'RECEIVING_DATA') {
|
|
||||||
document.getElementById("signalling_state").className = "btn btn-secondary";
|
|
||||||
document.getElementById("data_state").className = "btn btn-success";
|
|
||||||
|
|
||||||
} else if (arg.channel_state == 'SENDING_DATA') {
|
|
||||||
document.getElementById("signalling_state").className = "btn btn-secondary";
|
|
||||||
document.getElementById("data_state").className = "btn btn-danger";
|
|
||||||
} else {
|
|
||||||
document.getElementById("signalling_state").className = "btn btn-secondary"
|
|
||||||
document.getElementById("busy_state").className = "btn btn-secondary"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
ipcRenderer.on('action-update-data-state', (event, arg) => {
|
|
||||||
|
|
||||||
});
|
|
|
@ -187,7 +187,8 @@ if nread_exceptions:
|
||||||
print(f"RECEIVED BURSTS: {rx_bursts} RECEIVED FRAMES: {rx_total_frames} RX_ERRORS: {rx_errors}", file=sys.stderr)
|
print(f"RECEIVED BURSTS: {rx_bursts} RECEIVED FRAMES: {rx_total_frames} RX_ERRORS: {rx_errors}", file=sys.stderr)
|
||||||
frx.close()
|
frx.close()
|
||||||
|
|
||||||
# and at last check if we had an opened pyaudio instance and close it
|
# and at last check if we had an openend pyaudio instance and close it
|
||||||
if AUDIO_INPUT_DEVICE != -1:
|
if AUDIO_INPUT_DEVICE != -1:
|
||||||
stream_rx.close()
|
stream_rx.close()
|
||||||
p.terminate()
|
p.terminate()
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ parser.add_argument('--bursts', dest="N_BURSTS", default=1, type=int)
|
||||||
parser.add_argument('--framesperburst', dest="N_FRAMES_PER_BURST", default=1, type=int)
|
parser.add_argument('--framesperburst', dest="N_FRAMES_PER_BURST", default=1, type=int)
|
||||||
parser.add_argument('--delay', dest="DELAY_BETWEEN_BURSTS", default=500, type=int,
|
parser.add_argument('--delay', dest="DELAY_BETWEEN_BURSTS", default=500, type=int,
|
||||||
help="delay between bursts in ms")
|
help="delay between bursts in ms")
|
||||||
parser.add_argument('--mode', dest="FREEDV_MODE", type=str, choices=['datac0', 'datac1', 'datac3', 'fsk_ldpc'])
|
parser.add_argument('--mode', dest="FREEDV_MODE", type=str, choices=['datac0', 'datac1', 'datac3'])
|
||||||
parser.add_argument('--audiodev', dest="AUDIO_OUTPUT_DEVICE", default=-1, type=int,
|
parser.add_argument('--audiodev', dest="AUDIO_OUTPUT_DEVICE", default=-1, type=int,
|
||||||
help="audio output device number to use, use -2 to automatically select a loopback device")
|
help="audio output device number to use, use -2 to automatically select a loopback device")
|
||||||
parser.add_argument('--list', dest="LIST", action="store_true", help="list audio devices by number and exit")
|
parser.add_argument('--list', dest="LIST", action="store_true", help="list audio devices by number and exit")
|
||||||
|
@ -86,63 +86,18 @@ if args.TESTFRAMES:
|
||||||
else:
|
else:
|
||||||
data_out = b'HELLO WORLD!'
|
data_out = b'HELLO WORLD!'
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
class ADVANCED(ctypes.Structure):
|
|
||||||
""" """
|
|
||||||
_fields_ = [
|
|
||||||
("interleave_frames", ctypes.c_int),
|
|
||||||
("M", ctypes.c_int),
|
|
||||||
("Rs", ctypes.c_int),
|
|
||||||
("Fs", ctypes.c_int),
|
|
||||||
("first_tone", ctypes.c_int),
|
|
||||||
("tone_spacing", ctypes.c_int),
|
|
||||||
("codename", ctypes.c_char_p),
|
|
||||||
]
|
|
||||||
adv = ADVANCED()
|
|
||||||
adv.interleave_frames = 0 # max amplitude
|
|
||||||
adv.M = 2 # number of fsk tones 2/4
|
|
||||||
adv.Rs = 100 # symbol rate
|
|
||||||
adv.Fs = 8000 # sample rate
|
|
||||||
adv.first_tone = 1500 # first tone freq
|
|
||||||
adv.tone_spacing = 200 # shift between tones
|
|
||||||
'''
|
|
||||||
HRA_112_112 rate 0.50 (224,112) # BPF: 14
|
|
||||||
HRA_56_56 rate 0.50 (112,56) # BPF: 7, geht nicht
|
|
||||||
H_2064_516_sparse rate 0.80 (2580,2064) #BPF: 258,
|
|
||||||
HRAb_396_504 rate 0.79 (504,396) # BPF: 49, geht nicht payload !== %8
|
|
||||||
H_256_768_22 rate 0.33 (768,256) # BPF: 32, geht --> geht gut
|
|
||||||
H_256_512_4 rate 0.50 (512,256) # BPF: 32, geht
|
|
||||||
HRAa_1536_512 rate 0.75 (2048,1536) #BPF: 192, geht nicht
|
|
||||||
H_128_256_5 rate 0.50 (256,128) # BPF: 16, geht nicht
|
|
||||||
H_4096_8192_3d rate 0.50 (8192,4096) # BPF: 512, geht nicht
|
|
||||||
H_16200_9720 rate 0.60 (16200,9720) # BPF: 1215
|
|
||||||
H_1024_2048_4f rate 0.50 (2048,1024) # BPF: 128, geht nicht
|
|
||||||
'''
|
|
||||||
|
|
||||||
adv.codename = 'H_256_512_4'.encode('utf-8') # code word
|
# open codec2 instance
|
||||||
|
freedv = cast(codec2.api.freedv_open(MODE), c_void_p)
|
||||||
|
|
||||||
if MODE == 9:
|
|
||||||
# open codec2 advanced instance for ldpc codes
|
|
||||||
print(f"adv.interleave_frames {adv.interleave_frames}")
|
|
||||||
print(f"adv.M {adv.M}")
|
|
||||||
print(f"adv.Rs {adv.Rs}")
|
|
||||||
print(f"adv.Fs {adv.Fs}")
|
|
||||||
print(f"adv.first_tone {adv.first_tone}")
|
|
||||||
print(f"adv.tone_spacing {adv.tone_spacing}")
|
|
||||||
print(f"adv.codename {adv.codename}")
|
|
||||||
#freedv = codec2.api.freedv_open_advanced(MODE, pointer(adv))
|
|
||||||
freedv = cast(codec2.api.freedv_open_advanced(MODE, ctypes.byref(adv)), c_void_p)
|
|
||||||
else:
|
|
||||||
# open codec2 instance
|
|
||||||
freedv = cast(codec2.api.freedv_open(MODE), c_void_p)
|
|
||||||
|
|
||||||
# get number of bytes per frame for mode
|
# get number of bytes per frame for mode
|
||||||
bytes_per_frame = int(codec2.api.freedv_get_bits_per_modem_frame(freedv)/8)
|
bytes_per_frame = int(codec2.api.freedv_get_bits_per_modem_frame(freedv)/8)
|
||||||
payload_bytes_per_frame = bytes_per_frame -2
|
payload_bytes_per_frame = bytes_per_frame -2
|
||||||
print(bytes_per_frame)
|
|
||||||
# init buffer for data
|
# init buffer for data
|
||||||
n_tx_modem_samples = codec2.api.freedv_get_n_tx_modem_samples(freedv)
|
n_tx_modem_samples = codec2.api.freedv_get_n_tx_modem_samples(freedv)
|
||||||
mod_out = create_string_buffer(n_tx_modem_samples * 2)
|
mod_out = create_string_buffer(n_tx_modem_samples * 2)
|
||||||
|
@ -155,6 +110,7 @@ mod_out_preamble = create_string_buffer(n_tx_preamble_modem_samples * 2)
|
||||||
n_tx_postamble_modem_samples = codec2.api.freedv_get_n_tx_postamble_modem_samples(freedv)
|
n_tx_postamble_modem_samples = codec2.api.freedv_get_n_tx_postamble_modem_samples(freedv)
|
||||||
mod_out_postamble = create_string_buffer(n_tx_postamble_modem_samples * 2)
|
mod_out_postamble = create_string_buffer(n_tx_postamble_modem_samples * 2)
|
||||||
|
|
||||||
|
|
||||||
# create buffer for data
|
# create buffer for data
|
||||||
buffer = bytearray(payload_bytes_per_frame) # use this if CRC16 checksum is required ( DATA1-3)
|
buffer = bytearray(payload_bytes_per_frame) # use this if CRC16 checksum is required ( DATA1-3)
|
||||||
buffer[:len(data_out)] = data_out # set buffersize to length of data which will be send
|
buffer[:len(data_out)] = data_out # set buffersize to length of data which will be send
|
||||||
|
@ -171,8 +127,8 @@ for i in range(1,N_BURSTS+1):
|
||||||
|
|
||||||
# write preamble to txbuffer
|
# write preamble to txbuffer
|
||||||
codec2.api.freedv_rawdatapreambletx(freedv, mod_out_preamble)
|
codec2.api.freedv_rawdatapreambletx(freedv, mod_out_preamble)
|
||||||
#txbuffer = bytes(mod_out_preamble)
|
txbuffer = bytes(mod_out_preamble)
|
||||||
txbuffer = bytes()
|
|
||||||
# create modulaton for N = FRAMESPERBURST and append it to txbuffer
|
# create modulaton for N = FRAMESPERBURST and append it to txbuffer
|
||||||
for n in range(1,N_FRAMES_PER_BURST+1):
|
for n in range(1,N_FRAMES_PER_BURST+1):
|
||||||
|
|
||||||
|
@ -180,11 +136,12 @@ for i in range(1,N_BURSTS+1):
|
||||||
codec2.api.freedv_rawdatatx(freedv,mod_out,data) # modulate DATA and save it into mod_out pointer
|
codec2.api.freedv_rawdatatx(freedv,mod_out,data) # modulate DATA and save it into mod_out pointer
|
||||||
|
|
||||||
txbuffer += bytes(mod_out)
|
txbuffer += bytes(mod_out)
|
||||||
|
|
||||||
print(f"TX BURST: {i}/{N_BURSTS} FRAME: {n}/{N_FRAMES_PER_BURST}", file=sys.stderr)
|
print(f"TX BURST: {i}/{N_BURSTS} FRAME: {n}/{N_FRAMES_PER_BURST}", file=sys.stderr)
|
||||||
|
|
||||||
# append postamble to txbuffer
|
# append postamble to txbuffer
|
||||||
codec2.api.freedv_rawdatapostambletx(freedv, mod_out_postamble)
|
codec2.api.freedv_rawdatapostambletx(freedv, mod_out_postamble)
|
||||||
#txbuffer += bytes(mod_out_postamble)
|
txbuffer += bytes(mod_out_postamble)
|
||||||
|
|
||||||
# append a delay between bursts as audio silence
|
# append a delay between bursts as audio silence
|
||||||
samples_delay = int(MODEM_SAMPLE_RATE*DELAY_BETWEEN_BURSTS)
|
samples_delay = int(MODEM_SAMPLE_RATE*DELAY_BETWEEN_BURSTS)
|
||||||
|
@ -212,3 +169,4 @@ if AUDIO_OUTPUT_DEVICE != -1:
|
||||||
stream_tx.stop_stream()
|
stream_tx.stop_stream()
|
||||||
stream_tx.close()
|
stream_tx.close()
|
||||||
p.terminate()
|
p.terminate()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue