Source code for sensirion_shdlc_driver.commands.reply_delay

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

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

import logging
log = logging.getLogger(__name__)


[docs]class ShdlcCmdReplyDelayBase(ShdlcCommand): """ SHDLC command 0x95: "Get/Set Reply Delay". """
[docs] def __init__(self, *args, **kwargs): super(ShdlcCmdReplyDelayBase, self).__init__(0x95, *args, **kwargs)
[docs]class ShdlcCmdSetReplyDelay(ShdlcCmdReplyDelayBase):
[docs] def __init__(self, reply_delay): super(ShdlcCmdSetReplyDelay, self).__init__( data=pack(">H", reply_delay), max_response_time=0.05, min_response_length=0, max_response_length=0 )
[docs]class ShdlcCmdGetReplyDelay(ShdlcCmdReplyDelayBase):
[docs] def __init__(self): super(ShdlcCmdGetReplyDelay, self).__init__( data=[], max_response_time=0.05, min_response_length=2, max_response_length=2 )
[docs] def interpret_response(self, data): """ :return byte: Reply delay [μs]. """ return int(unpack(">H", data)[0])