16,551
社区成员
发帖
与我相关
我的任务
分享
void CxxxxDlg::OnTest()
{
// TODO: Add your control notification handler code here
BYTE send[100];
BYTE checksum=0;
send[0] = (BYTE)0xAA;
send[1] = (BYTE)0xFF;
send[2] = (BYTE)0xFF;
send[3] = (BYTE)0xFF;
send[4] = 0;//m_ID4;
send[5] = (BYTE)0x00;
send[6] = (BYTE)0x00;
send[7] = (BYTE)0x00;
send[8] = (BYTE)0x00;
send[9] = (BYTE)0x02;
send[10] = (BYTE)0x00;
send[11] = (BYTE)0x01;
//
for (int i=0;i<12;i++)
{
checksum += send[i];
}
CString prompt;
prompt.Format("0x%02X",checksum);
AfxMessageBox(prompt);// 0xAA
send[12] = checksum;
}
结果
0xAAm_edit.Format("%02X", (unsigned char)send[10])