Source code for sensirion_shdlc_sensorbridge.commands.device_information

# -*- 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.5.1
# Product:      Sensor Bridge
# 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 SensorBridgeCmdDeviceInformationBase(ShdlcCommand): """ SHDLC command 0xD0: "Device Information". """
[docs] def __init__(self, *args, **kwargs): super(SensorBridgeCmdDeviceInformationBase, self).__init__( 0xD0, *args, **kwargs)
[docs]class SensorBridgeCmdGetProductType(SensorBridgeCmdDeviceInformationBase):
[docs] def __init__(self): """ Get Product Type Command Gets the product type from the device. """ super(SensorBridgeCmdGetProductType, self).__init__( data=b"".join([bytes(bytearray([0x00]))]), max_response_time=0.005, post_processing_time=0.0, min_response_length=0, max_response_length=255 )
[docs] @staticmethod def interpret_response(data): """ :return: String containing the product type. :rtype: str """ prod_type = str(data[0:].decode('utf-8').rstrip('\0')) # string return prod_type
[docs]class SensorBridgeCmdGetProductName(SensorBridgeCmdDeviceInformationBase):
[docs] def __init__(self): """ Get Product Name Command Gets the product name from the device. """ super(SensorBridgeCmdGetProductName, self).__init__( data=b"".join([bytes(bytearray([0x01]))]), max_response_time=0.005, post_processing_time=0.0, min_response_length=0, max_response_length=255 )
[docs] @staticmethod def interpret_response(data): """ :return: String containing the product name. :rtype: str """ prod_name = str(data[0:].decode('utf-8').rstrip('\0')) # string return prod_name
[docs]class SensorBridgeCmdGetArticleCode(SensorBridgeCmdDeviceInformationBase):
[docs] def __init__(self): """ Get Article Code Command Gets the article code from the device. """ super(SensorBridgeCmdGetArticleCode, self).__init__( data=b"".join([bytes(bytearray([0x02]))]), max_response_time=0.005, post_processing_time=0.0, min_response_length=0, max_response_length=255 )
[docs] @staticmethod def interpret_response(data): """ :return: String containing the article code. :rtype: str """ article_code = str(data[0:].decode('utf-8').rstrip('\0')) # string return article_code
[docs]class SensorBridgeCmdGetSerialNumber(SensorBridgeCmdDeviceInformationBase):
[docs] def __init__(self): """ Get Serial Number Command Gets the serial number from the device. """ super(SensorBridgeCmdGetSerialNumber, self).__init__( data=b"".join([bytes(bytearray([0x03]))]), max_response_time=0.005, post_processing_time=0.0, min_response_length=0, max_response_length=255 )
[docs] @staticmethod def interpret_response(data): """ :return: String containing the serial number. :rtype: str """ serial_no = str(data[0:].decode('utf-8').rstrip('\0')) # string return serial_no