From 4370348c4fcdbd708715c35a38fdf06c9364d518 Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Sat, 21 Dec 2019 17:02:50 +0100 Subject: ps2: end data byte at rising clock edge of the stop bit Data byte transmission is complete when the STOP bit was communicated. End the STOP bit at the rising CLOCK edge of the 11th bit time, do not rely on the host's clock inhibit after data transmission. This avoids the unexpected expansion of a STOP bit well into the next data byte. This fixes bug #1460, where absence of host activity after the first data byte loses synchronization to the input stream. Rephrase pin level sampling while we are here. Reflect that the clock line is used for .wait() conditions, but its level is not evaluated. Only data line levels get processed. Comment on the implementation's assumption of specific input data (the device as transmitter, host transmit may not be supported, or can result in unexpected output). Which may be acceptable yet maintainers need to remain aware. --- decoders/ps2/pd.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'decoders/ps2') diff --git a/decoders/ps2/pd.py b/decoders/ps2/pd.py index 194b0b1..a9d0a98 100644 --- a/decoders/ps2/pd.py +++ b/decoders/ps2/pd.py @@ -116,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) -- cgit v1.2.3-70-g09d2