Device or resource busy running on Raspberry 4
AlanAlex-AR opened this issue · comments
AlanAlex-AR commented
We are running the run controller.py example on a Raspberry 4 but we get the following error
sudo python3 ble.py DC:A6:32:68:FA:17 device.json hci-socket:0
DEBUG:asyncio:Using selector: EpollSelector
>>> connecting to HCI...
Traceback (most recent call last):
File "/home/kenko/Documents/Kabanta/Kabanta/Proy_graph/ble.py", line 251, in <module>
asyncio.run(main())
File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/home/kenko/Documents/Kabanta/Kabanta/Proy_graph/ble.py", line 197, in main
async with await open_transport_or_link(sys.argv[3]) as (hci_source, hci_sink):
File "/usr/local/lib/python3.9/dist-packages/bumble/transport/__init__.py", line 182, in open_transport_or_link
return await open_transport(name)
File "/usr/local/lib/python3.9/dist-packages/bumble/transport/__init__.py", line 74, in open_transport
return _wrap_transport(await _open_transport(name))
File "/usr/local/lib/python3.9/dist-packages/bumble/transport/__init__.py", line 131, in _open_transport
return await open_hci_socket_transport(spec[0] if spec else None)
File "/usr/local/lib/python3.9/dist-packages/bumble/transport/hci_socket.py", line 93, in open_hci_socket_transport
raise IOError(ctypes.get_errno(), os.strerror(ctypes.get_errno()))
OSError: [Errno 16] Device or resource busy
I can see the controller using hciconfig
hci0: Type: Primary Bus: UART
BD Address: DC:A6:32:68:FA:17 ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING PSCAN
RX bytes:2241 acl:0 sco:0 events:119 errors:0
TX bytes:5095 acl:0 sco:0 commands:119 errors:0
Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH SNIFF
Link mode:hci0: Type: Primary Bus: UART
BD Address: DC:A6:32:68:FA:17 ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING PSCAN
RX bytes:2241 acl:0 sco:0 events:119 errors:0
TX bytes:5095 acl:0 sco:0 commands:119 errors:0
Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH SNIFF
Link mode: SLAVE ACCEPT
Name: 'raspberrypi'
Class: 0x7c0000
Service Classes: Rendering, Capturing, Object Transfer, Audio, Telephony
Device Class: Miscellaneous,
HCI Version: 5.0 (0x9) Revision: 0x17e
LMP Version: 5.0 (0x9) Subversion: 0x6119
Manufacturer: Cypress Semiconductor (305) SLAVE ACCEPT
Name: 'raspberrypi'
Class: 0x7c0000
Service Classes: Rendering, Capturing, Object Transfer, Audio, Telephony
Device Class: Miscellaneous,
HCI Version: 5.0 (0x9) Revision: 0x17e
LMP Version: 5.0 (0x9) Subversion: 0x6119
Manufacturer: Cypress Semiconductor (305)
Gilles Boccon-Gibod commented
When using the built-in controller on the RPi, you need exclusive access to it, so you need to first disable the native Bluetooth stack, which claims the device by default. You can read about the details here: https://google.github.io/bumble/platforms/linux.html#using-hci-sockets
(see the "Disabling bluetoothd" section)