Closing a serial port

E

Empi

Hi.

I have a project on which I use SPP.
I open a serial port that is actually a BT serial port.
Since moving to standby mode kill the connection, I have to reinitiate it by
closing and reopening the port.
All this is quite messy since it take ages to detect that comm was lost,
close the port and reopen it.
(Not to talk about pairing loss that occur from time to time, but this is
another topic...).

My question is, is there a way to make the close port faster?
It takes about 14 seconds to finish...

I use
[DllImport ("coredll.dll")]

private static extern int CloseHandle(int hObject);

To close it.



Am I doing anything wrong?

Should I flush first?

Kill my object and recreate it?

Thank you very much.





Empi
 
S

Simon Hart [MVP]

You could try using the SerialPort class if you haven't done so already and
that you are running at least CF 2.0. Of course there is no guarantee this
will run any faster as I suspect the SerialPort class is probably calling
CloseHandle anyway.
 
E

Empi

Hi and thanks.

I'm afraid this class hanged when the handheld was in standby.
After several crashes I've created my own serial port class using the api's
(readfile writefile etc).


Thanks.


Simon Hart said:
You could try using the SerialPort class if you haven't done so already
and
that you are running at least CF 2.0. Of course there is no guarantee this
will run any faster as I suspect the SerialPort class is probably calling
CloseHandle anyway.
--
Simon Hart
Visual Developer - Device Application Development MVP
http://simonrhart.blogspot.com


Empi said:
Hi.

I have a project on which I use SPP.
I open a serial port that is actually a BT serial port.
Since moving to standby mode kill the connection, I have to reinitiate it
by
closing and reopening the port.
All this is quite messy since it take ages to detect that comm was lost,
close the port and reopen it.
(Not to talk about pairing loss that occur from time to time, but this is
another topic...).

My question is, is there a way to make the close port faster?
It takes about 14 seconds to finish...

I use
[DllImport ("coredll.dll")]

private static extern int CloseHandle(int hObject);

To close it.



Am I doing anything wrong?

Should I flush first?

Kill my object and recreate it?

Thank you very much.





Empi
 
L

Leif Eirik Olsen

Empi said:
Hi.


My question is, is there a way to make the close port faster?
It takes about 14 seconds to finish...

Hi,

I sent you my implementation to your mailadr. I'm no expert, but I do not
have the delay closing the BT PDA comport you're talking about so mabe it's
worth checking out? :)

regards,
Leo
 
D

Dick Grier

Hi,

The problem here (in my experience) is with the Bluetooth driver, which
creates the Virtual Serial port. This is something over which we developers
have no control. Establishing the actual underlying connection (etc.),
simply takes time.

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
C

chrkon

Hello everybody,
The problem here (in my experience) is with the Bluetooth driver, which
creates the Virtual Serial port. This is something over which we
developers have no control. Establishing the actual underlying connection
(etc.), simply takes time.

I have seen a 20 seconds delay after reactivating the PPC after standby.

On our systems the BlueTooth driver shows a blue symbol in the bottom right
corner if it is ready for use. And I had to wait for this symbol before our
software wwould be able to access the serial port. If I try it before, I
receive a "port not available" error.

Kind regards,

Christof Konstantinopoulos
(Dortmund, Germany)
 
M

Markus Humm

Hello,

which Bluetooth stack are you using on the device concerned?

Greetings

Markus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top