Skip to content

Commit

Permalink
Fix i2c issues found (param and division by zero) (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
flynneva authored Jan 15, 2023
1 parent f04b088 commit 16d2430
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions bno055/bno055.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ def read_data():
except BusOverRunException:
# data not available yet, wait for next cycle | see #5
return
except ZeroDivisionError:
# division by zero in get_sensor_data, return
return
except Exception as e: # noqa: B902
node.get_logger().warn('Receiving sensor data failed with %s:"%s"'
% (type(e).__name__, e))
Expand Down
4 changes: 2 additions & 2 deletions bno055/params/NodeParameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ def __init__(self, node: Node):
self.connection_type = node.get_parameter('connection_type')
node.get_logger().info('\tconnection_type:\t"%s"' % self.connection_type.value)

if self.connection_type == I2C.CONNECTIONTYPE_I2C:
if self.connection_type.value == I2C.CONNECTIONTYPE_I2C:

self.i2c_bus = node.get_parameter('i2c_bus')
node.get_logger().info('\ti2c_bus:\t\t"%s"' % self.i2c_bus.value)

self.i2c_addr = node.get_parameter('i2c_addr')
node.get_logger().info('\ti2c_addr:\t\t"%s"' % self.i2c_addr.value)

elif self.connection_type == UART.CONNECTIONTYPE_UART:
elif self.connection_type.value == UART.CONNECTIONTYPE_UART:

self.uart_port = node.get_parameter('uart_port')
node.get_logger().info('\tuart_port:\t\t"%s"' % self.uart_port.value)
Expand Down

0 comments on commit 16d2430

Please sign in to comment.