Skip to main content

RealTimeClock

caution

This service is rc and may change in the future.

Real time clock to support collecting data with precise time stamps.

import { RealTimeClock } from "@devicescript/core"

const realTimeClock = new RealTimeClock()

Commands

setTime

Sets the current time and resets the error.

realTimeClock.setTime(year: number, month: number, day_of_month: number, day_of_week: number, hour: number, min: number, sec: number): Promise<void>

Registers

reading

Current time in 24h representation. Default streaming period is 1 second.

  • day_of_month is day of the month, starting at 1

  • day_of_week is day of the week, starting at 1 as monday. Leave at 0 if unsupported.

  • type: Register<any[]> (packing format u16 u8 u8 u8 u8 u8 u8)

  • track incoming values

import { RealTimeClock } from "@devicescript/core"

const realTimeClock = new RealTimeClock()
// ...
realTimeClock.reading.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

drift

Time drift since the last call to the set_time command.

  • type: Register<number> (packing format u16.16)

  • optional: this register may not be implemented

  • read only

import { RealTimeClock } from "@devicescript/core"

const realTimeClock = new RealTimeClock()
// ...
const value = await realTimeClock.drift.read()
  • track incoming values
import { RealTimeClock } from "@devicescript/core"

const realTimeClock = new RealTimeClock()
// ...
realTimeClock.drift.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

precision

Error on the clock, in parts per million of seconds.

  • type: Register<number> (packing format u16.16)

  • optional: this register may not be implemented

  • constant: the register value will not change (until the next reset)

  • read only

import { RealTimeClock } from "@devicescript/core"

const realTimeClock = new RealTimeClock()
// ...
const value = await realTimeClock.precision.read()
note

write and read will block until a server is bound to the client.

variant

The type of physical clock used by the sensor.

  • type: Register<number> (packing format u8)

  • optional: this register may not be implemented

  • constant: the register value will not change (until the next reset)

  • read only

import { RealTimeClock } from "@devicescript/core"

const realTimeClock = new RealTimeClock()
// ...
const value = await realTimeClock.variant.read()
note

write and read will block until a server is bound to the client.