fossasia / pslab-python

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

concurrent USB devicss #170

Closed orangecms closed 3 years ago

orangecms commented 3 years ago

Cross-referenced from pslab-desktop: https://github.com/fossasia/pslab-desktop/issues/673

Please have a look over there, an issue reported with multiple USB serial devices present.

bessman commented 3 years ago

This is already possible by specifying the port name of the second device, e.g:

import pslab
h1 = pslab.serial_handler.SerialHandler(port="/dev/ttyUSB0")
h2 = pslab.serial_handler.SerialHandler(port="/dev/ttyUSB1")
scope1 = pslab.Oscilloscope(h1)
scope2 = pslab.Oscilloscope(h2)

However, autodiscovery currently only picks up the first device. That's worth fixing.

SwapnilSoni1999 commented 3 years ago

So what is the expected behaviour?

orangecms commented 3 years ago

Here's my suggestion: Iterate over all USB devices, see if they respond with a PSLab name / version number, and in the desktop app, offer a list. The CLI could report that there are multiple devices available and ask to rerun the command with the device specified through an argument. That is also the behvior of other tools, e.g., flashrom.

What do you think?

bessman commented 3 years ago

That seems like a good solution.

bessman commented 3 years ago

173

bessman commented 3 years ago

I'm closing this since #173 is merged. Let me know if you think the solution works for pslab-desktop.

orangecms commented 3 years ago

Sounds good, thank you so much! :)