From: Uwe Hermann Date: Sat, 14 Jan 2012 00:32:47 +0000 (+0100) Subject: srd: USB: Move pids dict to global level. X-Git-Tag: libsigrokdecode-0.1.0~167 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=bbe99ad5311855f2c1e12195ba8632ca8524b654;p=libsigrokdecode.git srd: USB: Move pids dict to global level. --- diff --git a/decoders/srd_usb.py b/decoders/srd_usb.py index e0ef277..6cf8c2d 100644 --- a/decoders/srd_usb.py +++ b/decoders/srd_usb.py @@ -53,6 +53,20 @@ syms = { (1, 1): SE1, } +# ... +pids = { + '10000111': 'OUT', # Tokens + '10010110': 'IN', + '10100101': 'SOF', + '10110100': 'SETUP', + '11000011': 'DATA0', # Data + '11010010': 'DATA1', + '01001011': 'ACK', # Handshake + '01011010': 'NAK', + '01111000': 'STALL', + '01101001': 'NYET', +} + def bitstr_to_num(bitstr): if not bitstr: return 0 @@ -61,19 +75,6 @@ def bitstr_to_num(bitstr): return int(''.join(l), 2) def packet_decode(packet): - pids = { - '10000111': 'OUT', # Tokens - '10010110': 'IN', - '10100101': 'SOF', - '10110100': 'SETUP', - '11000011': 'DATA0', # Data - '11010010': 'DATA1', - '01001011': 'ACK', # Handshake - '01011010': 'NAK', - '01111000': 'STALL', - '01101001': 'NYET', - } - sync = packet[:8] pid = packet[8:16] pid = pids.get(pid, pid)