RTC Hardware Clock Settings Modify "Go"

Source: Internet
Author: User

Transferred from: http://os.chinaunix.net/a2008/0526/981/000000981211.shtml

These two days have been doing an i²c device driven understanding, so rarely updated articles.

Because the RTC hardware clock is very important for the meter, and its precision design requirements are high, in BusyBox, the current system time can be set through the Date command, and then the current system time is written to the hardware clock by Hwclock. But BusyBox's date command has a flaw, which is not accurate to the second, which is not tolerated in our design, here we feel that the open source is very good for us.

To modify the Buxybox coreutils/date.c file:

Static struct TM *date_conv_time (struct TM *tm_time, const char *t_string)

{

int nr;

Char *CP;

NR = sscanf (t_string, "%2d%2d%2d%2d%2d%d", & (Tm_time->tm_mon),

& (Tm_time->tm_mday), & (Tm_time->tm_hour), & (Tm_time->tm_min),& (tm_time->tm_sec),

& (Tm_time->tm_year));

if (nr 6) {

Bb_error_msg_and_die (Bb_msg_invalid_date, t_string);

}

Make the above function as modified as above, then you can be accurate to the second!

The format is date followed by the month of the year

Note that the year is 4 years, for example: October 26, 2007 10:00:30

Date 10261000302007

Then use Hwclock-w to write the current system time into the RTC hardware clock!!

RTC Hardware Clock Settings Modify "Go"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.