Kizoku-Dev / pybluez

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

RFCOMM socket.connect() doesn't wait till connection is ready #21

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I've the problem that this code doesn't work for me:

---8<---------------------------------------------------
import binascii
from bluetooth import *

socket = BluetoothSocket( RFCOMM )
socket.connect( ("32:32:XX:XX:XX:XX", 1) )

print "sending start measure command"
socket.send( binascii.a2b_hex("FD15040D7700500600018F") )

print "response from sensor:"
print binascii.b2a_hex( socket.recv(7) )
---8<--------------------------------------------------- 

I've to add a time.sleep() statement after socket.connect()
to not getting a deathlock and waiting forever to recv an
answer ...

I'm using libbluetooth3 (4.32-0ubuntu4) and PyBluez-0.14
(installed via easy_install) on Ubuntu 9.04.

Original issue reported on code.google.com by mhubig on 25 Sep 2009 at 3:09

GoogleCodeExporter commented 8 years ago
Hmm actually I have to put several time.sleep()
statements in to get the right answer:

---8<---------------------------------------------------
import binascii
from bluetooth import *

socket = BluetoothSocket( RFCOMM )
socket.connect( ("32:32:XX:XX:XX:XX", 1) )

time.sleep(1)

print "sending start measure command"
socket.send( binascii.a2b_hex("FD15040D7700500600018F") )

time.sleep(1)

print "response from sensor:"
print binascii.b2a_hex( socket.recv(7) )
---8<--------------------------------------------------- 

Regards, Markus

Original comment by mhubig on 25 Sep 2009 at 3:18

GoogleCodeExporter commented 8 years ago
Try this in a recent Ubuntu/kernel/BlueZ combination. The 
examples/simple/rfcomm-{client,server}.py does 
pretty much the same thing (client blocks around connect()) and worked 
perfectly. (Ubuntu 10.04, PyBluez 0.18). 
If it still problematic in your computer, test whether the example works ok.

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

GoogleCodeExporter commented 8 years ago
I need feedback on this, otherwise I will close the issue as "works for me".

Original comment by elvis.pf...@gmail.com on 5 Jul 2010 at 1:11

GoogleCodeExporter commented 8 years ago
Invalid because refers to a pretty old version (0.14). Recent versions don't 
reproduce the bug. Upgrade to 0.18 or CVS. 

Original comment by elvis.pf...@gmail.com on 13 Jul 2010 at 3:23