A basic ax26 terminal.

main.py 1.0KB

    import ax26 import sys, fcntl, os import kiss2 from termcolor import colored import time #Set input to be non-blocking fd = sys.stdin.fileno() fl = fcntl.fcntl(fd, fcntl.F_GETFL) fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK) readbuf = "" k = kiss2.TCPKISS(host='localhost', port=8001) k.start() client = ax26.Client(k, "YOUR_CALLSIGN") connected = False while True: time.sleep(0.2) readbuf += sys.stdin.read(4096) splitInput = readbuf.split('\n') if len(splitInput) > 1: for line in splitInput[:-1]: if line.startswith(":connect"): if not connected: connected = client.connect(line[9:]) else: print(colored("Already connected!", 'red')) elif line.startswith(":disconnect"): if connected: client.disconnect() print(colored("Disconnected.", 'yellow')) connected = False else: print(colored("Not connected!", 'red')) elif connected: client.send_data(line.encode()) axbuf = client.receive_data() if axbuf: print(colored(axbuf.decode(), 'green')) readbuf = splitInput[-1]