particle-iot / particle-cli

Command Line Interface for Particle Cloud and devices
Apache License 2.0
212 stars 92 forks source link

Automate Protected Devices to run `particle serial` commands #755

Closed keeramis closed 1 month ago

keeramis commented 1 month ago

Description

Support Protected Devices while running particle serial xxx commands

How to Test

Run particle serial xxx commands on your Protected Devices as well as Open Devices

Related Issues / Discussions

https://app.shortcut.com/particle/story/129645/automate-protected-devices-to-run-particle-serial-commands https://app.shortcut.com/particle/story/129646/automate-protected-devices-to-run-particle-serial-commands-e2e-tests

Completeness

monkbroc commented 1 month ago

The serial monitor command hangs after I press reset on an Argon.

 particle.js serial monitor
Opening serial monitor for com port: " /dev/ttyACM0 "
Serial monitor opened successfully:

Serial connection closed.
(hangs here)
monkbroc commented 1 month ago

With particle serial monitor --follow, it doesn't put the device in service mode after every reconnect so it's possible to get lose the logs after a bunch of resets.

particle serial monitor --follow
Polling for available serial device...Opening serial monitor for com port: " /dev/ttyACM0 "
Serial monitor opened successfully:

Serial connection closed.  Attempting to reconnect...
Serial monitor opened successfully:
0000001674 [ncp.esp32.at] TRACE: > AT
0000001676 [ncp.esp32.at] TRACE: < OK
0000002676 [ncp.esp32.client] TRACE: NCP ready to accept AT commands
0000002677 [ncp.esp32.at] TRACE: > AT+MVER
0000002678 [ncp.esp32.at] TRACE: < 5
0000002678 [ncp.esp32.at] TRACE: < OK
0000002679 [ncp.esp32.at] TRACE: > AT+GETMAC=0
0000002681 [ncp.esp32.at] TRACE: < +GETMAC: "30:ae:a4:d2:b2:64"
0000002681 [ncp.esp32.at] TRACE: < OK
0000002683 [ncp.esp32.at] TRACE: > AT+CMUX=0
0000002690 [ncp.esp32.at] TRACE: < OK
0000002690 [ncp.esp32.mux] INFO: Starting GSM07.10 muxer
0000002691 [ncp.esp32.mux] INFO: Opening mux channel 0
0000002692 [ncp.esp32.mux] INFO: GSM07.10 muxer thread started
0000002695 [ncp.esp32.mux] INFO: Opening mux channel 1
0000002699 [ncp.esp32.at] TRACE: > AT
0000002702 [ncp.esp32.at] TRACE: < OK
0000002702 [ncp.esp32.at] TRACE: > AT+CWDHCP=0,3
0000002707 [ncp.esp32.at] TRACE: < OK
0000002707 [ncp.esp32.client] TRACE: NCP state changed: 1
0000002707 [net.esp32ncp] TRACE: NCP event 1
0000002708 [net.esp32ncp] TRACE: NCP event 3
0000002708 [net.esp32ncp] TRACE: NCP power state changed: IF_POWER_STATE_UP
0000002709 [system.nm] TRACE: Interface 4 power state changed: UP
0000002715 [ncp.esp32.at] TRACE: > AT+CWLAP

Serial connection closed.  Attempting to reconnect...
Serial monitor opened successfully:
monkbroc commented 1 month ago

Serial monitor without follow now properly exits. Good fix :+1:

I'm getting a crash when pressing reset on an Argon during serial monitor follow.

$ particle.js serial monitor --follow
Polling for available serial device...Opening serial monitor for com port: " /dev/ttyACM0 "
Serial monitor opened successfully:

Serial connection closed.  Attempting to reconnect...
TypeError: Cannot read properties of undefined (reading 'getDevice')