Odd caracteres

remi.druilhe at orange-ftgroup.com remi.druilhe at orange-ftgroup.com
Wed Jul 13 16:19:31 CEST 2011


Hello everyone,

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.

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).

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

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.

That's why, I think I have a problem with my script.

Here is the error:

Traceback (most recent call last):
4107A6A
  File "./PowerSpy.py", line 64, in <module>
    powerspy = PowerSpy("/dev/rfcomm0")
  File "./PowerSpy.py", line 33, in __init__
    u = (struct.unpack('<f', Ucalib.decode('hex'))[0]) 	# Unpack in
LittleIndian + float (see IEEE 32-bit float representation)
  File "/usr/lib/python2.7/encodings/hex_codec.py", line 42, in
hex_decode
    output = binascii.a2b_hex(input)
TypeError: Odd-length string

The python file is in the attachement.

I am using Ubuntu 11.04 with Python 2.7.1+.

Do you have some clues to help me resolving this problem ?

Thanks,

Reg <<orange_logo.gif>> ards,
-- 

Rémi Druilhe
RD-MAPS-GRE
OLNC/MAPS/SHINE/MADE
Phone: +33 (0)4 76 76 24 27
E-mail : remi.druilhe at orange-ftgroup.com
Orange Labs Grenoble - 28 chemin du Vieux Chêne - BP98 38243 Meylan
Cedex  - France
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110713/990b48ef/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: orange_logo.gif
Type: image/gif
Size: 765 bytes
Desc: orange_logo.gif
URL: <http://mail.python.org/pipermail/python-list/attachments/20110713/990b48ef/attachment.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PowerSpy.py
Type: text/x-python
Size: 2011 bytes
Desc: PowerSpy.py
URL: <http://mail.python.org/pipermail/python-list/attachments/20110713/990b48ef/attachment.py>


More information about the Python-list mailing list