Rockbox

Tasklist

FS#7845 - Time Sync to PC

Attached to Project: Rockbox
Opened by Victor Rajewski (vik) - Thursday, 27 September 2007, 15:55 GMT
Last edited by Jonathan Gordon (jdgordon) - Monday, 01 October 2007, 08:48 GMT
Task Type Patches
Category Operating System/Drivers
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

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 
Closed by  Jonathan Gordon (jdgordon)
Monday, 01 October 2007, 08:48 GMT
Reason for closing:  Rejected
Additional comments about closing:  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
Comment by Victor Rajewski (vik) - Friday, 28 September 2007, 01:43 GMT
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.
Comment by Johnathon Mihalop (Soul-Slayer) - Saturday, 29 September 2007, 00:59 GMT
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.
Comment by Victor Rajewski (vik) - Saturday, 29 September 2007, 03:10 GMT
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.

Loading...