diff options
author | Eric Blossom <eb@comsec.com> | 2010-05-10 14:31:15 -0700 |
---|---|---|
committer | Eric Blossom <eb@comsec.com> | 2010-05-10 14:31:15 -0700 |
commit | 1fc7c57f778a9f05ded1d216247242ee13632d03 (patch) | |
tree | f840058fa4f5a7ce421c196f8a06d9496e7b1966 /gnuradio-core/src/python/gnuradio | |
parent | 591c12fc9de3a318a983d1e02eed789f76c0b5fb (diff) |
Add gru.hexshort to deal with short hex constants
Diffstat (limited to 'gnuradio-core/src/python/gnuradio')
-rw-r--r-- | gnuradio-core/src/python/gnuradio/gruimpl/hexint.py | 12 |
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 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 |