UINT mThreadUp2(LPVOID pParam)//端點(diǎn)2上傳線(xiàn)程

{

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)//設(shè)備打開(kāi),線(xiàn)程啟動(dòng)

{

/**************在線(xiàn)程中用CreateFile打開(kāi)設(shè)備,因?yàn)槊總€(gè)句柄同一時(shí)候只能執(zhí)行一個(gè)API**************************/

if ( pDlg->T2UHandle != INVALID_HANDLE_VALUE ) { ?// 打開(kāi)設(shè)備成功

datalen = min( pDlg->m_uplen2, sizeof(mBuf));

dlen = datalen;

if(CH375ReadData((ULONG)pDlg->T2UHandle,&mBuf[0],&dlen)){//操作成功輸出數(shù)據(jù)

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); //顯示數(shù)據(jù)

{//更新長(zhǎng)度顯示

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,"端點(diǎn)2上傳失敗!如果設(shè)備斷開(kāi)過(guò)那么請(qǐng)先關(guān)閉本程序","DEBUG372",MB_OK|MB_ICONSTOP);

}

}

pDlg->m_trdup2 = FALSE;

pDlg->m_btnup2.EnableWindow(TRUE);

//ExitThread(0);

return 0;

}



程序中的j=j+3是為了顯示一個(gè)空格,但是為什么在我的電腦上j=j+3顯示錯(cuò)誤,我把它改成j=j+2就可以顯示。只是中間沒(méi)有空格?? ?是不是數(shù)據(jù)類(lèi)型不合適呀,求大神給我指點(diǎn)指點(diǎn),謝謝啦