X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=decoders%2Fps2%2Fpd.py;h=a9d0a986daf0356b265c61f7e1fd6a24a09cfdd2;hb=826981ac5a2105c7231aeb5e5e523cd37ce72edd;hp=1a7f0be988cd6d3af7212b39bd848f27782fb14c;hpb=6c0a0f6177b3de5df9d8a21549f2702d2d04733a;p=libsigrokdecode.git diff --git a/decoders/ps2/pd.py b/decoders/ps2/pd.py index 1a7f0be..a9d0a98 100644 --- a/decoders/ps2/pd.py +++ b/decoders/ps2/pd.py @@ -33,7 +33,8 @@ class Decoder(srd.Decoder): desc = 'PS/2 keyboard/mouse interface.' license = 'gplv2+' inputs = ['logic'] - outputs = ['ps2'] + outputs = [] + tags = ['PC'] channels = ( {'id': 'clk', 'name': 'Clock', 'desc': 'Clock line'}, {'id': 'data', 'name': 'Data', 'desc': 'Data line'}, @@ -53,8 +54,10 @@ class Decoder(srd.Decoder): ) def __init__(self): + self.reset() + + def reset(self): self.bits = [] - self.samplenum = 0 self.bitcount = 0 def start(self): @@ -113,6 +116,11 @@ class Decoder(srd.Decoder): def decode(self): while True: - # Sample data bits on falling clock edge. - clock_pin, data_pin = self.wait({0: 'f'}) + # Sample data bits on the falling clock edge (assume the device + # is the transmitter). Expect the data byte transmission to end + # at the rising clock edge. Cope with the absence of host activity. + _, data_pin = self.wait({0: 'f'}) self.handle_bits(data_pin) + if self.bitcount == 1 + 8 + 1 + 1: + _, data_pin = self.wait({0: 'r'}) + self.handle_bits(data_pin)