This commit is contained in:
dj2ls 2022-02-19 20:45:57 +01:00
parent 879ba00137
commit 34cf0a4b05
9 changed files with 34 additions and 33 deletions

View file

@ -1,8 +0,0 @@
{
"tnc_host" : "127.0.0.1",
"tnc_port" : "3000",
"daemon_host" : "127.0.0.1",
"daemon_port" : "3001",
"mycall" : "AA0AA",
"mygrid" : "AA11ea"
}

View file

@ -175,9 +175,17 @@ app.whenReady().then(() => {
console.log("Trying to start daemon binary")
var folder = path.join(__dirname);
fs.readdir(folder, (err, files) => {
files.forEach(file => {
console.log(file);
});
});
if(os.platform()=='linux'){
daemonProcess = exec('./tnc/daemon', [])
daemonProcess = exec(path.join(__dirname) + '/tnc/daemon', [])
daemonProcess.on('error', (err) => {
console.log(err);
@ -192,7 +200,7 @@ app.whenReady().then(() => {
if(os.platform()=='win32' || os.platform()=='win64'){
daemonProcess = exec('tnc\\daemon.exe', [])
daemonProcess = exec(path.join(__dirname) + '\\tnc\\daemon.exe', [])
daemonProcess.on('error', (err) => {
console.log(err);

View file

@ -2,20 +2,17 @@
import json
import sys
import multiprocessing
####################################################
# https://stackoverflow.com/questions/7088672/pyaudio-working-but-spits-out-error-messages-each-time
# https://github.com/DJ2LS/FreeDATA/issues/22
# we need to have a look at this if we want to run this on Windows and MacOS !
# Currently it seems, this is a Linux-only problem
from ctypes import *
from contextlib import contextmanager
import pyaudio
ERROR_HANDLER_FUNC = CFUNCTYPE(None, c_char_p, c_int, c_char_p, c_int, c_char_p)
def py_error_handler(filename, line, function, err, fmt):
@ -35,14 +32,19 @@ def noalsaerr():
#####################################################
def get_audio_devices():
# we need to run this on windows for multiprocessing support
# multiprocessing.freeze_support()
#multiprocessing.get_context('spawn')
proxy_input_devices = multiprocessing.Manager().list()
proxy_output_devices = multiprocessing.Manager().list()
p = multiprocessing.Process(target=fetch_audio_devices, args=(proxy_input_devices, proxy_output_devices))
p.start()
p.join()
with multiprocessing.Manager() as manager:
proxy_input_devices = manager.list()
proxy_output_devices = manager.list()
#print(multiprocessing.get_start_method())
p = multiprocessing.Process(target=fetch_audio_devices, args=(proxy_input_devices, proxy_output_devices))
p.start()
p.join()
return list(proxy_input_devices), list(proxy_output_devices)
return list(proxy_input_devices), list(proxy_output_devices)
def fetch_audio_devices(input_devices, output_devices):
# UPDATE LIST OF AUDIO DEVICES
@ -59,7 +61,7 @@ def fetch_audio_devices(input_devices, output_devices):
#output_devices = []
for i in range(0, p.get_device_count()):
# we need to do a try exception, beacuse for windows theres now audio device range
# we need to do a try exception, beacuse for windows theres no audio device range
try:
maxInputChannels = p.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')
maxOutputChannels = p.get_device_info_by_host_api_device_index(0, i).get('maxOutputChannels')
@ -75,9 +77,3 @@ def fetch_audio_devices(input_devices, output_devices):
output_devices.append({"id": i, "name": str(name)})
p.terminate()
#proxy_input_devices = input_devices
#proxy_output_devices = output_devices
#d = [input_devices, output_devices]

View file

@ -38,7 +38,6 @@ sys.path.append(app_path)
structlog.get_logger("structlog").info("[C2 ] Searching for libcodec2...")
if sys.platform == 'linux':
files = glob.glob('**/*libcodec2*',recursive=True)
files.append('libcodec2.so')
elif sys.platform == 'darwin':
files = glob.glob('**/*libcodec2*.dylib',recursive=True)
@ -68,6 +67,9 @@ if not 'api' in locals():
# ctypes function init
#api.freedv_set_fmin_fmax.restype = c_int
#api.freedv_set_fmin_fmax.argype = [c_void_p, c_float, c_float]
api.freedv_open.argype = [c_int]
api.freedv_open.restype = c_void_p

View file

@ -1122,8 +1122,8 @@ class DATA():
def received_beacon(self, data_in:bytes):
# here we add the received station to the heard stations buffer
dxcallsign = bytes(data_in[2:8]).rstrip(b'\x00')
dxgrid = bytes(data_in[8:14]).rstrip(b'\x00')
dxcallsign = bytes(data_in[1:7]).rstrip(b'\x00')
dxgrid = bytes(data_in[7:13]).rstrip(b'\x00')
static.INFO.append("BEACON;RECEIVING")
structlog.get_logger("structlog").info("[TNC] BEACON RCVD [" + str(dxcallsign, 'utf-8') + "]["+ str(dxgrid, 'utf-8') +"] ", snr=static.SNR)
helpers.add_to_heard_stations(dxcallsign,dxgrid, 'BEACON', static.SNR, static.FREQ_OFFSET, static.HAMLIB_FREQUENCY)

View file

@ -24,7 +24,7 @@ import re
import queue
import codec2
import audio
import multiprocessing
@ -97,6 +97,9 @@ class RF():
# open codec2 instance
self.datac0_freedv = cast(codec2.api.freedv_open(codec2.api.FREEDV_MODE_DATAC0), c_void_p)
#self.c_lib.freedv_set_fmin_fmax(self.datac0_freedv, c_float(-150.0), c_float(150.0))
self.datac0_bytes_per_frame = int(codec2.api.freedv_get_bits_per_modem_frame(self.datac0_freedv)/8)
self.datac0_payload_per_frame = self.datac0_bytes_per_frame -2
self.datac0_n_nom_modem_samples = self.c_lib.freedv_get_n_nom_modem_samples(self.datac0_freedv)
@ -166,8 +169,8 @@ class RF():
try:
structlog.get_logger("structlog").debug("[TNC] starting pyaudio callback")
#self.audio_stream.start_stream()
multiprocessing.Process(target=self.audio_stream.start_stream).start()
self.audio_stream.start_stream()
except Exception as e:
structlog.get_logger("structlog").error("[TNC] starting pyaudio callback failed", e=e)