@@ -70,6 +70,18 @@ class FeatureBits(IntFlag):
7070 HAS_CSUM_UNIT = 4
7171 HAS_FPU = 8
7272
73+ class Frame :
74+ def __init__ (self , time , number , direction , error , match , payload ):
75+ self .time = time
76+ self .number = number
77+ self .direction = direction
78+ self .error = error
79+ self .match = match
80+ self .payload = payload
81+
82+ def __repr__ (self ):
83+ return f"FrameDetector.Frame(number={ self .number } , time={ self .time } , direction={ self .direction } , match={ self .match } , error={ self .error } , captured_size={ len (self .payload )} )"
84+
7385 def __init__ (self , parent , dev_id , initial_props ):
7486 super ().__init__ (parent , dev_id , initial_props )
7587
@@ -92,25 +104,19 @@ def __init__(self, parent, dev_id, initial_props):
92104
93105 def receive_measurement (self , data ):
94106 if len (data ) < 15 :
95- return
96-
97- if self .measurement_handler == None :
98- return
107+ return None
99108
100109 time = decode_u64 (data [0 :8 ])
101110 number = decode_u32 (data [8 :12 ])
102- match_dir = data [12 ] - 64
111+ direction = data [12 ] & 1
112+ error = data [12 ] >> 1
103113 log_width = data [13 ]
104114 match_mask = data [14 ]
105115
106116 ext_offset = ((log_width + 23 ) // log_width ) * log_width - 8
107-
108- if match_dir < 0 or match_dir > 1 :
109- return
110-
111117 ext_data = data [ext_offset :]
112118
113- self . measurement_handler ( self . id , ( time , number , match_dir , match_mask , ext_data ) )
119+ return FrameDetector . Frame ( time , number , direction , error , match_mask , ext_data )
114120
115121 def load_script (self , path ):
116122 comparator_instr = [(0 , 0 )] * self .max_script_size
0 commit comments