profile
viewpoint

DexterInd/GoPiGo3 67

The GoPiGo3 is a Raspberry Pi Robot!

dlech/AutoSaveDraftsFolders 11

Auto Save Drafts Folders extension for Mozilla Thunderbird

DexterInd/DI_Sensors 9

Dexter Industries Sensors

DexterInd/script_tools 1

Common installation scripts used in multiple products around the Dexter Industries Galaxy of products.

dlech/Chaos.NaCl 1

Chaos.NaCl cryptography library

dlech/code-settings-sync 1

Synchronize your Visual Studio Code Settings Across Multiple Machines using Github GIST

dlech/ace 0

Ace (Ajax.org Cloud9 Editor)

dlech/ace-builds 0

Packaged version of Ace code editor

dlech/Adafruit_ILI9341 0

Library for Adafruit ILI9341 displays

dlech/add-linked-images-to-gallery-v01 0

WordPress.org Plugin Mirror

issue commentpybricks/support

Pybricks v3 Beta Announcements

https://code.pybricks.com has been updated.

Fixed:

  • Not working in offline mode.
dlech

comment created time in 19 hours

issue closedpybricks/pybricks-code

[Bug] code.pybricks.com without Internet connection

Without Internet connection, the program is not loaded to the hub.

The BLE connection work well, and show the output of the hub (if you run the main.py built-in), but is not possible to load a new program.

closed time in 19 hours

GianCann

issue commentpybricks/pybricks-code

[Bug] code.pybricks.com without Internet connection

This should be fixed by https://github.com/pybricks/pybricks-code/commit/441d517a52c578a85e692cd9dc000ac1bc9d8d65

It looks like the .zip files are already properly cached.

GianCann

comment created time in 19 hours

push eventpybricks/pybricks-code

David Lechner

commit sha 441d517a52c578a85e692cd9dc000ac1bc9d8d65

Rework web assembly inclusion This moves the .wasm file out of the static/js/ folder and into the source tree. This way we can import it and webpack will pick it up and version the file with a hash. This fixes possibly running with an out of date file from the browser cache and also fixes running offline. The file extension had to be changed because there is a default rule in webpack that matches the .wasm extension and causes the following error: Failed to compile. ./src/sagas/mpy-cross.wasm Module parse failed: magic header not detected File was processed with these loaders: * ./node_modules/file-loader/dist/cjs.js You may need an additional loader to handle the result of these loaders. Error: magic header not detected The webpack configuration cannot be modified without ejecting create-react-app or using something like react-app-rewired, which we would like to avoid. Also using ncp to copy file now which fixes building on Windows.

view details

push time in 19 hours

PR merged pybricks/pybricks-code

Rework web assembly inclusion

This moves the .wasm file out of the static/js/ folder and into the source tree. This way we can import it and webpack will pick it up and version the file with a hash.

This fixes possibly running with an out of date file from the browser cache and also fixes running offline.

The file extension had to be changed because there is a default rule in webpack that matches the .wasm extension and causes the following error:

Failed to compile.

./src/sagas/mpy-cross.wasm
Module parse failed: magic header not detected
File was processed with these loaders:
* ./node_modules/file-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
Error: magic header not detected

The webpack configuration cannot be modified without ejecting create-react-app or using something like react-app-rewired, which we would like to avoid.

Also using ncp to copy file now which fixes building on Windows.

+26 -8

0 comment

6 changed files

dlech

pr closed time in 19 hours

PR opened pybricks/pybricks-code

Rework web assembly inclusion

This moves the .wasm file out of the static/js/ folder and into the source tree. This way we can import it and webpack will pick it up and version the file with a hash.

This fixes possibly running with an out of date file from the browser cache and also fixes running offline.

The file extension had to be changed because there is a default rule in webpack that matches the .wasm extension and causes the following error:

Failed to compile.

./src/sagas/mpy-cross.wasm
Module parse failed: magic header not detected
File was processed with these loaders:
* ./node_modules/file-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
Error: magic header not detected

The webpack configuration cannot be modified without ejecting create-react-app or using something like react-app-rewired, which we would like to avoid.

Also using ncp to copy file now which fixes building on Windows.

+26 -8

0 comment

6 changed files

pr created time in 19 hours

push eventpybricks/pybricks-code

David Lechner

commit sha a0ec1502316535d8e8cc73a31b5126e17cc2a7d7

yarn upgrade

view details

David Lechner

commit sha e7f9d55bc3b5837c2b2b5078ce083461003f5c0b

Update firmware to v3.0.0a4

view details

David Lechner

commit sha 78b17df163a9353e6057ebc1656eab25231b69e5

add city hub to firmware flasher

view details

David Lechner

commit sha 7b49d84876586cbe1b69ec059e89dfc585b11628

add code snippet for city hub

view details

David Lechner

commit sha c3037a56e65dcfef694a37e9ec332aaf182b2dac

Clarify city hub error message It is only the bootloader/flashing firmware that is not compatible. It can still be used with older browsers after Pybricks firmware has been flashed.

view details

David Lechner

commit sha 0944a27eb9eebcf402d482cfef42ddc46b06083a

increase firmware flashing packet size

view details

David Lechner

commit sha 9cfc7c5bd1b57ffb0ab8506107d453e778797f02

wait for feedback more often during flashing There have been some reports of firmware flashing not working with a checksum timeout error, meaning that we probably overflowed a buffer on the Bluetooth chip from sending data too fast. We don't have info of the Bluetooth firmware so we are just guessing here.

view details

David Lechner

commit sha 52d6abc58df2aed9a6b910d7090d3dae11eb1592

Rework web assembly inclusion This moves the .wasm file out of the static/js/ folder and into the source tree. This way we can import it and webpack will pick it up and version the file with a hash. This fixes possibly running with an out of date file from the browser cache and also fixes running offline. The file extension had to be changed because there is a default rule in webpack that matches the .wasm extension and causes the following error: Failed to compile. ./src/sagas/mpy-cross.wasm Module parse failed: magic header not detected File was processed with these loaders: * ./node_modules/file-loader/dist/cjs.js You may need an additional loader to handle the result of these loaders. Error: magic header not detected The webpack configuration cannot be modified without ejecting create-react-app or using something like react-app-rewired, which we would like to avoid. Also using ncp to copy file now which fixes building on Windows.

view details

push time in 19 hours

push eventpybricks/pybricks-code

David Lechner

commit sha 752fcca7d163947b227d6d81de7d6cd422cf350e

Rework web assembly inclusion This moves the .wasm file out of the static/js/ folder and into the source tree. This way we can import it and webpack will pick it up and version the file with a hash. This fixes possibly running with an out of date file from the browser cache and also fixes running offline. The file extension had to be changed because there is a default rule in webpack that matches the .wasm extension and causes the following error: Failed to compile. ./src/sagas/mpy-cross.wasm Module parse failed: magic header not detected File was processed with these loaders: * ./node_modules/file-loader/dist/cjs.js You may need an additional loader to handle the result of these loaders. Error: magic header not detected The webpack configuration cannot be modified without ejecting create-react-app or using something like react-app-rewired, which we would like to avoid. Also using ncp to copy file now which fixes building on Windows.

view details

push time in 19 hours

push eventpybricks/pybricks-micropython

David Lechner

commit sha 793bfe416cccd43136d2b8640edf4b27533f3aa4

@pybricks/mpy-cross-v5: Add optional wasmPath parameter This adds an option parameter to the `compile()` function in the mpy-cross JavaScript package. This is needed when the `.wasm` file cannot be found using the default search path.

view details

David Lechner

commit sha 6766a7bd7bf82bb9e6c97021102459250cedd9d4

@pybricks/mpy-cross-v5: add README and CHANGELOG

view details

David Lechner

commit sha 4fe9f0f2bf0445e4598bd26635269a8852007609

@pybricks/mpy-cross-v5 v1.1.0

view details

push time in 20 hours

created tagpybricks/pybricks-micropython

tag@pybricks/mpy-cross-v5/v1.1.0

MicroPython firmware for Pybricks-compatible devices.

created time in 20 hours

issue commentpybricks/support

[Question] Limiting connections to running hubs

Yes, we plan on making the hub no longer connectable once a program has started.

Nelvarion

comment created time in a day

issue commentpybricks/support

[Question] Motor speed value missing?

Assuming this is not a built-in motor on a Move hub.

We would have to check the source code to be sure, but I think we are just reporting the speed sent via UART by the motor. So this is probably a question for LEGO. :smile:

GianCann

comment created time in a day

push eventpybricks/pybricks-micropython

David Lechner

commit sha ebe6bc6b3ab61a2d73cbe655b8c42f1a74b5ebe4

CONTRIBUTING: add notes about building npm packages

view details

push time in a day

issue commentpybricks/support

[Feature] Small user persistent data space

Although it is technically possible to implement something like this, it is not something we have on the roadmap right now.

GianCann

comment created time in a day

issue commentpybricks/support

[Question] Motor speed value missing?

It takes a certain amount of power to overcome the internal friction of the motor before it starts turning. So this looks exactly as expected if nothing is connected to the motor.

If you block the motor from turning it will still have speed of 0 even at 100% duty cycle because it is not turning.

GianCann

comment created time in a day

issue commentpybricks/pybricks-code

[Bug] code.pybricks.com without Internet connection

Actually, I guess we are using fetch() to get the firmware zip files, so that needs to be look into as well. The .wasm file is handled by code automatically generated by Emscripten, so we need to investigate how that works too.

GianCann

comment created time in a day

delete branch pybricks/pybricks-micropython

delete branch : dlech

delete time in a day

push eventpybricks/pybricks-micropython

David Lechner

commit sha 02bee7f07c898775fec1f402fc1971e95d936d1a

CONTRIBUTING: expand document Explains how to set up the development environment and compile the code.

view details

push time in a day

issue commentev3dev/vscode-ev3dev-browser

[Question] Difference between stopping the program with EV3 Brick's physical Back/Stop button vs. stopping by VSCode stop button

It is more of an educated guess than a positive identification at this point. :smile: But there probably isn't anything to do in the VS Code extension, so we can close this issue. Does adding sleep() fix the problem for you?

AntoniLuongPham

comment created time in a day

issue commentpybricks/pybricks-code

[Bug] code.pybricks.com without Internet connection

We are currently using fetch() to get the mpy-cross .wasm file. This needs to be changed so that it is available offline.

GianCann

comment created time in a day

issue commentpybricks/support

[Question] Motor speed value missing?

The actual speed of the motor should be returned. So if the motor is not actually moving, the returned speed will be 0.

GianCann

comment created time in a day

startedgpdaniels/spike-prime

started time in a day

issue closedpybricks/support

[Feature] Add City Hub Support

EDIT: I just noticed this message in the Documentation: "At the moment, only the Control+ Hub is ready for beta use." This issue may be "By Design" for now...

Describe the bug I am unable to update my City Hub to Pybricks. This happened when the firmware on my City hub was old (last used around December 2019), and again after updating the firmware in the Powered Up app.

To Reproduce Steps to reproduce the behavior:

  1. at code.pybricks.com, click on the "City Hub" icon on the right nav bar.
  2. scroll down, press "Click to show/hide the written steps" to see written instructions (I don't watch videos).
  3. press-and-hold power on City Hub, and while still holding the button press icon with "flash hub firmware" tooltip in top navbar.
  4. Select the "LEGO Bootloader" option in new window.

Expected behavior 5a. Flashing to begin

Actual Behavior 5b. Red error box (with rounded corners) indicating that the hub is not compatible.

Error Text: "Sorry, we don't have firmware for this hub yet."

System Info Windows 10, 1909, Intel i7-9700K, 32gb RAM. Chrome Dev: Version 85.0.4168.3 (Official Build) dev (64-bit) image

Screenshots image

closed time in a day

tomalphin

issue commentpybricks/support

[Feature] Add City Hub Support

City hub support is now in beta. Be sure to unplug everything from the port before flashing the firmware.

tomalphin

comment created time in a day

issue closedpybricks/support

[Report] Flashing CityHub successful

After some problems in setting up the work environment, I managed to compile and load the firmware for the CityHub.

The working environment is Ubuntu 18.04, running in Virtualbox on Windows 10.

I noticed that pairing with code.pybricks.com does not happen if the Hub has a connected device. You have to do the pairing first, and then connect the motor.

closed time in a day

GianCann

pull request commentpybricks/pybricks-micropython

Change to default main.py

Thanks!

Be sure to run ./tools/codeformat.py to fix the formatting problems.

GianCann

comment created time in a day

issue commentev3dev/ev3dev

Sometimes not all child processes are ended by `conrun-kill`

Test case:

#!/usr/bin/env python3


from ev3dev2.motor import MediumMotor, OUTPUT_A
from ev3dev2.sensor import INPUT_1
from ev3dev2.sensor.lego import TouchSensor

from multiprocessing import Process


TOUCH_SENSOR = TouchSensor(address=INPUT_1)
MOTOR = MediumMotor(address=OUTPUT_A)


def motor_on_when_touched():
    while True:
        if TOUCH_SENSOR.is_pressed:
            MOTOR.on_for_seconds(
                speed=100,
                seconds=1,
                brake=False,
                block=True)


Process(target=motor_on_when_touched,
        daemon=True).start()
# *** process still alive after program ended through VSCode ***


while True:
    pass
  • Run this program using the ev3dev VS Code extension.
  • Stop the program using the ev3dev VS Code extension.
  • Subprocess is still running
dlech

comment created time in a day

issue openedev3dev/ev3dev

Sometimes not all child processes are ended by `conrun-kill`

However, when I exit the program using the VSCode red-square stop button, the daemon process lives on -- when I press the Touch Sensor, the Motor continues to run -- even after VSCode shows: "Program ended by stop button. Completed successfully." I have to reboot the EV3 Brick to kill that process.

The fact that the subprocess is not being killed could be a bug in brickrun/console-runner.

Originally posted by @dlech in https://github.com/ev3dev/vscode-ev3dev-browser/issues/103#issuecomment-653591557

created time in a day

issue commentev3dev/vscode-ev3dev-browser

[Question] Difference between stopping the program with EV3 Brick's physical Back/Stop button vs. stopping by VSCode stop button

However, when I exit the program using the VSCode red-square stop button, the daemon process lives on -- when I press the Touch Sensor, the Motor continues to run -- even after VSCode shows: "Program ended by stop button. Completed successfully." I have to reboot the EV3 Brick to kill that process.

The fact that the subprocess is not being killed could be a bug in brickrun/console-runner.

AntoniLuongPham

comment created time in a day

issue commentev3dev/vscode-ev3dev-browser

[Question] Difference between stopping the program with EV3 Brick's physical Back/Stop button vs. stopping by VSCode stop button

In theory, they should work the same. But of course reality never exactly matches theory.

When stopping via VS Code it takes a little bit longer because the request has to go through SSH encryption. This delay is usually not noticeable, but when there is a program like this one that is using 100% CPU, it is noticeable.

One thing you can do to improve things is to add a sleep(0.01) in both of the while True: loops so that the program does not use 100% CPU. Ev3dev is a full Linux operating system, so it needs some CPU cycles free to do other things while your program is running.

The fact that the subprocess is not being killed could be a bug in brickrun/console-runner.

AntoniLuongPham

comment created time in a day

issue commentpybricks/support

[Question] Doesn't pybricks have sys.path that can be extended by sys.path.append(...)?

sys.path.append('/home/robot')

This works for me using Pybricks 2.0.0 on EV3.

>>> import sys
>>> dir(sys)
['__class__', '__name__', 'argv', 'byteorder', 'exit', 'getsizeof', 'implementation', 'maxsize', 'modules', 'path', 'platform', 'print_exception', 'stderr', 'stdin', 'stdout', 'version', 'version_info']
>>> sys.path
['', '', '/home/robot/.pybricks-micropython/lib', '/usr/lib/pybricks-micropython']
>>> sys.path.append('/home/robot')
>>> sys.path
['', '', '/home/robot/.pybricks-micropython/lib', '/usr/lib/pybricks-micropython', '/home/robot']
>>> 

Can you share a full working example that causes the problem?

TheVinhLuong102

comment created time in a day

issue commenthbldh/bleak

MacOS: cannot use BleakScanner with an event loop in another thread

@dlech can comment if there's anything to fix with regard to the threading.Event that caused the original backtrace error, but my guess is not.

No, I don't think there is anything to fix here.

This is the key point I did not realize, since this restriction isn't necessarily true on the other platforms (or at least my code works by accident on those platforms). It would be good to mention this somewhere in the documentation; that's probably the only action item from this issue.

Previously, if using the loop= parameters, one could get away with passing around event loops between threads. But some of the recent changes are ignoring the loop parameter since it is going away soon anyway. Not sure what the timeline is for 0.8.0, but is might be good to update the docs now to explain that loop= is going away and how to work around it.

dhalbert

comment created time in a day

issue commentpybricks/support

Not able to upload firmware on Imac[Bug]

I have made some changes that could affect this. Could everyone please test again?

Patlepirate01

comment created time in 2 days

issue commentpybricks/support

Flashing firmware to Technic hub gets stuck during flashing

I have made some changes that could affect this. Could everyone please test again?

AlbanT

comment created time in 2 days

issue commentpybricks/support

Pybricks v3 Beta Announcements

https://code.pybricks.com has been updated.

Added:

  • Support for City hub (note, requires Chrome 85 to flash firmware due to quirks in the City hub bootloader)
  • Changed firmware flashing packet size on City hub and Control+ hub (speeds up flash time)
  • Increased frequency of progress checks when flashing firmware (slows down flash time but should help prevent errors)
  • Firmware v3.0.0a4
    • Bluetooth support on City hub
    • Fixed sensor ID issue on City hub
    • WeDo 2.0 sensor support
    • Fixed Move hub motor polarity
    • Enabled builtin help and input functions
    • Enabled urandom module
dlech

comment created time in 2 days

push eventpybricks/pybricks-code

David Lechner

commit sha a0ec1502316535d8e8cc73a31b5126e17cc2a7d7

yarn upgrade

view details

David Lechner

commit sha e7f9d55bc3b5837c2b2b5078ce083461003f5c0b

Update firmware to v3.0.0a4

view details

David Lechner

commit sha 78b17df163a9353e6057ebc1656eab25231b69e5

add city hub to firmware flasher

view details

David Lechner

commit sha 7b49d84876586cbe1b69ec059e89dfc585b11628

add code snippet for city hub

view details

David Lechner

commit sha c3037a56e65dcfef694a37e9ec332aaf182b2dac

Clarify city hub error message It is only the bootloader/flashing firmware that is not compatible. It can still be used with older browsers after Pybricks firmware has been flashed.

view details

David Lechner

commit sha 0944a27eb9eebcf402d482cfef42ddc46b06083a

increase firmware flashing packet size

view details

David Lechner

commit sha 9cfc7c5bd1b57ffb0ab8506107d453e778797f02

wait for feedback more often during flashing There have been some reports of firmware flashing not working with a checksum timeout error, meaning that we probably overflowed a buffer on the Bluetooth chip from sending data too fast. We don't have info of the Bluetooth firmware so we are just guessing here.

view details

push time in 2 days

push eventpybricks/pybricks-code

David Lechner

commit sha 8d2d6e12ed48a8d999790c53228e618c279959f8

add notes about authenticating to Github package manager

view details

David Lechner

commit sha 4a3440d8a534677d1201c699bc327534352e2a55

fix typo

view details

David Lechner

commit sha d44fcad411d0cf80f865866fcd0d06d46fc8b7d8

yarn upgrade

view details

David Lechner

commit sha d74a4aabd0c67df0cd22df4d27b4eef39760f127

yarn upgrade

view details

David Lechner

commit sha b64b002ae178a15b2616ff26aaa39799157ca2f1

Update firmware to v3.0.0a4

view details

David Lechner

commit sha 882a4abaae87ccab24dc6e81df4d886d5ffeae6a

add city hub to firmware flasher

view details

David Lechner

commit sha 49b99a24a1ab17754b6c94ddeb5df5d6d3d5d75c

add code snippet for city hub

view details

David Lechner

commit sha 3c095dda5108a745a089d8fd0847be55f7d2b629

Clarify city hub error message It is only the bootloader/flashing firmware that is not compatible. It can still be used with older browsers after Pybricks firmware has been flashed.

view details

David Lechner

commit sha 961c45287a4a657c8d375df0181fba074a930a9f

increase firmware flashing packet size

view details

David Lechner

commit sha 0b32caa691e2599224d0b73ed4b1f21a47a0a005

wait for feedback more often during flashing There have been some reports of firmware flashing not working with a checksum timeout error, meaning that we probably overflowed a buffer on the Bluetooth chip from sending data too fast. We don't have info of the Bluetooth firmware so we are just guessing here.

view details

push time in 2 days

push eventpybricks/pybricks-micropython

David Lechner

commit sha bd6eb7d9ef7e2a9a6114addd26556e986b8ae734

v3.0.0a4

view details

David Lechner

commit sha cdd626896be6e6ca8195a2cbdd140597f5834842

github: add cityhub firmware to release upload

view details

David Lechner

commit sha 64db116dbc9e3496752429e9580416f97cea52b7

poetry: add project to manage dependencies We aren't actually building a Python package here, but poetry is still useful to manage the virtual environment and dependencies needed for the development environment. `black` is needed for `tools/codeformat.py` and `pyusb` is needed for `make deploy`.

view details

David Lechner

commit sha 1a2a9b914c2497194beaa9583e7e9b2e46ede772

@pybricks/firmware: download assets instead of building This modifies the @pybricks/firmware npm package to download the firmware zip file from GitHub instead of building them locally. This way we have fewer firmware versions floating around. The npm package also now has the firmware version in the build metadata portion of the the package version. This is enforced by having the firmware download script parse package.json for this version.

view details

David Lechner

commit sha b6c59d5e3c020f0f484ce354ae7d27b9e24f5a80

@pybricks/firmare: add cityhub constant Firmware assets now include this hub, so we need to make it part of the API.

view details

David Lechner

commit sha cd66c7b9d2c7fae2266946e56698901d1ea31e1a

github: fix npm-firmware job name Looks like this was copied and pased from the mpy-cross npm package.

view details

David Lechner

commit sha 4fd6c3cc9f1fb06a89811f0bc85fef03573c2cf5

@pybricks/firmware: add README and CHANGELOG

view details

David Lechner

commit sha 815bc41607c93934bc02f76ac11d67bed45485ba

@pybricks/firmware v2.4.0+firmware.v3.0.0a4

view details

push time in 2 days

created tagpybricks/pybricks-micropython

tag@pybricks/firmware/v2.4.0+firmware.v3.0.0a4

MicroPython firmware for Pybricks-compatible devices.

created time in 2 days

created tagpybricks/pybricks-micropython

tag@pybricks/firmware/v2.3.0+firmware.v3.0.0a4

MicroPython firmware for Pybricks-compatible devices.

created time in 2 days

push eventpybricks/pybricks-micropython

David Lechner

commit sha cdd626896be6e6ca8195a2cbdd140597f5834842

github: add cityhub firmware to release upload

view details

push time in 2 days

created tagpybricks/pybricks-micropython

tagv3.0.0a4

MicroPython firmware for Pybricks-compatible devices.

created time in 2 days

push eventpybricks/pybricks-micropython

David Lechner

commit sha a860f4bc43ce63142c3603aebab40f098ddc8ef1

github: add cityhub firmware to release upload

view details

push time in 2 days

push eventpybricks/pybricks-micropython

Laurens Valk

commit sha b7b466828184456deaec105fa2f5383e3a1941ed

extmod/modpupdevices: Add InfraredSensor Using the raw data, we can get much more information than the 10 distance increments that this sensor normally gives. We provide two convenience methods based on this data: - distance() nonlinearly scales the raw data to provide an approximately linear distance value. It corresponds to the original sensor value, but with higher resolution and a scale from 0-100 to match similar relative distance methods on the other sensors. Resolution is somewhat course above 50%. - reflection() linearly scales the data to provide reflection data close to the sensor. This can be used for line following or precise distance sensing up close. There is also a count() method, which does the same as the original sensor. In this class, the count is reset to 0 upon instantiation. Using the other methods does not reset this count.

view details

Laurens Valk

commit sha b9295f89033f70cc59e9cf42966563e832a1451d

extmod/modpupdevices/InfraredSensor: resolution By returning a floating point value on supported platforms, the resolution is much higher, which is useful when using the reflection value in a feedback controller.

view details

Laurens Valk

commit sha 047c46bf21f74f7788c6f26f412d6a105877459b

extmod/modpupdevices: Add TiltSensor This adds a very minimal implementation, exposing tilt relative to the horizontal plane only (pitch, roll). Other more useful methods may be added once the generic attitude/orientation API is in place and implemented for the IMUs internal to the hubs.

view details

David Lechner

commit sha bd6eb7d9ef7e2a9a6114addd26556e986b8ae734

v3.0.0a4

view details

push time in 2 days

push eventdlech/scratch-vm

David Lechner

commit sha d24c0464b7f133ce42b5e6d148c7067085841da5

Fix deserialization of variable with value of null

view details

push time in 2 days

issue commenthbldh/bleak

BlueZ error when connecting to BLE device

I find it useful to use Wireshark to capture Bluetooth packets to see what is actually going on.

Matt-Hicks-Bose

comment created time in 2 days

issue commenthbldh/bleak

MacOS: cannot use BleakScanner with an event loop in another thread

so that the BleakScanner() is created in the new thread

Yes, everything related to bleak needs to be done in the thread after the new event loop is created.

I now have a whole slew of new problems related to MacOS returning a UUID instead of an actual address

This is a known issue. Apple does not make the Bluetooth address available anywhere for security/privacy reasons.

dhalbert

comment created time in 2 days

pull request commenthbldh/bleak

Fix when characteristic updates value faster than asyncio schedule.

This looks like a good fix to me. We should probably make the same change for descriptor values.

superfashi

comment created time in 2 days

issue commentpybricks/support

[Bug] Invalid Argument for DriveBase on ev3dev

Yes, it happens sometimes.

ekmanb

comment created time in 2 days

issue commentpybricks/pybricksdev

Windows compatibility

Another aspect of Windows support is that CTRL+C is handled differently (if I am remembering correctly). https://github.com/pybricks/support/issues/78

dlech

comment created time in 3 days

issue commentpybricks/support

[Bug] [pybricksdev] Stop program

Windows?

GianCann

comment created time in 3 days

issue commentpybricks/pybricksdev

Windows compatibility

Please rename our current master branch so we don't lose it. Call it 0.6.x-fixes or something like that.

dlech

comment created time in 3 days

issue commenthbldh/bleak

Evaluate switching from txdbus to other Python DBus package

I think I would be in favor of exploring one of the alternatives. I did some work last year to fix some bugs in txdbus. One bug (that fortunately doesn't affect Bleak) I was not able to fix because it would require changing twisted, but I found it to just be too complicated.

Both of the packages you have listed look good.

hbldh

comment created time in 3 days

push eventpybricks/pybricks-micropython

David Lechner

commit sha 559c64f168d7770b08d2fd8085f2d86c95f934d6

drv/uart_stm32f4_ll_irq: prevent multiple broadcasts This uses the read and write buffer pointers as a one-shot to ensure that a broadcast is only sent once when a read or write is completed. Otherwise we could potentially overflow the event queue.

view details

David Lechner

commit sha f1aecedfc67bb253fb210bacb61a227c838ea361

platform/debug: convert to uart_stm32f4_ll_irq

view details

David Lechner

commit sha 689f788f611dd5363fa184879d1960a73724d803

drv/uart_stm32_hal: remove driver This driver would miss Rx data since it was not constantly listening. It has been replaced by the uart_stm32x4xx_ll_x drivers.

view details

David Lechner

commit sha 0665a273e978b1b6762be759fbbe3f986a3f2972

drv/button/adc: fix ranges This was causing the center button to not work.

view details

push time in 4 days

push eventpybricks/pybricks-micropython

David Lechner

commit sha 559c64f168d7770b08d2fd8085f2d86c95f934d6

drv/uart_stm32f4_ll_irq: prevent multiple broadcasts This uses the read and write buffer pointers as a one-shot to ensure that a broadcast is only sent once when a read or write is completed. Otherwise we could potentially overflow the event queue.

view details

David Lechner

commit sha f1aecedfc67bb253fb210bacb61a227c838ea361

platform/debug: convert to uart_stm32f4_ll_irq

view details

David Lechner

commit sha 689f788f611dd5363fa184879d1960a73724d803

drv/uart_stm32_hal: remove driver This driver would miss Rx data since it was not constantly listening. It has been replaced by the uart_stm32x4xx_ll_x drivers.

view details

David Lechner

commit sha 0665a273e978b1b6762be759fbbe3f986a3f2972

drv/button/adc: fix ranges This was causing the center button to not work.

view details

push time in 4 days

push eventpybricks/pybricks-micropython

David Lechner

commit sha fe7b9d1c978bdb49820593b2c910b3122f655952

platform/cplus_hub: use macros for DMA channel/request There are already macros for this, so we might as well use them (makes it more obvious where the values come from).

view details

David Lechner

commit sha 1385bee6476133f3bc6c652742ef65879c50081e

drv/uart_stm32l4_ll: remove callbacks from platform data Platform data should just describe the hardware (e.g. which pins we are using) and not be tied to the implementation. Also reduces firmware size a bit.

view details

David Lechner

commit sha 2e705cc5487f6da64a4f555b21e7638fb833c8b7

drv/uart_stm32l4_ll: document platform data

view details

David Lechner

commit sha e757bd82ea699423b4492a6c2d4472604038b479

drv/uart_stm32l4_ll_dma: add DMA to name This way we can also have a separate interrupt-based driver that doesn't use DMA.

view details

David Lechner

commit sha bccb7c3835dd2db31dfbb06201ded61eb3a50e2d

bricks/stm32: define HSE_VALUE in Makefile stm32f4xx_ll_rcc needs HSE_VALUE to be correctly defined, however it doesn't include stm32l4xx_hal_conf.h, so it was falling back to the default. The only way to define it without modifying upstream code is to do so via compiler flag.

view details

David Lechner

commit sha c7408423b298d4de60d49da9f9084a31985879c6

drv/uart_stm32f4_ll_irq: New UART driver This adds a new UART driver that always receives in the background so that we don't lose anything. It is implemented using interrupts, so there is one interrupt for each byte send and received.

view details

push time in 4 days

push eventpybricks/pybricks-micropython

Laurens Valk

commit sha 383786b252a6372308e90a0870d4ec6893d89b0c

pbdrv/cityhub/motor: fix port A polarity Positive duty should make the motor turn clockwise.

view details

Laurens Valk

commit sha cc2f9c2ce06346e9ca89aedf265c31057f7d7e46

pbdrv/movehub/motor: fix port A polarity Positive duty should make the motor turn clockwise. This fixes it at the driver level instead of patching for a specific hub at the module level.

view details

Laurens Valk

commit sha ee678d637b7efc6025a54cc67396829064894e1a

platform/movehub: invert counter on port A Make it match the convention that clockwise is positive.

view details

Laurens Valk

commit sha 5b0be4ecf4b72f2ddcb590f31b4d0dc309e1cc29

pbdrv/counter: fix trailing space

view details

David Lechner

commit sha fe7b9d1c978bdb49820593b2c910b3122f655952

platform/cplus_hub: use macros for DMA channel/request There are already macros for this, so we might as well use them (makes it more obvious where the values come from).

view details

David Lechner

commit sha 1385bee6476133f3bc6c652742ef65879c50081e

drv/uart_stm32l4_ll: remove callbacks from platform data Platform data should just describe the hardware (e.g. which pins we are using) and not be tied to the implementation. Also reduces firmware size a bit.

view details

David Lechner

commit sha 2e705cc5487f6da64a4f555b21e7638fb833c8b7

drv/uart_stm32l4_ll: document platform data

view details

David Lechner

commit sha e757bd82ea699423b4492a6c2d4472604038b479

drv/uart_stm32l4_ll_dma: add DMA to name This way we can also have a separate interrupt-based driver that doesn't use DMA.

view details

David Lechner

commit sha bccb7c3835dd2db31dfbb06201ded61eb3a50e2d

bricks/stm32: define HSE_VALUE in Makefile stm32f4xx_ll_rcc needs HSE_VALUE to be correctly defined, however it doesn't include stm32l4xx_hal_conf.h, so it was falling back to the default. The only way to define it without modifying upstream code is to do so via compiler flag.

view details

David Lechner

commit sha c7408423b298d4de60d49da9f9084a31985879c6

drv/uart_stm32f4_ll_irq: New UART driver This adds a new UART driver that always receives in the background so that we don't lose anything. It is implemented using interrupts, so there is one interrupt for each byte send and received.

view details

push time in 4 days

push eventdlech/stm32lib

David Lechner

commit sha aae07595b1cabd393df26819e4c24bbcc9b1872d

stm32f4xx_ll_usart: fix clock for UART9/10

view details

push time in 4 days

issue commentpybricks/pybricksdev

Fix Python version

Also need to update to bleak ~0.7 at the same time.

laurensvalk

comment created time in 4 days

PR opened micropython/stm32lib

stm32f4xx_ll_usart: fix UART10 in LL_USART_Init
+1 -1

0 comment

1 changed file

pr created time in 4 days

push eventdlech/stm32lib

David Lechner

commit sha e9624fcd3d7f440ccd9a8d02bc31df6b02b2374a

stm32f4xx_ll_usart: fix UART10 in LL_USART_Init

view details

push time in 4 days

fork dlech/stm32lib

STM32 Cube library - CMSIS and HAL for F4, F7 and L4 microcontrollers

fork in 4 days

issue commenthbldh/bleak

[macOS] AttributeError: 'CBCentralManager' object has no attribute 'isScanning'

isScanning was introduced in macOS 10.13 so we will need a workaround for the call at https://github.com/hbldh/bleak/blob/release/v0.7.0/bleak/backends/corebluetooth/CentralManagerDelegate.py#L130 to support older macOS.

mfilippo

comment created time in 4 days

delete branch pybricks/bleak

delete branch : cb-fixes

delete time in 4 days

delete branch dlech/bleak

delete branch : patch-1

delete time in 4 days

pull request commenthbldh/bleak

Add David Lechner as contributor

You are welcome. I am glad to be part of this project. :smile:

dlech

comment created time in 4 days

PR opened hbldh/bleak

Add David Lechner as contributor
+2 -0

0 comment

1 changed file

pr created time in 4 days

push eventdlech/bleak

David Lechner

commit sha 3a3831a5888ea0f2aef6f2e26e6b6b045609a3d3

Add David Lechner as contributor

view details

push time in 4 days

issue commenthbldh/bleak

Scan peripherals and filter by service UUID

Interesting that you put the connect method on the Scanner object. I have this morning thought that it would have been better to merge the scanning to the BleakClient and use that for everything, removing the costly double implementations of most things...

Don't put any importance on that. I was just being lazy and didn't look up the existing API. :smile:

joelviel

comment created time in 4 days

issue commenthbldh/bleak

Scan peripherals and filter by service UUID

Is there a compelling reason (like performance) that the filtering should be done at the OS level?

I've been thinking it would be nice to have an async iterator in the scanner. This could be used to implement filters in Python and it would not be restricted to the lowest common denominator of OS capabilities. (Off topic: this feature would also nicely replace register_detection_callback())

For example, get the first device with matching service UUID (ignore that it doesn't match the current API - this is more like pseudo-code):

MY_UUID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'

async with BleakScanner() as scanner:
    # this has an iteration every time a new advertisement is seen
    async for advertisement in scanner.scan(timeout=5.0):
        if advertisement.service_uuids and MY_UUID in advertisement.service_uuids:
            my_device_id = advertisement.device_id
            # Breaking out of the for loop stops scanning. If there were any advertisements
            # already received after this one, they are ignored.
            break
    else:
        # The for loop completed without `break` so we must have reached timeout.
        print('device not found!')
        exit(1)

    my_device = await scanner.connect(my_device_id)
    ...

Or for all matching devices:

MY_UUID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'

device_ids = []

async with BleakScanner() as scanner:
    async for advertisement in scanner.scan(timeout=5.0):
        if not advertisement.service_uuids:
            continue
        if MY_UUID not in advertisement.service_uuids:
            continue
        device_ids.append(advertisement.device_id)

    if not device_ids:
        print('no devices found!')
        exit(1)

    devices = await asyncio.gather(*(scanner.connect(x) for x in device_ids))
    ...
joelviel

comment created time in 5 days

CommitCommentEvent
CommitCommentEvent

issue commentpybricks/pybricksdev

Fix Python version

I have read that pythonnet (needed for bleak on Windows) now works on Python 3.8. So it should be OK to make 3.8 the minimum (and maximum) requirement. ~3.8 should do the trick.

BlueZ on Ubuntu 18.04 is too old anyway, so we probably don't want to support that.

laurensvalk

comment created time in 5 days

issue commentpybricks/pybricks-micropython

Battery tasks

If I am remembering correctly, the official firmware for EV3 will turn on the low battery light when the voltage drops below ACCU_WARNING_LOW and will turn the light back off it the voltage rises back above ACCU_WARNING_LOW. Likewise, the brick will shut down if the voltage drops below ACCU_SHUTDOWN_LOW for 10 seconds and will cancel the shutdown if the voltage rises back above ACCU_SHUTDOWN_HIGH.

I saw a note on this page that the EV3 rechargeable battery runs at a bit lower voltage compare to the other Li-ion batteries so that might explain the difference.

dlech

comment created time in 6 days

issue commentpybricks/pybricks-micropython

Compiling firmware on Windows don't work

I would recommend using the Windows Subsystem for Linux instead.

GianCann

comment created time in 6 days

push eventpybricks/pybricks-micropython

David Lechner

commit sha e72966e49300729aea6486c4c24793859c79bc13

modexperimental: add Move Hub Motion sensor class This moves the old code from accel.c to modexperimental.c and gets the motion sensor working (was missing READ_FLAG when reading). Currently is just returns a raw 8-bit value for acceleration readings.

view details

push time in 7 days

push eventpybricks/pybricks-micropython

David Lechner

commit sha e72966e49300729aea6486c4c24793859c79bc13

modexperimental: add Move Hub Motion sensor class This moves the old code from accel.c to modexperimental.c and gets the motion sensor working (was missing READ_FLAG when reading). Currently is just returns a raw 8-bit value for acceleration readings.

view details

push time in 7 days

issue commentpybricks/pybricks-micropython

Battery tasks

For reference, here are the battery levels used in EV3. BATT is 6 Alkaline cells and ACCU is the rechargeable Li-on battery.

source

#define   BATT_INDICATOR_HIGH           7500          //!< Battery indicator high [mV]
#define   BATT_INDICATOR_LOW            6200          //!< Battery indicator low [mV]

#define   ACCU_INDICATOR_HIGH           7500          //!< Rechargeable battery indicator high [mV]
#define   ACCU_INDICATOR_LOW            7100          //!< Rechargeable battery indicator low [mV]

#define   LOW_VOLTAGE_SHUTDOWN_TIME     10000         //!< Time from shutdown lower limit to shutdown [mS]

#define   BATT_WARNING_HIGH             6.2           //!< Battery voltage warning upper limit [V]
#define   BATT_WARNING_LOW              5.5           //!< Battery voltage warning lower limit [V]
#define   BATT_SHUTDOWN_HIGH            5.5           //!< Battery voltage shutdown upper limit [V]
#define   BATT_SHUTDOWN_LOW             4.5           //!< Battery voltage shutdown lower limit [V]

#define   ACCU_WARNING_HIGH             7.1           //!< Rechargeable battery voltage warning upper limit [V]
#define   ACCU_WARNING_LOW              6.5           //!< Rechargeable battery voltage warning lower limit [V]
#define   ACCU_SHUTDOWN_HIGH            6.5           //!< Rechargeable battery voltage shutdown upper limit [V]
#define   ACCU_SHUTDOWN_LOW             6.0           //!< Rechargeable battery voltage shutdown lower limit [V]

@ZPhilo do the ACCU values sound reasonable for the Li-on battery pack you have made?

dlech

comment created time in 7 days

issue openedpybricks/pybricks-micropython

Battery tasks

We already have basic battery current and voltage monitoring and shutdown on low battery. Some outstanding tasks:

  • [ ] Confirm accuracy of current and voltage readings.
  • [ ] Use hub LED to indicate low battery.
  • [ ] Allow for different battery chemistries.
  • [ ] Refactor battery monitoring out of sys.c and share more code between platforms.
  • [ ] Provide battery indication to pybricks-code IDE.

Current battery levels are defined as follows:

#define BATTERY_OK_MV           6000    // 1.0V per cell
#define BATTERY_LOW_MV          5400    // 0.9V per cell
#define BATTERY_CRITICAL_MV     4800    // 0.8V per cell

created time in 7 days

push eventpybricks/pybricks-micropython

David Lechner

commit sha 71ce8ceedde55b34db4f5885ab44ec4720cf349e

platform/stm32: adjust interrupt priorities On STM32F0 MCUs, the interrupt priority is only a 2-bit value, so 0 is the most urgent and 3 is the least urgent (lower priority number will preempt higher priority number). On these (move hub and city hub), we make UART have priority of 0, position/speed of built-in motors have priority 1 and everything else priority 3. It is especially important to allow UART to preempt all other interrupts so that we don't miss incoming data. On STM32F4/L4, the HAL library configures interrupts for 16-bit priority and 16-bit subpriority. Priority determines preemption as above and subpriority determines precedence if two interrupts happen at the same time. Again, UART used in interrupt mode needs to be able to preempt all other interrupts. But UART in DMA mode it is not as urgent to handle interrupts. Other priority values were chosen arbitrarily and could be reconsidered in the future.

view details

push time in 7 days

push eventpybricks/pybricks-micropython

David Lechner

commit sha 71ce8ceedde55b34db4f5885ab44ec4720cf349e

platform/stm32: adjust interrupt priorities On STM32F0 MCUs, the interrupt priority is only a 2-bit value, so 0 is the most urgent and 3 is the least urgent (lower priority number will preempt higher priority number). On these (move hub and city hub), we make UART have priority of 0, position/speed of built-in motors have priority 1 and everything else priority 3. It is especially important to allow UART to preempt all other interrupts so that we don't miss incoming data. On STM32F4/L4, the HAL library configures interrupts for 16-bit priority and 16-bit subpriority. Priority determines preemption as above and subpriority determines precedence if two interrupts happen at the same time. Again, UART used in interrupt mode needs to be able to preempt all other interrupts. But UART in DMA mode it is not as urgent to handle interrupts. Other priority values were chosen arbitrarily and could be reconsidered in the future.

view details

push time in 7 days

issue commentpybricks/pybricks-micropython

[Question] Normal Boot & Bootloader: How it works?

Again, this is just what I have learned from reverse engineering, so not guaranteed to 100% accurate...

The STM32 chips used in the Powered Up hubs start by reading the stack pointer memory location, the reset vector and the interrupt vector table from the beginning of flash memory, then program control jumps to the address given by the reset vector.

At the factory, LEGO has programmed a "bootloader" (LWP3 docs call this Boot Loader service or Flash Loader). This area of the flash memory is write protected, so it is theoretically impossible to accidentally wipe out the bootloader and brick your brick. The size of this flash memory area can be seen in the linker (*.ld) scripts.

When the bootloader first starts, it checks to see if the button is being held down or if a certain RAM address contains a certain value (the ones you have pointed out). If either one is true, then it starts the BLE bootloader service for flashing the firmware, otherwise it sends program control to the firmware that was flashed. The main entry point is Reset_Handler in startup.s which initializes the RAM (global variable initial values), calls the SystemInit function in platform.c and finally the MicroPython main() function.

GianCann

comment created time in 7 days

issue commenthbldh/bleak

disconnect() hangs for ever on Linux (Raspberry Pi 3)

Probably better to not close this yet or it might be forgotten before it is fixed.

paoloaveri

comment created time in 7 days

issue closedpybricks/pybricks-micropython

Copy Bluetooth from Control+ Hub to City Hub

These hubs use the same Bluetooth chip, so we should be able to copy the code from one hub to the other. Refactoring to share code would be even better.

closed time in 8 days

dlech

issue commentpybricks/pybricks-micropython

Copy Bluetooth from Control+ Hub to City Hub

Done in https://github.com/pybricks/pybricks-micropython/commit/05b616ca86590ee22bc1ead8946eecf012aa2f49

dlech

comment created time in 8 days

push eventpybricks/pybricks-micropython

David Lechner

commit sha 9d51ca1ecf6ccb399981f26da69ef1aff38be48b

platform/city_hub: move port VCC to SystemInit Move the port VCC power on to SystemInit to be consistent with other hubs.

view details

David Lechner

commit sha 1e063ceb89fac9cb16a675a8df89fbd4eee37b6f

lib/ble5stack: remove conflicting macros These macros are not used anywhere and conflict with macros in the STM32 libraries.

view details

David Lechner

commit sha 71c42b8ed010282955f199ed0f64a196daee2278

platform/movehub: use correct DMA IFCR macro This uses the macro that maches the register name. The value of the macro is the same, so no functional change.

view details

David Lechner

commit sha aa005be9402da66b7f67e0e0be7d0b42a6a5e103

bircks/movehub/accel: fix macro names This uses the correct macro name for some gpios. This doesn't change the value.

view details

David Lechner

commit sha 02115c650bc1023e23a24e36a41e481cec283c32

platform/city_hub: add unknown gpio This is another unknown gpio that gets set low and initialization and shutdown. Not sure what effect it has, if anything.

view details

David Lechner

commit sha 62ecced801d980523041d958730a6b0e685b46f7

platform/city_hub: fix I/O port gpios

view details

David Lechner

commit sha 05b616ca86590ee22bc1ead8946eecf012aa2f49

drv/bluetooth/city_hub: new driver This driver basically has the same pins as the move hub and the same bluetooth chip as the control+ hub.

view details

push time in 8 days

push eventpybricks/pybricks-micropython

David Lechner

commit sha 05b616ca86590ee22bc1ead8946eecf012aa2f49

drv/bluetooth/city_hub: new driver This driver basically has the same pins as the move hub and the same bluetooth chip as the control+ hub.

view details

push time in 8 days

create barnchpybricks/pybricks-micropython

branch : dlech

created branch time in 8 days

issue commentpybricks/pybricksdev

Is jupyter really a depedency?

It looks like jupyter is a meta package that is never updated (and so doesn't give us any control over the version of its dependencies). The packages we are actually using are notebook an ipykernel.

dlech

comment created time in 8 days

push eventpybricks/bleak

David Lechner

commit sha e1ee35a9d03e22947fce53a28631482e9765a2ca

Fix Darwin dependencies The pyobjc package requires in all pyobjc-* packages, most of which we don't use. This fixes the requirements so that we only install the packages we are using.

view details

push time in 8 days

push eventpybricks/pybricksdev

David Lechner

commit sha 4d71aa475a71e0fc8e2f86a635f7cc375708169c

config: poetry lock after fixing bleak pyobjc deps Bleak doesn't actually need the full pyobjc, just a few packages.

view details

push time in 8 days

push eventpybricks/bleak

David Lechner

commit sha 5c741687528dec05d48aedbd5c97d3593800c5a2

Fix Darwin dependencies The pyobjc package requires in all pyobjc-* packages, most of which we don't use. This fixes the requirements so that we only install the packages we are using.

view details

push time in 8 days

issue commenthbldh/bleak

Error During simple device scan

Root permissions should not be needed. Make sure your user account is a member of the bluetooth group.

DionisisBozikis

comment created time in 8 days

issue commentpybricks/support

[Bug] DriveBase's drive command has an incorrect argument named "drive_speed"

Also reported at https://github.com/pybricks/pybricks-api/issues/23

markovian72

comment created time in 9 days

PR opened hbldh/bleak

CoreBluetooth fixes

This is some of the fixes I have been working on. If fixes several of the outstanding CoreBluetooth issues. I didn't rebase on #209 because that PR seems a bit unfinished.

+269 -113

0 comment

6 changed files

pr created time in 9 days

push eventpybricks/bleak

David Lechner

commit sha 304b695892ef9d461cee2b03e8527e4a0c49da65

Remove corebluetooth global central manager. This removes the global Application() class in the corebluetooth backend. Instead, a new central manager is created for each scanner object. Since an instance of the `Application()` was created on module import, it could interfere with other code like introspection tools that don't actually want to run `bleak`. This also fixes running `bleak` in threads (hbldh/bleak#206).

view details

push time in 9 days

push eventpybricks/bleak

David Lechner

commit sha 9830c824ea3955742b2281f5bfd7a61403436268

fix race condition in core bluetooth startup core bluetooth has to wait until centralManagerDidUpdateState_ is called and the state is CBManagerStatePoweredOn before any other bluetooth functions can be used. Since __init__ can't be async, this means we have to move the check to the other async entry points of discovery and scanner.

view details

David Lechner

commit sha e5d7207158bc6b12f19adcc5cd23e3bc2971f0ac

fix enumeration of devices in CoreBluetooth backend Apparently some things were removed from the CentralManagerDelegate that kept track of scanned peripherals. This replaces it with a new implementation in BleakScannerCoreBluetooth instead.

view details

David Lechner

commit sha 815e5035654ea1f893e0494bf54245d59caec00e

implement register_detection_callback in CoreBluetooth

view details

David Lechner

commit sha 6064096d8dc3cc2d62735bd5ba3ffc8adb549831

Replace NSRunLoop with dispatch queue This replaces the NSRunLoop integration in the corebluetooth backend with a dispatch queue. This causes callbacks to be dispatched on a background thread instead of on the main dispatch queue on the main thread. `call_soon_threadsafe()` is used to synchronize the events with the event loop where the central manager was created. The NSRunLoop caused problems because it had to manually be called from the main thread. This left an asyncio task that had to be manually stopped at the end of a program to prevent errors about the still running task (issue: hbldh/bleak#111). The NSRunLoop implementation was also not very efficient since it was waking up the event loop every millisecond to check for events.

view details

David Lechner

commit sha 19f099cad4c5c5b4181a5f85d01e1af9561763a1

Remove corebluetooth global central manager. This removes the global Application() class in the corebluetooth backend. Instead, a new central manager is created for each scanner object. Since an instance of the `Application()` was created on module import, it could interfere with other code like introspection tools that don't actually want to run `bleak`. This also fixes running `bleak` in threads (hbldh/bleak#206).

view details

push time in 9 days

push eventpybricks/bleak

David Lechner

commit sha d75fd2c150b0ef3f799b1e0f1e477d289dcc19a9

spelling

view details

David Lechner

commit sha d53a60d0d69f5453420c28ed982217b359df64bb

use CBManagerState constants This replaces hard-coded numbers with constants from objc bindings

view details

David Lechner

commit sha d5512168a0123a505c5b4e514ef34a8c3ef06bb9

fix race condition in core bluetooth startup core bluetooth has to wait until centralManagerDidUpdateState_ is called and the state is CBManagerStatePoweredOn before any other bluetooth functions can be used. Since __init__ can't be async, this means we have to move the check to the other async entry points of discovery and scanner.

view details

David Lechner

commit sha 4a26c9172c4ff216969169cac423fde42503bb45

fix enumeration of devices in CoreBluetooth backend Apparently some things were removed from the CentralManagerDelegate that kept track of scanned peripherals. This replaces it with a new implementation in BleakScannerCoreBluetooth instead.

view details

David Lechner

commit sha b5b78ffb57ef6c0e2aaf77988c2400708d1cb4c5

implement register_detection_callback in CoreBluetooth

view details

David Lechner

commit sha 56ec40ea2dc6f960c042fa05a04b5319f4990297

Replace NSRunLoop with dispatch queue This replaces the NSRunLoop integration in the corebluetooth backend with a dispatch queue. This causes callbacks to be dispatched on a background thread instead of on the main dispatch queue on the main thread. `call_soon_threadsafe()` is used to synchronize the events with the event loop where the central manager was created. The NSRunLoop caused problems because it had to manually be called from the main thread. This left an asyncio task that had to be manually stopped at the end of a program to prevent errors about the still running task (issue: hbldh/bleak#111). The NSRunLoop implementation was also not very efficient since it was waking up the event loop every millisecond to check for events.

view details

David Lechner

commit sha 133879b146f185fb4214dadfedbf8d61eee0b511

Remove corebluetooth global central manager. This removes the global Application() class in the corebluetooth backend. Instead, a new central manager is created for each scanner object. Since an instance of the `Application()` was created on module import, it could interfere with other code like introspection tools that don't actually want to run `bleak`. This also fixes running `bleak` in threads (hbldh/bleak#206).

view details

push time in 9 days

more