Open RobotJuices opened 3 weeks ago
Hello.
I think it is due to the MTU size limitation of BLE. On Windows, the MTU size is 23Byte, of which 20Byte is available for GATT.
If the number of targets specified in cube.api.motor.motor_control_multiple_targets is 3, I think it will fail because the data size exceeds 20Byte.
Hello,
While using the TOIO python bindings, tutorial, and examples in Toio for Python, I encountered a possible bug.
I am running on Window 10 Home. Python 3.11.5 via command prompt access and IDLE and Pyton 3.12.7 within VSCode. Note: The crash/bug is the same via straight Python environment or within VSCode.
At the bottom I also list the package dependencies.
The Problem When using the example for
cube.api.motor.motor_control_multiple_targets
with 3 or more targets defined, it crashes and a Traceback occurs (see below) and the Cube does not move.cube.api.motor.motor_control_multiple_targets
is supposed to be able to handle up to 29 targets according toTo recreate the error, see motor_3() at https://pypi.org/project/toio.py/ and add a 3rd target to the targets list.
Same code located at the github. See https://github.com/toio/toio.py/blob/main/examples/motor_control.py
Code Snipet with an added 3rd target
Run and Traceback C:\Users\IdeaLINQ\Documents\Development\TOIO>python "test_motor3.py" Traceback (most recent call last): File "C:\Users\IdeaLINQ\Documents\Development\TOIO\test_motor3.py", line 30, in
asyncio.run(motor_3())
File "C:\Users\IdeaLINQ\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\IdeaLINQ\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\IdeaLINQ\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\IdeaLINQ\Documents\Development\TOIO\test_motor3.py", line 18, in motor_3
await cube.api.motor.motor_control_multiple_targets(
File "C:\Users\IdeaLINQ\AppData\Local\Programs\Python\Python311\Lib\site-packages\toio\cube\api\motor.py", line 591, in motor_control_multiple_targets
await self._write_without_response(bytes(motor_target))
File "C:\Users\IdeaLINQ\AppData\Local\Programs\Python\Python311\Lib\site-packages\toio\cube\api\base_class.py", line 108, in _write_without_response
return await self.interface.write(self.uuid, data, response=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\IdeaLINQ\AppData\Local\Programs\Python\Python311\Lib\site-packages\toio\device_interface\ble.py", line 106, in write
await self.device.write_gatt_char(char_uuid, data, response)
File "C:\Users\IdeaLINQ\AppData\Local\Programs\Python\Python311\Lib\site-packages\bleak__init__.py", line 786, in write_gatt_char
await self._backend.write_gatt_char(characteristic, data, response)
File "C:\Users\IdeaLINQ\AppData\Local\Programs\Python\Python311\Lib\site-packages\bleak\backends\winrt\client.py", line 906, in write_gatt_char
await characteristic.obj.write_value_with_result_async(buf, response),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [WinError -2147024809] The parameter is incorrect
For convenience, here is the full program that works with 2 targets but not 3 or more. Example code below has 3 targets and test_motor1 and test_motor2 have been removed (they work).
Package Dependencies
Requirement already satisfied: setuptools in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (75.3.0) Requirement already satisfied: typing-extensions in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (4.12.2) Requirement already satisfied: bleak in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (0.22.3) Requirement already satisfied: bleak-winrt<2.0.0,>=1.2.0 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from bleak) (1.2.0) Requirement already satisfied: typing-extensions>=4.7.0 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from bleak) (4.12.2) Requirement already satisfied: toio-py in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (1.1.0) Requirement already satisfied: bleak>=0.22.1 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from toio-py) (0.22.3) Collecting setuptools<70.0.0,>=69.5.1 (from toio-py) Using cached setuptools-69.5.1-py3-none-any.whl.metadata (6.2 kB) Requirement already satisfied: typing-extensions<5.0.0,>=4.10.0 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from toio-py) (4.12.2) Requirement already satisfied: bleak-winrt<2.0.0,>=1.2.0 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from bleak>=0.22.1->toio-py) (1.2.0) Using cached setuptools-69.5.1-py3-none-any.whl (894 kB) Installing collected packages: setuptools Attempting uninstall: setuptools Found existing installation: setuptools 75.3.0 Uninstalling setuptools-75.3.0: Successfully uninstalled setuptools-75.3.0 Successfully installed setuptools-69.5.1 Requirement already satisfied: ipykernel in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (6.29.5) Requirement already satisfied: comm>=0.1.1 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from ipykernel) (0.2.2) Requirement already satisfied: debugpy>=1.6.5 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from ipykernel) (1.8.7) Requirement already satisfied: ipython>=7.23.1 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from ipykernel) (8.29.0) Requirement already satisfied: jupyter-client>=6.1.12 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from ipykernel) (8.6.3) Requirement already satisfied: jupyter-core!=5.0.,>=4.12 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from ipykernel) (5.7.2) Requirement already satisfied: matplotlib-inline>=0.1 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from ipykernel) (0.1.7) Requirement already satisfied: nest-asyncio in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from ipykernel) (1.6.0) Requirement already satisfied: packaging in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from ipykernel) (24.1) Requirement already satisfied: psutil in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from ipykernel) (6.1.0) Requirement already satisfied: pyzmq>=24 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from ipykernel) (26.2.0) Requirement already satisfied: tornado>=6.1 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from ipykernel) (6.4.1) Requirement already satisfied: traitlets>=5.4.0 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from ipykernel) (5.14.3) Requirement already satisfied: decorator in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from ipython>=7.23.1->ipykernel) (5.1.1) Requirement already satisfied: jedi>=0.16 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from ipython>=7.23.1->ipykernel) (0.19.1) Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.41 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from ipython>=7.23.1->ipykernel) (3.0.48) Requirement already satisfied: pygments>=2.4.0 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from ipython>=7.23.1->ipykernel) (2.18.0) Requirement already satisfied: stack-data in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from ipython>=7.23.1->ipykernel) (0.6.3) Requirement already satisfied: typing-extensions>=4.6 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from ipython>=7.23.1->ipykernel) (4.12.2) Requirement already satisfied: colorama in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from ipython>=7.23.1->ipykernel) (0.4.6) Requirement already satisfied: python-dateutil>=2.8.2 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from jupyter-client>=6.1.12->ipykernel) (2.9.0.post0) Requirement already satisfied: platformdirs>=2.5 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from jupyter-core!=5.0.,>=4.12->ipykernel) (4.3.6) Requirement already satisfied: pywin32>=300 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from jupyter-core!=5.0.*,>=4.12->ipykernel) (308) Requirement already satisfied: parso<0.9.0,>=0.8.3 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from jedi>=0.16->ipython>=7.23.1->ipykernel) (0.8.4) Requirement already satisfied: wcwidth in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from prompt-toolkit<3.1.0,>=3.0.41->ipython>=7.23.1->ipykernel) (0.2.13) Requirement already satisfied: six>=1.5 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from python-dateutil>=2.8.2->jupyter-client>=6.1.12->ipykernel) (1.16.0) Requirement already satisfied: executing>=1.2.0 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from stack-data->ipython>=7.23.1->ipykernel) (2.1.0) Requirement already satisfied: asttokens>=2.1.0 in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from stack-data->ipython>=7.23.1->ipykernel) (2.4.1) Requirement already satisfied: pure-eval in c:\users\idealinq\appdata\local\programs\python\python311\lib\site-packages (from stack-data->ipython>=7.23.1->ipykernel) (0.2.3)