Skip to content

Commit 1377d27

Browse files
authored
Merge pull request #474 from neurobionics/461-daq-board-fails-silently
fixes #461: daq board fails silently
2 parents 8ff3a5f + abefe63 commit 1377d27

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

opensourceleg/sensors/adc.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,18 @@ def reset(self) -> None:
152152
def update(self) -> None:
153153
"""
154154
Update the ADC data by reading the latest voltage values in millivolts.
155+
Attempts to read a maximum of 1000 times before throwing an error.
155156
"""
157+
MAX_ATTEMPTS = 1000
158+
attempts = 0
156159
while not self._ready_to_read():
157160
sleep(0.001)
161+
attempts += 1
162+
if attempts > MAX_ATTEMPTS:
163+
raise RuntimeError(
164+
"Couldn't connect to the ADC, please ensure that the device is connected and powered on."
165+
)
166+
158167
self._data = self._read_data_millivolts()
159168

160169
def calibrate(self) -> None:

0 commit comments

Comments
 (0)