Home > Back-end >  Why don't program will then run at full speed into the message processing function, can set bre
Why don't program will then run at full speed into the message processing function, can set bre

Time:09-16

Everybody is good, why don't program will then run at full speed into the message processing function, can set breakpoints and then comb into the message function? Is the key code below, and please feel free to comment! Thank you very much! If the code is not complete, I upload again,
Development tools and development language: RAD c + + Builder 10.2

 
//when receive the data sent to the window message
# define ON_COM_RECEIVE (WM_USER + 618)//WPARAM port

Private://User declarations
Void __fastcall OnReadData (TMessage & amp; Msg);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER (ON_COM_RECEIVE TMessage, OnReadData)
END_MESSAGE_MAP (TForm)

//message handler:
Void __fastcall TForm_TestSpecDevice: : OnReadData (TMessage & amp; Msg)
{
If (Msg, Msg==ON_COM_RECEIVE)
{
Len=MyComm1. Read (Temp, 6152);

If ((len==8) & amp; & ((Temp [0]=='S') & amp; & (Temp [3]=='A') & amp; & (Temp [4]=='C') & amp; & (Temp [5]=='K')))
{
RecvFlg=1;
Memset (Temp, 0, sizeof (Temp));
}
Else if ((len & gt; 2048))
{
DataDecompressionAlgorithm (Temp, len, G_pArray);
If (SpecDateRecvOK==1)
{
RecvFlg=0;
SpecDateRecvOK=0;
Memset (Temp, 0, sizeof (Temp));
//len=0;
}
The else
{
SpecDateRecvOK=0;
Memset (G_pArray, 0, sizeof (G_pArray));
RecvFlg=0;
Memset (Temp, 0, sizeof (Temp));
//len=0;
}
}
Else if ((len==0) | | ((len> 8) & amp; & (len<2048)))
{
RecvFlg=0;
//len=0;
}
The else.
}
}

CodePudding user response:

Long cycle of Application - & gt; ProcessMessages () to process the response message in the queue,

CodePudding user response:

Thank you for your answer, still do not understand, would you please give me detailed said,

CodePudding user response:

Check the Help, TApplication ProcessMessages method of a class,

CodePudding user response:

Check to have a lot of resources occupy the main thread code,

CodePudding user response:

Estimation is the place:
Len=MyComm1. Read (Temp, 6152);
Blocked

CodePudding user response:

refer to fifth floor early play big play nuclear war reply:
estimation is the place:
Len=MyComm1. Read (Temp, 6152);
Blocked

That if a serial port is synchronous mode, and doesn't set the timeout, this place is blocked
  • Related