heihei1252 / pybluez

Automatically exported from code.google.com/p/pybluez
GNU General Public License v2.0
0 stars 0 forks source link

Bug in bluetooth.discover_devices on Sheeva Plug(Debian ARMEL Kernel 2.6.30-2-kirkwood ) #25

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
pybluez Version: 
   Version: 0.17-1 
   Filename: pool/main/p/pybluez/python-bluez_0.17-1_armel.deb 
bluez Version: 
   Architecture: armel 
   Version: 4.57-1 
   Filename: pool/main/b/bluez/bluez_4.57-1_armel.deb 
My System information: 
   uname -a: 
      Linux mikomovil 2.6.30-2-kirkwood #1 Sun Sep 27 22:57:55 UTC 
2009 armv5tel GNU/Linux 
   Sheeva Plug whit debian. 
--------------------------------------------------------------------------- 
--------------------------------------------------------------------------- 
----- 
The problem: 
test.py: 
import bluetooth 
print "performing inquiry..." 
nearby_devices = bluetooth.discover_devices(lookup_names = True) 
print "found %d devices" % len(nearby_devices) 
for addr, name in nearby_devices: 
    print "  %s - %s" % (addr, name) 
when I run this code: 
python test2.py: 
performing inquiry... 
Traceback (most recent call last): 
  File "test2.py", line 12, in <module> 
    nearby_devices = bluetooth.discover_devices(lookup_names = True) 
  File "/usr/lib/python2.5/site-packages/bluetooth/bluez.py", line 17, 
in discover_devices 
    sock = _gethcisock () 
  File "/usr/lib/python2.5/site-packages/bluetooth/bluez.py", line 
230, in _gethcisock 
    raise BluetoothError ("error accessing bluetooth device") 
bluetooth.btcommon.BluetoothError: error accessing bluetooth device 
I had to use the asynchronous method to scan bluetooth devices 
from bluetooth import * 
from s e l e c t import * 
class MyDiscoverer ( DeviceDiscoverer ) : 
        def preinquiry ( self ) : 
                     ̄ 
             self.done = False 
        def devicediscovered( self , address , device class , name ):
             print "%s - %s" % ( address , name ) 
        def inquirycomplete( self ) :                               
             self.done = True 
d = MyDiscoverer() 
d.finddevices( lookup names = True )                                    
while True :
        can_read , can_write , has_exc = select ( [d ] , [ ] , [ ] ) 
        if d in can_read :                             
             d.process event( )                                
        if d.done : break 

I spend too much time fixing my problem and I want to share with the 
community, and report the bug 

Original issue reported on code.google.com by fulit...@gmail.com on 21 Dec 2009 at 11:47

GoogleCodeExporter commented 9 years ago
Thanks for your report, I ran into the same error and your solution worked for 
me.

Also, I want to report that this bug still persists in my version:

pybluez: 0.18-1
bluez: 4.60-0ubuntu5
system: xubuntu 10.04a3, kernel: 2.6.32-16-generic

When using bluez directly from C everything works fine.

Original comment by voig...@gmail.com on 11 Mar 2010 at 8:19

GoogleCodeExporter commented 9 years ago
First, note that recommended way to do inquires is using the D-BUS API, because 
in this case BlueZ can 
coordinate between several applications inquiring at the same time, while using 
the C API is a safe source of 
conflicts/comtempts, because only one process can do that at a time.

Also, it is known that different BT devices work a bit differently, and this 
kind of deviation is better handled by 
BlueZ itself. This is not ideal, but that's how it is. Bug fix in this case 
would be in kernel device driver for the 
specific BT dongle.

I'd bet that some specific characteristic of SheevaPlug's Bluetooth dongle is 
causing this. Could you provide 
hciconfig -a information about it? I hope to put my hands on my own plug in one 
month or so, then I could 
take a look into this.

Original comment by elvis.pf...@gmail.com on 31 May 2010 at 4:50

GoogleCodeExporter commented 9 years ago
Any update on this ?
The shiva plugs bt seems to be the same device as on the gumstix overo fire
and I've had that working without problems for inquiries , scans etc.

The difference seems to be the python and kernel versions.

Been using python 2.6  and  kernels 2.6.32 , 2.6.33 and 2.6.34 on 
Angstrom(default gumstix distro). 

If anyone wants me to try some code for them, just give me a yell(email).

I'm also interested in the sheeva and guru pods.

One thing is we get better range with an external dlink bt dongle than the 
onboard bluetooth(same with wifi - and much higher speeds).

Original comment by alxxtheg...@gmail.com on 26 Sep 2010 at 4:07

GoogleCodeExporter commented 9 years ago
Hi, bluetooth.discover_devices wasn't working for me neither. So I dig into the 
lib code and found why.

bt_hci_inquiry (bluez/btmodule.c) set the ir->dev_id to 0. But it should be set 
to the value of the dev variable in bt_hci_open_dev (bluez/btmodule.c).
Which is either the return value of hci_get_route(NULL), either the value 
passed as parameter of the bt_hci_open_dev function.

===

version 0.20 (from source)
Linux Archlinux 3.13.5-1-ARCH #1 SMP PREEMPT Sun Feb 23 00:25:24 CET 2014 
x86_64 GNU/Linux

Original comment by inceax64 on 16 Mar 2014 at 3:26

GoogleCodeExporter commented 9 years ago
Merged to more recent bug with same cause

Original comment by karu...@wp.pl on 10 Feb 2015 at 6:39