PDA

View Full Version : How to properly use alarmd?


fiferboy
02-15-2008, 09:21 AM
Hi,

I have been looking for an easy way to access all the alarms set in chinook. osso_worldclock has a nifty little dialog for viewing/adding/editing/deleting alarms that would be perfect to add to my statusbar clock except that I cannot find the source for osso_worldclock anywhere.

The alarm statusbar plugin uses the same dialog, but its source is also unavailable. Does anyone know if this dialog can be called using a command or dbus? That would be very helpful.

Also, if I try to check what alarms are set in my program using alarmd commands I get a segfault. The following is the code I was using:

#include <alarmd/alarm_event.h>
...
cookie_t *list;
list=alarm_event_query(time(NULL),time(NULL)+40,0, 0);
...


My program crashes every time at the "list=..." line both in scratchbox (ARMEL and x86) and on the device. The code above is directly taken from the apitest.c included in the alarmd source, so it should be correct. Does anyone have experience using alarmd?

wnd
02-20-2008, 10:33 AM
Also, if I try to check what alarms are set in my program using alarmd commands I get a segfault. -- My program crashes every time at the "list=..."

I've only used alarmd in one application so far, but I haven't really had any problems with it. alarm_event_query() works just fine here, compile with gcc -Wall $(pkg-config --libs --cflags libalarm) file.c:


#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <alarmd/alarm_event.h>

int
main(int argc, char **argv)
{
cookie_t *list, *iter;
time_t now;

now = time(NULL);
list = alarm_event_query(now, now + 60, 0, 0);
if (list == NULL) {
fprintf(stderr, "alarm_event_query() failed\n");
return EXIT_FAILURE;
}

if (list[0] == (cookie_t) 0) {
printf("no alarms set\n");
} else {
printf("alarm ids:");
for (iter = list; *iter != (cookie_t) 0; iter++) {
printf(" %u\n", (unsigned int) *iter);
}
printf("\n");
}

free(list);
return EXIT_SUCCESS;
}

fiferboy
02-20-2008, 10:34 AM
Thank you very much for the reply. I suspect my problem was not compiling with the correct libraries. I will give this another try.

UPDATE: Yes, that was my problem - I wasn't compiling with libalarm CFLAGS and LIBS. Now the program runs with no hitches. So, I can now start the fun task of building an interface similar to that in world clock for managing alarms (since there is no available source for this)

fiferboy
02-21-2008, 10:56 AM
Okay, while my code now compiles and runs with no problems I cannot for the life of me get alarmd running in scratchbox.

alarmd is installed, and when I have af-sb-init running the following occur:
- running "/etc/init.d/alarmd start" comes back with "Starting OSSO Alarm Daemon: alarmd." but no process gets started.
- running "alarmd -d" executes, but again no process starts.

As I only have one tablet I do not relish doing any testing of alarmd on it, especially to the level I eventually want to get. If anyone has been successful in getting alarmd testing to work in scratchbox, please let me know.

Thanks

fiferboy
02-28-2008, 04:02 PM
Just for posterity's sake (in case anyone is searching for how to do this in the future) I will post how to get alarmd to work in scratchbox!

This really is the simplest solution to a frustrating problem I have seen in quite some time.

run-standalone.sh alarmd

That's all folks! And you thought run-standalone just made your application look pretty! This is really going to help with testing alarms in statusbar-clock.

niv
04-27-2011, 11:55 AM
#!/usr/bin/env python
#simple example to issue a command using python and maemo alarmed RTC tool
# look at /var/cache/alarmd/alarm_queue.ini for the full queue
import time,alarm

if __name__ == '__main__':
event = alarm.Event()
event.appid = 'lovelyName'
event.alarm_time = time.time() +10
action = event.add_actions(1)[0]
action.flags |= alarm.ACTION_WHEN_TRIGGERED | alarm.ACTION_TYPE_EXEC
action.command = 'touch /tmp/alarm.txt'
cookie = alarm.add_event(event)
print cookie