Adding environment setup and instructions

This commit is contained in:
Brent Perteet
2025-07-22 14:04:27 -05:00
parent 311981ceb4
commit dc2885e02e
23 changed files with 3741 additions and 114 deletions

45
flash_tool/monitor.py Normal file
View File

@@ -0,0 +1,45 @@
import json
import serial
import sys
import time
from pathlib import Path
# import colorama
# colorama.just_fix_windows_console()
print("\x1b[0;32mThis should be green\x1b[0m")
print("\x1b[0;31mThis should be red\x1b[0m")
def main():
# Load config
root = Path(__file__).resolve().parent.parent
config_file = root / "settings.json"
if not config_file.exists():
print(f"Error: settings.json not found at {config_file}")
sys.exit(1)
with open(config_file) as f:
cfg = json.load(f)
port = cfg.get("port", "COM3")
baud = cfg.get("monitor_baud", 115200)
print(f"[Serial Monitor] Connecting to {port} at {baud} baud...")
try:
with serial.Serial(port, baud, timeout=0.5) as ser:
print("[Serial Monitor] Press Ctrl+C to exit.\n")
while True:
if ser.in_waiting:
line = ser.readline().decode(errors="replace")
if line:
print(line, end="")
time.sleep(0.01)
except KeyboardInterrupt:
print("\n[Serial Monitor] Disconnected.")
except serial.SerialException as e:
print(f"[Error] Could not open serial port {port}: {e}")
sys.exit(1)
if __name__ == "__main__":
main()