Skip to content

Commit 076a7a5

Browse files
committed
Raise exception in start_measuring if input/output voltage is not set. Fixes #12.
1 parent 2121aa0 commit 076a7a5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/ppk2_api/ppk2_api.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def __init__(self, port):
6868
self.vdd_low = 800
6969
self.vdd_high = 5000
7070

71-
self.current_vdd = 0
71+
self.current_vdd = None
7272

7373
self.adc_mult = 1.8 / 163840
7474

@@ -229,11 +229,17 @@ def get_modifiers(self):
229229
return ret
230230

231231
def start_measuring(self):
232-
"""Start continous measurement"""
232+
"""Start continuous measurement"""
233+
if not self.current_vdd:
234+
if self.mode == PPK2_Modes.SOURCE_MODE:
235+
raise Exception("Output voltage not set!")
236+
if self.mode == PPK2_Modes.AMPERE_MODE:
237+
raise Exception("Input voltage not set!")
238+
233239
self._write_serial((PPK2_Command.AVERAGE_START, ))
234240

235241
def stop_measuring(self):
236-
"""Stop continous measurement"""
242+
"""Stop continuous measurement"""
237243
self._write_serial((PPK2_Command.AVERAGE_STOP, ))
238244

239245
def set_source_voltage(self, mV):

0 commit comments

Comments
 (0)