<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.32.2">
</HEAD>
<BODY>
Hello everyone,<BR>
<BR>
I am using a Python script to get data from a BlueTooth device but it seems there is some problem when reading from the interface on Linux.<BR>
<BR>
I have a three devices (PowerSpy) that measure energy from an outlet (I plug a computer on a PowerSpy that I plug on an outlet). This device communicates using BlueTooth. So I connect my laptop via BT to get those data (using : sudo rfcomm bind /dev/rfcomm0 powerspy_mac_address).<BR>
<BR>
Then, I execute my Python script. This script reads data from  /dev/rfcomm0 (with root priviledge). The first data is successfully read. The second and the third too. But the fourth time that I access /dev/rfcomm0, I get some odd caracteres: A<BR>
<BR>
I tried to access to this interface using minicom, no problem, I can read easily these data. I changed the computer that was under test, no change. I changed every physical devices by other, no change.<BR>
<BR>
That's why, I think I have a problem with my script.<BR>
<BR>
Here is the error:<BR>
<BR>
Traceback (most recent call last):<BR>
4107A6A<BR>
  File "./PowerSpy.py", line 64, in <module><BR>
    powerspy = PowerSpy("/dev/rfcomm0")<BR>
  File "./PowerSpy.py", line 33, in __init__<BR>
    u = (struct.unpack('<f', Ucalib.decode('hex'))[0])        # Unpack in LittleIndian + float (see IEEE 32-bit float representation)<BR>
  File "/usr/lib/python2.7/encodings/hex_codec.py", line 42, in hex_decode<BR>
    output = binascii.a2b_hex(input)<BR>
TypeError: Odd-length string<BR>
<BR>
The python file is in the attachement.<BR>
<BR>
I am using Ubuntu 11.04 with Python 2.7.1+.<BR>
<BR>
Do you have some clues to help me resolving this problem ?<BR>
<BR>
Thanks,<BR>
<BR>
Regards,<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
-- <BR>
<IMG SRC="cid:1310565500.2520.0.camel@g-e6400-55" ALIGN="bottom" BORDER="0"><BR>
<B>Rémi Druilhe</B><BR>
RD-MAPS-GRE<BR>
OLNC/MAPS/SHINE/MADE<BR>
Phone: +33 (0)4 76 76 24 27<BR>
E-mail : <A HREF="mailto:remi.druilhe@orange-ftgroup.com">remi.druilhe@orange-ftgroup.com</A><BR>
Orange Labs Grenoble - 28 chemin du Vieux Chêne - BP98 38243 Meylan Cedex  - France
</TD>
</TR>
</TABLE>
</BODY>
</HTML>