• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Access to RTC from my own container application
#1
Dear Armin,

netPI has a RTC so that I suppose Linux (host OS) always has accurate date & time from RTC.
That means I don't have to set date & time to Linux at the bootup of netPI.

Then, I would like to know how to get/set current date & time from/to RTC by my own container application, please.

- I should open Control panel of Web GUI if I need to set date & time, right? 
- I can just use 'hwclock' command from a guest OS (a container) to get current date & time, right?
- I don't have to access RTC directly via I2C interface, right?

I am not familiar with C/Python/,,, so I may be asking an incomprehensible question.

Thank you very much for checking my understandings above.
Best regards,
  Reply
#2
Well right now I have no idea how to do it. Setting the time was for me always a task for the Linux OS running in the background and its related services doing this job.

Correct is that the RTC chip PCF8563 used in netPI is connected to the I2C-1 bus of the main CPU and keeps the clock running for 7 days due to the supercapacitor based buffering on power outages. Each time the Linux is booted the clock register of this chip is read one time and copied to the Linux local time register. Of course in case you configured an NTP server then the time is resychronized with this server instead.

In summary I have not collected any experience ever how to change a system time within a container. So this time I have no answer ready. I could be that cause of the security restriction a container is never allowed to change the system time by any default commands. 

The badest solution I can think of is mapping the I2C-1 bus directly into a container and access the RTC chip directly. This is possible but in my opinion a very bad idea since you just chance the clock in the chip but not in Linux overall. And this method needs definitively knowledge about c-programming or python etc which you do not have.

The very official command to set the RTC under normal Linux is "hwclock" as it is described here https://www.geeksforgeeks.org/hwclock-co...hut%20down. You could test if this command works when you load a Raspbian container on netPI running in privileged mode and mapping the two devices "/dev/rtc" and /dev/rtc0" into the container. But I have never tried this.

Thx
Armin
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Wi-fi in Access Point mode Renato75 7 4,596 June-3rd-2022, 12:59 PM
Last Post: Armin@netPI
  NetPI wifi access to WPA2-Enterprise MikeP 4 4,215 September-3rd-2021, 02:56 PM
Last Post: MikeP
  TOSILOCK for CONTAINER COswald 3 2,156 July-13th-2021, 11:32 AM
Last Post: Armin@netPI
  netPI RTE 3: access from several comm. masters tad 3 3,994 June-3rd-2021, 12:03 PM
Last Post: Armin@netPI
  [SOLVED] Starting services/commands/scripts at startup of a container Jonas.Sellmann@outlook.de 9 5,908 March-9th-2021, 08:47 AM
Last Post: WalterSchaefer
  OpenVPN container Armin@netPI 0 1,597 January-3rd-2021, 12:13 PM
Last Post: Armin@netPI
  operating Console of a container on netPI connected to Wi-Fi tethering tad 3 2,578 December-3rd-2020, 12:32 PM
Last Post: tad
  NIOT-E-NPIX-4DI4DO with netpi-netx container WalterSchaefer 3 6,367 November-25th-2020, 01:06 PM
Last Post: zen89
  NPIX-4DI4DO and NetPi-Nodered container issues alhammi 4 7,457 November-16th-2020, 01:35 PM
Last Post: alhammi
  Get host MAC via REST API inside container bschandra 4 3,607 November-16th-2020, 09:26 AM
Last Post: bschandra

Forum Jump:


Users browsing this thread: 1 Guest(s)