上位機和設備通過CH395Q通訊正常,設備更改IP地址后,CH395Q如何更新設置,有沒有相關的流程。我嘗試過重新初始化,但出了很多問題。尤其是在上位機和設備一直在通訊的情況下,更改設備的IP地址,初始化CH395Q,然后,CH395會不停的發(fā)送數(shù)據(jù),導致設備死機!
void ch395_modify(void)
{
u8 i;
? //初始化以太網(wǎng)口地址和端口
? for (i=0;i<4;i++)
? ?{
CH395IPAddr[i]? =ethernet[0].CH395Q.ip[i]&0xff;
CH395GWIPAddr[i]=ethernet[0].CH395Q.gateway[i]&0xff;
CH395IPMask[i]? =ethernet[0].CH395Q.subnet[i]&0xff;
}
SocketLocalPort=ethernet[0].CH395Q.port[0];
CH395CloseSocket(0);//關閉以太網(wǎng)口
SocketServerStatus=0;
?
? CH395_RST();? //復位 CH395
? //獲取芯片版本
ch395_version = CH395CMDGetVer();
while(ch395_version? < 0x40)
{
delay_1ms(100);
break;
}
//測試命令,按位取反返回說明測試通過
while(CH395CMDCheckExist(0x55) != 0xaa)
{
delay_1ms(100);
break;
} ?
CH395CMDSetIPAddr(CH395IPAddr);? ? //設置CH395的IP地址?
CH395CMDSetGWIPAddr(CH395GWIPAddr);//設置網(wǎng)關地址?
CH395CMDSetMASKAddr(CH395IPMask);? //設置子網(wǎng)掩碼,默認為255.255.255.0?
//初始化模塊:成功返回 0?
while(CH395CMDInitCH395() != 0)
{
delay_1ms(100);
break;
}
? socket_buffer_config();
}