Forum: GNU Radio Python report typeError of argument for my block

Posted by Alex Zhang (Guest)
on 2012-11-16 03:44
(Received via mailing list)
Hello,

I wrote a signal block whose constructor has an argument of type
"uint64_t".  But when in python it is constructed, the error is reported
as TypeErrorL in method 'myblock', argument 1 of type 'uint64_t'.

Then I changed the uint64_t to unsigned long long in my C++ code, but 
the
python still report  TypeError for 'unsigned long long'.

I am thinking that SWIG can not recognize the uint64_t and unsigned long
long, so I need to do something like type mapping , but not know how to 
do
it.
Is there any example that I can follow?

Thanks

--

Alex,
*Dreams can come true  just believe.*
Posted by Josh Blum (Guest)
on 2012-11-16 04:21
(Received via mailing list)
On 11/15/2012 06:44 PM, Alex Zhang wrote:
> long, so I need to do something like type mapping , but not know how to do
> it.
> Is there any example that I can follow?
>

It should be possible. Try adding %include <stdint.i> at the top of your
swig file.

-josh
Posted by Alex Zhang (Guest)
on 2012-11-16 04:40
(Received via mailing list)
Thanks Josh,

Just found that my C++ interface is using type of uint64_t while I 
passed
the data of time_t in python. And the python/SWIG cannot convert the 
time_t
to uint64_t automatically, unlike in C++...

Changed the C++ interface to time_t and make the type conversion within 
the
C++ code. The constructor works in python now.

But we do need to pay attention when c++ types is not recognized in 
python,
assuming your suggestion is a solution. I will try this later for 
possible
case.


On Thu, Nov 15, 2012 at 9:20 PM, Josh Blum <josh@ettus.com> wrote:

> > python still report  TypeError for 'unsigned long long'.
>
> >
>
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>



--

Alex,
*Dreams can come true  just believe.*
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.