# -*- 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 Sfc5xxxCmdGetProductType(Sfc5xxxCmdDeviceInformationBase):
"""
Get Product Type Command
Get the product type of the device.
"""
[docs] def __init__(self):
"""
Constructor.
"""
super(Sfc5xxxCmdGetProductType, self).__init__(
data=b"".join([bytes(bytearray([0x00]))]),
max_response_time=0.01,
post_processing_time=0.0,
min_response_length=0,
max_response_length=255
)
[docs] @staticmethod
def interpret_response(data):
"""
:return: The product type as an ASCII string.
:rtype: str
"""
product_type = str(data[0:].decode('utf-8').rstrip('\0')) # string
return product_type
[docs]class Sfc5xxxCmdGetProductName(Sfc5xxxCmdDeviceInformationBase):
"""
Get Product Name Command
Get the product name of the device. This information is also contained on
the product label.
"""
[docs] def __init__(self):
"""
Constructor.
"""
super(Sfc5xxxCmdGetProductName, self).__init__(
data=b"".join([bytes(bytearray([0x01]))]),
max_response_time=0.01,
post_processing_time=0.0,
min_response_length=0,
max_response_length=255
)
[docs] @staticmethod
def interpret_response(data):
"""
:return: The product name as an ASCII string.
:rtype: str
"""
product_name = str(data[0:].decode('utf-8').rstrip('\0')) # string
return product_name
[docs]class Sfc5xxxCmdGetArticleCode(Sfc5xxxCmdDeviceInformationBase):
"""
Get Article Code Command
Get the article code of the device. This information is also contained on
the product label.
"""
[docs] def __init__(self):
"""
Constructor.
"""
super(Sfc5xxxCmdGetArticleCode, self).__init__(
data=b"".join([bytes(bytearray([0x02]))]),
max_response_time=0.01,
post_processing_time=0.0,
min_response_length=0,
max_response_length=255
)
[docs] @staticmethod
def interpret_response(data):
"""
:return: The article code as an ASCII string.
:rtype: str
"""
article_code = str(data[0:].decode('utf-8').rstrip('\0')) # string
return article_code
[docs]class Sfc5xxxCmdGetSerialNumber(Sfc5xxxCmdDeviceInformationBase):
"""
Get Serial Number Command
Get the serial number of the device. This information is also contained on
the product label.
"""
[docs] def __init__(self):
"""
Constructor.
"""
super(Sfc5xxxCmdGetSerialNumber, self).__init__(
data=b"".join([bytes(bytearray([0x03]))]),
max_response_time=0.01,
post_processing_time=0.0,
min_response_length=0,
max_response_length=255
)
[docs] @staticmethod
def interpret_response(data):
"""
:return: The serial number as an ASCII string.
:rtype: str
"""
serial_number = str(data[0:].decode('utf-8').rstrip('\0')) # string
return serial_number
[docs]class Sfc5xxxCmdGetProductSubtype(Sfc5xxxCmdDeviceInformationBase):
"""
Get Product Subtype Command
Get the product subtype of the device.
"""
[docs] def __init__(self):
"""
Constructor.
"""
super(Sfc5xxxCmdGetProductSubtype, self).__init__(
data=b"".join([bytes(bytearray([0x04]))]),
max_response_time=0.01,
post_processing_time=0.0,
min_response_length=1,
max_response_length=1
)
[docs] @staticmethod
def interpret_response(data):
"""
:return: Product subtype.
:rtype: int
"""
product_subtype = int(unpack(">B", data[0:1])[0]) # uint8
return product_subtype