[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Discuss-gnuradio] Decoding UDP socket output
From: |
Josh Blum |
Subject: |
Re: [Discuss-gnuradio] Decoding UDP socket output |
Date: |
Thu, 13 Jun 2013 13:29:23 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 |
On 06/13/2013 01:23 PM, Adriana Arteaga wrote:
> 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 <module>
> 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
> Thanks.
>
> Adriana
>
>
>
>
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>