-
Hi all, Currently, I am unsure what the intended way to send data to the hub in import asyncio
from pybricksdev.connections import PybricksHub
from pybricksdev.ble import find_device
async def main():
hub = PybricksHub()
device = await find_device("Pybricks Hub")
await hub.connect(device)
await hub.run("auto_train_updated.py", wait=False)
while not hub.program_running:
await asyncio.sleep(0.5)
await hub.send_block(b"message")
await hub.user_program_stopped.wait()
asyncio.run(main()) Output (line 6 is proper output from my program):
Curiously, if I send longer data, the last few characters of my message is properly received. This is independent of how long after starting the program I wait to send the data. When running the same script via Pybricks Code and mashing on the keyboard, the program properly responds to the sent data:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
from pybricksdev.connections import NUS_RX_UUID
...
await hub.client.write_gatt_char(NUS_RX_UUID, b"message", False) |
Beta Was this translation helpful? Give feedback.
send_block
is for sending the program and not for general use. Try this instead: