Home > Back-end >  Delphi 7 spcomm communication problems
Delphi 7 spcomm communication problems

Time:10-13

Delphi 7 + spcomm, spcomm Readintervaltimeout=10, can from the received data, but if the input data interval is big what also don't get, and the input data is more bytes, the individual feels lost even if the receiving data should not be what also can't receive!
And download sscom32 serial debugging why below what circumstance can receive data, ask ace to help!
Work progress, expert help!

CodePudding user response:

Readintervaltimeout this parameter (remember there are two parameters, is directly to Windows API set), in general use, if not directly communicate with API, but with the encapsulation of serial communication control, can not manage these parameters, with the default values,
You receive data way is to use spcomm event, in the event the code to add a delay, sleep (100) to sleep (400), the time to adjust, can receive the complete data,
Better way is in the judgment to receive data length, like this:
While WantNum & lt; InputNum do
The begin
If (timeout)/(very) times then
The Exit;
Sleep (10);
The end;
Read ();
WantNum to receive the number of bytes, InputNum is the number of bytes in the buffer, this parameter is the Read API function () of inBytes parameters, the Spcomm OnRecieveData shall be with the parameters in the () of (CPort controls is the parameter)

CodePudding user response:

Thank you for your help, you're in the receive events adjustment I can understand that, but it is clearly there are data to serial port, with sscom32 tools can be received, and my program spcomm OnRecieveData (), but can not trigger, adjustable Readintervaltimeout could also trigger, but not every time after the startcom can trigger,
Hope can tell thank you again!

CodePudding user response:

2 floor said at the time of sending the delay can be

In addition, look at your BufferLength, and see if it is suitable for your data

CodePudding user response:

You can try
  • Related