From 1fc7c57f778a9f05ded1d216247242ee13632d03 Mon Sep 17 00:00:00 2001
From: Eric Blossom <eb@comsec.com>
Date: Mon, 10 May 2010 14:31:15 -0700
Subject: Add gru.hexshort to deal with short hex constants

---
 gnuradio-core/src/python/gnuradio/gruimpl/hexint.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

(limited to 'gnuradio-core/src/python/gnuradio')

diff --git a/gnuradio-core/src/python/gnuradio/gruimpl/hexint.py b/gnuradio-core/src/python/gnuradio/gruimpl/hexint.py
index 8d46e8192f..f2808c4489 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
-- 
cgit v1.2.3