guruthree / palm-calendar-sync2

Make your Palm Pilot useful again by downloading your Google Calendar to it
GNU General Public License v2.0
14 stars 1 forks source link

Events in Incorrect Timezone #5

Open ecliptik opened 1 week ago

ecliptik commented 1 week ago

Thank you for writing this software, and to start I can't tell you how pleased I was when I first saw my calendar sync'd to my Palm Zire.

I have run into an issue with the timezone being off by +8hrs for all events though. Here's my configuration,

  1. Palm Zire m150 with PalmOS 4.1 fully reset
  2. palm-calendar-sync2 built from source
  3. ICS file exported from Fastmail
  4. Linux Mint 22 on Dell Latitude
  5. Zire and laptop are both on PDT timezone with DST turned on
  6. FROMYEAR=2024 and TIMEZONE="America/Los_Angeles" options set in datebook.cfg

Using a .ics file with a single event, Thursday 10/10/2024 9AM-10AM PDT. It syncs successfully, but shows up in Datebook on the Zire at 10/10/2024 5PM-6PM.

I've tried a variety of things- setting the Zire timezone to UTC, seeing TIMEZONE="UTC" and a variety of combinations, but it's always ahead by 8 hours. I also get a segfault after running, but it says that the update was complete and the Palm gives a happy chime and notes the sync as successful. Previously I had used the apptainer version and while it didn't segfault it still had the timezone incorrect.

Here's is the event, configuration, logs and some screenshots.

palmdatebook.ics

BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
PRODID:-//Fastmail/2020.5/EN
X-APPLE-CALENDAR-COLOR:#9C27B0
X-WR-CALNAME:Palm Datebook
X-WR-TIMEZONE:America/Los_Angeles
BEGIN:VTIMEZONE
TZID:America/Los_Angeles
BEGIN:STANDARD
DTSTART:19700101T000000
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19700101T000000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
DTEND;TZID=America/Los_Angeles:20241010T100000
DTSTAMP:20241010T171943Z
DTSTART;TZID=America/Los_Angeles:20241010T090000
LOCATION:Home
SEQUENCE:0
SUMMARY:Palm Test Event
TRANSP:OPAQUE
UID:25c79fd0-9363-4b08-86d8-68a77c2a6e41
END:VEVENT
END:VCALENDAR

datebook.cfg

URI="file:///tmp/palmdatebook.ics"
PORT="usb:"
DOHOTSYNC=true
READONLY=false
SECURE=true
TIMEZONE="America/Los_Angeles"
FROMYEAR=2024
OVERWRITE=true
ONLYNEW=true
DOALARMS=false

calendar-sync2 log

   sync-calendar2 (e533128)

    ==> Reading arguments <==
    No arguments

    ==> Reading configuration <==
    Reading from datebook.cfg
    Config URI: file:///tmp/palmdatebook.ics
    Config PORT: usb:
    Config DOHOTSYNC: 1
    Config READONLY: 0
    Config TIMEZONE: America/Los_Angeles
    Config FROMYEAR: 2024
    Config OVERWRITE: 1
    Config ONLYNEW: 1
    Config DOALARMS: 0
    Config SECURE: 1

    ==> Connecting to Palm <==
    Listening for incoming connection on usb:... connected!

    ==> Downloading calendar <==
    Fetching file:///tmp/palmdatebook.ics
    Calendar downloaded successfully

    ==> Parsing calendar <==
    Calendar parsed successfully

    ==> Processing event <==
    UID: 25c79fd0-9363-4b08-86d8-68a77c2a6e41
    Start UTC: Thu Oct 10 16:00:00 2024
    End UTC: Thu Oct 10 17:00:00 2024
    Summary: Palm Test Event
    Note:
Location:
Home
    Stored for sync

    ==> Timezone Conversion <==
    Converted to America/Los_Angeles
    ==> Downloading to Palm <==
    DatebookDB opened.
    Deleting existing Palm datebook... done!
    Writing calendar appointments... done!
    DatebookDB closed.
    Closing connection... disconnecting... [1]    43053 segmentation fault (core dumped)  sync-calendar2

Palm Info IMG_1907 IMG_1908

Datebook Event Details IMG_1909 IMG_1910

guruthree commented 1 week ago

I'm glad you're getting some use out of this!

I think I should have fixed the time zone issue in 10d1b67. If you could check that would be great, I now realise testing UTC vs Europe/London was not the most useful...

Your crashes might be related to the issue I had with libusb hanging. If you could run a debug build and generate a stack trace that should reveal where the crash happened let us look a little deeper. To do so

cmake -DCMAKE_BUILD_TYPE=Debug ..   # build the debug build
gdb ./sync-calendar2                # setup to run in the debugger

and then inside gdb

run   # start execution
bt    # print a stack trace

From there you can copy paste in the stack trace from the terminal into a comment. ctrl-c should then let you quit gdb.

If it is dying in libusb, try changing all instances of pi_close_fixed(sd, port) to pi_close(sd) in sync-calendar2.cpp to test without the workaround I had to add.

ecliptik commented 1 week ago

Thank you for such a fast response and code update. I just built from latest commit and did a sync with the same config I have above and the event shows up at 9AM PDT as expected, so it looks like that fixed it.

I'm doing this as part of the RetroChallenge 2024 and using my Zire on a day-to-day basis. Having calendar functionality is wonderful and lets me make even more use out of the device. I'm taking notes on my journey on Gopher and writing up my new post on palm-calendar-sync2 as we speak.

gopher://sdf.org:70/1/users/ecliptik/_rc2024/ https://portal.mozz.us/gopher/sdf.org/1/users/ecliptik/_rc2024/

I will work on re-building with debug and getting some information on the seg fault later today. Thank you again.

guruthree commented 1 week ago

No worries! Sounds like a fun project getting this stuff working and using it day to day. I original wrote palm-calendary-sync2 to try and use my m515 more day to day, but it ended up being difficult to remember to take it out of my backpack to sync at the start of the day and even more difficult to remember to charge over long breaks.

Just so you know, if you're using this as your only calendar that I've seen some issues with repeating events that I haven't had the time to debug. I've detailed what I think might be happening in #7 and #8 - if you find some combination of events that triggers these (or other any issues) I'll try to have a look.

ecliptik commented 1 week ago

Here's the output for a debug build with no changes,

gdb ./sync-calendar2
GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./sync-calendar2...
(gdb)
(gdb) run
Starting program: /home/micheal/git/palm-calendar-sync2/build/sync-calendar2
warning: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libical.so.3
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
warning: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/liblber.so.2
warning: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libbrotlidec.so.1
warning: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libbrotlicommon.so.1
warning: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libcap.so.2
    sync-calendar2 (debug build)

    ==> Reading arguments <==
    No arguments

    ==> Reading configuration <==
    Reading from datebook.cfg
    Config URI: file:///tmp/palmdatebook.ics
    Config PORT: usb:
    Config DOHOTSYNC: 1
    Config READONLY: 0
    Config TIMEZONE: America/Los_Angeles
    Config FROMYEAR: 2024
    Config OVERWRITE: 1
    Config ONLYNEW: 1
    Config DOALARMS: 0
    Config SECURE: 1

    ==> Connecting to Palm <==
    Listening for incoming connection on usb:... [New Thread 0x7ffff44006c0 (LWP 68300)]
connected!

    ==> Downloading calendar <==
    Fetching file:///tmp/palmdatebook.ics
    Calendar downloaded successfully

    ==> Parsing calendar <==
    Calendar parsed successfully

    ==> Processing event <==
    UID: 25c79fd0-9363-4b08-86d8-68a77c2a6e41
    Start UTC: Thu Oct 10 16:00:00 2024
    End UTC: Thu Oct 10 17:00:00 2024
    Summary: Palm Test Event
    Note:
Location:
Home
    Stored for sync

    ==> Timezone Conversion <==
    Converted to America/Los_Angeles

    ==> Downloading to Palm <==
    DatebookDB opened.
    Deleting existing Palm datebook... done!
    Writing calendar appointments... done!
    DatebookDB closed.
    Closing connection... disconnecting...
Thread 1 "sync-calendar2" received signal SIGSEGV, Segmentation fault.
0x000055555555949f in pi_close_fixed (sd=3, port="usb:") at /home/micheal/git/palm-calendar-sync2/sync-calendar2.h:75
75              libusb_context *ctx = HANDLE_CTX(dev_handle);
(gdb) bt
#0  0x000055555555949f in pi_close_fixed (sd=3, port="usb:") at /home/micheal/git/palm-calendar-sync2/sync-calendar2.h:75
#1  0x000055555555e602 in main (argc=1, argv=0x7fffffffe048) at /home/micheal/git/palm-calendar-sync2/sync-calendar2.cpp:1134
(gdb)

Here's the output when changing all instances of pi_close_fixed(sd, port) to pi_close(sd) in sync-calendar2.cpp, which does not give a segfault and exit successfully with events sync'd to the Palm.

gdb ./sync-calendar2
GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./sync-calendar2...
(gdb) run
Starting program: /home/micheal/git/palm-calendar-sync2/build/sync-calendar2
warning: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libical.so.3
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
warning: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/liblber.so.2
warning: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libbrotlidec.so.1
warning: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libbrotlicommon.so.1
warning: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libcap.so.2
    sync-calendar2 (debug build)

    ==> Reading arguments <==
    No arguments

    ==> Reading configuration <==
    Reading from datebook.cfg
    Config URI: file:///tmp/palmdatebook.ics
    Config PORT: usb:
    Config DOHOTSYNC: 1
    Config READONLY: 0
    Config TIMEZONE: America/Los_Angeles
    Config FROMYEAR: 2024
    Config OVERWRITE: 1
    Config ONLYNEW: 1
    Config DOALARMS: 0
    Config SECURE: 1

    ==> Connecting to Palm <==
    Listening for incoming connection on usb:... [New Thread 0x7ffff44006c0 (LWP 73707)]
connected!

    ==> Downloading calendar <==
    Fetching file:///tmp/palmdatebook.ics
    Calendar downloaded successfully

    ==> Parsing calendar <==
    Calendar parsed successfully

    ==> Processing event <==
    UID: 25c79fd0-9363-4b08-86d8-68a77c2a6e41
    Start UTC: Thu Oct 10 16:00:00 2024
    End UTC: Thu Oct 10 17:00:00 2024
    Summary: Palm Test Event
    Note:
Location:
Home
    Stored for sync

    ==> Timezone Conversion <==
    Converted to America/Los_Angeles

    ==> Downloading to Palm <==
    DatebookDB opened.
    Deleting existing Palm datebook... done!
    Writing calendar appointments... done!
    DatebookDB closed.
Couldn't read debug register: No such process.
(gdb) [Thread 0x7ffff44006c0 (LWP 73707) exited]
[Inferior 1 (process 73702) exited normally]

(gdb) bt
No stack.
(gdb)
ecliptik commented 1 week ago

Just so you know, if you're using this as your only calendar that I've seen some issues with repeating events that I haven't had the time to debug. I've detailed what I think might be happening in #7 and #8 - if you find some combination of events that triggers these (or other any issues) I'll try to have a look.

Good to know, I did notice that a recurring all-day event I had every other Tuesday showed up, but was on every day for the week it re-occurred. I'll try and get some more info by re-creating similar events on a test calendar and update those issues accordingly. Thank you.

guruthree commented 1 week ago

Thanks, your stack trace confirms the segfault is happening in my code:

#0  0x000055555555949f in pi_close_fixed (sd=3, port="usb:") at /home/micheal/git/palm-calendar-sync2/sync-calendar2.h:75

Could you please try replacing lines 68 to 82 of sync-calendar2.sh with

    if (ps && port.find("usb") == 0) {
        // don't try and close usb if we're not USB
        // (we need to pass port for this because there's no way to get the port back from the socket)

        pi_usb_data_t *data = (pi_usb_data_t *)ps->device->data;
        usb_dev_handle *dev = (usb_dev_handle*)data->ref;
        libusb_device_handle *dev_handle = dev->handle;
        if (dev_handle) {
            // if it still exists then something has gone wrong and we should clean up
            libusb_context *ctx = HANDLE_CTX(dev_handle);
            if (ctx) {
                libusb_unlock_events(ctx);
            }
            else {
                failed = true;
            }
        }
    }

and check if it still segfaults when using pi_close_fixed(sd, port)?