Skip to content

MarineAppliedResearch/MEG-D_Terminal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MEG-D Terminal

A responsive, network-based terminal for interacting with MEG-D microcontrollers over a UDP JSON serial bridge.

MEG-D Terminal provides a clean desktop interface for sending commands and observing device output in real time, without requiring a direct serial connection.


Overview

MEG-D Terminal bridges a local user interface to remote serial devices through a microcontroller acting as a UDP-to-UART gateway.

User Input -> UDP (JSON) -> MCU -> UART -> Device
Device Output -> UART -> MCU -> UDP (JSON) -> Terminal

The application communicates with the microcontroller over UDP using a structured JSON protocol. The MCU performs routing between network packets and serial devices.


Features

  • UDP-based communication
  • JSON protocol for structured messaging
  • Device-targeted serial routing
  • Real-time console output
  • Local echo with distinct styling
  • Responsive UI (non-blocking architecture)
  • Automatic endpoint latching
  • Packaged executable support (no Python required on target system)

Communication Protocol

The terminal communicates with the MEG-D microcontroller using a JSON-over-UDP protocol.

Outbound (Terminal -> MCU)

{
  "type": "serial_tx",
  "device": "SerialLIGHT",
  "data": "$Lb100",
  "seq": 1
}

Fields

  • type
    Must be "serial_tx"

  • device
    Target serial device on the MCU (e.g. SerialLIGHT, SerialUSB)

  • data
    Raw string transmitted directly to the UART

  • seq
    Sequence number generated by the client


Inbound (MCU -> Terminal)

{
  "type": "serial_rx",
  "device": "SerialLIGHT",
  "data": "OK\\r\\n",
  "seq": 42
}

Behavior

  • Only messages matching the selected device are displayed
  • data is a JSON-escaped string
  • Output is appended directly to the console stream

Connection Model

This system uses UDP, so there is no persistent connection. Instead, the MCU tracks the most recent client.

  • The client sends an initial packet (empty serial_tx)
  • The MCU records the sender’s IP and port
  • All responses are sent to that endpoint

Implications

  • Only one active client is effectively supported at a time
  • The most recent client to send a packet becomes the active console

Application Behavior

Sending Data

  • User enters text in the input field
  • Pressing Enter or Send transmits the text exactly as entered
  • No newline characters are automatically added
  • Text is wrapped into a serial_tx JSON packet and sent over UDP

Receiving Data

  • The application listens on a local UDP port
  • Incoming packets are parsed as JSON
  • Valid serial_rx messages are displayed in the console

Local Echo

  • Sent text is immediately displayed in the console
  • Local echo is rendered in a different color from device output

Getting Started

Requirements

  • Python 3.10+
  • Tkinter (included with standard Python on Windows)

Run from Source

python megd_terminal.py

Packaging (Windows Executable)

Install PyInstaller:

pip install pyinstaller

Build executable:

pyinstaller --windowed --onefile --name "MEG-D Terminal" megd_terminal.py

The output executable will be located in:

dist/

Project Structure

MEGD-Terminal/
├── megd_terminal.py
├── README.md
├── requirements.txt
└── assets/

Design Notes

  • The terminal is stream-oriented, not line-oriented
  • The MCU handles all routing between network and serial devices
  • The protocol is intentionally minimal and extensible
  • No ANSI / VT100 terminal emulation is implemented

Future Improvements

  • Optional newline modes (CR, LF, CRLF)
  • Multi-device tabs or sessions
  • Binary-safe transmission mode
  • Logging and session recording
  • Improved connection diagnostics

License

MIT License

Copyright (c) 2026

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.

About

A responsive, network-based terminal for interacting with MEG-D microcontrollers over a UDP JSON serial bridge.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages