Serial port is closed when Power button is pressed

S

Star

Hi all,

I am using the OpenNETCF.IO.Serial.Port class for reading data from a
COM port (to use a GPS)
Everything works fine, however when the Power button of my PDA is
pressed, the port seems to be closed (the GPS led stops blinking)
However if I press the power button again, it will start blinking again.

Is there a way of keep the port open even when the power button is
pressed (I guess while the PDA is in sleep mode)?
I think it´s possible because I've seen some other GPS programs that do
that.

I've check the NGs for some information but I couldn't find anything.
Here is a sample code that shows basically what I do:


private static OpenNETCF.IO.Serial.Port m_Port;

public Form1()
{
InitializeComponent();

m_Port = new OpenNETCF.IO.Serial.Port("COM4:");
m_Port.Settings.Parity = Parity.none;
m_Port.Settings.BaudRate =
OpenNETCF.IO.Serial.BaudRates.CBR_2400;
m_Port.Settings.StopBits = StopBits.one;
}

private void button1_Click(object sender, EventArgs e)
{
m_Port.Open();
}

Thanks
 
C

Chris Tacke, MVP

The behavior of the port is driver (and therefore device) specific. If the
device closes the port on you, then there's not much your software can do
other than look for power state changes and re-open the port itself on wake.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 
S

Star

Thanks for your reply, Chris.
The thing is I think I saw some GPS program that kept running after your
pressed the Power button. Maybe I'm wrong.

Perhaps a solution is to intercept the Power Button and turn off the
screen. I think I can do that. However, the problem that I have is after
turning off the screen, the screen is still active and I haven't found a
way of disabling that.
 
C

Chris Tacke, MVP

If you have an app that keeps working, my guess is that they went the extra
mile to ensure that the port is still open after wake. You have to do the
same.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 
M

Markus Humm

Hello,

why do you want to do this?
If I press the power button I want the device
go into sleep mode. Nothing more and nothing less.

Or do I really want some app. still running and draining
my battery? I wouldn't.

Greetings

Markus
 
S

Star

It's a GPS tracking program. Imagine you go hiking and you want to turn
off everything but your GPS so it keeps logging data.
 
S

Star

I would have to catch everything even for the other applications.
It's not the first time that my phone calls somebody accidentally
while the screen is off.
 
P

Paul G. Tobey [eMVP]

Just capture the 'mouse' with SetCapture. All mouse messages would come to
your program until you released the capture. In that state, you could
either just completely ignore everything, or force the user to at least tap
in a very specific area of the screen, on your application, before you
unlock the device.

I agree with the others about changing the behavior of the power button. If
you're building a new device for sale in the consumer market, it's
reasonable to have the power button do whatever you tell people in your
manual it does. However, you'd better not change the behavior of my
device's power button behind my back or you'll have lost a customer.

Paul T.
 

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