rtc

package
v0.0.0-...-683b059 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package rtc provides access to a device's Real Time Clock (hardware clock)

Index

Constants

View Source
const (

	// HwclockTimeout defines the hwclock command execution timeout.
	HwclockTimeout = 3 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type RTC

type RTC struct {
	// DevName indicates which RTC to use. For example DevName="rtc1" means that /dev/rtc1 will be used.
	DevName string
	// LocalTime indicates whether the "--localtime" flag should be set with the hwclock command.
	LocalTime bool
	// NoAdjfile indicates whether the "--noadjfile" flag should be set with the hwclock command.
	NoAdjfile bool
}

RTC represents a real time clock that is accessed with the "hwclock" command.

func (RTC) HwclockArgs

func (rtc RTC) HwclockArgs() []string

HwclockArgs returns the necessary arguments to be passed as flags with hwclock command based on the RTC struct state.

func (RTC) Read

func (rtc RTC) Read(ctx context.Context) (time.Time, error)

Read reads the RTC using the "hwclock" command. It uses a 3 second timeout on top of the given context.

func (RTC) Write

func (rtc RTC) Write(ctx context.Context, t time.Time) error

Write sets the RTC using the "hwclock" command. This only changes the external hardware clock, it does not change the OS/system time. It uses a 3 second timeout on top of the given context.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL