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

        """Read the configuration data from the device, saves it to disk"""

        # Send the read info command to the device
        self._buffer = [0xab, 0xcd, 0x03, 0x11, 0x71, 0x03]

        # Write the command
        self._write_buffer()

        # Now get the data from the buffer. We know the returned length will
        # be 46.
        self._read_buffer(46)

        # Now, interpret the data in the buffer
        config = {}

        # Get the device name
        self._index = 4
        config['device name'] = self._get_name()

        # I don't know what bytes 15 to 19 are

        config['sampling interval'] = (256*256*self._buffer[22] +
                                       256*self._buffer[21] +
                                       self._buffer[20])

        config['readings count'] = 256*self._buffer[24] + self._buffer[23]
        config['readings limit'] = 256*self._buffer[26] + self._buffer[25]

        config['battery power'] = self._buffer[27]

        config['overwrite records'] = bool(self._buffer[28])
        config['delay start'] = bool(self._buffer[29])

        config['delay timing'] = (256*256*self._buffer[32] +
                                  256*self._buffer[31] +
                                  self._buffer[30])

        # I don't know what byte 33 is

        # It's possible the high temp alarm could be negative
        if self._buffer[34] < 128:
            config['high temperature alarm'] = self._buffer[34]
        else:
            config['high temperature alarm'] = -256 + self._buffer[34]

        # It's possible the low temperature alarm could be positive
        if self._buffer[35] >= 128:
            config['low temperature alarm'] = -256 + self._buffer[35]
        else:
            config['low temperature alarm'] = self._buffer[35]

        config['high humidity alarm'] = self._buffer[36]
        config['low humidity alarm'] = self._buffer[37]

        self._index = 38
        config['timestamp'] = self._get_datetime()

        return config
Read the configuration data from the device, saves it to disk
Read the configuration data from the device, saves it to disk
Read the configuration data from the device saves it to disk
def read_config(self):
        self._buffer = [0xab, 0xcd, 0x03, 0x11, 0x71, 0x03]
        self._write_buffer()
        self._read_buffer(46)
        config = {}
        self._index = 4
        config['device name'] = self._get_name()
        config['sampling interval'] = (256*256*self._buffer[22] +
                                       256*self._buffer[21] +
                                       self._buffer[20])
        config['readings count'] = 256*self._buffer[24] + self._buffer[23]
        config['readings limit'] = 256*self._buffer[26] + self._buffer[25]
        config['battery power'] = self._buffer[27]
        config['overwrite records'] = bool(self._buffer[28])
        config['delay start'] = bool(self._buffer[29])
        config['delay timing'] = (256*256*self._buffer[32] +
                                  256*self._buffer[31] +
                                  self._buffer[30])
        if self._buffer[34] < 128:
            config['high temperature alarm'] = self._buffer[34]
        else:
            config['high temperature alarm'] = -256 + self._buffer[34]
        if self._buffer[35] >= 128:
            config['low temperature alarm'] = -256 + self._buffer[35]
        else:
            config['low temperature alarm'] = self._buffer[35]
        config['high humidity alarm'] = self._buffer[36]
        config['low humidity alarm'] = self._buffer[37]
        self._index = 38
        config['timestamp'] = self._get_datetime()
        return config
def read_config ( self ) : self . _buffer = [ 0xab , 0xcd , 0x03 , 0x11 , 0x71 , 0x03 ] self . _write_buffer ( ) self . _read_buffer ( 46 ) config = { } self . _index = 4 config [ 'device name' ] = self . _get_name ( ) config [ 'sampling interval' ] = ( 256 * 256 * self . _buffer [ 22 ] + 256 * self . _buffer [ 21 ] + self . _buffer [ 20 ] ) config [ 'readings count' ] = 256 * self . _buffer [ 24 ] + self . _buffer [ 23 ] config [ 'readings limit' ] = 256 * self . _buffer [ 26 ] + self . _buffer [ 25 ] config [ 'battery power' ] = self . _buffer [ 27 ] config [ 'overwrite records' ] = bool ( self . _buffer [ 28 ] ) config [ 'delay start' ] = bool ( self . _buffer [ 29 ] ) config [ 'delay timing' ] = ( 256 * 256 * self . _buffer [ 32 ] + 256 * self . _buffer [ 31 ] + self . _buffer [ 30 ] ) if self . _buffer [ 34 ] < 128 : config [ 'high temperature alarm' ] = self . _buffer [ 34 ] else : config [ 'high temperature alarm' ] = - 256 + self . _buffer [ 34 ] if self . _buffer [ 35 ] >= 128 : config [ 'low temperature alarm' ] = - 256 + self . _buffer [ 35 ] else : config [ 'low temperature alarm' ] = self . _buffer [ 35 ] config [ 'high humidity alarm' ] = self . _buffer [ 36 ] config [ 'low humidity alarm' ] = self . _buffer [ 37 ] self . _index = 38 config [ 'timestamp' ] = self . _get_datetime ( ) return config
Read the configuration data from the device, saves it to disk
Read the configuration data from the device saves it to disk
"""Read the configuration data from the device, saves it to disk""" # Send the read info command to the device # Write the command # Now get the data from the buffer. We know the returned length will # be 46. # Now, interpret the data in the buffer # Get the device name # I don't know what bytes 15 to 19 are # I don't know what byte 33 is # It's possible the high temp alarm could be negative # It's possible the low temperature alarm could be positive
self