Decoding UDP socket output

Hi!
I’m using an udp_sink block to send the power values (float) to an
common udp socket writing with python

data, addr = sock.recvfrom(2048)

but the outup was:

�����ˆ�„׬��ٶ��e�¹�¢���\d�Ÿ5�˜S���8�®Z��xS�����A��‡™��T�

I found “data = sock.recv(1).decode(‘utf-8’)” function, but the output
was:

received message: ׬
Traceback (most recent call last):
File “udp_connection.py”, line 12, in
data = sock.recv(1).decode(‘utf-8’)
File “/usr/lib/python2.7/encodings/utf_8.py”, line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: ‘utf8’ codec can’t decode byte 0xf9 in position 0:
invalid start byte

I’m try changing “utf-8” for “utf8” and the result is the same. Anyone
knows how can I decode the output?

Thanks.

Adriana

On 06/13/2013 01:23 PM, Adriana A. wrote:

received message: ׬
Traceback (most recent call last):
File “udp_connection.py”, line 12, in
data = sock.recv(1).decode(‘utf-8’)
File “/usr/lib/python2.7/encodings/utf_8.py”, line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: ‘utf8’ codec can’t decode byte 0xf9 in position 0: invalid
start byte

I’m try changing “utf-8” for “utf8” and the result is the same. Anyone knows how
can I decode the output?

If the bytestream is encoded as floats (if I have understood correctly),
why would you decode it as utf8?

Try numpy.fromstring(your_data, numpy.float32) to get a nice array
object in python from such a string.

-josh