NW   NE
 

Sharp Zaurus Developer Information

Corrections and Comments: Spencer Huang
 
SW   SE
NW   NE
 
Howtos

Upgrading The ROM

Connectivity
Wireless 802.11b

Linux Connectivity
Generic (USB)
Debian (USB)
Red Hat (USB)
Suse (USB)
Mandrake (USB)
Generic (PPP USB)
Generic (PPP Serial)

Windows Connectivity
Win2K (Serial)
Win98se (Serial)
WinMe Over (Serial)
WinNTSP6 (Serial)
WinXP Over (Serial)

Developing
Compiler Setup
Compiling the Kernel
Special Considerations
Checklist
System Layout
Application Help Files
IPKG Howto
Buzzer Howto
Led Howto
IrDa Howto
Audio Howto
Fullscreen Howto
Resume Event
Keys
Turning off the screen

Syncing
Linux
Win2K
Wireless

Other
Wireless Comparison
The Z Boot Process
Ipv6 Setup
Servers Setup
SD And CF FAQ
Setting Up A Feed
Converting TTF fonts
Building a ROM
MPEG Encoding

Downloads
ZaurusZone Feed
Links
 
SW   SE
NW   NE
 

How to detect when the user resumes.

Author: Neil Horlock

For an application that will probably never come to see the light of day I wanted to detect the power on (resume) event. Thanks to Darryl Okahata who responded to my inital query on the Zaurus developer mailing list (zaurus-devel@lists.sourceforge.net).

There does not appear to be a suspend event, this may seem harsh or even unwise but really this makes sense as you probably want the system to simply turn off, not to wait while a poorly written app tidies up after itself. So we are left with the resume event.

When the Zaurus is powered on all process that are running receive the SIGCONT signal.The following code tests this. All it aims to do is prove that the SIGCONT is generated and that it is received upon resume.

/* first include the relevent headers */
#include "signal.h"
#include "stdio.h"
#include "time.h"
/* define a signal handler see signal(2) fro more details */ /* In this case for the given signal signum, get the present time print it along with the signal number */ /* reinstate the handler for the next time and return */ void handler(int signum)
{
time_t tim;
time(&tim);
fprintf(stderr, "Time now is %s", ctime(&tim));
fprintf(stderr, "received signal %d\n", signum);
signal(signum, handler);
} /* finally the simplest little main to activeate the thing */ /* set up the signal handler across a range of signals, this was done to check whether anything other */ /* than SIGCONT occurred (it doesn't) */ /* then loop forever printing the current time and sleepiong for a second */
int main(int argc, char *argv[])
{
int i;
for(i=12;i<60;i++)
{
signal(i, handler);
}
for(;;){
time_t tim;
time(&tim);
fprintf(stderr, "Time is %s\n", ctime(&tim));
sleep(1);
};
}

Compiling this and running it in a console on the Z will clearly show timestamps ticking away every second until the shutdown. Upon resume (some time later) the signal will be received and the time logged along with the signal number (18), the normal loop now continues. The timestamp logged alongside the SIGCONT clearly shows that the signal was received immediately upon resume.

 
SW   SE

    This page was last updated: Wednesday, 09-Apr-2003 04:57:24 PDT