void CPD218Dlg::setupCnDev(void)
{
cnrouting_running = true;
all_device_connected = false;
update_start_butten(ATestRunning,BTestRunning);
AfxBeginThread((AFX_THREADPROC)doDeviceConnect,NULL);
}
代码执行AfxBeginThread,调用函数doDeviceConnect:
//------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------
DWORD WINAPI doDeviceConnect(LPVOID ref_mts)
{
CString ShowMessage;
bool rValue = true;
CString temp;
CString Name;
ConfigFile &cfg = pCfgf;
testSet *tset = pMainWnd->tSetA;
struct test_sel_t& tsel = tset->tsel;
CTcpLog *ptcplog = pMainWnd->tcp_log;
// bool pwrOff_cur_sel = cfg.ItemSelect(s_PwrOff_cur_sel);
// bool com_use_gd32mcu = cfg.ItemSelect(s_use_gdmcu_com);
bool robot_sel = cfg.ItemSelect(s_robot_need);
//skip monitor first
if(pTbox) pTbox->skip_monitor(true);
if(probot) probot->stop(true);
if(!pMainWnd->terminal_test && !pMainWnd->authorization)
{
temp = "检测电脑测试环境. . .";
DEV_OP_PROMP(temp);
if(verifyIdFile()) pMainWnd->authorization = true;
else
{
ShowMessage = "此计算机环境配置失败!!";
rValue = false;
goto __err_out;
}
}
// connect USB IO dev
#if 0
if(!pMainWnd->terminal_test)
{
pusbio->io_initial();
}
if(!pMainWnd->terminal_test)
{
if((tsel.man_input_addr_sel && tsel.addr_input_by_com_port) &&
(tsel.wAddress_test || tsel.verify_def_addr_sel || tsel.verify_addr_sel) &&
!plable_reader->cn_dev())
{
ShowMessage += "未连接 IO 电源控制板!!\n";
rValue = false;
}
}
#endif
// connect DUT & GLODEN
pMainWnd->selDutComDlgFinsh = 0;
pMainWnd->PostMessage(WM_SHOW_SEL_DUT_DLG,(WPARAM)NULL,(LPARAM)NULL);
while(!pMainWnd->selDutComDlgFinsh) Sleep(200);
/*
if(!pMainWnd->terminal_test && !is_bt_com_allocate())
{
temp = "定位测试板及金机 COM 口";
DEV_OP_PROMP(temp);
if(!com_use_gd32mcu)
{
pMainWnd->selDutComDlgFinsh = 0;
pMainWnd->PostMessage(WM_SHOW_SEL_DUT_DLG,(WPARAM)NULL,(LPARAM)NULL);
while(!pMainWnd->selDutComDlgFinsh) Sleep(200);
}
else
{
int dut_com = INVALID_COM_INDEX;
int golden_com = INVALID_COM_INDEX;
pusbio->get_com_num(USB_IO_DEV_A_ID,dut_com,golden_com);
pMainWnd->tSetA->pObj->allocation_com(dut_com,golden_com);
pusbio->get_com_num(USB_IO_DEV_B_ID,dut_com,golden_com);
pMainWnd->tSetB->pObj->allocation_com(dut_com,golden_com);
}
if(!is_bt_com_allocate())
{
ShowMessage = "测试板 COM 口未全定位!\n";
rValue = false;
}
UPDATE_TITLE();
}
*/
if(!pMainWnd->terminal_test && !pMCU1_Com )
{
//串口线连接到板上的COM口。
temp = "U18 正在分配COM口...";
DEV_OP_PROMP(temp);
pMCU1_Com = new CMCU_COM("U18"); /*U18, dev name*/
if(pMCU1_Com->connect("", 0)) UPDATE_TITLE();
else
{
delete(pMCU1_Com);
pMCU1_Com = NULL;
ShowMessage += "U18 分配COM口失败!!\n";
rValue = false;
}
}
if(!pMainWnd->terminal_test && !pMCU2_Com)
{
temp = "U5 正在分配COM口...";
DEV_OP_PROMP(temp);
pMCU2_Com = new CMCU_COM("U5");
if(pMCU2_Com->connect("", 1)) UPDATE_TITLE();
else
{
delete(pMCU2_Com);
pMCU2_Com = NULL;
ShowMessage += "U5 分配COM口失败!!\n";
rValue = false;
}
}
if(!pMainWnd->terminal_test &&
(cfg.ItemSelect(s_Curent_sel) ))
{
UPDATE_MULTIMETER();
if(!pMultimeter)
{
temp = "Connecting Multimeter ... ";
DEV_OP_PROMP(temp);
pMultimeter = getMultimeterDev();
if(pMultimeter) UPDATE_TITLE();
else
{
ShowMessage += "Multimeter not connect!!\n";
rValue = false;
}
}
}
// connect N4010A,需要判断probeName,ParN4010A_Probedev
if(!pMainWnd->terminal_test && cfg.ItemSelect(s_N4010A_TEST_Sel))
{
Name = "N4010A"; //cfg.VCString(ParBtTestSetsDev);
temp = "connecting ";
temp += Name;
DEV_OP_PROMP(temp);
CREAT_AND_CONNECT_DEVICE(bt_TSET,pBtTestSet, "N4010A");
if(pBtTestSet && !pBtTestSet->dev_is_ready())
{
delete pBtTestSet;
pBtTestSet = NULL;
}
UPDATE_TITLE();
}
// connect test box
if(!pMainWnd->terminal_test && cfg.ItemSelect(parTestBoxNeed) && !pTbox)
{
temp = "正在连接屏蔽箱...";
DEV_OP_PROMP(temp);
CTBOX::creat_dev(pTbox);
if(pTbox && pTbox->connect()) UPDATE_TITLE();
else
{
delete(pTbox);
pTbox = NULL;
ShowMessage += "未连接屏蔽箱!!\n";
rValue = false;
}
}
//connect server for record log data
if(!pMainWnd->terminal_test && tsel.database_svr_need)
{
bool res = true;
if(ptcplog) res = ptcplog->cn_svr(&tcp_cn_promp_par);
if(!res)
{
ShowMessage += "未连接数据记录服务器!\n";
rValue = false;
}
}
//start robot
if(!pMainWnd->terminal_test && robot_sel && !probot) probot = new CROBOT();
if(!pMainWnd->terminal_test && robot_sel)
{
probot->start();
}
if(pTbox) pTbox->skip_monitor(false);
if(pMainWnd->terminal_test)
{
pMainWnd->cnrouting_running = false;
return(false);
}
__err_out:
pMainWnd->all_device_connected = rValue;
pMainWnd->PostMessage(WM_CNDEV_FINSH,(WPARAM)rValue,(LPARAM)NULL);
if(rValue == true) return(true);
AfxMessageBox(ShowMessage.GetBuffer(0));
return(false);
}
return后跳转到thrdcore.cpp 109行:
// first -- check for simple worker thread
DWORD nResult = 0;
if (pThread->m_pfnThreadProc != NULL)
{
nResult = (*pThread->m_pfnThreadProc)(pThread->m_pThreadParams);
ASSERT_VALID(pThread);
}
报错:Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.