Reputation: 3757
I have a tinker IMU and I'm using their library which is utilizing a callback to output data. I want to do this all on a separate thread but the callback function is not being called when I try. What am I doing wrong?
def myIMUCallback():
print("callback called")
# Function to start recording IMU data via callback function
def startIMUData():
HOST = "localhost"
PORT = 4223
UID = "6Dcx3Y" # Change XXYYZZ to the UID of your IMU Brick 2.0
ipcon = IPConnection() # Create IP connection
imu = BrickIMUV2(UID, ipcon) # Create device object
ipcon.connect(HOST, PORT) # Connect to brickd
# Don't use device before ipcon is connected
# Register all data callback to function cb_all_data
imu.register_callback(imu.CALLBACK_ALL_DATA, myIMUCallback)
# Set period for all data callback to 0.1s (100ms)
imu.set_all_data_period(100)
# This doesn't work, callback is not called
threadIMU = Thread(target = startIMUData, args = ())
threadIMU.daemon = True
threadIMU.start
# This works
startIMUData()
Upvotes: 0
Views: 450