1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #include <stdio.h>
- #include <unistd.h>
- #include <software_watchdog.h>
- // in this test it is expected that the watchdog_timeout_cb1 is called, but not watchdog_timeout_cb2
- int test_result = -1;
- bool cb1called = false;
- bool cb2called = false;
- void watchdog_timeout_cb1(void *data)
- {
- SoftwareWatchdog *watchdog = data;
- printf("!! watchdog_timeout_cb1 called !! \n");
- fflush(stdout);
- cb1called = true;
- }
- void watchdog_timeout_cb2(void *data)
- {
- SoftwareWatchdog *watchdog = data;
- printf("!! watchdog_timeout_cb2 called !! \n");
- fflush(stdout);
- cb2called = true;
- }
- int main(void){
- printHelloWorld();
- SoftwareWatchdog watchdog1;
- struct timespec timeout1;
- timeout1.tv_nsec = 500*1000000;
- timeout1.tv_sec = 1;
- swd_setup(&watchdog1, "watchdog1", watchdog_timeout_cb1, timeout1, NULL);
- swd_enable(&watchdog1);
- SoftwareWatchdog watchdog2;
- struct timespec timeout2;
- timeout2.tv_nsec = 500*1000000;
- timeout2.tv_sec = 1;
- swd_setup(&watchdog2, "watchdog2", watchdog_timeout_cb2, timeout2, NULL);
- swd_enable(&watchdog2);
- printf("Main: Sleeping for some seconds:\n");
- for (int i = 3; i > 0; i--) {
- swd_kick(&watchdog2);
- printf("%d\n", i);
- fflush(stdout);
- sleep(1);
- }
- if(cb1called && !cb2called)
- return 0;
- return -1;
- }
|