PDA

View Full Version : reading from rfcomm device


mbertazz
2006-08-23, 21:09
hi,
i'm writing a simple cmd-line application based on serial bt communication to a bt reader.

I'm using perl cause i have to call this script from opera browser (but same problem using this perl script with cmd-line).

Thanks to your help, no problem connecting to
/dev/rfcomm0:
# after setting up with "rfcomm connect... " and after opening connection
open ($fd, "+< /dev/rfcomm0") or die "cannot open serial port";

and no problem writing on it:
print $fd chr(0x03). chr(0x00). chr(0x01). chr(0x01). chr (0x03 ^ 0x00 ^ 0x01 ^ 0x01);
as written into device serial port communication manual, with this print, device beeps a special tone.

but...
on every request i send with a "print" my device have to do something and send me a response.

i can't read this response...

can you help me? other languages are welcome too.

thank you in advance,
mbertazz

aleksandyr
2006-08-23, 22:09
What problem are you encountering, exactly?

Does the application hang and return no data on read?
Do you get a permission error when attempting to read?
You seem to have the right file mode...and it's not a buffering issue...

mbertazz
2006-08-24, 09:17
another test:

connected to device using /dev/rfcomm0
use the script to test connection sending a msg from 770 to device: OK
use this:
cat /dev/rfcomm0
now, i'm connected (i hear same beeps as with the previous script), but i don't see any data printed on stdout when i press generate a event on the device (if i do this with a bt gps i see nmea data)

fanoush
2006-08-24, 12:06
Some devices can have only one way communication, this is possible with BT rfcomm specs. Both GPS and BT keyboards usually only send but cannot receive. Maybe you need to connect to another rfcomm port to receive? Depends on specific device of course.

mbertazz
2006-08-25, 14:11
maybe, but how to solve this problem?
this is sdptool output ("sdptool records [BTADDRESS]" cause nothing is shown with "browse"):
Service Name: Spp
ServiceRecHandle: 0X10000
Service Class ID List:
"Service Port" (0x1101)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 1

any ideas?


thanks a lot,
mbertazz