Skip to content

Commit 02e2d23

Browse files
author
marcusw
committed
Need to keep our paperwork in order...updating the copyright dec for that last change.
1 parent fe92109 commit 02e2d23

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

nxt/sensor/digital.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# nxt.sensor module -- Classes to read LEGO Mindstorms NXT sensors
22
# Copyright (C) 2006,2007 Douglas P Lau
33
# Copyright (C) 2009 Marcus Wanner, Paulo Vieira, rhn
4-
# Copyright (C) 2010 Marcus Wanner
4+
# Copyright (C) 2010,2011 Marcus Wanner
55
#
66
# This program is free software: you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
1313
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414
# GNU General Public License for more details.
1515

16-
from nxt.error import I2CError, I2CPendingError
16+
from nxt.error import I2CError, I2CPendingError, DirProtError
1717

1818
from common import *
1919
from time import sleep, time
@@ -128,7 +128,13 @@ def read_value(self, name):
128128
tuples containing only one element.
129129
"""
130130
address, fmt = self.I2C_ADDRESS[name]
131-
return self._i2c_query(address, fmt)
131+
for n in range(3):
132+
try:
133+
return self._i2c_query(address, fmt)
134+
except DirProtError:
135+
print "DEBUG: DirProtError averted!"
136+
pass
137+
raise I2CError, "read_value timeout"
132138

133139
def write_value(self, name, value):
134140
"""Writes value to the sensor. Name must be a string found in

0 commit comments

Comments
 (0)