From 1fc7c57f778a9f05ded1d216247242ee13632d03 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Mon, 10 May 2010 14:31:15 -0700 Subject: [PATCH] Add gru.hexshort to deal with short hex constants --- gnuradio-core/src/python/gnuradio/gruimpl/hexint.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gnuradio-core/src/python/gnuradio/gruimpl/hexint.py b/gnuradio-core/src/python/gnuradio/gruimpl/hexint.py index 8d46e819..f2808c44 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 -- 2.30.2