X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=decoders%2Fusb_packet%2Fpd.py;h=e262074e0ba7d4bbd6a0fb57d022f22bdfc6159b;hb=4c58713b0d536f37b8630ebd142185aa56946335;hp=3e061c9ccf3edad7a4cac625c30cd00ae74ecac2;hpb=e655c0aa44ac56ff66ad98d30a97cf852bdf7048;p=libsigrokdecode.git diff --git a/decoders/usb_packet/pd.py b/decoders/usb_packet/pd.py index 3e061c9..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 @@ -113,7 +112,7 @@ pids = { # Special '00111100': ['PRE', 'Host-issued preamble; enables downstream bus traffic to low-speed devices'], - '00111100': ['ERR', 'Split transaction error handshake'], + #'00111100': ['ERR', 'Split transaction error handshake'], '00011110': ['SPLIT', 'HS split transaction token'], '00101101': ['PING', 'HS flow control probe for a bulk/control EP'], '00001111': ['Reserved', 'Reserved PID'], @@ -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 = '' @@ -281,7 +284,7 @@ class Decoder(srd.Decoder): self.packet.append(pid) self.packet_summary += pidname - if pidname in ('OUT', 'IN', 'SOF', 'SETUP', 'PRE', 'PING'): + if pidname in ('OUT', 'IN', 'SOF', 'SETUP', 'PING'): if len(packet) < 32: self.putp([28, ['Invalid packet (shorter than 32 bits)']]) return @@ -357,6 +360,8 @@ class Decoder(srd.Decoder): self.packet.append(crc16) 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. else: pass # TODO: Handle 'SPLIT' and possibly 'Reserved' packets.