From 5b0ae93c8f319bbc367254172719d40f11a0f55b Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 6 Oct 2011 09:26:40 -0700 Subject: uhd: backwards compat work which support streamer API --- gr-uhd/swig/__init__.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'gr-uhd/swig') diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py index 7745b4b79..5c7642a81 100644 --- a/gr-uhd/swig/__init__.py +++ b/gr-uhd/swig/__init__.py @@ -57,6 +57,13 @@ def _prepare_uhd_swig(): def __setitem__(self, key, val): self.set(key, val) setattr(uhd_swig, 'device_addr_t', device_addr_t) + #make the streamer args take **kwargs on init + class streamer_args(uhd_swig.stream_args_t): + def __init__(self, *args, **kwargs): + super(stream_args_t, self).__init__(*args) + for key, val in kwargs.iteritems(): setattr(self, key, val) + setattr(uhd_swig, 'stream_args_t', stream_args_t) + #handle general things on all uhd_swig attributes #Install the __str__ and __repr__ handlers if applicable #Create aliases for uhd swig attributes to avoid the "_t" @@ -87,9 +94,12 @@ def _prepare_uhd_swig(): for index, key, cast in ( (0, 'device_addr', device_addr), (1, 'io_type', io_type), + (1, 'stream_args', stream_args), ): - if len(args) > index: args[index] = cast(args[index]) - if kwargs.has_key(key): kwargs[key] = cast(kwargs[key]) + try: + if len(args) > index: args[index] = cast(args[index]) + if kwargs.has_key(key): kwargs[key] = cast(kwargs[key]) + except: pass return old_constructor(*args, **kwargs) return constructor_interceptor setattr(uhd_swig, attr, constructor_factory(getattr(uhd_swig, attr))) -- cgit From 84c3e0e0fb2df99213ed238ac4f032411d003b30 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 6 Oct 2011 13:39:21 -0700 Subject: uhd: python/swig/grc tweaks until it works --- gr-uhd/swig/__init__.py | 15 +++++++++++---- gr-uhd/swig/uhd_swig.i | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'gr-uhd/swig') diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py index 5c7642a81..a50ec82a5 100644 --- a/gr-uhd/swig/__init__.py +++ b/gr-uhd/swig/__init__.py @@ -58,10 +58,15 @@ def _prepare_uhd_swig(): setattr(uhd_swig, 'device_addr_t', device_addr_t) #make the streamer args take **kwargs on init - class streamer_args(uhd_swig.stream_args_t): + class stream_args_t(uhd_swig.stream_args_t): def __init__(self, *args, **kwargs): super(stream_args_t, self).__init__(*args) - for key, val in kwargs.iteritems(): setattr(self, key, val) + for key, val in kwargs.iteritems(): + #for some reason, i cant assign a list in the constructor + #but what i can do is append the elements individually + if key == 'channels': + for v in val: self.channels.append(v) + else: setattr(self, key, val) setattr(uhd_swig, 'stream_args_t', stream_args_t) #handle general things on all uhd_swig attributes @@ -94,13 +99,15 @@ def _prepare_uhd_swig(): for index, key, cast in ( (0, 'device_addr', device_addr), (1, 'io_type', io_type), - (1, 'stream_args', stream_args), ): try: if len(args) > index: args[index] = cast(args[index]) if kwargs.has_key(key): kwargs[key] = cast(kwargs[key]) except: pass - return old_constructor(*args, **kwargs) + #dont pass kwargs, it confuses swig, map into args list: + for key in ('device_addr', 'stream_args', 'io_type', 'num_channels'): + if kwargs.has_key(key): args.append(kwargs[key]) + return old_constructor(*args) return constructor_interceptor setattr(uhd_swig, attr, constructor_factory(getattr(uhd_swig, attr))) diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index 7e612907c..6ff9d9843 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -48,6 +48,8 @@ //////////////////////////////////////////////////////////////////////// %template(string_vector_t) std::vector; +%template(size_vector_t) std::vector; + %include %include -- cgit From d470318227a3275fe6cdc7ad6fd293c06da2a963 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 13 Oct 2011 15:29:56 -0700 Subject: uhd: grc xml tweaks + streamer args --- gr-uhd/swig/__init__.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gr-uhd/swig') diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py index a50ec82a5..d098a7b8a 100644 --- a/gr-uhd/swig/__init__.py +++ b/gr-uhd/swig/__init__.py @@ -66,6 +66,8 @@ def _prepare_uhd_swig(): #but what i can do is append the elements individually if key == 'channels': for v in val: self.channels.append(v) + elif key == 'args': + self.args = device_addr_t(val) else: setattr(self, key, val) setattr(uhd_swig, 'stream_args_t', stream_args_t) -- cgit