增加bug56的分支, 主站发送4个字节的00,从站异常的反应
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
#encoding=utf-8
|
||||
import random
|
||||
import copy
|
||||
|
||||
class GenPkt(object):
|
||||
def __init__(self):
|
||||
@@ -10,12 +11,14 @@ class GenPkt(object):
|
||||
self.pkt_type = 0
|
||||
self.pkt_sub_pkt = 0
|
||||
self.sub_pkt = list()
|
||||
self.pkt_data = None
|
||||
|
||||
def clean(self):
|
||||
self.pkt_buf = list() #bytearray(b'\0' * 2048)
|
||||
self.pkt_type = 0
|
||||
self.pkt_sub_pkt = 0
|
||||
self.sub_pkt = list()
|
||||
self.pkt_data = None
|
||||
|
||||
def setPktType(self, type):
|
||||
if (type != 0) and (type != 1):
|
||||
@@ -23,6 +26,16 @@ class GenPkt(object):
|
||||
else:
|
||||
self.pkt_type = type
|
||||
|
||||
def setPkt(self, type, data = None):
|
||||
if (type != 0) and (type != 1):
|
||||
if type == 2:
|
||||
self.pkt_type = 2
|
||||
self.pkt_data = copy.copy(data)
|
||||
else:
|
||||
print('Error...set type failed:', type)
|
||||
else:
|
||||
self.pkt_type = type
|
||||
|
||||
def addBeforeExc(self, str):
|
||||
self.sub_pkt.append([1, str])
|
||||
|
||||
@@ -58,7 +71,7 @@ class GenPkt(object):
|
||||
print("pkt_len:%d, data_len:%d"%(pkt_len, pkt_len - 4))
|
||||
|
||||
i = 4
|
||||
if self.pkt_type == 1:
|
||||
if (self.pkt_type == 1):
|
||||
pkt_len = 4
|
||||
'''
|
||||
self.pkt_buf[0] = 0
|
||||
@@ -70,6 +83,12 @@ class GenPkt(object):
|
||||
self.pkt_buf.append(self.pkt_type & 0x3)
|
||||
self.pkt_buf.append(0x3f)
|
||||
self.pkt_buf.append(0xff)
|
||||
elif (self.pkt_type == 2):
|
||||
pkt_len = len(self.pkt_data)
|
||||
|
||||
for d in self.pkt_data:
|
||||
self.pkt_buf.append(d)
|
||||
#print("-----------------------------", filename, self.pkt_type, pkt_len, self.pkt_buf)
|
||||
else:
|
||||
#for i in range(pkt_len):
|
||||
'''
|
||||
@@ -263,7 +282,7 @@ def genSlvSMWriteData(dev, sm, data_len, data = None):
|
||||
|
||||
if (data != None) and (len(data) != 0) and (len(data) < data_len):
|
||||
return ''
|
||||
|
||||
|
||||
if (data == None) or (len(data) == 0):
|
||||
data = list()
|
||||
for i in range(data_len):
|
||||
@@ -301,6 +320,19 @@ if __name__ == '__main__':
|
||||
gen_file_def = "detect_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>错误的嗅探数据包
|
||||
genPkt.clean()
|
||||
genPkt.setPkt(2, [0, 0, 0, 0])
|
||||
gen_file_def = "detect_err_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
|
||||
Reference in New Issue
Block a user