X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=decoders%2Fusb_packet%2Fpd.py;h=e262074e0ba7d4bbd6a0fb57d022f22bdfc6159b;hb=4c58713b0d536f37b8630ebd142185aa56946335;hp=8d1de65bc33460a5605e77036a492134047a23c3;hpb=be0f8fee99fe939c50ed5d2483a924754788c0b3;p=libsigrokdecode.git diff --git a/decoders/usb_packet/pd.py b/decoders/usb_packet/pd.py index 8d1de65..e262074 100644 --- a/decoders/usb_packet/pd.py +++ b/decoders/usb_packet/pd.py @@ -15,8 +15,7 @@ ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +## along with this program; if not, see . ## import sigrokdecode as srd @@ -148,7 +147,7 @@ def reverse_number(num, count): out = list(count * '0') for i in range(0, count): if num >> i & 1: - out[i] = '1'; + out[i] = '1' return int(''.join(out), 2) def calc_crc5(bitstr): @@ -174,7 +173,7 @@ def calc_crc16(bitstr): return reverse_number(crc16, 16) class Decoder(srd.Decoder): - api_version = 2 + api_version = 3 id = 'usb_packet' name = 'USB packet' longname = 'Universal Serial Bus (LS/FS) packet' @@ -182,6 +181,7 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['usb_signalling'] outputs = ['usb_packet'] + tags = ['PC'] options = ( {'id': 'signalling', 'desc': 'Signalling', 'default': 'full-speed', 'values': ('full-speed', 'low-speed')}, @@ -223,6 +223,9 @@ class Decoder(srd.Decoder): ) def __init__(self): + self.reset() + + def reset(self): self.bits = [] self.packet = [] self.packet_summary = '' @@ -358,7 +361,7 @@ class Decoder(srd.Decoder): elif pidname in ('ACK', 'NAK', 'STALL', 'NYET', 'ERR'): pass # Nothing to do, these only have SYNC+PID+EOP fields. elif pidname in ('PRE'): - pass # Nothing to do, PRE only has SYNC+PID fields. + pass # Nothing to do, PRE only has SYNC+PID fields. else: pass # TODO: Handle 'SPLIT' and possibly 'Reserved' packets.