UINT mThreadUp2(LPVOID pParam)//端點2上傳線程
{
UCHAR mBuf[mCH375_PACKET_LENGTH];
? ? //UCHAR mBuf[64];
ULONG dlen,datalen;
CCH372UpDownDlg *pDlg = (CCH372UpDownDlg *)pParam;
pDlg->m_btnup2.EnableWindow(FALSE);
if(pDlg->m_open && pDlg->m_trdup2)//設備打開,線程啟動
{
/**************在線程中用CreateFile打開設備,因為每個句柄同一時候只能執(zhí)行一個API**************************/
if ( pDlg->T2UHandle != INVALID_HANDLE_VALUE ) { ?// 打開設備成功
datalen = min( pDlg->m_uplen2, sizeof(mBuf));
dlen = datalen;
if(CH375ReadData((ULONG)pDlg->T2UHandle,&mBuf[0],&dlen)){//操作成功輸出數據
CHAR buffer[mCH375_PACKET_LENGTH*2+1];
ULONG i,j;
for(i=0,j=0;i
{
sprintf(&buffer[j],"%02X ",mBuf[i]);
j += 3;
}
buffer[j] = '\0';
ShowUpdata(buffer,j); //顯示數據
{//更新長度顯示
char tem[50]="";
UpCount=UpCount+dlen;
sprintf(tem,"Up: %d",UpCount);
SetDlgItemText(pDlg->m_hWnd,IDC_UpCount,tem);
}
}
else if ( !pDlg->m_close ) MessageBox(NULL,"端點2上傳失??!如果設備斷開過那么請先關閉本程序","DEBUG372",MB_OK|MB_ICONSTOP);
}
}
pDlg->m_trdup2 = FALSE;
pDlg->m_btnup2.EnableWindow(TRUE);
//ExitThread(0);
return 0;
}
程序中的j=j+3是為了顯示一個空格,但是為什么在我的電腦上j=j+3顯示錯誤,我把它改成j=j+2就可以顯示。只是中間沒有空格?? ?是不是數據類型不合適呀,求大神給我指點指點,謝謝啦