Repository navigation
firmware: a serial command sets the real-time clock - #64
Merged
Merged
Conversation
SetRTCToken (0x6474, 'dt') takes UTC seconds since 1970, big endian, and sets the RTC, which a TR+ with a battery keeps through power-off. Until now the clock could only be set from NTP or stepped an hour, minute or second at a time from the menu. tools/bench/setclock.py sends this computer's clock.
…s four bytes can't hold SetRTC no longer refreshes the IO1 TOD registers: every C64 reader asks for them first, which refreshes them.
int() truncates toward zero, so 1969-12-31T23:59:59.5 became 0 and passed the range check.
kfox
marked this pull request as ready for review
October 21, 2026 19:49
SensoriumEmbedded
approved these changes
Oct 22, 2026
SensoriumEmbedded
left a comment
Owner
There was a problem hiding this comment.
Thanks for the bench script and the clock check.
Memory: RAM1 is unchanged on both targets; flash grows 320 B on the TR+ and 296 B on the TR. No changes needed.
Hardware testing still to do: for one of us to possibly get to before release
Your test covers setting the clock at the menu and reading it back.
- the time surviving a power-off on a TR+ with the battery (as you noted)
- the command while the TR isn't at its menu: it should answer Fail/"Busy!", and the next command should still work, since the 4 time bytes are left in the input as with
SetColorToken's payload - a plain TR
kfox
marked this pull request as draft
October 23, 2026 00:06
Contributor
Author
|
Thanks for the approval, and for spotting the payload bytes a refused command leaves behind. A refused setclock now reads and drops its 4 time bytes, in the main and minimal images. Left in the input, each would run as a command of its own, and a time whose low byte is Tested since:
Follow-ups, outside this PR:
|
kfox
marked this pull request as ready for review
October 26, 2026 03:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A serial command to set the real-time clock. Until now the clock could only be set from NTP, which needs Ethernet, or stepped an hour, minute or second at a time from the menu. GEOS 64 (#70) starts with the TR's time, so this is how a board without Ethernet gets it right.
SetRTCToken(0x6474, "dt") takes UTC seconds since 1970, 4 bytes big endian, and answersAckTokenorFailToken. Away from the menu it is refused with "Busy!", likeSetColorToken, and its 4 time bytes are read and dropped so none of them runs as a command of its own. The time zone setting still applies when the TR shows or hands on the time.docs/ControlComms.mddocuments it.tools/bench/setclock.pysends this computer's clock, or a given ISO 8601 time (UTC unless it carries an offset).Tested on a TR+:
e,bandd(the EEPROM-reset, bus-analysis and command-prefix bytes) were refused with "Busy!", nothing else ran, and the board kept answering.test_protocol.pychecks the token against the firmware.