UT330BUI/model/UT330.py
def read_data(self):

        """Downloads the device buffer data (temperature, humidity, pressure),
        and decodes it"""

        # We split this function into a header and data part to speed up
        # reading. Reading the header tells us how much data there is in the
        # data part

        # The read data command
        self._buffer = [0xab, 0xcd, 0x03, 0x19, 0x70, 0xc5]

        # Write the command
        self._write_buffer()

        # Read the header
        # ---------------
        # Now get the header data from the buffer
        self._read_buffer(8)

        # Check that some data has actually been returned
        if len(self._buffer) == 0:
            print("Warning! Empty buffer returned by device")
            return []

        # Get the length of data in the buffer
        length = (self._buffer[4] + 256*self._buffer[5] +
                  256*256*self._buffer[6] + 256*256*256*self._buffer[7])

        # Check that there's actually some data on the device - 22 is the
        # minimum buffer length if there's actually data
        if length < 22:

            # Need to read the CRC code and so clear the buffer before
            # returning - gives an error later if this isn't done.
            self._read_buffer(2)

            print("Warning! No temperature/humidity/pressure data on the " \
                  "device")
            return []

        # Now get the data
        # ----------------
        self._read_buffer(length)

        self._index = 0  # This is the offset of the first data item

        # The output data structure
        data = []

        # Loop over every set of readings
        while self._index < length - 2:

            timestamp = self._get_datetime()

            self._index += 6

            temperature = self._get_temperature()

            self._index += 2

            humidity = float(self._buffer[self._index] +
                             256*self._buffer[self._index + 1])/10
            pressure = float(self._buffer[self._index + 2] +
                             256*self._buffer[self._index + 3])/10

            self._index += 4

            data.append({'Timestamp': timestamp,
                         'Temperature (C)': temperature,
                         'Relative humidity (%)': humidity,
                         'Pressure (hPa)': pressure})

        return data
Downloads the device buffer data (temperature, humidity, pressure),
        and decodes it
Downloads the device buffer data (temperature, humidity, pressure),
and decodes it
Downloads the device buffer data ( temperature humidity pressure ) and decodes it
def read_data(self):
        self._buffer = [0xab, 0xcd, 0x03, 0x19, 0x70, 0xc5]
        self._write_buffer()
        self._read_buffer(8)
        if len(self._buffer) == 0:
            print("Warning! Empty buffer returned by device")
            return []
        length = (self._buffer[4] + 256*self._buffer[5] +
                  256*256*self._buffer[6] + 256*256*256*self._buffer[7])
        if length < 22:
            self._read_buffer(2)
            print("Warning! No temperature/humidity/pressure data on the " \
                  "device")
            return []
        -
        self._read_buffer(length)
        self._index = 0  
        data = []
        while self._index < length - 2:
            timestamp = self._get_datetime()
            self._index += 6
            temperature = self._get_temperature()
            self._index += 2
            humidity = float(self._buffer[self._index] +
                             256*self._buffer[self._index + 1])/10
            pressure = float(self._buffer[self._index + 2] +
                             256*self._buffer[self._index + 3])/10
            self._index += 4
            data.append({'Timestamp': timestamp,
                         'Temperature (C)': temperature,
                         'Relative humidity (%)': humidity,
                         'Pressure (hPa)': pressure})
        return data
def read_data ( self ) : self . _buffer = [ 0xab , 0xcd , 0x03 , 0x19 , 0x70 , 0xc5 ] self . _write_buffer ( ) self . _read_buffer ( 8 ) if len ( self . _buffer ) == 0 : print ( "Warning! Empty buffer returned by device" ) return [ ] length = ( self . _buffer [ 4 ] + 256 * self . _buffer [ 5 ] + 256 * 256 * self . _buffer [ 6 ] + 256 * 256 * 256 * self . _buffer [ 7 ] ) if length < 22 : self . _read_buffer ( 2 ) print ( "Warning! No temperature/humidity/pressure data on the " "device" ) return [ ] self . _read_buffer ( length ) self . _index = 0 data = [ ] while self . _index < length - 2 : timestamp = self . _get_datetime ( ) self . _index += 6 temperature = self . _get_temperature ( ) self . _index += 2 humidity = float ( self . _buffer [ self . _index ] + 256 * self . _buffer [ self . _index + 1 ] ) / 10 pressure = float ( self . _buffer [ self . _index + 2 ] + 256 * self . _buffer [ self . _index + 3 ] ) / 10 self . _index += 4 data . append ( { 'Timestamp' : timestamp , 'Temperature (C)' : temperature , 'Relative humidity (%)' : humidity , 'Pressure (hPa)' : pressure } ) return data
Downloads the device buffer data (temperature, humidity, pressure),
and decodes it
Downloads the device buffer data ( temperature humidity pressure ) and decodes it
"""Downloads the device buffer data (temperature, humidity, pressure),
        and decodes it""" # We split this function into a header and data part to speed up # reading. Reading the header tells us how much data there is in the # data part # The read data command # Write the command # Read the header # --------------- # Now get the header data from the buffer # Check that some data has actually been returned # Get the length of data in the buffer # Check that there's actually some data on the device - 22 is the # minimum buffer length if there's actually data # Need to read the CRC code and so clear the buffer before # returning - gives an error later if this isn't done. # Now get the data # ---------------- # This is the offset of the first data item # The output data structure # Loop over every set of readings
self