Skip to content

run: add -p/--port shortcut to set upload-port and monitor-port simultaneously.#5429

Open
TinyuZhao wants to merge 1 commit intoplatformio:developfrom
TinyuZhao:develop
Open

run: add -p/--port shortcut to set upload-port and monitor-port simultaneously.#5429
TinyuZhao wants to merge 1 commit intoplatformio:developfrom
TinyuZhao:develop

Conversation

@TinyuZhao
Copy link
Copy Markdown

Description

Problem

When developing with multiple devices connected, specifying --upload-port does not automatically apply to --monitor-port. Users must repeat the same port twice:

pio run -e M5Atom \
  --upload-port /dev/cu.usbserial-6152FEC7E2 \
  --monitor-port /dev/cu.usbserial-6152FEC7E2

Worse, when --upload-port is specified but --monitor-port is not, PlatformIO still scans all available serial ports to find a monitor port. This causes failures when other ports are occupied by different devices:

UserSideException: [Errno 35] Could not exclusively lock port /dev/cu.usbserial-75527D1BB6: 
[Errno 35] Resource temporarily unavailable

This is counterintuitive — the user has already explicitly told PlatformIO which device to use, but PlatformIO still tries to touch other devices.

Expected Behavior

When a user specifies --upload-port, PlatformIO should:

  1. Use that port for uploading
  2. Default monitor-port to the same port instead of scanning other ports

Solution

Add -p / --port as a shortcut that sets both --upload-port and --monitor-port to the same value:

# Before
pio run -e M5Atom \
  --upload-port /dev/cu.usbserial-6152FEC7E2 \
  --monitor-port /dev/cu.usbserial-6152FEC7E2

# After
pio run -e M5Atom -p /dev/cu.usbserial-6152FEC7E2

Use Case

Multi-device development environment:

Computer
├── /dev/cu.usbserial-AAA  ← Device A (uploading to this one)
├── /dev/cu.usbserial-BBB  ← Device B (occupied by another process)
└── /dev/cu.usbserial-CCC  ← Device C (occupied by another process)

Currently PlatformIO scans and tries to lock all ports even when the target port is explicitly specified, causing unnecessary errors.

Add shortcut option for upload and monitor ports
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 9, 2026

CLA assistant check
All committers have signed the CLA.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants