Regression in 6.2.0: device monitor rejects piped stdout even when stdin is a TTY

Open Beginner friendly
#5,551 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
cli, embedded-iot

Research direction

Start with platformio/device/monitor/terminal.py, especially new_terminal(), and platformio/compat.py where is_terminal() is defined. Trace how the monitor checks terminal input and review the existing coverage for the guard added in #5503. Add coverage for TTY stdin with piped stdout and confirm the monitor accepts that case while still rejecting non-TTY stdin.

Written by the indexing model from the issue text.

Description

  • PlatformIO Core
Configuration
  • Operating system: macOS 26.6 (arm64)
  • PlatformIO Core: 6.2.0
Steps to reproduce

From an interactive terminal, run:

pio device monitor --port loop:// | cat

loop:// avoids requiring a physical serial device. Only stdout is piped; stdin remains attached to the terminal. The same error occurs when piping a real device's output to jq.

Actual result

The monitor refuses to start:

UserSideException: `pio device monitor` requires an interactive terminal on stdin and cannot run with piped or redirected input. If you're scripting device I/O, talk to the serial port directly instead (e.g., with pyserial) rather than through `pio device monitor`.
Expected result

The monitor starts, reads keyboard input from the terminal, and writes its output to the pipe. It should still reject input that is not a TTY, as intended by #5503.

Additional information

In 6.2.0, new_terminal() calls is_terminal(), which checks sys.stdout.isatty(). That returns False for the pipe even though sys.stdin.isatty() is True. The guard was added in #5503 and is absent in 6.1.19.

Could the monitor check stdin specifically and add coverage for TTY stdin with piped stdout?

Dominant language
Python
Stars
9.6k
Forks
916
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from platformio/platformio-core

All issues in platformio/platformio-core

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.