summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnuradio-core/src/python/gnuradio/gruimpl/hexint.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/gnuradio-core/src/python/gnuradio/gruimpl/hexint.py b/gnuradio-core/src/python/gnuradio/gruimpl/hexint.py
index 8d46e8192..f2808c448 100644
--- a/gnuradio-core/src/python/gnuradio/gruimpl/hexint.py
+++ b/gnuradio-core/src/python/gnuradio/gruimpl/hexint.py
@@ -30,3 +30,15 @@ def hexint(mask):
if mask >= 2**31:
return int(mask-2**32)
return mask
+
+def hexshort(mask):
+ """
+ Convert unsigned masks into signed shorts.
+
+ This allows us to use hex constants like 0x8000 when talking to
+ our hardware and not get screwed by them getting treated as python
+ longs.
+ """
+ if mask >= 2**15:
+ return int(mask-2**16)
+ return mask