Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #9399

Odd caracteres

Subject Odd caracteres
Date 2011-07-13 16:19 +0200
From <remi.druilhe@orange-ftgroup.com>
Newsgroups comp.lang.python
Message-ID <mailman.983.1310567785.1164.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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@orange-ftgroup.com
Orange Labs Grenoble - 28 chemin du Vieux Chêne - BP98 38243 Meylan
Cedex  - France

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Odd caracteres <remi.druilhe@orange-ftgroup.com> - 2011-07-13 16:19 +0200

csiph-web