From 515cc9bcffb72d38c6f674dea75f14904a6999f6 Mon Sep 17 00:00:00 2001 From: jlpoole Date: Wed, 29 Apr 2026 17:07:08 -0700 Subject: [PATCH] picking up eos change that did not get committed, for PORT designation feature --- README.md | 25 ++++++++++++++++++++++++- gui.cpp | 30 ++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bf9b350..659e444 100644 --- a/README.md +++ b/README.md @@ -125,11 +125,19 @@ cd /usr/local/src/MotionCal Then select the T-Beam USB serial port in the MotionCal window. +To include a manually-created PTY, such as a `socat` split stream, pass it with `--port`: + +```sh +./MotionCal --port /tmp/ttyMotionCal +``` + +The port will appear in the Port menu and the Port dropdown even if it is not discovered by MotionCal's automatic `/dev/tty*` scan. + If running under Wayland and the GUI has trouble starting or rendering, `GDK_BACKEND=x11` forces the wx/GTK path through X11 compatibility. ```sh cd /usr/local/src/MotionCal -GDK_BACKEND=x11 ./MotionCal +GDK_BACKEND=x11 ./MotionCal --port /tmp/ttyMotionCal ``` ## Calibration Procedure @@ -233,6 +241,21 @@ Try the calibration in a different physical location. Watch for read_fail or overflow messages from the bridge firmware. ``` +If MotionCal crashes after a long run with Mesa or AMDGPU allocation errors: + +```text +MotionCal's magnetometer sample buffer is bounded at 650 points, so it is not +intended to grow without limit. Errors such as "MESA: error: amdgpu: failed to +allocate ... from the 32-bit address space" point to the OpenGL/Mesa rendering +stack rather than the calibration data buffer. + +Save calibration once the fit is stable, then restart MotionCal for another run. +Avoid running multiple OpenGL-heavy viewers at the same time if this reproduces. +For troubleshooting, try software rendering: + +LIBGL_ALWAYS_SOFTWARE=1 GDK_BACKEND=x11 ./MotionCal --port /tmp/ttyMotionCal +``` + ## Repository Notes The upstream project did not include a README at the time this fork was created. This document records the local build workflow and the T-Beam/QMC6310 calibration workflow used with this fork. diff --git a/gui.cpp b/gui.cpp index 919afbe..9e9ab5a 100644 --- a/gui.cpp +++ b/gui.cpp @@ -3,9 +3,22 @@ wxString port_name; +static wxArrayString requested_ports; static bool show_calibration_confirmed = false; static bool calibration_saved = false; +static wxArrayString available_port_list(void) +{ + wxArrayString list = serial_port_list(); + for (size_t i=0; i < requested_ports.GetCount(); i++) { + if (list.Index(requested_ports[i]) == wxNOT_FOUND) { + list.Add(requested_ports[i]); + } + } + list.Sort(); + return list; +} + static int valid_mag_point_count(void) { int i, count=0; @@ -383,7 +396,7 @@ void MyFrame::OnShowMenu(wxMenuEvent &event) menu->AppendRadioItem(9000, " (none)"); bool isopen = port_is_open(); if (!isopen) menu->Check(9000, true); - wxArrayString list = serial_port_list(); + wxArrayString list = available_port_list(); int num = list.GetCount(); for (int i=0; i < num; i++) { menu->AppendRadioItem(9001 + i, list[i]); @@ -399,7 +412,7 @@ void MyFrame::OnShowPortList(wxCommandEvent& event) //printf("OnShowPortList\n"); m_port_list->Clear(); m_port_list->Append("(none)"); - wxArrayString list = serial_port_list(); + wxArrayString list = available_port_list(); int num = list.GetCount(); for (int i=0; i < num; i++) { m_port_list->Append(list[i]); @@ -480,6 +493,19 @@ bool MyApp::OnInit() // make sure we exit properly on macosx SetExitOnFrameDelete(true); + for (int i=1; i < argc; i++) { + wxString arg(argv[i]); + if ((arg == "--port" || arg == "-p") && i + 1 < argc) { + wxString requested(argv[++i]); + if (!requested.IsEmpty() && requested_ports.Index(requested) == wxNOT_FOUND) { + requested_ports.Add(requested); + } + } else if (arg == "--help" || arg == "-h") { + fprintf(stderr, "Usage: MotionCal [--port /path/to/tty]\n"); + return false; + } + } + wxPoint pos(100, 100); MyFrame *frame = new MyFrame(NULL, -1, "Motion Sensor Calibration Tool",