Skip to content

Add SDL2-based native Tools Menu app and documentation - #2

Open
RedMist20 wants to merge 1 commit into
mainfrom
codex/create-sdl2-gui-program-from-tools-menu.sh-so2zaz
Open

Add SDL2-based native Tools Menu app and documentation#2
RedMist20 wants to merge 1 commit into
mainfrom
codex/create-sdl2-gui-program-from-tools-menu.sh-so2zaz

Conversation

@RedMist20

Copy link
Copy Markdown
Owner

Motivation

  • Provide a native SDL2 + SDL2_ttf replacement for the existing Tools Menu.sh shell script to run on the R36S display.
  • Offer a more interactive UI with keyboard/joystick support and a built-in terminal output pane for easier device management.
  • Add a few safety/read-only helper actions such as MDK4 status + version and MDK4 help (safe read-only) not present in the original script.

Description

  • Added a new SDL2-based application under cprog/tools-menu-sdl2 with source tools-menu-sdl2.c implementing the menu, terminal pane, editable channel/txpower entries, and keyboard/joystick controls.
  • Added a CMakeLists.txt at cprog/tools-menu-sdl2/CMakeLists.txt to discover SDL2 and SDL2_ttf via pkg-config and build the tools-menu-sdl2 executable.
  • Updated README.md with a new "SDL2 Tools Menu" section that documents the source location, build instructions using cmake/ninja, and control mappings for the app.
  • The UI executes shell commands via popen() and displays output plus exit codes, supports toggling a terminal input mode, and includes special handling for ACTION_SET_CHANNEL and ACTION_SET_TXPOWER commands.

Testing

  • No automated tests were executed for these changes.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d6c154468a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

} else if (idx == ACTION_SET_TXPOWER) {
snprintf(shell_cmd, sizeof(shell_cmd), "sh -c 'echo Requested txpower: %d mBm; ip link set wlan0 down 2>/dev/null; iw dev wlan0 set txpower fixed %dmBm 2>/dev/null; ip link set wlan0 up 2>/dev/null; iwlist wlan0 txpower 2>/dev/null'", txpower_value, txpower_value);
} else {
snprintf(shell_cmd, sizeof(shell_cmd), "sh -c '%s'", actions[idx].command);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Stop re-quoting action commands with single quotes

Building shell_cmd as sh -c '%s' breaks any action command that already contains single quotes (for example the awk script in WiFi Scan and the quoted regex/echo strings in later actions), so selecting those menu items produces a shell parse error instead of running the tool action. This is a functional regression for multiple built-in commands and should be fixed by avoiding this quoting pattern or properly escaping embedded quotes.

Useful? React with 👍 / 👎.

if (copy) {
char *line = strtok(copy, "\n");
while (line && oy < 420) {
line[56] = '\0';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Prevent out-of-bounds write when truncating output lines

The renderer unconditionally writes line[56] = '\0' for each tokenized output line, but when a line (or the remaining buffer tail) is shorter than 57 bytes this writes past the allocated strdup buffer, causing undefined behavior and potential crashes; a short output such as the "No command entered." path is enough to trigger this condition. Truncation should only happen when the line length is at least 56.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant