• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 
March 29, 2024, 03:39:23 am

News:

SMF - Just Installed!


Open Error

Started by jeremyk, September 04, 2014, 12:55:59 pm

Previous topic - Next topic

jeremyk

I'm getting some curious happenings in an app, which works fine for almost all the time, then for some (as yet unidentified) reason, things stop working correctly, and we get this error when re-connecting to the device:

Device "COM11" Open Error !!!
Access is denied

It's using TnrComm via serial, and if another part of the system is seen to stop working (one we are communicating with over tcp/ip) then we restart our serial comms. This happens by initially doing the following (fComPort is the TnrComm )

fComPort.Active:=False;
FreeAndNil(fComPort);

Then we recreate fComPort with the relevant parameters and try fComPort.Active:=True but this is when the above error happens.

It is as if the previous object didn't somehow release the com port when it closed. Is this likely at all ?


Customer is using XP embedded, and the app is built with XE6 (latest TnrComm)

Thanks
Jeremy

Roman Novgorodov

Hello

You can try to add time delay after closing port. Something like that:

fComPort.Active:=False;
Sleep(1000);
FreeAndNil(fComPort);


Also possible problem is in long data handling and serial port thread is not finished before you close port.
You need check that OnAfterReceive event finished before close port.

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

jeremyk

Many thanks, that seems to have resolved it.