Void CTEST_MFCApplication1Dlg: : OnBnClickedButtonOpen ()
{
//TODO: add the control notification handler code
//the UpdateData (true);
RT_CAN can;
RT_COM com;
CAN_msg MSG.
MSG. Id=0 x01223211;//configuration message ID
MSG. Len=8;//configuration message length
MSG. The format=EXTENDED_FORMAT;//configuration message format
MSG. Type=REMOTE_FRAME;//configuration message type
If (can Open (3, 115200))
{
//open the virtual serial port successful operation
For (int j=1; j <10; J++)
{
The UpdateData (true);
For (int I=1; i <=15; I++)
{
Can. RecvCANMessage (& amp; MSG);
Int temp=(MSG) data [1] <8) | MSG. Data [2];
The switch (MSG) data [0])
{
Case 0 x00: m_V0=temp;
break;
Case 0 x01: m_V1=temp;
break;
Case 0 x02: m_V2=temp;
break;
Case 0 x03: m_V3=temp;
break;
Case 0 x04: m_V4=temp;
break;
Case 0 x05: m_V5=temp;
break;
Case 0 x06: m_V6=temp;
break;
Case 0 x07: m_V7=temp;
break;
Case 0 x08: m_I0=temp;
break;
Case 0 x09: m_I1=temp;
break;
Case 0 x0a: m_I2=temp;
break;
Case 0 x0b: m_I3=temp;
break;
Case 0 x0c: m_P0=temp;
break;
Case 0 x0d: m_P1=temp;
break;
Case 0 x0e: m_P2=temp;
break;
Case 0 x0f: m_P3=temp;
break;
Case 0 x10: m_POSITION_X=temp;
break;
Case 0 x11: m_POSITION_Y=temp;
break;
Case 0 x12: m_POSITION_Z=temp;
break;
Case 0 x13: m_T=temp;
break;
Case 0 x14: m_T0=temp;
break;
Case 0 x15: m_T1=temp;
break;
Case 0 x16: m_T2=temp;
break;
Default: m_T3=temp;
}
}
The UpdateData (false);
}
}
The else
{
MessageBox (_T (" open the equipment failure!" ));
return;
}
}
CodePudding user response:
Message loop is added in the loop:MSG MSG.
If (GetMessage (& amp; MSG, NULL, 0, 0)) {
TranslateMessage (& amp; MSG);
DispatchMessage (& amp; MSG);
}
CodePudding user response:
Strong!!!!!! To solve theCodePudding user response: