Open berkersal opened 6 months ago
By looking at list_devices()
I implemented
import serial.tools.list_ports
ports = serial.tools.list_ports.comports()
for port in ports:
dev = port.device
serial_number = port.serial_number
It may be a good idea to but serial number in PPK2_API object so people can easily get the serial number
@berkersal Will this suffice https://github.com/IRNAS/ppk2-api-python/pull/43 ?
Yes it helps for my case but it will break the examples for Windows
Ah, of course. Will have a look at that later when I have access to a Windows computer. If you have any input and you're able to test, please feel free to pitch in and I will update the PR (I don't know if serialtools has the same support for fetching the serial in Windows)
Added the same changes to the windows part of list_devices()
as I would assume that works
I don't have access to a Windows computer that I can use with PPK. But the documentation of pyserial says Windows also supports serial number. https://pyserial.readthedocs.io/en/latest/tools.html?highlight=serial.tools.list_ports.comports()#serial.tools.list_ports.comports
Got around to test it now, it works for both systems
I know it is possible to get which port the device is connected to with
list_devices()
but I have two PPK2's in a system and need to know which is which without relying on systems enumeration (a.k.a/dev/ttyACM0
).I checked the source code of the library but couldn't find it.
Thanks in advance.