ekmmeters.py
def crcMeterRead(self, raw_read, def_buf):
        """ Internal read CRC wrapper.

        Args:
            raw_read (str): Bytes with implicit string cast from serial read
            def_buf (SerialBlock): Populated read buffer.

        Returns:
            bool:  True if passed CRC equals calculated CRC.
        """
        try:
            if len(raw_read) == 0:
                ekm_log("(" + self.m_context + ") Empty return read.")
                return False
            sent_crc = self.calc_crc16(raw_read[1:-2])
            logstr = "(" + self.m_context + ")CRC sent = " + str(def_buf["crc16"][MeterData.StringValue])
            logstr += " CRC calc = " + sent_crc
            ekm_log(logstr)
            if int(def_buf["crc16"][MeterData.StringValue], 16) == int(sent_crc, 16):
                return True

        # A cross simple test lines on a USB serial adapter, these occur every
        # 1000 to 2000 reads, and they show up here as a bad unpack or
        # a bad crc type call.  In either case, we suppress them a log will
        # become quite large.  ekmcrc errors come through as type errors.
        # Failures of int type conversion in 16 bit conversion occur as value
        # errors.
        except struct.error:
            ekm_log(str(sys.exc_info()))
            for frame in traceback.extract_tb(sys.exc_info()[2]):
                fname, lineno, fn, text = frame
                ekm_log("Error in %s on line %d" % (fname, lineno))
            return False

        except TypeError:
            ekm_log(str(sys.exc_info()))
            for frame in traceback.extract_tb(sys.exc_info()[2]):
                fname, lineno, fn, text = frame
                ekm_log("Error in %s on line %d" % (fname, lineno))
            return False

        except ValueError:
            ekm_log(str(sys.exc_info()))
            for frame in traceback.extract_tb(sys.exc_info()[2]):
                fname, lineno, fn, text = frame
                ekm_log("Error in %s on line %d" % (fname, lineno))
            return False

        return False
def crcMeterRead(self, raw_read, def_buf):
        try:
            if len(raw_read) == 0:
                ekm_log("(" + self.m_context + ") Empty return read.")
                return False
            sent_crc = self.calc_crc16(raw_read[1:-2])
            logstr = "(" + self.m_context + ")CRC sent = " + str(def_buf["crc16"][MeterData.StringValue])
            logstr += " CRC calc = " + sent_crc
            ekm_log(logstr)
            if int(def_buf["crc16"][MeterData.StringValue], 16) == int(sent_crc, 16):
                return True

        # A cross simple test lines on a USB serial adapter, these occur every
        # 1000 to 2000 reads, and they show up here as a bad unpack or
        # a bad crc type call.  In either case, we suppress them a log will
        # become quite large.  ekmcrc errors come through as type errors.
        # Failures of int type conversion in 16 bit conversion occur as value
        # errors.
        except struct.error:
            ekm_log(str(sys.exc_info()))
            for frame in traceback.extract_tb(sys.exc_info()[2]):
                fname, lineno, fn, text = frame
                ekm_log("Error in %s on line %d" % (fname, lineno))
            return False

        except TypeError:
            ekm_log(str(sys.exc_info()))
            for frame in traceback.extract_tb(sys.exc_info()[2]):
                fname, lineno, fn, text = frame
                ekm_log("Error in %s on line %d" % (fname, lineno))
            return False

        except ValueError:
            ekm_log(str(sys.exc_info()))
            for frame in traceback.extract_tb(sys.exc_info()[2]):
                fname, lineno, fn, text = frame
                ekm_log("Error in %s on line %d" % (fname, lineno))
            return False

        return False
def crcMeterRead ( self , raw_read , def_buf ) : try : if len ( raw_read ) == 0 : ekm_log ( "(" + self . m_context + ") Empty return read." ) return False sent_crc = self . calc_crc16 ( raw_read [ 1 : - 2 ] ) logstr = "(" + self . m_context + ")CRC sent = " + str ( def_buf [ "crc16" ] [ MeterData . StringValue ] ) logstr += " CRC calc = " + sent_crc ekm_log ( logstr ) if int ( def_buf [ "crc16" ] [ MeterData . StringValue ] , 16 ) == int ( sent_crc , 16 ) : return True # A cross simple test lines on a USB serial adapter, these occur every # 1000 to 2000 reads, and they show up here as a bad unpack or # a bad crc type call.  In either case, we suppress them a log will # become quite large.  ekmcrc errors come through as type errors. # Failures of int type conversion in 16 bit conversion occur as value # errors. except struct . error : ekm_log ( str ( sys . exc_info ( ) ) ) for frame in traceback . extract_tb ( sys . exc_info ( ) [ 2 ] ) : fname , lineno , fn , text = frame ekm_log ( "Error in %s on line %d" % ( fname , lineno ) ) return False except TypeError : ekm_log ( str ( sys . exc_info ( ) ) ) for frame in traceback . extract_tb ( sys . exc_info ( ) [ 2 ] ) : fname , lineno , fn , text = frame ekm_log ( "Error in %s on line %d" % ( fname , lineno ) ) return False except ValueError : ekm_log ( str ( sys . exc_info ( ) ) ) for frame in traceback . extract_tb ( sys . exc_info ( ) [ 2 ] ) : fname , lineno , fn , text = frame ekm_log ( "Error in %s on line %d" % ( fname , lineno ) ) return False return False
Internal read CRC wrapper.

        Args:
            raw_read (str): Bytes with implicit string cast from serial read
            def_buf (SerialBlock): Populated read buffer.

        Returns:
            bool:  True if passed CRC equals calculated CRC.
Internal read CRC wrapper .