Thanks for offering the support Kartik. 

I ended up not going through SWIG route at all. Basically I got away with 
typecasting in the C domain itself and not expose complex data types to Python 
at all (through SWIG). For now I am Ok. I will shoot you an email in case SWIG 
catches up with me again 😊

Vipin

Sent from Mail for Windows 10

From: Kartik Patel
Sent: Tuesday, July 18, 2017 1:35 PM
To: Vipin Sharma
Cc: GNURadio Discussion List
Subject: Re: [Discuss-gnuradio] Complex data types in SWIG for custom C blocks

Dear Vipin,

I believe I came across the issue recently. But I m not sure if that is the 
exact issue.

I was using Numpy SWIG in my OOT, so that when I convert from C++ to Python, I 
got a Numpy complex numbers. My reason of using Numpy was mainly continuous 
buffer support but probably getting complex number support was a side product.

So, I don't have solution to exactly what's your issue but here is my SWIG 
file. It would be great if you can share a minimal example or provide the link 
to public repo so that I can debug on my end.

Thanks!


Regards,
Kartik Patel


On Tue, Jul 18, 2017 at 10:11 PM, Vipin Sharma <[email protected]> 
wrote:
I have a custom C block for which one of the input argument is of a complex 
type (real_T, essentially a structure of primitive type). It appears that the 
SWIG by default cannot handle any input or output arguments  other than simple 
primitive types (int, float, etc.). 

I researched a bit and found that the answer is in defining a custom type for 
SWIG using %typemap feature. 

SWIG offers the %typemap documentation here: 
http://www.swig.org/Doc1.3/Typemaps.html but I was wondering if there are any 
examples, specifically for GNU-RADIO that I can follow? 

For the curious, this is the error I see once the top_block.py is run:

linux; GNU C++ version 5.4.0 20160609; Boost_105800; 
UHD_003.010.001.001-79-g7ac01c7f

-- Detected Device: B210
-- Operating over USB 2.
-- Initialize CODEC control...
-- Initialize Radio control...
-- Performing register loopback test... pass
-- Performing register loopback test... pass
-- Performing CODEC loopback test... pass
-- Performing CODEC loopback test... pass
-- Setting master clock rate selection to 'automatic'.
-- Asking for clock rate 16.000000 MHz... 
-- Actually got clock rate 16.000000 MHz.
-- Performing timer loopback test... pass
-- Performing timer loopback test... pass
-- Asking for clock rate 50.000000 MHz... 
-- Actually got clock rate 50.000000 MHz.
-- Performing timer loopback test... pass
-- Performing timer loopback test... pass
Traceback (most recent call last):
 File "/home/vipin/a1/grc/a1-rfe+mimo/gr-a1System/build/top_block.py", line 
234, in <module>
 main()
 File "/home/vipin/a1/grc/a1-rfe+mimo/gr-a1System/build/top_block.py", line 
222, in main
 tb = top_block_cls()
 File "/home/vipin/a1/grc/a1-rfe+mimo/gr-a1System/build/top_block.py", line 
164, in __init__
 self.a1System_TargetDetector_cf_0 = a1System.TargetDetector_cf(512, 10, 1024, 
2, 5, 1, 1, 1, 1)
 File "/usr/local/lib/python2.7/dist-packages/a1System/a1System_swig.py", line 
214, in make
 return _a1System_swig.TargetDetector_cf_make(samps_per_sweep, num_sweeps, 
frame_size, rang_max, v_max, rng_nfft, dop_nfft, num_peaks, num_tgts)
TypeError: in method 'TargetDetector_cf_make', argument 1 of type 'real_T'

Thanks,
Vipin

_______________________________________________
Discuss-gnuradio mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

ᐧ

_______________________________________________
Discuss-gnuradio mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to