77import serial
88import time
99import struct
10-
10+ import logging
1111
1212class PPK2_Command ():
1313 """Serial command opcodes"""
@@ -94,7 +94,7 @@ def __del__(self):
9494 if self .ser :
9595 self .ser .close ()
9696 except Exception as e :
97- logging .error (e )
97+ logging .error (f"An error occured while closing ppk2_api: { e } " )
9898
9999 def _pack_struct (self , cmd_tuple ):
100100 """Returns packed struct"""
@@ -106,7 +106,7 @@ def _write_serial(self, cmd_tuple):
106106 cmd_packed = self ._pack_struct (cmd_tuple )
107107 self .ser .write (cmd_packed )
108108 except Exception as e :
109- logging .error (e )
109+ logging .error (f"An error occured when writing to serial port: { e } " )
110110
111111 def _twos_comp (self , val ):
112112 """Compute the 2's complement of int32 value"""
@@ -242,16 +242,13 @@ def set_source_voltage(self, mV):
242242
243243 def toggle_DUT_power (self , state ):
244244 """Toggle DUT power based on parameter"""
245- try :
246- if state == "ON" :
247- self ._write_serial (
248- (PPK2_Command .DEVICE_RUNNING_SET , PPK2_Command .TRIGGER_SET )) # 12,1
249-
250- if state == "OFF" :
251- self ._write_serial (
252- (PPK2_Command .DEVICE_RUNNING_SET , PPK2_Command .NO_OP )) # 12,0
253- except :
254- pass
245+ if state == "ON" :
246+ self ._write_serial (
247+ (PPK2_Command .DEVICE_RUNNING_SET , PPK2_Command .TRIGGER_SET )) # 12,1
248+
249+ if state == "OFF" :
250+ self ._write_serial (
251+ (PPK2_Command .DEVICE_RUNNING_SET , PPK2_Command .NO_OP )) # 12,0
255252
256253 def use_ampere_meter (self ):
257254 """Configure device to use ampere meter"""
0 commit comments