Source code for sensirion_shdlc_sfc5xxx.commands.reply_delay

# -*- coding: utf-8 -*-
# (c) Copyright 2020 Sensirion AG, Switzerland

##############################################################################
##############################################################################
#                 _____         _    _ _______ _____ ____  _   _
#                / ____|   /\  | |  | |__   __|_   _/ __ \| \ | |
#               | |       /  \ | |  | |  | |    | || |  | |  \| |
#               | |      / /\ \| |  | |  | |    | || |  | | . ` |
#               | |____ / ____ \ |__| |  | |   _| || |__| | |\  |
#                \_____/_/    \_\____/   |_|  |_____\____/|_| \_|
#
#     THIS FILE IS AUTOMATICALLY GENERATED AND MUST NOT BE EDITED MANUALLY!
#
# Generator:    sensirion-shdlc-interface-generator 0.8.2
# Product:      SFC5xxx
# Version:      0.1.0
#
##############################################################################
##############################################################################

# flake8: noqa

from __future__ import absolute_import, division, print_function
from sensirion_shdlc_driver.command import ShdlcCommand
from struct import pack, unpack

import logging
log = logging.getLogger(__name__)


[docs]class Sfc5xxxCmdReplyDelayBase(ShdlcCommand): """ SHDLC command 0x95: "Reply Delay". """
[docs] def __init__(self, *args, **kwargs): """ Constructor. """ super(Sfc5xxxCmdReplyDelayBase, self).__init__( 0x95, *args, **kwargs)
[docs]class Sfc5xxxCmdGetReplyDelay(Sfc5xxxCmdReplyDelayBase): """ Get Reply Delay Command Get the SHDLC reply delay of the device. """
[docs] def __init__(self): """ Constructor. """ super(Sfc5xxxCmdGetReplyDelay, self).__init__( data=[], max_response_time=0.01, post_processing_time=0.0, min_response_length=2, max_response_length=2 )
[docs] @staticmethod def interpret_response(data): """ :return: The reply delay of the device in Microseconds. :rtype: int """ reply_delay = int(unpack(">H", data[0:2])[0]) # uint16 return reply_delay
[docs]class Sfc5xxxCmdSetReplyDelay(Sfc5xxxCmdReplyDelayBase): """ Set Reply Delay Command Set the SHDLC reply delay of the device. .. note:: The reply delay must not be set to a value smaller than 2us! Due to a bug in some firmware versions, the values 0us and 1us can lead to unrecoverable communication issues! """
[docs] def __init__(self, reply_delay): """ Constructor. :param int reply_delay: The reply delay in Microseconds. """ super(Sfc5xxxCmdSetReplyDelay, self).__init__( data=b"".join([pack(">H", reply_delay)]), max_response_time=0.01, post_processing_time=0.0, min_response_length=0, max_response_length=0 )