Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix i2c issues found (param and division by zero) #56

Merged
merged 2 commits into from
Jan 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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