network: 台架 IP 迁到 192.168.31.100,并把重复写死的值收进单一真源
分两段(用户裁定 2026-11-02):先做地址迁移,再把同类字面量收敛成
单一真源,以后再改地址只动一处。
一、IP 迁移 192.168.1.100 → 192.168.31.100(gw 同步 → .31.1)
- 工厂默认:Drivers/BSP/NETCFG/net_cfg.c 的 NET_CFG_DEF_IP/_GW
- 注释/文档示例、主机与板级测试、台架 py 脚本、两份 sim_config.ini
- 字节序教学点同步换算 hex:0x6401A8C0 → 0x641FA8C0(内存
C0 A8 1F 64),旧版示例引文与历史 Trap 记录按冻结纪律不动
- UI 黄金基准:网口设置 4 态 + shot_info 共 5 张 .bin 由
check_content_pages.py --update 重刷(渲染值 IP 变了,属预期变更)
- 保留判定:客户点表引用(IEC104/继电保护规划)、芯片手册摘录、
日期冻结的变更记录行、已退役台架档案 MDK-ARM/retracted_bench_*
二、单一真源收口(A+B+C+D,用户批准全做)
- 新建 test/host/bench_defaults.py:台架 py 默认值唯一定义点
(DEVICE_IP/DEVICE_GW/PC_IP/NET_BCAST),22 个脚本改为引用;
MDK-ARM 两探针与 scripts/board_ui_nav.py 经 sys.path shim 引入
- test/board/net_test_task.h 新增 TEST_PC_PEER_IP,板测三处
PHASE*_REMOTE_IP 改引该宏(保留 -D 覆盖);Phase1 断言改
memcmp 数组比较,数组各只出现一次
- simulator/tests/check_content_pages.py 从 net_cfg.c 正则解析
NET_CFG_DEF_* 推导期望值(解析失败即报错、不静默兜底),
脚本内台架 IP 字面量清零
- 装饰性注释去具体值(net_cfg.h/net_socket.h/net_socket.c/
net_socket_sim.c);字节序教学 hex 对刻意保留为唯一写值点
- 刻意不动:主机单测夹具 IP(逐文件钉住的任意值是正确测试
实践)、文档正文 IP(那是文档内容本身)
顺带:scripts/gen_task_table.py 规范串清掉「,B5」——编号清退提交
72b4b094 改了受管区没重跑生成器,task-table 门禁因此一直红
验证:产品 @build 0/0;CH395F 套件开关构建 0/0 后还原产品态;
6 套主机单测 rc=0;content_pages(含宏推导路径)/菜单 8 态/
推流位比对全 PASS;bom-drift 99 无漂移;doc-links/coding-standard/
cppcheck 绿;py_compile 23 文件 + --help 冒烟(含 shim 绝对路径)
This commit is contained in:
@@ -33,7 +33,7 @@ static void tc_400_net_init_downlink(void)
|
||||
/* 1) 芯片不在位:直接失败,且不得继续下发任何参数 */
|
||||
reset_all();
|
||||
g_fx.exist_rc = (int)CH395F_STATUS_NOT_DETECTED;
|
||||
CHECK(net_init("192.168.1.100", "255.255.255.0", "192.168.1.1", NULL) == -1,
|
||||
CHECK(net_init("192.168.31.100", "255.255.255.0", "192.168.31.1", NULL) == -1,
|
||||
"TC-NETSOCK-400a chip not present -> -1");
|
||||
CHECK(g_fxchip.reset_calls == 0 && g_fxchip.init_calls == 0,
|
||||
"TC-NETSOCK-400b when absent it must not reset or initialise (do not drag the error into the stack)");
|
||||
@@ -42,21 +42,21 @@ static void tc_400_net_init_downlink(void)
|
||||
/* 2) 协议栈初始化失败 */
|
||||
reset_all();
|
||||
g_fx.init_rc = (int)CH395F_STATUS_ERROR;
|
||||
CHECK(net_init("192.168.1.100", "255.255.255.0", "192.168.1.1", NULL) == -1,
|
||||
CHECK(net_init("192.168.31.100", "255.255.255.0", "192.168.31.1", NULL) == -1,
|
||||
"TC-NETSOCK-400d ch395f_init failure -> -1");
|
||||
CHECK(g_fxchip.ping_calls == 0, "TC-NETSOCK-400e after an init failure PING must not be enabled (half-configured state)");
|
||||
|
||||
/* 3) 版本门控:低于 0x46 必须**拒置** bit3(SOCKET_CLOSE),退回芯片自动关断 */
|
||||
reset_all();
|
||||
g_fx.version = 0x45U;
|
||||
CHECK(net_init("192.168.1.100", "255.255.255.0", "192.168.1.1", NULL) == 0,
|
||||
CHECK(net_init("192.168.31.100", "255.255.255.0", "192.168.31.1", NULL) == 0,
|
||||
"TC-NETSOCK-400f a too-old version is not fatal: bring-up continues");
|
||||
CHECK(g_fx.fun_para == 0U && g_ns_error_count == 1,
|
||||
"TC-NETSOCK-400g ver<0x46 -> FUN_PARA actually sends 0 (bit3 refused) plus [ERR], never silently degraded");
|
||||
|
||||
/* 4) 版本够新:FUN_PARA=0x08;bit1(TCP_SERVER 多连接) 与 bit0(保留) 都必须为 0 */
|
||||
reset_all();
|
||||
CHECK(net_init("192.168.1.100", "255.255.255.0", "192.168.1.1", NULL) == 0,
|
||||
CHECK(net_init("192.168.31.100", "255.255.255.0", "192.168.31.1", NULL) == 0,
|
||||
"TC-NETSOCK-400h normal initialisation succeeds");
|
||||
/* bit3=SOCKET_CLOSE 要置;bit1=TCP_SERVER 多连接(本项目单连接模型)与
|
||||
* bit0=保留位都必须为 0——旧实现把 0x09 当「多 Socket 模式」下发,2026-10-11
|
||||
@@ -76,7 +76,7 @@ static void tc_400_net_init_downlink(void)
|
||||
"TC-NETSOCK-400l SET-class commands (MSS/KeepAlive) come before INIT_CH395 (manual hard requirement)");
|
||||
|
||||
/* 5) IP/掩码/网关三样都按点分顺位下发,并缓存本机 IP 供 getsockname 用 */
|
||||
CHECK(g_fx.ip[0] == 192U && g_fx.ip[1] == 168U && g_fx.ip[2] == 1U &&
|
||||
CHECK(g_fx.ip[0] == 192U && g_fx.ip[1] == 168U && g_fx.ip[2] == 31U &&
|
||||
g_fx.ip[3] == 100U && g_fx.gw[3] == 1U && g_fx.mask[0] == 255U,
|
||||
"TC-NETSOCK-400m IP, gateway and mask follow the parse_ip_string order (segment 0 lands at [0])");
|
||||
CHECK(g_fxchip.set_dhcp_calls == 0 && g_fx.dhcp_enable == 0U,
|
||||
@@ -92,10 +92,10 @@ static void tc_400_net_init_downlink(void)
|
||||
|
||||
/* 7) MAC:全零=用芯片内置,不下发;非零必须下发(写 EEPROM,须在 INIT 之前) */
|
||||
reset_all();
|
||||
(void)net_init("192.168.1.100", "255.255.255.0", "192.168.1.1", mac_zero);
|
||||
(void)net_init("192.168.31.100", "255.255.255.0", "192.168.31.1", mac_zero);
|
||||
CHECK(g_fxchip.set_mac_calls == 0, "TC-NETSOCK-400q all-zero MAC -> keep the chip built-in one, do not issue it");
|
||||
reset_all();
|
||||
(void)net_init("192.168.1.100", "255.255.255.0", "192.168.1.1", mac_real);
|
||||
(void)net_init("192.168.31.100", "255.255.255.0", "192.168.31.1", mac_real);
|
||||
CHECK(g_fxchip.set_mac_calls == 1 && g_fx.mac[0] == 0x02U && g_fx.mac[5] == 0x55U,
|
||||
"TC-NETSOCK-400r a non-zero MAC is issued (device online identity stays consistent with the UI)");
|
||||
CHECK(ch395f_fake_log_find('M') < ch395f_fake_log_find('n') ||
|
||||
@@ -104,7 +104,7 @@ static void tc_400_net_init_downlink(void)
|
||||
|
||||
/* 8) 收发缓冲块布局:6 块/Socket,先配数据 Socket 再配监听 Socket 0(TRAP-NET-01) */
|
||||
reset_all();
|
||||
(void)net_init("192.168.1.100", "255.255.255.0", "192.168.1.1", NULL);
|
||||
(void)net_init("192.168.31.100", "255.255.255.0", "192.168.31.1", NULL);
|
||||
CHECK(g_fxchip.set_recv_buf_calls == NET_MAX_SOCKETS &&
|
||||
g_fxchip.set_send_buf_calls == NET_MAX_SOCKETS,
|
||||
"TC-NETSOCK-400t all 8 sockets are explicitly reallocated (power-on defaults only cover 0-3)");
|
||||
@@ -122,7 +122,7 @@ static void tc_400_net_init_downlink(void)
|
||||
|
||||
/* 9) net_init 的第一件事是取消挂起并通知调用方(顺序错了 = 调用方永久挂死) */
|
||||
reset_all();
|
||||
(void)net_init("192.168.1.100", "255.255.255.0", "192.168.1.1", NULL);
|
||||
(void)net_init("192.168.31.100", "255.255.255.0", "192.168.31.1", NULL);
|
||||
CHECK(g_peers.pending_cancel_all_calls == 1 &&
|
||||
g_peers.send_cancel_all_calls == 1,
|
||||
"TC-NETSOCK-400w both pending tables are cancelled before a rebuild (recv and send each one, missing one strands a task)");
|
||||
@@ -358,7 +358,7 @@ static void tc_430_connect(void)
|
||||
(void)memset(&in, 0, sizeof(in));
|
||||
in.sin_family = NET_AF_INET;
|
||||
in.sin_port = net_htons(8888);
|
||||
in.sin_addr.s_addr = net_inet_addr("192.168.1.200");
|
||||
in.sin_addr.s_addr = net_inet_addr("192.168.31.200");
|
||||
g_ns_cur_task = (TaskHandle_t)&g_ns_task_caller;
|
||||
CHECK(net_connect(fd, (struct net_sockaddr *)&in, (int)sizeof(in)) == 0,
|
||||
"TC-NETSOCK-430e connect command issued (asynchronous, the interrupt decides success)");
|
||||
@@ -367,7 +367,7 @@ static void tc_430_connect(void)
|
||||
CHECK(s_net_socks[fd].remote_port == 8888U,
|
||||
"TC-NETSOCK-430g peer port stored in bookkeeping as host order");
|
||||
CHECK(g_fx.des_ip[fd][0] == 192U && g_fx.des_ip[fd][1] == 168U &&
|
||||
g_fx.des_ip[fd][2] == 1U && g_fx.des_ip[fd][3] == 200U,
|
||||
g_fx.des_ip[fd][2] == 31U && g_fx.des_ip[fd][3] == 200U,
|
||||
"TC-NETSOCK-430h destination IP issued as a big-endian array (the order set_des_ip needs, reversed means no link)");
|
||||
CHECK(g_chip.set_port_calls == 1 && g_fx.des_port[fd] == 8888U,
|
||||
"TC-NETSOCK-430i source port issued once (SET_SOUR_PORT), the peer port goes via SET_DES_PORT=8888");
|
||||
@@ -455,7 +455,7 @@ static void tc_440_udp_datagram(void)
|
||||
fd = net_socket(NET_AF_INET, NET_SOCK_DGRAM);
|
||||
(void)memset(&in, 0, sizeof(in));
|
||||
in.sin_port = net_htons(8888);
|
||||
in.sin_addr.s_addr = net_inet_addr("192.168.1.9");
|
||||
in.sin_addr.s_addr = net_inet_addr("192.168.31.9");
|
||||
CHECK(net_sendto(fd, "hello", 5, 0, sa, (int)sizeof(in)) == 5,
|
||||
"TC-NETSOCK-440f sendto returns the number of bytes sent");
|
||||
CHECK(g_fx.des_ip[fd][3] == 9U && g_fx.des_port[fd] == 8888U,
|
||||
|
||||
Reference in New Issue
Block a user