HipsterBrown / xs-dev

The quickest way for getting started with JS on devices
https://xs-dev.js.org
MIT License
41 stars 13 forks source link

scan fails when non-Espressif device present #27

Closed phoddie closed 2 years ago

phoddie commented 2 years ago

The scan feature works very nicely for ESP8266 and ESP32. But, when neither of those is connected and instead something else is (e.g. Pico), scan exits with an exception:

$ xs-dev scan
⠧ Scanning for devices.../usr/local/lib/node_modules/xs-dev/node_modules/gluegun/build/index.js:15
    throw up;
    ^

Error: Command failed with exit code 1: esptool.py --port /dev/tty.usbmodem14101 read_mac
Traceback (most recent call last):
  File "/Users/hoddie/.espressif/python_env/idf4.4_py3.8_env/lib/python3.8/site-packages/serial/serialposix.py", line 398, in _reconfigure_port
    orig_attr = termios.tcgetattr(self.fd)
termios.error: (6, 'Device not configured')

During handling of the above exception, another exception occurred:
...
HipsterBrown commented 2 years ago

I was a little concerned about this being an issue. Would it be correct to follow the same assumptions as Moddable to check a particular port per platform for an existing pico? Does raspberry pi provide any sort of CLI for scanning that's similar to esptool?

phoddie commented 2 years ago

I unintentionally tangled together two topics here:

  1. There are many kinds of devices that could be connected to the computer using serial. Not all of them will be development boards. There's no way to know which might be development boards (hence scan!). So, when the scan of a given port fails, the scan should continue with the next candidate port.
  2. Detecting Pico. That's trickier. When Pico is in install mode (power up with boot button pressed) it appears on the computer as a disk volume. When in run mode, there may be a serial port, but that depends on the installed project. Moddable SDK projects set-up a serial port for xsbug on debug builds. That could be detected in a scan.

I intended this issue to be about (1) only. I think (2) is a separate development task.

phoddie commented 2 years ago

FWIW – an easy way to see this problem is to attach the Moddable Programmer to USB but not a device. The serial port will work, but won't reply eventually leading to an exception from esptool.py as above.

HipsterBrown commented 2 years ago

For the pico discovery, it looks like picotool could help with getting device info, as long as the chip is in BOOTSEL mode.

Capturing errors / exceptions from esptool shouldn't been too bad to allow for scanning without interruption. :+1: