-
Notifications
You must be signed in to change notification settings - Fork 40
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
Minor changes to make it works with bleak 0.6.4 #19
Comments
I was encountering the same issue and just started poking about when I saw this. I took the liberty of creating a fork to implement and test these changes. See: https://github.com/esklarski/bricknil I was picking through the two versions and noticed that the current version of BLEAK has a lot more error catching than the bricknil version, and I suspect the errors we are getting are for things not handled at the time of the fork. Thanks for starting this, i will be doing testing as I have free time. |
Found the first issue, seems there is a problem unwrapping values from a list returned by a sensor.
I am just playing with the DuploTrain example (link). I can fix the problem by eliminating one of the values from the attach statement. Does not work, and produces the above error: Works fine with no error: |
@virantha if you're about still, what modifications were necessary when you forked Bleak originally? |
I am getting the same error from both @virantha and your branch @esklarski . This is observed in MacOS 10.14.6 when trying to run vernie_remote.py, and upgrading to bleak 0.7.1 results in the same issue: inside curio run loop |
@janvrany has a better solution in the works. See: I've tried the devel branch and it seems to work well. |
Thanks. I tried this branch and it works well to output control signals. But it seems not returning input correctly. I'm reading sensor like this. I expect it returns value of position and speed but output it [None]. print("DEBUG", self.rear_drive.value) DEBUG: Rear [None]
DEBUG {<capability.sense_speed: 1>: [None], <capability.sense_pos: 2>: [None]} #!/usr/bin/env python3
import logging
# from curio import sleep
from asyncio import sleep
from bricknil import attach, start
from bricknil.hub import CPlusHub
from bricknil.sensor.motor import CPlusXLMotor, CPlusLargeMotor, TachoMotor
@attach(CPlusLargeMotor, name='front_drive', capabilities=['sense_speed', ('sense_pos', 1)], port=1)
@attach(CPlusXLMotor, name='rear_drive', capabilities=['sense_speed', 'sense_pos'], port=3)
class Truck(CPlusHub):
def __init__(self, name, query_port_info=False, ble_id=None):
super().__init__(name, query_port_info, ble_id)
self.set_rear_speed = 100
async def front_drive_change(self):
front_speed = self.front_drive.value[TachoMotor.capability.sense_speed]
front_pos = self.front_drive.value[TachoMotor.capability.sense_pos]
async def rear_drive_change(self):
rear_speed = self.rear_drive.value[TachoMotor.capability.sense_speed]
async def run(self):
self.message_info("Running")
await self.rear_drive.activate_updates()
await sleep(5) # Give it enough time to gather data
await self.rear_drive.set_pos(0)
print("DEBUG", self.rear_drive.value)
async def system():
hub = Truck('truck', True)
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
start(system) Is there any idea about this? My bleak version == 0.7.1 λ uname -a |
I figured out what's wrong. Seems exception inside async routines are ignored. If they failed then it doesn't produce meaningful value. |
What was causing the exceptions? |
My code was bad as async def front_drive_change(self):
front_speed = self.front_drive.value[TachoMotor.capability.sense_speed]
front_pos = self.front_drive.value[TachoMotor.capability.sense_pos] This triggered exception. Didn't figure out where it is handled. But the result is invalid value read back and the process seems dead. |
For some reason, I randomly hit following error and no clue how it happens.
From error message, I guess it's because of some random events that old version of bleak can't handle properly. I made some minor changes to use the latest bleak and it works well. As my knowledge of entire code base is limited, I'm not sure if it works well for other part of the code. Attached is diff.
Diffs
The text was updated successfully, but these errors were encountered: