Author Topic: Open Error  (Read 711 times)

jeremyk

  • Newbie
  • *
  • Posts: 2
    • View Profile
Open Error
« on: September 04, 2014, 03:55:59 pm »
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

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Open Error
« Reply #1 on: September 09, 2014, 04:45:33 pm »
Hello

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

Code: [Select]
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

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Open Error
« Reply #2 on: September 15, 2014, 01:30:53 pm »
Many thanks, that seems to have resolved it.