Re: [Discuss-gnuradio] Reading ZMQ messages in Python

2015-09-08 Thread Stephen Harrison
try struct.unpack()

On Tue, Sep 8, 2015 at 11:17 AM, Daniel Mazzer  wrote:

> Hello,
>
> I have a flowgraph that send ZMQ PUB messages generated by a custom
> OOT block. The messages transmitted by GNURadio ZMQ PUB block are
> received by a Python application, using a standard ZMQ Library.
>
> [custom_oot_block] ---(GNURadio message)---> [ZMQ Publisher]
> .(ethernet).> [Python ZMQ SUB Library]
>
> This is the part of the code of the OOT block that creates the message:
>
> -
> float *outPdPfa = (float *) output_items[0];
>
> pmt::pmt_t msg = pmt::init_f32vector(1, outPdPfa);
> message_port_pub(pmt::mp("hard_decision"), msg);
> -
>
> In Python, I receive the transmitted message and this is some of the
> strings that are received:
>
> '\n\x08\x00\x00\x00\x01\x01\x00?\xe4\xbe\x83\x00\x00\x00\x00'
> '\n\x08\x00\x00\x00\x01\x01\x00?\xe5R\xb5 \x00\x00\x00'
> '\n\x08\x00\x00\x00\x01\x01\x00?\xe4B0\xa0\x00\x00\x00'
> '\n\x08\x00\x00\x00\x01\x01\x00?\xe4\xa3\\\xa0\x00\x00\x00'
> '\n\x08\x00\x00\x00\x01\x01\x00?\xe5jV\xa0\x00\x00\x00'
> '\n\x08\x00\x00\x00\x01\x01\x00?\xe4\xf8\x00\x00\x00\x00\x00'
> '\n\x08\x00\x00\x00\x01\x01\x00?\xe4\x90\x00\x00\x00\x00\x00'
>
> How do I convert these strings to a floating number value?
>
> Thank you.
>
> Regards,
> Daniel
>
> ___
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] Reading ZMQ messages in Python

2015-09-08 Thread Marcus Müller
Hi,

the "right way" to do this is use PMT's python bindings:

import pmt
s='\n\x08\x00\x00\x00\x01\x01\x00?\xe4\xbe\x83\x00\x00\x00\x00'
p = pmt.deserialize_str(s)
python_numpy_array = pmt.pmt_to_python.pmt_to_python(p)

Best regards,
Marcus


On 08.09.2015 20:17, Daniel Mazzer wrote:
> Hello,
>
> I have a flowgraph that send ZMQ PUB messages generated by a custom
> OOT block. The messages transmitted by GNURadio ZMQ PUB block are
> received by a Python application, using a standard ZMQ Library.
>
> [custom_oot_block] ---(GNURadio message)---> [ZMQ Publisher]
> .(ethernet).> [Python ZMQ SUB Library]
>
> This is the part of the code of the OOT block that creates the message:
>
> -
> float *outPdPfa = (float *) output_items[0];
>
> pmt::pmt_t msg = pmt::init_f32vector(1, outPdPfa);
> message_port_pub(pmt::mp("hard_decision"), msg);
> -
>
> In Python, I receive the transmitted message and this is some of the
> strings that are received:
>
> '\n\x08\x00\x00\x00\x01\x01\x00?\xe4\xbe\x83\x00\x00\x00\x00'
> '\n\x08\x00\x00\x00\x01\x01\x00?\xe5R\xb5 \x00\x00\x00'
> '\n\x08\x00\x00\x00\x01\x01\x00?\xe4B0\xa0\x00\x00\x00'
> '\n\x08\x00\x00\x00\x01\x01\x00?\xe4\xa3\\\xa0\x00\x00\x00'
> '\n\x08\x00\x00\x00\x01\x01\x00?\xe5jV\xa0\x00\x00\x00'
> '\n\x08\x00\x00\x00\x01\x01\x00?\xe4\xf8\x00\x00\x00\x00\x00'
> '\n\x08\x00\x00\x00\x01\x01\x00?\xe4\x90\x00\x00\x00\x00\x00'
>
> How do I convert these strings to a floating number value?
>
> Thank you.
>
> Regards,
> Daniel
>
> ___
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] Reading ZMQ messages in Python

2015-09-08 Thread Daniel Mazzer
Hi Marcus,

I was missing the "deserialize" call. I'll try it tomorrow.

Thank you.
Regards,
Daniel


On Tue, Sep 8, 2015 at 6:28 PM, Marcus Müller  wrote:
> Hi,
>
> the "right way" to do this is use PMT's python bindings:
>
> import pmt
> s='\n\x08\x00\x00\x00\x01\x01\x00?\xe4\xbe\x83\x00\x00\x00\x00'
> p = pmt.deserialize_str(s)
> python_numpy_array = pmt.pmt_to_python.pmt_to_python(p)
>
> Best regards,
> Marcus
>
>
> On 08.09.2015 20:17, Daniel Mazzer wrote:
>> Hello,
>>
>> I have a flowgraph that send ZMQ PUB messages generated by a custom
>> OOT block. The messages transmitted by GNURadio ZMQ PUB block are
>> received by a Python application, using a standard ZMQ Library.
>>
>> [custom_oot_block] ---(GNURadio message)---> [ZMQ Publisher]
>> .(ethernet).> [Python ZMQ SUB Library]
>>
>> This is the part of the code of the OOT block that creates the message:
>>
>> -
>> float *outPdPfa = (float *) output_items[0];
>>
>> pmt::pmt_t msg = pmt::init_f32vector(1, outPdPfa);
>> message_port_pub(pmt::mp("hard_decision"), msg);
>> -
>>
>> In Python, I receive the transmitted message and this is some of the
>> strings that are received:
>>
>> '\n\x08\x00\x00\x00\x01\x01\x00?\xe4\xbe\x83\x00\x00\x00\x00'
>> '\n\x08\x00\x00\x00\x01\x01\x00?\xe5R\xb5 \x00\x00\x00'
>> '\n\x08\x00\x00\x00\x01\x01\x00?\xe4B0\xa0\x00\x00\x00'
>> '\n\x08\x00\x00\x00\x01\x01\x00?\xe4\xa3\\\xa0\x00\x00\x00'
>> '\n\x08\x00\x00\x00\x01\x01\x00?\xe5jV\xa0\x00\x00\x00'
>> '\n\x08\x00\x00\x00\x01\x01\x00?\xe4\xf8\x00\x00\x00\x00\x00'
>> '\n\x08\x00\x00\x00\x01\x01\x00?\xe4\x90\x00\x00\x00\x00\x00'
>>
>> How do I convert these strings to a floating number value?
>>
>> Thank you.
>>
>> Regards,
>> Daniel
>>
>> ___
>> Discuss-gnuradio mailing list
>> Discuss-gnuradio@gnu.org
>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
>
> ___
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


[Discuss-gnuradio] Reading ZMQ messages in Python

2015-09-08 Thread Daniel Mazzer
Hello,

I have a flowgraph that send ZMQ PUB messages generated by a custom
OOT block. The messages transmitted by GNURadio ZMQ PUB block are
received by a Python application, using a standard ZMQ Library.

[custom_oot_block] ---(GNURadio message)---> [ZMQ Publisher]
.(ethernet).> [Python ZMQ SUB Library]

This is the part of the code of the OOT block that creates the message:

-
float *outPdPfa = (float *) output_items[0];

pmt::pmt_t msg = pmt::init_f32vector(1, outPdPfa);
message_port_pub(pmt::mp("hard_decision"), msg);
-

In Python, I receive the transmitted message and this is some of the
strings that are received:

'\n\x08\x00\x00\x00\x01\x01\x00?\xe4\xbe\x83\x00\x00\x00\x00'
'\n\x08\x00\x00\x00\x01\x01\x00?\xe5R\xb5 \x00\x00\x00'
'\n\x08\x00\x00\x00\x01\x01\x00?\xe4B0\xa0\x00\x00\x00'
'\n\x08\x00\x00\x00\x01\x01\x00?\xe4\xa3\\\xa0\x00\x00\x00'
'\n\x08\x00\x00\x00\x01\x01\x00?\xe5jV\xa0\x00\x00\x00'
'\n\x08\x00\x00\x00\x01\x01\x00?\xe4\xf8\x00\x00\x00\x00\x00'
'\n\x08\x00\x00\x00\x01\x01\x00?\xe4\x90\x00\x00\x00\x00\x00'

How do I convert these strings to a floating number value?

Thank you.

Regards,
Daniel

___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio