The Multiprocessing API will sometimes be blocked or is unable to stop measuring. The PPK2 seems to be remain in measure mode until the program is killed. I've traced the block to the following function:
def stop_measuring(self):
PPK2_API.stop_measuring(self)
PPK2_API.get_data(self) # flush the serial buffer (to prevent unicode error on next command)
self._quit_evt.set()
if self._fetcher is not None:
print(self._fetcher)
self._fetcher.join() # join() will block if the queue isn't empty
self._fetcher = None
The code that produces the bug:
import time
from ppk2_api.ppk2_api import PPK2_MP
ppk2s_connected = PPK2_MP.list_devices()
if(len(ppk2s_connected) == 1):
ppk2_port = ppk2s_connected[0]
print(f'Found PPK2 at {ppk2_port}')
else:
print(f'Too many connected PPK2\'s: {ppk2s_connected}')
exit()
ppk2_test = PPK2_MP(ppk2_port) # Serial port
ppk2_test.get_modifiers()
ppk2_test.use_source_meter() # Set source meter mode
ppk2_test.set_source_voltage(3750) # Set source voltage in mV
ppk2_test.toggle_DUT_power("ON") # Enable DUT power
time.sleep(1) # For timing
ppk2_test.start_measuring()
time.sleep(2) # For timing
for i in range(0, 10):
read_data = ppk2_test.get_data()
if read_data != b'':
samples = ppk2_test.get_samples(read_data)
print(f"Average of {len(samples)} samples is: {sum(samples)/len(samples)}uA")
time.sleep(2) # Higher time seems to recreate the bug more often
ppk2_test.toggle_DUT_power("OFF")
ppk2_test.stop_measuring()
The Multiprocessing API will sometimes be blocked or is unable to stop measuring. The PPK2 seems to be remain in measure mode until the program is killed. I've traced the block to the following function:
The code that produces the bug: