EVaCommError

Hello,

I am getting this sometimes and I do not know why.

exception class    : EVaCommError
exception message  : Error retrieving statistics (5), Access is denied

The program is running, accessing the port for 10 seconds to 10 hours and this might occur. Port is open at program start and used continuously.

What causes this? And I do not see any way to trap it.

Thanks,

Mark

main thread ($219c):
00a10a54 +05c Runtime.exe  VaComm         TVaCustomComm.Error
00a10ab0 +02c Runtime.exe  VaComm         TVaCustomComm.Watch
00a117c1 +059 Runtime.exe  VaComm         TVaCustomComm.GetCommStatus
00a11330 +024 Runtime.exe  VaComm         TVaCustomComm.ClearLineErrors
00a11ad0 +018 Runtime.exe  VaComm         TVaCustomComm.HandleLineEvent
00a0fec2 +00a Runtime.exe  VaComm         TVaCommWriteThread.DoWriteError
004dc0b7 +12b Runtime.exe  Classes        CheckSynchronize
006034b6 +136 Runtime.exe  Forms          TApplication.Idle
006026f7 +017 Runtime.exe  Forms          TApplication.HandleMessage
00602a15 +0c9 Runtime.exe  Forms          TApplication.Run
01a40358 +08c Runtime.exe  Runtime 730 +9 initialization
750d8482 +022 KERNEL32.DLL                BaseThreadInitThunk

Are you sure that at all times, there is only one process opening or trying to open this COM port you use?



Yes.

I can test the theory by trying to reproduce the error by attempting to open the port with another program.

But let us say another program is the problem. I would prefer an error message/code/callback, not an exception that I can not trap and handle.

Is there a single point in your application where you open & close VaComm?
Normally, the VaComm.Open call is where the check should be added to see if the port can be opened and only if it could be opened succesfully, data can be read or written.



Yes, the port is open at program start and closed when ends. The port is used constantly while the program is running. The error does not occur on program state/port open.

Can there be interruptions in the physical connection? Anything else that could happen at the time you get this error?


No. These applications are 24/7 and most are in hardened cabinets. I have had it occur here sitting at my desk.

Let's say the cause is undetermined. I am seeking a way to trap this error/exception and inform the user via our normal methods, not an exception dialog.

Maybe it is also worth checking if there aren't any serial port driver updates.



Perhaps. I know my drivers are current. The last bug report, the customer was using W10.

What about the question to trap and prevent this exception?

Looking around in code. Will the "OnErrorException" catch this exception?

Implementing this event allows to bypass the default exception that is triggered.

Thanks

Getting back around to testing/coding for this issue.
Why is OnErrorException not exposed in TVaComm?
Another program attempting to open the same port does not produce the exception.
  1. OnErrorException is right now in the protected section, so if you want to override this, you'd need to create a descending class and override there.

    2) I cannot see the issue with opening the same port. An exception should be triggered. Are you just calling VaComm.Open?
1) Yes that is what I did.
2) Yes

Your original question: "Are you sure that at all times, there is only one process opening or trying to open this COM port you use?"

An external process attempting to open the port does not trigger the exception.
In my program IF I attempted to open the serial port again it does generate the exception. My program does not open the port twice.

If you do not get the exception that an open port is not opened again, then I assume that it indeed doesn't happen.

I do not know the meaning of the last post and we have strayed a bit.

Back to the original question.

The exception "Error retrieving statistics (5)" is not the same exception message when opening the port a second time: "Can't open the specified device \.\COM1 (Error 5, access denied).

While both are “access denied (5)” they seem to be different, as the message indicates.

Original question: "What causes this? And I do not see any way to trap it."
First part; I still do not know what causes the exception, “Error retrieving statistics (5)”.
Second part; the OnErrorException should at least catch the issue and prevent the crash.

Without having anything to analyze / reproduce / see code details, all I could do was guesswork that it had something to do with open/close.

If it appears not to be open/close related, I cannot think of anything else given the limited amount of information.
Possibly the exception you see is an application exception and  you could try to catch it by writing a handle for Application.OnException()
Thanks for the response.
Since the stack trace does not originate in my code I am also lacking data.
The program has application exception handling.
The program will log all com port exceptions, now, and hopefully that will provide more data.