pushi commit kreten sploh ni res.. upam da crknes

This commit is contained in:
0xEmm 2024-05-21 15:00:13 +02:00
parent 1249c29956
commit 8a3eb2de70
3 changed files with 97 additions and 31 deletions

View file

@ -7,11 +7,11 @@ from extron_audio_matrix_telnet_interpreter import *
async def extron_audio_telnet_status(client, reader):
while True:
while True: #TODO TODO TODO
output = await reader.readuntil(b']')
raw_response: str = output.decode().strip() # strip not necessary? needed for local netcat testing though
print("Received: " + raw_response + " from Barco")
parsed = parse_barco_response(raw_response)
parsed = eam_telnet_code_to_field(raw_response)
if parsed == None:
continue # TODO alert for errors
print(f"Updating topic [{parsed[0]}] with value [{parsed[1]}]")
@ -44,14 +44,14 @@ async def extron_audio_telnet_control(client, writer):
# TODO add initial pull
async def shell(reader, writer):
async with aiomqtt.Client('localhost', 1883) as client:
#task_status_query = asyncio.create_task(extron_audio_telnet_query_status(client, writer, reader))
task_status_query = asyncio.create_task(extron_audio_telnet_status(client, writer, reader))
task_control = asyncio.create_task(extron_audio_telnet_control(client, writer))
await asyncio.gather(task_control)
if __name__ == '__main__':
loop = asyncio.get_event_loop()
coro = telnetlib3.open_connection('localhost', 1234, shell=shell)
#coro = telnetlib3.open_connection('192.168.192.14', 23, shell=shell)
#coro = telnetlib3.open_connection('localhost', 1234, shell=shell)
coro = telnetlib3.open_connection('192.168.192.14', 23, shell=shell)
reader, writer = loop.run_until_complete(coro)
loop.run_until_complete(writer.protocol.waiter_closed)