Re: alarm() - what am I doing wrong???
- From: Jan Panteltje <pNaonStpealmtje@xxxxxxxxx>
- Date: Mon, 22 May 2006 18:10:05 GMT
On a sunny day (Mon, 22 May 2006 17:39:35 GMT) it happened Charles Sullivan
<cwsulliv@xxxxxxxxxxxx> wrote in
<pan.2006.05.22.17.39.34.902403@xxxxxxxxxxxx>:
On Mon, 22 May 2006 09:44:37 +0000, Jan Panteltje wrote:
Cannot you use alarm_isr() to increment a variable each second,
and set a flag for main if it reaches 5?
Then have main set a flag that resets the counter in alarm_isr()
before it reaches 5 if data comes in?
Then when mai nsees the flag that 5 is reached (in your main loop),
it should do something.
?
If I'm using alarm() to count seconds, then the read() would only
be able to check for incoming data every second, no? I think I'd
lose a lot of data that way.
Not sure, maybe I undestand you wrong.
You read loop (using poll() or select(), or whatever, would run continously.
But the alrm servuice routine would only be called once a second, and
retrigger *itself*.
Normal 'clock'
static elapsed_seconds;
main()
{
// init
while(1)
{
//read input status
// if something do whatever, reset elapsed_seconds.
// else
if elapsed_seconds > 5)
{
scream TIME!!!!!
elapsed_second = 0;
}
}
// add alarm signal handler one_second_tick
alarm(1);
}
void one_second_tick()
{
elapsed_seconds++;
// re-trigger self
alarm(1);
}
.
- Follow-Ups:
- Re: alarm() - what am I doing wrong???
- From: Charles Sullivan
- Re: alarm() - what am I doing wrong???
- References:
- alarm() - what am I doing wrong???
- From: Charles Sullivan
- Re: alarm() - what am I doing wrong???
- From: Jan Panteltje
- Re: alarm() - what am I doing wrong???
- From: Charles Sullivan
- alarm() - what am I doing wrong???
- Prev by Date: Re: alarm() - what am I doing wrong???
- Next by Date: Re: alarm() - what am I doing wrong???
- Previous by thread: Re: alarm() - what am I doing wrong???
- Next by thread: Re: alarm() - what am I doing wrong???
- Index(es):
Relevant Pages
|
|