'(gnuradio) Is there a way I can use "python block" to make a source?

I have an ADC module with 1 MHZ sampling rate. Here is the URL of his sample program

I will give him a 40khz carrier signal as an analog input. I want to write the voltage signal he received into the "python block" of "GNURADIO". let his

output_items[0][:]=adc.readA1Volts()

But when I do this it runs out:

swig director method error: error detected when calling 'feval_p.eval'

Is there any way I can achieve this?

(I'm not very good in English, I translated it by Google, sorry)



Solution 1:[1]

Generally, yes. You can write a GNU Radio source in Python.

output_items[0][:]=adc.readA1Volts()

That says "assign the many items in output_items[0] the value or values from adc.readA1Volts(), which is almost certainly not correct.

Possibly, something throws an error here, maybe because of array size mismatch or similar, and hence that error you see arises.

I think this reflects a bit of misunderstanding on how to write a python block. The Official GNU Radio Tutorials might be the best place to start.

Solution 2:[2]

adc.readA1Volts() is a single voltage (POINT) that will read adc, I can store it as a matrix,

ex:

ADC=[]
ADC.append(adc.readA1Volts())

Then it is output by output_items[0], ex:

output_items[0][:]=ADC

Is this thought correct? I don't know what his output form is like.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Marcus Müller
Solution 2 user19104274