FabulaTech Forum (http://www.serial-port-control.com/forum)
Serial Port Solution >> Serial Port Control >> Close procedure
(Message started by: giloutho on Apr 12th, 2006, 10:58pm)

Title: Close procedure
Post by giloutho on Apr 12th, 2006, 10:58pm
I developed a GPS application written in Delphi but I have problems of communication with USB emulators. I Try Serial Port Control v1.4, it seems to work perfectly.

I work with your example TinyTerm.I put a simple form with 2 buttons and a TMemo.

With Button1, I send a sentence to the port where a GPS is connected. Parameters in Open procedure are 57600,N,8,1. If communication is OK, GPS answers a sentence with serial number.

With button2 I stop the test with a simple procedure called Stop_Test :

   FTSerialControl1.Close;
   TTY.Lines.Add('  Test finished...');

No problem... when i use button1 followed by button2. One second of delay and it's OK. If I call Stop_Test in FormClose evenment, same thing...

I have a problem when I want to close the port by program. Basically when I have anwser of GPS, I close the port. In a FTSerialControl1CommEvent procedure, I recover anwser of GPS and I call Stop_Test. When I make this, application is freezing... What is the right way to close the port by program ?

Many thanks. ( sorry for my bad english !!!)

Title: Re: Close procedure
Post by Andrew on Apr 13th, 2006, 7:14am
You can not call blocking methods (like CLOSE or READ with non-zero Timeout parameter )  within FTSerialControl1CommEvent handler because that can cause deadlocks as in your case. We suggest you to close port outside of handler.

Title: Re: Close procedure
Post by giloutho on Apr 13th, 2006, 8:28am
Thanks for this quick reply. I put a Close action in the formClose evenment. It's OK... We keep on test on PC with USB emultors.