Skip to content

crashes one first communication with boost sensor #17

@mischamol

Description

@mischamol

Thanks for the great piece of work! I have one issue I don't seem able to solve.
Every time when I run a simple piece of code on my Mac communicating with one of my boost sensors it crashes, stating something about an unknown device being attached. This happens with all sensors. Any suggestions what is going wrong?

......
INFO:BLE Event Q.0:Connected to device LEGO Move Hub:c631f6ec-........
INFO:BLE Event Q.0:Waiting for hubs to end
INFO:Test.3:Running
INFO:Test.3:start
INFO:motor_left.2:Setting speed to 10
2020-06-17 21:11:49.597 python[1206:29044] *** Terminating app due to uncaught exception 'OC_PythonException', reason: '<class 'AssertionError'>: Unknown device with id 66 being attached (port 70'
.......

And the code I'm running.

`import logging

from curio import sleep
from bricknil import attach, start
from bricknil.hub import BoostHub
from bricknil.sensor import InternalMotor

@Attach(InternalMotor, name='motor_right', port=InternalMotor.Port.B)
@Attach(InternalMotor, name='motor_left', port=InternalMotor.Port.A)

class Robot(BoostHub):

async def run(self):
    self.message_info("Running")
    while (True):  
        self.message_info('start')
        await self.motor_left.set_speed(10)
        await self.motor_right.set_speed(10)
        sleep(3)
        self.message_info('stop')
        await self.motor_left.set_speed(0)
        await self.motor_right.set_speed(0)            

async def system():
robot = Robot('Test')

if name == 'main':
logging.basicConfig(level=logging.INFO)
start(system)`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions