• Status Closed
  • Percent Complete
  • Task Type Patches
  • Category Operating System/Drivers
  • Assigned To No-one
  • Operating System All players
  • Severity Low
  • Priority Very Low
  • Reported Version Daily build (which?)
  • Due in Version Undecided
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: Rockbox
Opened by vik - 2007-09-27
Last edited by jdgordon - 2007-10-01

FS#7845 - Time Sync to PC

This synchronises the rockbox clock with the PCs clock after the USB has been connected. It works like this: before the usb connection is made, rockbox creates a file. When the PC is connected, an autorun script is run (autorun must be enabled), which creates another file. When the USB is disconnected, rockbox looks at the modification times of both files. Now it can work out the difference between the computer’s and player’s clocks, and adjust its RTC accordingly. The attached autorun script is only for linux (works in ubuntu via System→Preferences→Removable Drives). Other options for linux involve playing with HAL for the particular drive (i.e. autorun sourced from the computer rather than the drive). I don’t have a windows box to develop a windows autorun.inf, but all that is necessary is to create the file .rockbox/.timepc . And I have no idea how this would be possible on a Mac.

This requires the localtime patch  FS#7844 

The task depends upon
ID Project Summary Priority Severity Assigned To Progress
7844 Rockbox  FS#7844 - localtime lib function  Very Low Low
Closed by  jdgordon
2007-10-01 08:48
Reason for closing:  Rejected
Additional comments about closing:   Warning: Undefined array key "typography" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 371 Warning: Undefined array key "camelcase" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 407

if you need to fix the time its easy to get to from the main menu. using usb is not an ideal solution and is unnecessary bloat anyway

vik commented on 2007-09-28 01:43

I’ve cleaned up the patch slightly, and created a callback in the menu which adds/removes the autorun file when the function is enabled/disabled.
But I’ve just discovered that windows doesn’t allow autorun via USB by default; it seems there are ways around it, including using autoplay instead, but I haven’t got a windows box to play around with it.

Looking beyond the fact it sounds like a pretty dirty way of doing things, it sounds like could cause the time to be less in sync. If I was to plug in my player and leave it plugged in for an hour or so, how would it react? It sounds like it would sync the time when it’s first inserted, meaning my clock is now an hour out, but I could be wrong.

How will it react if the clock isn’t set? For instance, flicking the battery switch off on the Gigabeat causes the clock information to be lost, glancing at the code I see it makes references to the current time.

Also, is this really needed? My RTC has never lost sync, I’m not sure it’s that common a problem.

vik commented on 2007-09-29 03:10

It is pretty dirty, but alas, there’s no other way of doing it (at least on my h300) - communication b/w the computer and the PC is limited to the filesystem.

The patch deals with the scenario you mention like so: it takes note of the internal time you plug it in, then the PC writes a file as soon as it is plugged in (via autorun). The RTC has not been changed yet. When the usb is unplugged, it checks the time difference between when it was plugged in and the time the PC wrote the file, and calculates the offset (rather than the absolute time), adds this offset to the RTC time, and writes it back. It will be out by the amount of time it takes between plugging in and the PC running the script (usually less than a minute).

If the clock isn’t set, I’m not sure. I suspect it will still work, simply using whatever was in the clock before and working out the offset as before. Give it a try!

As for necessity, well, my iriver’s RTC drifts by a few minutes a week. With the alarm code reaching maturity, this will start becoming useful I think.


Available keyboard shortcuts


Task Details

Task Editing