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

RE: Closing a serial port by srhartone

srhartone
Sun Jul 13 15:50:36 CDT 2008

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" wrote:

> 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
>
>
>
>
>
>
>

Re: Closing a serial port by Empi

Empi
Sun Jul 13 16:16:33 CDT 2008

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 [MVP]" <srhartone@yahoo.com> wrote in message
news:796AF722-DEE6-4620-91B3-09B344727BA1@microsoft.com...
> 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" wrote:
>
>> 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
>>
>>
>>
>>
>>
>>
>>



Re: Closing a serial port by Leif

Leif
Mon Jul 14 05:55:28 CDT 2008

"Empi" <mpeleg@softstart.co.il> wrote in message
news:OuaQUHO5IHA.832@TK2MSFTNGP05.phx.gbl...
> 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



Re: Closing a serial port by Dick

Dick
Mon Jul 14 11:24:20 CDT 2008

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.



Re: Closing a serial port by chrkon

chrkon
Mon Jul 14 13:45:10 CDT 2008

Hello everybody,

I agree with Richard Grier. He wrote:

> 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)



Re: Closing a serial port by Markus

Markus
Tue Jul 15 13:18:38 CDT 2008

Hello,

which Bluetooth stack are you using on the device concerned?

Greetings

Markus