2025-07-30 15:50:16 +08:00
|
|
|
|
from pyutils import *
|
|
|
|
|
|
|
2025-08-11 18:04:35 +08:00
|
|
|
|
def watchdog_test_sm_wr_timeout(tc_id, wd_id):
|
2025-07-30 15:50:16 +08:00
|
|
|
|
genPkt = GenPkt()
|
2025-08-02 15:59:42 +08:00
|
|
|
|
|
2025-08-11 18:04:35 +08:00
|
|
|
|
gen_file_def = "watchdog_tc%02d"%(tc_id, )
|
2025-08-02 15:59:42 +08:00
|
|
|
|
sm_idx = 0
|
2025-08-11 18:04:35 +08:00
|
|
|
|
|
|
|
|
|
|
slave_sm_id = int((wd_id - 1) / 2)
|
|
|
|
|
|
tc_des = (f"使能看门狗{wd_id},监视SM{slave_sm_id},写数据到SM中,只写一半,看Watchdog是否超时。\\n"
|
|
|
|
|
|
"清除中断后,错误消失,出问题的设备恢复正常。"
|
|
|
|
|
|
)
|
2025-08-02 15:59:42 +08:00
|
|
|
|
|
2025-07-30 15:50:16 +08:00
|
|
|
|
#--------------------------------------------------------------------------
|
|
|
|
|
|
#>>>>>> 测试用例1 看门狗测试
|
|
|
|
|
|
genPkt.clean()
|
|
|
|
|
|
genPkt.setPktType(0)
|
|
|
|
|
|
|
2025-08-11 18:04:35 +08:00
|
|
|
|
data = 1 << wd_id ##使能看门狗
|
2025-07-30 15:50:16 +08:00
|
|
|
|
data0 = [data&0xff, (data>>8)&0xff, (data>>16)&0xff, (data>>24)&0xff]
|
|
|
|
|
|
|
2025-08-11 18:04:35 +08:00
|
|
|
|
data = 0x002000 ##看门狗的超时值
|
2025-07-30 15:50:16 +08:00
|
|
|
|
data1 = [data&0xff, (data>>8)&0xff, (data>>16)&0xff, (data>>24)&0xff]
|
|
|
|
|
|
|
|
|
|
|
|
data = 0xffffffff ##清除中断
|
|
|
|
|
|
data2 = [data&0xff, (data>>8)&0xff, (data>>16)&0xff, (data>>24)&0xff]
|
|
|
|
|
|
|
2025-08-02 15:59:42 +08:00
|
|
|
|
genPkt.addBeforeExc(genTcStartFrameCode(gen_file_def, tc_des)
|
|
|
|
|
|
+ genIFRwDataCode(1, 0x404, True, 4, data0)
|
2025-07-30 15:50:16 +08:00
|
|
|
|
+ genIFRwDataCode(1, 0x40C, True, 4, data1)
|
|
|
|
|
|
+ genIFRwDataCode(1, 0x078, True, 4, data2)
|
|
|
|
|
|
+ genIFRwDataCode(2, 0x078, True, 4, data2)
|
|
|
|
|
|
+ genIFRwDataCode(3, 0x078, True, 4, data2)
|
|
|
|
|
|
+ genIFRwDataCode(4, 0x078, True, 4, data2)
|
|
|
|
|
|
+ genIFRwDataCode(1, 0x400, True, 4, [0xff, 0xff, 0xff, 0xff])
|
|
|
|
|
|
+ genIFRwDataCode(0, 0x074, False, 0x04)
|
|
|
|
|
|
+ genIFRwDataCode(1, 0x074, False, 0x04)
|
|
|
|
|
|
+ genIFRwDataCode(2, 0x074, False, 0x04)
|
|
|
|
|
|
+ genIFRwDataCode(3, 0x074, False, 0x04)
|
|
|
|
|
|
+ genIFRwDataCode(4, 0x074, False, 0x04)
|
|
|
|
|
|
+ genIFRwDataCode(1, 0x400, False, 0x04))
|
|
|
|
|
|
#genPkt.addBeforeExc( genIFRwDataCode(1, 0x078, True, 4, [0xff, 0xff, 0xff, 0xff]))
|
|
|
|
|
|
|
|
|
|
|
|
data = [0,] * 2
|
|
|
|
|
|
data[0] = 0x80
|
|
|
|
|
|
data[1] = 0x00
|
2025-08-11 18:04:35 +08:00
|
|
|
|
genPkt.addSubPkt(0x0, 0, 0x302 + slave_sm_id * 4, 0xe, 2, data)
|
2025-07-30 15:50:16 +08:00
|
|
|
|
|
|
|
|
|
|
data = [0,] * 0x50
|
|
|
|
|
|
|
2025-08-11 18:04:35 +08:00
|
|
|
|
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
|
|
|
|
|
sm_addr = slave_sm_id * 0x1000 + 0x800
|
|
|
|
|
|
genPkt.addSubPkt(1, 0, sm_addr, 0x1, 0x50, data)
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
+genMessageCode("--检查中断寄存器")
|
|
|
|
|
|
+genIFRwDataCode(0, 0x074, False, 0x04)
|
|
|
|
|
|
+genIFRwDataCode(1, 0x074, False, 0x04)
|
|
|
|
|
|
+genIFRwDataCode(2, 0x074, False, 0x04)
|
|
|
|
|
|
+genIFRwDataCode(3, 0x074, False, 0x04)
|
|
|
|
|
|
+genIFRwDataCode(4, 0x074, False, 0x04)
|
2025-08-22 07:08:59 +08:00
|
|
|
|
+"#700000\n"
|
2025-08-11 18:04:35 +08:00
|
|
|
|
+genIFRwDataCode(1, 0x400, False, 0x04)
|
|
|
|
|
|
+genIFRwDataCode(1, 0x400, True, 4, [0xff, 0xff, 0xff, 0xff])
|
|
|
|
|
|
+genIFRwDataCode(1, 0x400, False, 0x04)
|
|
|
|
|
|
+genIFRwDataCode(1, 0x300 + slave_sm_id * 4, True, 1, [0, ])
|
|
|
|
|
|
+genTcEndFrameCode(gen_file_def))
|
|
|
|
|
|
|
|
|
|
|
|
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
|
|
|
|
|
|
|
|
|
|
|
return gen_file_def
|
|
|
|
|
|
|
|
|
|
|
|
def watchdog_test_sm_rd_timeout(tc_id, wd_id):
|
|
|
|
|
|
genPkt = GenPkt()
|
|
|
|
|
|
|
|
|
|
|
|
gen_file_def = "watchdog_tc%02d"%(tc_id, )
|
|
|
|
|
|
sm_idx = 0
|
|
|
|
|
|
|
|
|
|
|
|
slave_sm_id = int((wd_id - 1) / 2)
|
|
|
|
|
|
tc_des = (f"使能看门狗{wd_id},监视SM{slave_sm_id},写数据到SM中,只读一半,看Watchdog是否超时。\\n"
|
|
|
|
|
|
"清除中断后,错误消失,出问题的设备恢复正常。"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------------
|
|
|
|
|
|
#>>>>>> 测试用例1 看门狗测试
|
|
|
|
|
|
genPkt.clean()
|
|
|
|
|
|
genPkt.setPktType(0)
|
|
|
|
|
|
|
|
|
|
|
|
data = 1 << wd_id ##使能看门狗
|
|
|
|
|
|
data0 = [data&0xff, (data>>8)&0xff, (data>>16)&0xff, (data>>24)&0xff]
|
|
|
|
|
|
|
|
|
|
|
|
data = 0x002000 ##看门狗的超时值
|
|
|
|
|
|
data1 = [data&0xff, (data>>8)&0xff, (data>>16)&0xff, (data>>24)&0xff]
|
|
|
|
|
|
|
|
|
|
|
|
genPkt.addBeforeExc(genTcStartFrameCode(gen_file_def, tc_des)
|
|
|
|
|
|
+ genIFRwDataCode(1, 0x404, True, 4, data0)
|
|
|
|
|
|
+ genIFRwDataCode(1, 0x40C, True, 4, data1)
|
|
|
|
|
|
+ genIFRwDataCode(1, 0x078, True, 4, [0xff, 0xff, 0xff, 0xff])
|
|
|
|
|
|
+ genIFRwDataCode(2, 0x078, True, 4, [0xff, 0xff, 0xff, 0xff])
|
|
|
|
|
|
+ genIFRwDataCode(3, 0x078, True, 4, [0xff, 0xff, 0xff, 0xff])
|
|
|
|
|
|
+ genIFRwDataCode(4, 0x078, True, 4, [0xff, 0xff, 0xff, 0xff])
|
|
|
|
|
|
+ genIFRwDataCode(1, 0x400, True, 4, [0xff, 0xff, 0xff, 0xff])
|
|
|
|
|
|
+ genIFRwDataCode(0, 0x074, False, 0x04)
|
|
|
|
|
|
+ genIFRwDataCode(1, 0x074, False, 0x04)
|
|
|
|
|
|
+ genIFRwDataCode(2, 0x074, False, 0x04)
|
|
|
|
|
|
+ genIFRwDataCode(3, 0x074, False, 0x04)
|
|
|
|
|
|
+ genIFRwDataCode(4, 0x074, False, 0x04)
|
|
|
|
|
|
+ genIFRwDataCode(1, 0x400, False, 0x04)
|
|
|
|
|
|
)
|
|
|
|
|
|
#genPkt.addBeforeExc( genIFRwDataCode(1, 0x078, True, 4, [0xff, 0xff, 0xff, 0xff]))
|
|
|
|
|
|
|
|
|
|
|
|
data = [0,] * 2
|
|
|
|
|
|
data[0] = 0x10
|
|
|
|
|
|
data[1] = 0x00
|
|
|
|
|
|
genPkt.addSubPkt(0x0, 0, 0x302 + slave_sm_id * 4, 0xe, 2, data)
|
|
|
|
|
|
|
|
|
|
|
|
data = [0,] * 0x10
|
|
|
|
|
|
|
|
|
|
|
|
#subPkt参数:索引、索引类型、地址、命令、长度、数据
|
|
|
|
|
|
sm_addr = slave_sm_id * 0x1000 + 0x800
|
|
|
|
|
|
genPkt.addSubPkt(1, 0, sm_addr, 0x1, 0x10, data)
|
2025-07-30 15:50:16 +08:00
|
|
|
|
|
|
|
|
|
|
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)
|
2025-08-05 17:24:01 +08:00
|
|
|
|
+genMessageCode("--检查中断寄存器")
|
2025-07-30 15:50:16 +08:00
|
|
|
|
+genIFRwDataCode(0, 0x074, False, 0x04)
|
|
|
|
|
|
+genIFRwDataCode(1, 0x074, False, 0x04)
|
|
|
|
|
|
+genIFRwDataCode(2, 0x074, False, 0x04)
|
|
|
|
|
|
+genIFRwDataCode(3, 0x074, False, 0x04)
|
|
|
|
|
|
+genIFRwDataCode(4, 0x074, False, 0x04)
|
2025-08-11 18:04:35 +08:00
|
|
|
|
+genIFRwDataCode(1, slave_sm_id * 0x1000 + 0x800, False, 4)
|
|
|
|
|
|
+"#500000\n"
|
2025-08-02 15:59:42 +08:00
|
|
|
|
+genIFRwDataCode(1, 0x400, False, 0x04)
|
2025-08-11 18:04:35 +08:00
|
|
|
|
+genIFRwDataCode(1, 0x400, True, 4, [0xff, 0xff, 0xff, 0xff])
|
|
|
|
|
|
+genIFRwDataCode(1, 0x400, False, 0x04)
|
|
|
|
|
|
+genIFRwDataCode(1, 0x300 + slave_sm_id * 4, True, 1, [0, ])
|
2025-08-02 15:59:42 +08:00
|
|
|
|
+genTcEndFrameCode(gen_file_def))
|
2025-07-30 15:50:16 +08:00
|
|
|
|
|
2025-07-30 22:59:06 +08:00
|
|
|
|
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
2025-08-11 18:04:35 +08:00
|
|
|
|
|
2025-07-30 22:59:06 +08:00
|
|
|
|
return gen_file_def
|
2025-08-11 18:04:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def tc1():
|
|
|
|
|
|
return watchdog_test_sm_wr_timeout(1, 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def tc2():
|
|
|
|
|
|
return watchdog_test_sm_rd_timeout(2, 2)
|