Skip to main content
deleted 4 characters in body
Source Link
jpsalm
  • 101
  • 2
  • 9

My solution was to write directly to the hwclockrtc using ioctrl. Here's an implementation for anyone who comes across this:

#include <linux/rtc.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>


int main(void)
{
  int fd;
  fd = open("/dev/rtc0",0);
  if (fd < 0)
    printf("Can't open rtc!");

  struct rtc_time time;

  time.tm_sec = 12;
  time.tm_min = 12;
  time.tm_hour = 7;
  time.tm_mday = 12;
  time.tm_mon = 7;
  time.tm_year = 118;

  if (ioctl(fd, RTC_SET_TIME, &time) < 0 )
    printf("Set rtc failed!");

  return 0;
}

My solution was to write directly to the hwclock using ioctrl. Here's an implementation for anyone who comes across this:

#include <linux/rtc.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>


int main(void)
{
  int fd;
  fd = open("/dev/rtc0",0);
  if (fd < 0)
    printf("Can't open rtc!");

  struct rtc_time time;

  time.tm_sec = 12;
  time.tm_min = 12;
  time.tm_hour = 7;
  time.tm_mday = 12;
  time.tm_mon = 7;
  time.tm_year = 118;

  if (ioctl(fd, RTC_SET_TIME, &time) < 0 )
    printf("Set rtc failed!");

  return 0;
}

My solution was to write directly to the rtc using ioctrl. Here's an implementation for anyone who comes across this:

#include <linux/rtc.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>


int main(void)
{
  int fd;
  fd = open("/dev/rtc0",0);
  if (fd < 0)
    printf("Can't open rtc!");

  struct rtc_time time;

  time.tm_sec = 12;
  time.tm_min = 12;
  time.tm_hour = 7;
  time.tm_mday = 12;
  time.tm_mon = 7;
  time.tm_year = 118;

  if (ioctl(fd, RTC_SET_TIME, &time) < 0 )
    printf("Set rtc failed!");

  return 0;
}
Source Link
jpsalm
  • 101
  • 2
  • 9

My solution was to write directly to the hwclock using ioctrl. Here's an implementation for anyone who comes across this:

#include <linux/rtc.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>


int main(void)
{
  int fd;
  fd = open("/dev/rtc0",0);
  if (fd < 0)
    printf("Can't open rtc!");

  struct rtc_time time;

  time.tm_sec = 12;
  time.tm_min = 12;
  time.tm_hour = 7;
  time.tm_mday = 12;
  time.tm_mon = 7;
  time.tm_year = 118;

  if (ioctl(fd, RTC_SET_TIME, &time) < 0 )
    printf("Set rtc failed!");

  return 0;
}