我现在使用ch375做一个数据采集通讯同时输出信号,在上位机开了一个线程调用库函数提供的读写函数往复通讯,同时在主画面中存在按钮调用读写函数通讯出现死机的情况,请问库函数提东的函数是否支持两个线程同时调用,如支持在线程中应如何设置

敬请回复

下附:线程中调用库函数的部分源码

struct CCommInfo { public: unsigned char m_Char1; unsigned char m_Char2; unsigned char m_Char3; unsigned char m_Char4; unsigned char m_Char5; unsigned char m_Char6; unsigned char m_Char7; unsigned char m_Char8; }; // 线程中使用的发送流程 unsigned long dlen=8; m_pReadSize=&dlen; m_pWriteSize=&dlen; m_WriteOnOffInfo.m_Char1=0X80; m_WriteOnOffInfo.m_Char2=0X80; m_WriteOnOffInfo.m_Char3=0X00; m_WriteOnOffInfo.m_Char4=0X00; m_WriteOnOffInfo.m_Char5=0X00; m_WriteOnOffInfo.m_Char6=0X00; m_WriteOnOffInfo.m_Char7=0X00; m_WriteOnOffInfo.m_Char8=0X00; CH375WriteData(m_Index,&m_WriteOnOffInfo,m_pWriteSize); Sleep(10); LONG iRet=CH375QueryBufUpload(m_Index); if(iRet>0) CH375ReadData(m_Index,&m_ReadInfo,m_pReadSize); //获得限位开关前握手信息 if(m_ReadInfo.m_Char3==0X00)//获得上下开关值 { if(m_ReadInfo.m_Char6==0) { m_UpOnOff=0; //上开关 m_DnOnOff=0; //下开关 int iLed = atoi(m_pView->GetDocument()->m_strLed); m_pView->m_DlgShowData->m_LedUp.SetLed(0); m_pView->m_DlgShowData->m_LedDn.SetLed(0); }else if(m_ReadInfo.m_Char6==1) { m_UpOnOff=1; //上开关 m_DnOnOff=0; //下开关 m_pView->m_DlgShowData->m_LedDn.SetLed(0); m_pView->m_DlgShowData->m_LedUp.SetLed(1); }else if(m_ReadInfo.m_Char6==2) { m_UpOnOff=0; //上开关 m_DnOnOff=1; //下开关 m_pView->m_DlgShowData->m_LedUp.SetLed(0); m_pView->m_DlgShowData->m_LedDn.SetLed(1); } Sleep(100); }