Skip to contentSkip to conversation

rfcomm device blocking/data available behaviour

Bluez-users Dave Marples 2 participants 3 messages Jun 16, 2006 – Jun 17, 2006 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Folks,

I've got a problem using rfcomm to a generic BT device (actually a SE K750i phone, but that's just what I'm using for an example). It looks to me like a bug in the rfcomm/socket interface, but what do I know?

The problem seems to be that blocking/select on a rfcomm serial port isn't working correctly. This is using Ubuntu Dapper (latest release) and I've checked the bluetooth/rfcomm directory against patch 2.6.16-mh3 to ensure that all of the current changes are in there, and they are (in fact, only core.c has changed, and that's mostly beautification).

The easiest way to create the problem is as follows;

1) In /etc/bluetooth/rfcomm.conf establish a connection to the phone;

rfcomm3 {
bind yes;
# Bluetooth address of the device
device xx:xx:xx:xx:xx:xx;
# RFCOMM channel for the connection
channel 1;
# Description of the connection
comment "K750i";
}

2) ...then cat /dev/rfcomm3

Obviously, at this point nothing happens.
3) _RING_ the phone

The output from the 'cat' job goes crazy, and never finishes.

Another way to create the problem is the following (using python);

fd=open("/dev/rfcomm3","r+")
fd.write("ATZ\n")
while 1:
c=fd.read(1)
print "Got",len(c),"Detail:",ord(c),c

Can anyone help? I'm stuck here....it's quite possible I'm doing something _really_ silly, but I need someone to hold a mirror up to be able to see that...

Regards

DAVE

_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

#1 lore raw

Folks,
Replying to myself here, but moving over to the python library, the following code _works_;

import bluetooth

s=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
s.connect(("xx:xx:xx:xx:xx:xx",1))
s.send('ATZ\r')
while 1:

    c=s.recv(1)
    print "Got",len(c),"Detail:",ord(c),c

...so, I can only conclude that it's something to do with the device emulation side of things. Hope this is helpful to someone.

Regards

DAVE

Quoted 47 lines · Dave Marples

Folks,

I've got a problem using rfcomm to a generic BT device (actually a SE K750i phone, but that's just what I'm using for an example). It looks to me like a bug in the rfcomm/socket interface, but what do I know?

The problem seems to be that blocking/select on a rfcomm serial port isn't working correctly. This is using Ubuntu Dapper (latest release) and I've checked the bluetooth/rfcomm directory against patch 2.6.16-mh3 to ensure that all of the current changes are in there, and they are (in fact, only core.c has changed, and that's mostly beautification).

The easiest way to create the problem is as follows;

1) In /etc/bluetooth/rfcomm.conf establish a connection to the phone;

rfcomm3 {
   bind yes;
   # Bluetooth address of the device
   device xx:xx:xx:xx:xx:xx;
   # RFCOMM channel for the connection
   channel    1;
   # Description of the connection
   comment "K750i";
}

2) ...then cat /dev/rfcomm3

Obviously, at this point nothing happens.
3) _RING_ the phone

The output from the 'cat' job goes crazy, and never finishes.

Another way to create the problem is the following (using python);

fd=open("/dev/rfcomm3","r+")
fd.write("ATZ\n")
while 1:

   c=fd.read(1)
   print "Got",len(c),"Detail:",ord(c),c

Can anyone help? I'm stuck here....it's quite possible I'm doing something _really_ silly, but I need someone to hold a mirror up to be able to see that...

Regards

Quoted 9 lines

DAVE

_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

maintainer
#2 lore raw

Hi Dave,

Quoted 9 lines

Replying to myself here, but moving over to the python library, the following code _works_;

import bluetooth

s=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
s.connect(("xx:xx:xx:xx:xx:xx",1))
s.send('ATZ\r')
while 1:

Quoted 5 lines
    c=s.recv(1)
    print "Got",len(c),"Detail:",ord(c),c

...so, I can only conclude that it's something to do with the device emulation side of things. Hope this is helpful to someone.

the RFCOMM TTY devices are not in raw mode by default. You need to do that by yourself. However every application should now what's the best mode to use the device and cat is simply too dumb.

Regards

Marcel

_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users