arcs

Amateur Radio Chat Server with a modern interface
git clone git://squid-tech.com/arcs.git
Log | Files | Refs | README

commit 53060834b4d0b10a4a79e5696c9b3eb0c8621e74
parent f4e42f6c53bb432f3ad437773153517eb4b6f2f2
Author: joshiemoore <jxm5210@g.rit.edu>
Date:   Fri, 20 Dec 2019 02:01:19 -0500

Add GUI frontend for the application

Diffstat:
MREADME.md | 2+-
Marcs.py | 87++++++++++++++++++++++++++++++++++++++-----------------------------------------
Aarcs_1.png | 0
3 files changed, 43 insertions(+), 46 deletions(-)

diff --git a/README.md b/README.md @@ -14,7 +14,7 @@ ARCS is based on "pure" python3, so no special setup is required. You also need 4. If you are running your own server, modify the server config section of `arcs.py` to match your setup. 5. Connect your radio to your computer, and set it to frequency 144.39 (national APRS frequency). 6. Run `direwolf -p`, making note of the path to the serial KISS TNC. -7. Start ARCS with `python3 arcs.py <serial/tnc/path> 9600 [options ...]` (If you are running your own server, include the `-server` flag in the options field) +7. Start ARCS with `python3 arcs.py <serial/tnc/path> 115200 [options ...]` (If you are running your own server, include the `-server` flag in the options field) 8. Open `index.html` in your web browser, and you're ready to go! ### Commands diff --git a/arcs.py b/arcs.py @@ -7,7 +7,7 @@ import threading import time import random -import socketserver +import tkinter # change this to your callsign MYCALL = 'KD2SIX' @@ -57,30 +57,9 @@ _SERVER = False _USERS = {} -# list of local unread messages, for use by the web client -# format is (CALLSIGN, MSG) -_MSGS = [] - _PATH = ["KD2AYD-3"] -# browser server host and port -CLIENTHOST, CLIENTPORT = "localhost", 8080 - - -""" -Handler for requests from the browser client. -""" -class BrowserHandler(socketserver.BaseRequestHandler): - def handle(self): - self.data = self.request.recv(1024).strip() - # output the data - print(self.data) - - # send back the same data, uppercase - self.request.sendall(self.data.upper()) - - """ Send command and data to the KISS TNC. data should be a byte array. @@ -256,7 +235,7 @@ def relay(port, msg): """ Main server daemon that receives and routes messages. """ -def serverd(port): +def serverd(port, textdisplay): while True: # receive and parse a packet recv = AX25parse(AX25read(port)) @@ -287,33 +266,21 @@ def serverd(port): #\TODO parse /commands - dispmsg = recv[1] + ": " + msg - - # add message to local unread messages - _MSGS.append(dispmsg) + dispmsg = padcall(recv[1]) + ": " + msg # send message to all connected users relay(port, dispmsg) - print(dispmsg) + textdisplay.insert("end", dispmsg) + """ -Test sending messages to the server +Send a chat message from the GUI, and clear the text box. """ -def clientsTest(port): - count = 0 - - time.sleep(5) - sendMessage(port, MYCALL, HOST, _PATH, "initialize") - - while True: - time.sleep(random.randint(30, 60)) - # callsign with random ssid - sendercall = MYCALL + "-" + str(random.randint(2, 5)) - - sendMessage(port, sendercall, HOST, _PATH, "testing" + str(count)) - count = count + 1 +def chatGuiSend(port, entryText): + sendMessage(port, MYCALL, HOST, _PATH, entryText.get()) + entryText.set("") @@ -332,15 +299,45 @@ def main(): # initialize the KISS TNC KISSinit(ser) - # start the browser server - server = socketserver.TCPServer((CLIENTHOST, CLIENTPORT), BrowserHandler) + + # setup GUI + top = tkinter.Tk() + top.title("Amateur Radio Chat Server") + top.geometry('640x480') + + display = tkinter.Listbox(top, font = "TkFixedFont") + display.pack(expand = True, fill = tkinter.BOTH) + + scrollbar = tkinter.Scrollbar(display, orient = "vertical") + scrollbar.config(command=display.yview) + scrollbar.pack(side = "right", fill = "y") + + display.config(yscrollcommand = scrollbar.set) + + bottomframe = tkinter.Frame(top) + bottomframe.pack(side = tkinter.BOTTOM, fill = 'x') + + entryText = tkinter.StringVar() + entry = tkinter.Entry(bottomframe, textvariable = entryText) + entry.pack(expand = True, side = tkinter.LEFT, fill = 'x') + + send = tkinter.Button(bottomframe, text="Send", command = lambda: chatGuiSend(ser, entryText)) + send.pack(side = tkinter.RIGHT) + + + + # start background daemons for client or server if _SERVER: # start beacon daemon threading.Thread(target=beacond, args=[ser]).start() # start server daemon - threading.Thread(target=serverd, args=[ser]).start() + threading.Thread(target=serverd, args=[ser, display]).start() + + + # start the GUI + top.mainloop() if __name__ == '__main__': diff --git a/arcs_1.png b/arcs_1.png Binary files differ.