File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 99import time
1010from src .ppk2_api import PPK2_API
1111
12- ppk2_test = PPK2_API ("/dev/ttyACM0" )
12+ ppk2s_connected = PPK2_API .list_devices ()
13+ if (len (ppk2s_connected ) == 1 ):
14+ ppk2_port = ppk2s_connected [0 ]
15+ print (f'Found PPK2 at { ppk2_port } ' )
16+ else :
17+ print (f'Too many connected PPK2\' s: { ppk2s_connected } ' )
18+ exit ()
19+
20+ ppk2_test = PPK2_API (ppk2_port )
1321ppk2_test .get_modifiers ()
1422ppk2_test .use_ampere_meter () # set ampere meter mode
1523ppk2_test .toggle_DUT_power ("OFF" ) # disable DUT power
Original file line number Diff line number Diff line change @@ -171,6 +171,13 @@ def _handle_raw_data(self, adc_value):
171171
172172 return analog_value
173173
174+ @staticmethod
175+ def list_devices ():
176+ import serial .tools .list_ports
177+ ports = serial .tools .list_ports .comports ()
178+ devices = [port .device for port in ports if port .product == 'PPK2' ]
179+ return devices
180+
174181 def get_data (self ):
175182 """Return readings of one sampling period"""
176183 sampling_data = self .ser .read (self .ser .in_waiting )
You can’t perform that action at this time.
0 commit comments