Author Topic: Error when re-selecting Com port using DeviceBox  (Read 925 times)

NigelL

  • Newbie
  • *
  • Posts: 4
    • View Profile
Error when re-selecting Com port using DeviceBox
« on: November 27, 2013, 02:19:05 pm »
Hello Roman

I am using a DeviceBox component to select the COM port on a simple Form. If the user selects a Com Port (e.g. COM1) the program works correctly.

If the user selects the same Com Port port again (using the DeviceBox), the program gives an error "Device "COM1" Open Error!!! Access Denied.".

I have tried to disable and re-enable the Com Port using the DeviceBoxChange procedure, but the error occurs before this procedure is called.

Do you have any suggestions on how to avoid this error?

Regards, Nigel

NigelL

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Error when re-selecting Com port using DeviceBox
« Reply #1 on: November 28, 2013, 08:23:56 am »
I have found a solution to my own problem.  ;)

The solution was to disable the Com Port in the DeviceBoxClick procedure and then re-enable it in the DeviceBoxChange procedure.

weirdo12

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Error when re-selecting Com port using DeviceBox
« Reply #2 on: December 17, 2014, 05:13:17 am »
I found that when trying to close and then reopen a virtual port on something like a ethernet-to-serial server I needed to put Sleep(1000) before trying to reopen the port. If you switch port numbers - close COM1 and then open COM2 for example - there is no need to call Sleep().

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Error when re-selecting Com port using DeviceBox
« Reply #3 on: December 18, 2014, 01:02:11 pm »
Hello

Delay between open() and close() port depend on device driver implementation.

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.