IRNAS / ppk2-api-python

Power Profiling Kit 2 unofficial python api.
http://irnas.eu
GNU General Public License v2.0
145 stars 37 forks source link

Serial Number of PPK2 #41

Open berkersal opened 6 months ago

berkersal commented 6 months ago

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.

berkersal commented 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

wlgrd commented 4 months ago

@berkersal Will this suffice https://github.com/IRNAS/ppk2-api-python/pull/43 ?

berkersal commented 4 months ago

Yes it helps for my case but it will break the examples for Windows

wlgrd commented 4 months ago

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)

wlgrd commented 4 months ago

Added the same changes to the windows part of list_devices() as I would assume that works

berkersal commented 4 months ago

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

wlgrd commented 4 months ago

Got around to test it now, it works for both systems