fossasia / pslab-python

Python Library for PSLab Desktop: https://pslab.io
GNU General Public License v3.0
1.62k stars 226 forks source link

Support multiple devices (closes #170) #173

Closed bessman closed 3 years ago

bessman commented 3 years ago

This changes the behavior of auto connect when more than one PSLab is detected. Previously, the device which appeared first in port enumeration would be connected to. Now, SerialHandler will raise an exception, list detected devices, and ask the user to explicitly choose which device they want to connect to.

Also adds a new function, pslab.serial_handler.detect, which returns a dictionary of port names where PSLabs were detected and their version numbers, e.g:

{'/dev/ttyUSB3': 'PSLab V6\n', '/dev/ttyACM3': 'PSLab V5\n'}

If only a single device is detected, auto connect works the same as before.