Skip to content

clock_id

Utility functions for clock IDs.

Functions:

parse_clock_id

parse_clock_id(string: str) -> ClockId

Parses a string in the format produced by readable_clock_id into a clock ID.

Possible ambiguities: * an interface name ending with @ followed by a valid IPv4 address will be interpreted as a sensor ID

Parameters:

  • string (str) –

    The string to parse.

Raises:

  • ValueError

    If the string could not be parsed into a valid clock ID

Returns:

  • ClockId ( ClockId ) –

    The parsed, valid clock ID

readable_clock_id

readable_clock_id(clock_id: ClockId) -> str

Convert a clock ID to a human-readable string.

Outputs of this function are canonical and can be parsed back using parse_clock_id. See that function for possible ambiguities.

Examples:

  • sensor_id: sensor_name@192.168.1.100
  • interface_id: hostname.eth0
  • linux_clock_device_id: hostname.ptp1
  • ptp_clock_id: 123456.fffe.123456
  • system_clock_id: hostname.sys

Parameters:

  • clock_id (ClockId) –

    The clock ID to convert.

Raises:

Returns:

  • str

    The human-readable string

readable_clock_type

readable_clock_type(clock_id: ClockId) -> str

Return a human-readable clock type for the given clock ID.

Parameters:

  • clock_id (ClockId) –

    The clock ID to get the type of

Returns:

  • str

    The human-readable clock type