- 'BIT', <bit>
- 'STUFF BIT', None
- 'EOP', None
+ - 'ERR', None
<sym>:
- 'J', 'K', 'SE0', or 'SE1'
<bit>:
- - 0 or 1
+ - '0' or '1'
- Note: Symbols like SE0, SE1, and the J that's part of EOP don't yield 'BIT'.
'''
('eop', 'End of packet (EOP)'),
('bit', 'Bit'),
('stuffbit', 'Stuff bit'),
+ ('error', 'Error'),
)
annotation_rows = (
- ('bits', 'Bits', (4, 5, 6, 7)),
+ ('bits', 'Bits', (4, 5, 6, 7, 8)),
('symbols', 'Symbols', (0, 1, 2, 3)),
)
if sym != 'K':
self.oldsym = sym
return
+ self.consecutive_ones = 0
self.ss_sop = self.samplenum
self.samplepos = self.ss_sop - (self.bitwidth / 2) + 0.5
self.set_new_target_samplenum()
self.state = 'GET BIT'
def handle_bit(self, sym, b):
- if self.consecutive_ones == 6 and b == '0':
- # Stuff bit.
- self.putpb(['STUFF BIT', None])
- self.putb([7, ['Stuff bit: %s' % b, 'SB: %s' % b, '%s' % b]])
- self.consecutive_ones = 0
+ if self.consecutive_ones == 6:
+ if b == '0':
+ # Stuff bit.
+ self.putpb(['STUFF BIT', None])
+ self.putb([7, ['Stuff bit: 0', 'SB: 0', '0']])
+ self.consecutive_ones = 0
+ else:
+ self.putpb(['ERR', None])
+ self.putb([8, ['Bit stuff error', 'BS ERR', 'B']])
+ self.state = 'IDLE'
else:
# Normal bit (not a stuff bit).
self.putpb(['BIT', b])
self.putpm(['EOP', None])
self.putm([5, ['EOP', 'E']])
self.syms, self.state = [], 'IDLE'
- self.consecutive_ones = 0
self.bitwidth = float(self.samplerate) / float(self.bitrate)
def get_bit(self, sym):