summaryrefslogtreecommitdiff
path: root/decoders
diff options
context:
space:
mode:
authorGerhard Sittig <gerhard.sittig@gmx.net>2020-08-12 18:46:28 +0200
committerGerhard Sittig <gerhard.sittig@gmx.net>2020-08-12 19:38:48 +0200
commit2bb149e691be4e1abf664a346b0d97c3eac0ad3b (patch)
tree04f65ff5c00ec8dd41faa144cf983dd9f1858360 /decoders
parentb094e81353b3c0c0e9bf5a8ee53bb1da3a05d276 (diff)
downloadlibsigrokdecode-2bb149e691be4e1abf664a346b0d97c3eac0ad3b.tar.gz
libsigrokdecode-2bb149e691be4e1abf664a346b0d97c3eac0ad3b.zip
sdq: use common bits to number conversion
Diffstat (limited to 'decoders')
-rw-r--r--decoders/sdq/pd.py9
1 files changed, 2 insertions, 7 deletions
diff --git a/decoders/sdq/pd.py b/decoders/sdq/pd.py
index 80b15ff..1dc9c1c 100644
--- a/decoders/sdq/pd.py
+++ b/decoders/sdq/pd.py
@@ -17,6 +17,7 @@
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
+from common.srdhelper import bitpack
import sigrokdecode as srd
class SamplerateError(Exception):
@@ -58,12 +59,6 @@ class Decoder(srd.Decoder):
def putbetu(self, data):
self.put(self.bytepos, self.startsample + int(self.bit_width), self.out_ann, data)
- def bits2num(self, bitlist):
- number = 0
- for i in range(len(bitlist)):
- number += bitlist[i] * 2**i
- return number
-
def __init__(self):
self.reset()
@@ -89,7 +84,7 @@ class Decoder(srd.Decoder):
self.putetu([0, ['Bit: %d' % bit, '%d' % bit]])
if len(self.bits) == 8:
- byte = self.bits2num(self.bits)
+ byte = bitpack(self.bits)
self.putbetu([1, ['Byte: %#04x' % byte, '%#04x' % byte]])
self.bits = []
self.bytepos = 0