SYNC_CODES = [SYNC1, SYNC2, SYNC3]
HRST_CODES = [RST1, RST1, RST1, RST2]
+SOP_SEQUENCES = [
+ (SYNC1, SYNC1, SYNC1, SYNC2),
+ (SYNC1, SYNC1, SYNC3, SYNC3),
+ (SYNC1, SYNC3, SYNC1, SYNC3),
+ (SYNC1, RST2, RST2, SYNC3),
+ (SYNC1, RST2, SYNC3, SYNC2),
+ (RST1, SYNC1, RST1, SYNC3),
+ (RST1, RST1, RST1, RST2),
+]
START_OF_PACKETS = {
- (SYNC1, SYNC1, SYNC1, SYNC2): 'SOP',
- (SYNC1, SYNC1, SYNC3, SYNC3): "SOP'",
- (SYNC1, SYNC3, SYNC1, SYNC3): 'SOP"',
- (SYNC1, RST2, RST2, SYNC3): "SOP' Debug",
- (SYNC1, RST2, SYNC3, SYNC2): 'SOP" Debug',
- (RST1, SYNC1, RST1, SYNC3): 'Cable Reset',
- (RST1, RST1, RST1, RST2): 'Hard Reset',
+ SOP_SEQUENCES[0]: 'SOP',
+ SOP_SEQUENCES[1]: "SOP'",
+ SOP_SEQUENCES[2]: 'SOP"',
+ SOP_SEQUENCES[3]: "SOP' Debug",
+ SOP_SEQUENCES[4]: 'SOP" Debug',
+ SOP_SEQUENCES[5]: 'Cable Reset',
+ SOP_SEQUENCES[6]: 'Hard Reset',
}
SYM_NAME = [
def find_corrupted_sop(self, k):
# Start of packet are valid even if they have only 3 correct symbols
# out of 4.
- for seq in START_OF_PACKETS.keys():
+ for seq in SOP_SEQUENCES:
if [k[i] == seq[i] for i in range(len(k))].count(True) >= 3:
return START_OF_PACKETS[seq]
return None