I on a Mac and using the CLI to program and debug an Electron. In a terminal window I launch the serial monitor using:
particle serial monitor
or
particle serial monitor /dev/tty.usbmodem331
no problem here until I want to reprogram the Electron. In order to stop the serial monitor I send a control Z in the terminal and get in response
^Z
[1]+ Stopped(SIGTSTP) particle serial monitor /dev/tty.usbmodem331
Good but then when I try to flash the electron I get:
! serial:
Error writing firmware...Error: Error Resource temporarily unavailable Cannot lock port
Error: Error Resource temporarily unavailable Cannot lock port
at Error (native)
If I try to relaunch the serial monitor I get:
particle serial monitor /dev/tty.usbmodem331
Opening serial monitor for com port: "/dev/tty.usbmodem331"
Serial err: Error: Error Resource temporarily unavailable Cannot lock port
Serial problems, please reconnect the device.
Caught Interrupt. Cleaning up.
The only way to clear the lock on the serial port appears to be to close the terminal window and relaunch it.
So the simple question is how do you terminate the CLI serial monitor process cleanly, i.e. the lock on the serial port is released on exit.