Programm crashes, if parameter not OK

I'm using Async for several Years without problems.
Not I have seen a problem.
If my customer does not set parameters correctly, program with Async will fail after data are received. If using correct parameters (baudrate etc.) program runs perfect.
What can I do to prevent hanging program, if parameters are not correct?

I cannot see an issue with hanging here. What exact code do you use that causes the application to hang?

I have a testprogram, which sends some data out. With another program I receive these data. For test, I send data out with 4800,8,1,e
and receiving with 9600, 8,1,e

After a short time I get following error:
I get access violation at 0x00409acc: read of address 0x6f646e61

Do I have to clear receive buffer in this case to prevent this error?
I only like to make my program more user friendly. Are some settings wrong, program should still react.

I suspect that the access violation is happening in the code that reads out the data (and this data is not correct as both ports are connected with different port parameters. I suspect the event VaComm.OnError will be triggered and when this event happens after connecting, I'd suggest to disable your code that processes incoming data.



Thanks for idea. It seems to be the problem.
Normally I evaluate bytes after incoming, but bytes would not fit because of wrong reading.

I have similar problem. The sender and receiver are using different baud rate. Read is done in background thread. During reading the software crashes with access violation but in main thread (!) on code address 0 (so EIP = 0 !). To be more precise at exactly the time of crash the backround thread is not calling any TVaComm method and it is sleeping in Windows Sleep function. This is very annoying, the software should detect such situation and print an error, not crash.

Also in OnError event there is not parameter that would tell me what is the source of error. Should I handle all possible errors by interrupting reading ?


typedef void __fastcall (__closure TVaCommErrorEvent)(System::TObject Sender, int Errors);

The OnError event  is triggered when the EV_ERR communications event flag is set after a WaitCommEvent.

From the Windows documentation:
<table responsive="true" summary="table" style="border-collapse: collapse; margin-bottom: 20px; margin-top: 20px; word-break: break-word; border: 1px solid rgb187, 187, 187; color: rgb0, 0, 0; font-family: "Segoe UI", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; font-size: 13px;"><td -th=" Flag" style="padding: 10px 8px; color: rgb42, 42, 42; vertical-align: top; min-width: 80px; border-style: solid; border-color: rgb187, 187, 187;">EV_ERR<td -th="Deion" style="padding: 10px 8px; color: rgb42, 42, 42; vertical-align: top; min-width: 80px; border-style: solid; border-color: rgb187, 187, 187;">A line-status error occurred. Line-status errors are CE_FRAME, CE_OVERRUN, and
CE_RXPARITY. To find the cause of the error, ClearCommError should be called.The Errors parameter in TVaComm.OnError is the result from the ClearCommError call.

See also:
https://msdn.microsoft.com/en-us/library/ff802693.aspx

Meanwhile I found that crash was flaw in my code. Nevertheless thank you for your comment.