Pages: [1]   Go Down
Author Topic: timeout for a function.  (Read 462 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 33
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi,
i am using a finger print sensor, and to see if a finger is valid it waits until a finger is on the sensor.
but  i want to do something if this function doesnt end after about 20 sec. (if nobody puts a finger)
i thought about timers, timeout, thread, and timed action but it seems that nothing can work cause the function check_a_finger() is blocking...

i wanted to do something like this:
set_a_time_out(20000);
check_a_finger();

if time out before check a finger is finish call a function.
else if check_a_finger end before, stop the timeout...

Any ideas on how to do this?
i hope you have some wonderful ideas;)
i am so desesperate that i think a bout an external i2c alarm...
Logged

California
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3434
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need to rewrite the check_a_finger() function to be non-blocking or to handle the timeout itself.
Logged

Offline Offline
Sr. Member
****
Karma: 9
Posts: 254
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Post the check_a_finger function (and the rest of your code) it depends what you are doing in this function
Logged

Poole, Dorset, UK
Offline Offline
Edison Member
*
Karma: 52
Posts: 2366
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Look at the blink without delay example and at the use of finite state machines in the playground.

Mark
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 33
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yeah i wanted to rewrite check_a_finger but it's not possible it's embed in the sensor's own micro  smiley-confuse
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 116
Posts: 4324
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does the sensor have any method by which it can be reset ?
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 631
Posts: 50165
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
yeah i wanted to rewrite check_a_finger but it's not possible it's embed in the sensor's own micro
You need to post your Arduino code and a link to the fingerprint reader. The check_a_finger function should not block waiting for hardware.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 33
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi ,
i was stupid i misunderstood the code th function was rewritable, and i include a timeout in it! it works now like i want.
Thanks all of you!
Logged

Pages: [1]   Go Up
Jump to: