cleanup and better logging

pull/367/head
DJ2LS 2023-02-21 12:03:47 +01:00
parent 755e5efec1
commit cc3b7b16c9
2 changed files with 7 additions and 33 deletions

View File

@ -184,7 +184,7 @@ class RF:
elif not TESTMODE:
# placeholder area for processing audio via TCI
# https://github.com/maksimus1210/TCI
self.log.debug("[MDM] [TCI] Not yet implemented", ip=static.TCI_IP, port=static.TCI_PORT)
self.log.warning("[MDM] [TCI] Not yet fully implemented", ip=static.TCI_IP, port=static.TCI_PORT)
# we are trying this by simulating an audio stream Object like with mkfifo
class Object:
"""An object for simulating audio stream"""
@ -194,15 +194,6 @@ class RF:
# lets init TCI module
self.tci_module = tci.TCI()
# lets open TCI radio
#self.tci_module.open_rig(static.TCI_IP, static.TCI_PORT)
# lets init TCI audio
#self.tci_module.init_audio()
# let's start the audio rx callback
#self.log.debug("[MDM] Starting tci rx callback thread")
tci_rx_callback_thread = threading.Thread(
target=self.tci_rx_callback,
name="TCI RX CALLBACK THREAD",
@ -353,22 +344,6 @@ class RF:
while True:
threading.Event().wait(0.01)
#print(self.tci_module.get_audio())
#data_in48k = self.tci_module.get_audio()
#x = np.frombuffer(self.audio_received_queue.get(), dtype=np.int16)
"""
if not self.audio_received_queue.empty():
x = self.audio_received_queue.get()
x = np.frombuffer(x, dtype=np.int16)
print(x)
print(len(x))
else:
#x = bytes([0]) * 9600
x = np.random.uniform(-1, 1, 2400)
x = np.frombuffer(x, dtype=np.int16)
print("dummy data")
"""
x = self.audio_received_queue.get()
x = np.frombuffer(x, dtype=np.int16)
#x = self.resampler.resample48_to_8(x)

View File

@ -25,8 +25,8 @@ class TCI:
self.audio_received_queue = AUDIO_RECEIVED_QUEUE
self.audio_transmit_queue = AUDIO_TRANSMIT_QUEUE
self.hostname = '127.0.0.1'
self.port = 50001
self.hostname = str(hostname)
self.port = str(port)
self.ws = ''
@ -37,11 +37,11 @@ class TCI:
)
tci_thread.start()
def connect(self):
print("starting..............")
self.ws = websocket.WebSocketApp("ws://127.0.0.1:50001",
self.log.info(
"[TCI] Starting TCI thread!", ip=self.hostname, port=self.port
)
self.ws = websocket.WebSocketApp("ws://" + self.hostname + ":" + self.port,
on_open=self.on_open,
on_message=self.on_message,
on_error=self.on_error,
@ -72,7 +72,6 @@ class TCI:
channel = int.from_bytes(message[28:32], "little")
reserved = int.from_bytes(message[32:36], "little")
audio_data = message[36+28:]
print(len(audio_data))
self.audio_received_queue.put(audio_data)
def on_error(self, error):