+ # End states (for additional checks).
+ if self.state == 'SLOT': # Wait for end of time slot.
+ # Wait for a falling edge and/or end of timeslot.
+ self.wait_falling_timeout(self.fall, timing['SLOT']['min'])
+
+ if self.matched[0] and not self.matched[1]:
+ # Low detected before end of slot.
+ self.putfs([1, ['Time slot not long enough',
+ 'Slot too short',
+ 'SLOT < ' + str(timing['SLOT']['min'][self.overdrive])]])
+ # Don't output invalid bit.
+ self.fall = self.samplenum
+ self.state = 'LOW'
+ else: # End of time slot.
+ # Output bit.
+ self.putfs([0, ['Bit: %d' % self.bit, '%d' % self.bit]])
+ self.putpfs(['BIT', self.bit])
+ # Save command bits.
+ if self.bit_count >= 0:
+ self.command += (self.bit << self.bit_count)
+ self.bit_count += 1
+ # Check for overdrive ROM command.
+ if self.bit_count >= 8:
+ if self.command == 0x3c or self.command == 0x69:
+ self.overdrive = True
+ self.put(self.samplenum, self.samplenum,
+ self.out_ann,
+ [4, ['Entering overdrive mode', 'Overdrive on']])
+ self.bit_count = -1
+ self.state = 'IDLE'
+
+ if self.state == 'PRESENCE DETECT':
+ # Wait for a falling edge and/or end of presence detect.
+ self.wait_falling_timeout(self.rise, timing['RSTH']['min'])
+
+ if self.matched[0] and not self.matched[1]:
+ # Low detected before end of presence detect.
+ self.putfs([1, ['Presence detect not long enough',
+ 'Presence detect too short',
+ 'RTSH < ' + str(timing['RSTH']['min'][self.overdrive])]])
+ # Inform about presence detected.
+ self.putrs([3, ['Slave presence detected', 'Slave present',
+ 'Present', 'P']])
+ self.putprs(['RESET/PRESENCE', True])
+ self.fall = self.samplenum
+ self.state = 'LOW'
+ else: # End of time slot.
+ # Inform about presence detected.
+ self.putrs([3, ['Presence: true', 'Presence', 'Pres', 'P']])
+ self.putprs(['RESET/PRESENCE', True])
+ self.rise = self.samplenum
+ # Start counting the first 8 bits to get the ROM command.
+ self.bit_count = 0
+ self.command = 0
+ self.state = 'IDLE'