Thursday, February 13, 2025

Re: Serial port data to variable

In this scenario, you would try to avoid python variables, and pass such things around
using message passing. In a pinch, you can use the "message to variable" block, to convert
a message to a variable, but, again, messages are the architecturally far superior
approach here, suffer no thread-safety issues, and as long as they can do the things you
need them to, you should go for them instead of trying to shoehorn a python variable into
something that can be updated regularly.

Best regards,
Marcus Müller

On 2/13/25 2:32 PM, Muhammad Anas wrote:
> Dear GNU Radio Community,
>
> I'm working on a GRC flowgraph, which has different variable blocks, e.g 'frequency'
> variable linked to the frequency parameter of signal source, and I have made a custom
> python block to receive the data as a float from serial port: 'COM4' by using the pyserial
> library, I want to equalize the 'frequency' variable with the float data coming from
> serial port, so that frequency value update according to the data coming from a port, but
> the issue is that 'frequency' variable is not recognizing as a variable, (variable not
> defined issue), is there any solution or any block that will update the variable
> 'frequency' with the variable 'frequency' defined in custom python block, because I want
> to control the frequency from the serial port. I am trying to do this on Windows, I don't
> want to go with OOT modules.
>
> Kindly help me in this regard.
>
> Regards
> Muhammad Anas

No comments:

Post a Comment