ekmmeters.py
def readMonthTariffs(self, months_type):
        """ Serial call to read month tariffs block into meter object buffer.

        Args:
            months_type (int): A :class:`~ekmmeters.ReadMonths` value.

        Returns:
            bool: True on completion.
        """
        self.setContext("readMonthTariffs")
        try:

            req_type = binascii.hexlify(str(months_type).zfill(1))
            req_str = "01523102303031" + req_type + "282903"
            work_table = self.m_mons
            if months_type == ReadMonths.kWhReverse:
                work_table = self.m_rev_mons

            self.request(False)
            req_crc = self.calc_crc16(req_str[2:].decode("hex"))
            req_str += req_crc
            self.m_serial_port.write(req_str.decode("hex"))
            raw_ret = self.m_serial_port.getResponse(self.getContext())
            self.serialPostEnd()
            unpacked_read = self.unpackStruct(raw_ret, work_table)
            self.convertData(unpacked_read, work_table, self.m_kwh_precision)
            return_crc = self.calc_crc16(raw_ret[1:-2])
            if str(return_crc) == str(work_table["crc16"][MeterData.StringValue]):
                ekm_log("Months CRC success, type = " + str(req_type))
                self.setContext("")
                return True
        except:
            ekm_log(traceback.format_exc(sys.exc_info()))

        self.setContext("")
        return False
def readMonthTariffs(self, months_type):
        """ Serial call to read month tariffs block into meter object buffer.

        Args:
            months_type (int): A :class:`~ekmmeters.ReadMonths` value.

        Returns:
            bool: True on completion.
        """
        self.setContext("readMonthTariffs")
        try:

            req_type = binascii.hexlify(str(months_type).zfill(1))
            req_str = "01523102303031" + req_type + "282903"
            work_table = self.m_mons
            if months_type == ReadMonths.kWhReverse:
                work_table = self.m_rev_mons

            self.request(False)
            req_crc = self.calc_crc16(req_str[2:].decode("hex"))
            req_str += req_crc
            self.m_serial_port.write(req_str.decode("hex"))
            raw_ret = self.m_serial_port.getResponse(self.getContext())
            self.serialPostEnd()
            unpacked_read = self.unpackStruct(raw_ret, work_table)
            self.convertData(unpacked_read, work_table, self.m_kwh_precision)
            return_crc = self.calc_crc16(raw_ret[1:-2])
            if str(return_crc) == str(work_table["crc16"][MeterData.StringValue]):
                ekm_log("Months CRC success, type = " + str(req_type))
                self.setContext("")
                return True
        except:
            ekm_log(traceback.format_exc(sys.exc_info()))

        self.setContext("")
        return False
Serial call to read month tariffs block into meter object buffer.

        Args:
            months_type (int): A :class:`~ekmmeters.ReadMonths` value.

        Returns:
            bool: True on completion.