Author Topic: Alarms With Kdepim/pi For Rc12 Sl-c3100  (Read 8260 times)

cattin

  • Newbie
  • *
  • Posts: 18
    • View Profile
Alarms With Kdepim/pi For Rc12 Sl-c3100
« on: December 04, 2005, 10:06:41 am »
I'm sure you are all well aware of the problems with KO/PI alarms on pdaxrom. I checked all the relevant threads in this forum but couldn't find a working solution. So I started designing my own.

My solution doesn't scan ko/pi's data file for the next alarm, but uses the two files (/home/root/.kopi_next_alarm & .kopi_suspend_alarm) created by ko/pi and relies on ko/pi to play the alarmtone and display the alarm message. My proposed solution can therefor not be called an 'alarm applet' as it just tries to fire-up the zaurus shortly before an alarm event triggers and as it requires KO/PI to be running.

The first problem I had to solve was related to bad parameters KO/PI used to play the alarm sound with the playwave command. This was easy to solve, as I just removed the offending sampling rate option '-r ....' from the source and recompiled KO/PI. With this simple change KO/PI could play the alarm sound given my zaurus was already running when the alarm was triggered.

Next I wrote three little scripts that would wake up the zaurus just before an alarm, so that KO/PI could ring the alarm. As you might know, the zaurus runs all scripts found in the folder /etc/apm/wakeup.d just before suspending. Each script either returns nothing or the number of minutes the zaurus should wait before wakeing up. So I created two little shell scripts (/etc/apm/wakeup.d/next_kopi_alarm & /etc/apm/wakeup.d/next_kopi_suspend) that are simple wrappers to the real awk script /etc/apm/scripts.d/min_to_next_kopi_alarm.awk. These scripts just  return the remaining minutes until the next alarm and are called just before the zaurus suspends.

So far so good. My Zaurus could now wake up just before an alarm and play the alarm sound. For some strange reason this only worked for alarms on the same day, and not for alarms e.g. the next morning. As can be easily seen in the suspending scripts, apmsleep is called in the following manner:

Code: [Select]
apmsleep +0:n
with n being the number of minutes until the next alarm (note: n can be bigger than 60). As it turned out, the Zaurus wouldn't wakeup if the next alarm wrapped around midnight. It turned out, that apmsleep is indeed not aware of day wraps and was thus waiting for a time that alread passed.
My first tests after making the apmsleep command aware of day wraps seem to work. I am, however, not sure that it works correctly with all timezones.

Attached you find the apmsleep.c with my suggested changes. If you feel like playing around with it you need the apmd_3.2.1.orig.tar.gz package from the pdaxrom site to compile. Otherwise just use the binary version I included in this thread.

I don't take any responsibility if it doesn't work or even fries your Z ;-)

any comments or suggestions?

regards, Philippe

### Installation

1. copy all the files (except apmsleep.c) to your zaurus (in my case a SL-C3100)

2. mv next_kopi_suspend next_kopi_alarm /etc/apm/wakeup.d

3. mv min_to_next_kopi_alarm.awk /etc/apm/scripts.d

4. mv /usr/bin/apmsleep /usr/bin/apmsleep.orig

5. mv apmsleep /usr/bin

6. check, that all files are executable
« Last Edit: December 04, 2005, 10:13:01 am by cattin »

gromituk

  • Full Member
  • ***
  • Posts: 207
    • View Profile
Alarms With Kdepim/pi For Rc12 Sl-c3100
« Reply #1 on: December 04, 2005, 10:51:05 am »
Well done *round of applause*

zautrix

  • Sr. Member
  • ****
  • Posts: 437
    • View Profile
    • http://www.pi-sync.net
Alarms With Kdepim/pi For Rc12 Sl-c3100
« Reply #2 on: December 04, 2005, 10:57:06 am »
Thanks for this detailed information.

In January I will try to integrate an automatic wakeup (based on your solution) into the KO/Pi ipks such that this is running out of the box when installing KO/Pi.

Now I have to find a used 760/860...

z.

Chero

  • Hero Member
  • *****
  • Posts: 1140
    • View Profile
    • http://users.telenet.be/zaurususer/Chero
Alarms With Kdepim/pi For Rc12 Sl-c3100
« Reply #3 on: December 04, 2005, 11:56:05 am »
I'm a married guy, but,

cattin, I LOVE YOU !!!!!
I installed your solution, everything seems to work just fine. Thanks a lot.

zautrix, I LOVE YOU !!!!!
If I wouldn't have kdepimpi, I'd give/sell you my C3100.  

(I sold my 860 2 weeks ago)  

Chero.
HP-95LX -> HP Jornada 680 -> SL-C860 -> SL-C3100 -> Fuji u810 -> SL-C1000 -> HTC uni -> SL-C860 -> SL-C760.
March 12 2009 : Back because the Zaurus is one of a kind.
SL-C760 : pdaXrom
Pandora pre-ordered -> received and tested : great device but not my cup of tea -> sold.

plcg

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • http://
Alarms With Kdepim/pi For Rc12 Sl-c3100
« Reply #4 on: December 04, 2005, 03:55:27 pm »
Thanks for your great work, Philippe.

But...
my C1000 doesn't wake up before the alarm  

Is it a C1000 problem ?

plcg
C760 & Pdaxrom 1.1.0beta1 / Transcend 512 MB CF
C1000 & Cacko 1.23 full / PQI 1 GB SD/ Hitachi 2GB microdrive
Linksys WCF12 CF WiFi Card

cattin

  • Newbie
  • *
  • Posts: 18
    • View Profile
Alarms With Kdepim/pi For Rc12 Sl-c3100
« Reply #5 on: December 04, 2005, 04:33:59 pm »
Quote
Thanks for your great work, Philippe.

But...
my C1000 doesn't wake up before the alarm   

Is it a C1000 problem ?

There are several thinks you could test to find out the problem:

1.) check that the scripts in /etc/apm/wakeup.d are working correctly

Code: [Select]
cd /etc/apm/wakeup.d
./next_kopi_alarm
./next_kopi_suspend

are there any errors? does next_kopi_alarm give you the right number of minutes until the next alarm? the output of next_kopi_suspend is most likely an empty line.

2.) check apmsleep

Code: [Select]
/usr/bin/apmsleep -d +0:1
this should put your zaurus at sleep for 1 minute and then wake up again. if you don't get an error here and your debug output looks okay then there might be a more fundamental problem with your setup.

regards, Philippe

willgan

  • Jr. Member
  • **
  • Posts: 84
    • View Profile
    • http://
Alarms With Kdepim/pi For Rc12 Sl-c3100
« Reply #6 on: December 04, 2005, 09:55:06 pm »
i'm having some problem with the ko/pi alarm on my C1000...

I followed the instruction provided by cattin

1. all the files are in the appropriate directory and executable..
2. Alarm works when my Z is running ko/pi
3. The alarm doesn't work when i off the Z or suspend the Z. But when i on the Z later, the alarm pops up.

Any idea on how to make the alarm work when the Z is in suspend mode?
My Current Z...

Zaurus C1000 - Pdaxii13
Using Pdaxrom-builder (SVN) for building packages

yswong

  • Newbie
  • *
  • Posts: 4
    • View Profile
Alarms With Kdepim/pi For Rc12 Sl-c3100
« Reply #7 on: December 05, 2005, 12:41:08 am »
Mine doesn't work either.  By running apmsleep I found that the RTC time is wrongly set if /etc/localtime exists.

For example:

Code: [Select]
/etc/localtime -> /usr/share/zoneinfo/Asia/Hong_Kong (which is GMT+8)

apmsleep -d +0:1

Current RTC time/date is 04:11:14 05-11-2005.
Current local time/date is 12:11:15 05-11-2005.
Setting RTC alarm time to 20:12:14 04-11-2005.
RTC alarm time now set to 20:12:14 04-11-2005.
Another example:

Code: [Select]
/etc/localtime -> /usr/share/zoneinfo/America/New_York

apmsleep -d +0:1

Current RTC time/date is 04:48:20 05-11-2005.
Current local time/date is 23:48:20 04-11-2005.
Setting RTC alarm time to 09:49:20 05-11-2005.
RTC alarm time now set to 09:49:20 05-11-2005.
Another bug with apmsleep?

plcg

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • http://
Alarms With Kdepim/pi For Rc12 Sl-c3100
« Reply #8 on: December 05, 2005, 01:13:04 am »
Quote
1.) check that the scripts in /etc/apm/wakeup.d are working correctly

Code: [Select]
cd /etc/apm/wakeup.d
./next_kopi_alarm
./next_kopi_suspend

are there any errors? does next_kopi_alarm give you the right number of minutes until the next alarm? the output of next_kopi_suspend is most likely an empty line.
It works as expected  

Quote
2.) check apmsleep

Code: [Select]
/usr/bin/apmsleep -d +0:1
this should put your zaurus at sleep for 1 minute and then wake up again. if you don't get an error here and your debug output looks okay then there might be a more fundamental problem with your setup.
My Zaurus doesn't wake up...
I have to push "On/Off" button to wake it up an then i see "Time Leap detected" on screen.
That's all !

plcg
C760 & Pdaxrom 1.1.0beta1 / Transcend 512 MB CF
C1000 & Cacko 1.23 full / PQI 1 GB SD/ Hitachi 2GB microdrive
Linksys WCF12 CF WiFi Card

cattin

  • Newbie
  • *
  • Posts: 18
    • View Profile
Alarms With Kdepim/pi For Rc12 Sl-c3100
« Reply #9 on: December 05, 2005, 03:29:05 am »
Quote
Mine doesn't work either.  By running apmsleep I found that the RTC time is wrongly set if /etc/localtime exists.

I must have messed up with the timezone logic. I'll look into it this afternoon and post a revised version. Shouldn't be too difficult to fix.

philippe

cattin

  • Newbie
  • *
  • Posts: 18
    • View Profile
Alarms With Kdepim/pi For Rc12 Sl-c3100
« Reply #10 on: December 05, 2005, 05:19:00 pm »
Quote
I must have messed up with the timezone logic. I'll look into it this afternoon and post a revised version. Shouldn't be too difficult to fix.

It took me a little longer as expected as I have a four week old NMI (non maskable interrupt) called Celine ;-)

the changelog for this new release 0.1 is as follows:

- rewrote the timezone logic in apmsleep.c. 'apmsleep +h:m' should work regardless your timezone.

- I also made 'apmsleep hh:mm' timezone aware and added one more twist to the original implementation. If hh:mm has already passed this day, the Zaurus will wake up @ hh:mm the next day :-) quite obvious but didn't work in the original implementation.

- the two scripts next_kopi_alarm & next_kopi_suspend both check whether kopi is indeed a running process, as it doesn't make sense to turn on the zaurus when kopi is not running in the first place (so don't change the filename of kopi or otherwise adapt the scripts accordingly).

I hope this release solves the problem people were reporting with my initial version and doesn't break for users were it already worked.

regards, Philippe

karlto

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
    • http://
Alarms With Kdepim/pi For Rc12 Sl-c3100
« Reply #11 on: December 05, 2005, 09:53:21 pm »
Hi

All this stuff is starting to look very good - having a working alarm is high on the priority list!

If you are having difficulties with apmsleep, it is quite simple to write a program that puts a specific date and time into the RTC alarm register - see the Linux kernel RTC documentation/apmsleep source for all the code you need. It can also be done using the registers.o module if you don't want to program anything (just convert date/time to hex and write to the /proc/cpu/registers/RTAR file). Personally I find it much easier to simply specify a date/time to wake up rather than figuring out the number of minutes

I have the code I was using to test my SL6000 somewhere if anyone is interested - problem is that the RTC alarm support in the pdaXrom kernel still doesn't work for the 6000! I am still trying to figure out how to get a kernel to cross compile when I have time - if anyone has any hints on which source, patches and version of the compiler I should use, please let me know!

Cheers

(RC12, SL6000L)
SL6000-L, RC12

pgas

  • Hero Member
  • *****
  • Posts: 1097
    • View Profile
    • http://
Alarms With Kdepim/pi For Rc12 Sl-c3100
« Reply #12 on: December 06, 2005, 01:28:03 am »
Quote
I am still trying to figure out how to get a kernel to cross compile when I have time - if anyone has any hints on which source, patches and version of the compiler I should use, please let me know!

try the pdaxrom builder, documentation here:
http://mail.pdaxrom.org/showpage.php?mid=3
download the builder here:
http://mail.pdaxrom.org/rc12/

you need the gcc2.95 toolchain  to compile the kernel ,  3.4 is used to build the rest of the packages.

The builder should download the sources and apply the patches for you.
SLC-860 cacko / senao wifi

yswong

  • Newbie
  • *
  • Posts: 4
    • View Profile
Alarms With Kdepim/pi For Rc12 Sl-c3100
« Reply #13 on: December 06, 2005, 02:04:54 am »
Hi Philippe,

Thanks for the fix.  I tested both cases and it worked great.  Now I can add back the localtime link with Kopi alarm working!

Your NMI has just proved that you have a great interrupt handler.  Keep that fresh and enjoy!  8)

Cheers,
ys

desertrat

  • Hero Member
  • *****
  • Posts: 743
    • View Profile
    • http://
Alarms With Kdepim/pi For Rc12 Sl-c3100
« Reply #14 on: December 06, 2005, 07:58:53 am »
Quote
Quote
2.) check apmsleep

Code: [Select]
/usr/bin/apmsleep -d +0:1
this should put your zaurus at sleep for 1 minute and then wake up again. if you don't get an error here and your debug output looks okay then there might be a more fundamental problem with your setup.
My Zaurus doesn't wake up...
I have to push "On/Off" button to wake it up an then i see "Time Leap detected" on screen.
That's all !

plcg
[div align=\"right\"][a href=\"index.php?act=findpost&pid=106040\"][{POST_SNAPBACK}][/a][/div]

I'm using wakeup_0.1.tar.gz and have the same problem. Here's my output:

Code: [Select]
# apmsleep -d +00:01
Current RTC time/date is 10:22:10 06-11-2005.
Current local time/date is 18:22:10 06-11-2005.
Setting RTC alarm time to 10:23:10 06-11-2005.
 equivalent in localtime  18:23:10 06-11-2005.
RTC alarm time now set to 10:23:10 06-11-2005.
Waiting until clock jumps

After waiting several minutes I was quite certain it will not switch on automatically, so after pressing the ON button:

Code: [Select]
Time leap detected
Is there anything I can do to further debug this? I would love to get it working (I've already installed the specially compiled version kdepim in anticipation )

-- cheers
SL-C3100 / Ambicon WL1100C-CF / pdaXrom 1.1.0beta3 / IceWM