Esempio n. 1
0
    def run(self):
        conn = self.frmwk.serial_connection

        data = self.options['PARAMS']
        if self.options['USE_HEX']:
            data = data.replace(' ', '')
            hex_regex = re.compile('^([0-9a-fA-F]{2})+$')
            if hex_regex.match(data) is None:
                self.frmwk.print_error(
                    'Non-hex characters found in \'PARAMS\'')
                return
            data = binascii.a2b_hex(data)
        else:
            data = data.encode('utf-8')

        self.frmwk.print_status('Initiating procedure ' + (
            C1219_PROCEDURE_NAMES.get(self.options['PROC_NUMBER']) or '#' +
            str(self.options['PROC_NUMBER'])))

        error_code, data = conn.run_procedure(
            self.options['PROC_NUMBER'], self.advanced_options['STD_VS_MFG'],
            data)

        self.frmwk.print_status('Finished running procedure #' +
                                str(self.options['PROC_NUMBER']))
        self.frmwk.print_status('Received response from procedure: ' + (
            C1219_PROC_RESULT_CODES.get(error_code) or 'UNKNOWN'))
        if len(data):
            self.frmwk.print_status('Received data output from procedure: ')
            self.frmwk.print_hexdump(data)
    def run(self):
        conn = self.frmwk.serial_connection
        if not self.frmwk.serial_login():  # don't alert on failed logins
            self.logger.warning('meter login failed')
            self.frmwk.print_error('Meter login failed, procedure may fail')

        data = self.options['PARAMS']
        if self.options['USEHEX']:
            data = unhexlify(data)

        self.frmwk.print_status('Initiating procedure ' + (
            C1219_PROCEDURE_NAMES.get(self.options['PROCNBR']) or '#' +
            str(self.options['PROCNBR'])))

        errCode, data = conn.run_procedure(self.options['PROCNBR'],
                                           self.advanced_options['STDVSMFG'],
                                           data)
        conn.stop()

        self.frmwk.print_status('Finished running procedure #' +
                                str(self.options['PROCNBR']))
        self.frmwk.print_status('Received respose from procedure: ' + (
            C1219_PROC_RESULT_CODES.get(errCode) or 'UNKNOWN'))
        if len(data):
            self.frmwk.print_status('Received data output from procedure: ')
            self.frmwk.print_hexdump(data)
        return
Esempio n. 3
0
    def run(self):
        conn = self.frmwk.serial_connection
        logger = self.logger
        mode = self.options['MODE']
        mode = mode.upper()
        mode = mode.replace('_', '')
        mode = mode.replace(' ', '')
        if mode[-4:] == 'MODE':
            mode = mode[:-4]
        mode_dict = C1219_METER_MODE_NAMES
        if not mode in mode_dict:
            self.frmwk.print_error(
                'unknown mode, please use METERING, TEST, METERSHOP, or FACTORY'
            )
            return

        logger.info('setting mode to: ' + mode)
        self.frmwk.print_status('Setting Mode To: ' + mode)

        mode = mode_dict[mode]
        try:
            result_code, response_data = conn.run_procedure(
                6, False, struct.pack('B', mode))
        except C1218ReadTableError as error:
            self.frmwk.print_exception(error)
            return
        except C1218WriteTableError as error:
            if error.code == 4:  # onp/operation not possible
                self.frmwk.print_error(
                    'Meter responded that it can not set the mode to the desired type'
                )
            else:
                self.frmwk.print_exception(error)
            return
        except C1219ProcedureError as error:
            self.frmwk.print_exception(error)
            return

        if result_code < 2:
            self.frmwk.print_good(C1219_PROC_RESULT_CODES[result_code])
        else:
            self.frmwk.print_error(
                C1219_PROC_RESULT_CODES.get(
                    result_code,
                    "Unknown status code: {0}".format(result_code)))
	def run(self):
		conn = self.frmwk.serial_connection
		if not self.frmwk.serial_login():	# don't alert on failed logins
			self.logger.warning('meter login failed')
			self.frmwk.print_error('Meter login failed, procedure may fail')

		data = self.options['PARAMS']
		if self.options['USEHEX']:
			data = data.decode('hex')

		self.frmwk.print_status('Initiating procedure ' + (C1219_PROCEDURE_NAMES.get(self.options['PROCNBR']) or '#' + str(self.options['PROCNBR'])))

		errCode, data = conn.run_procedure(self.options['PROCNBR'], self.advanced_options['STDVSMFG'], data)
		conn.stop()

		self.frmwk.print_status('Finished running procedure #' + str(self.options['PROCNBR']))
		self.frmwk.print_status('Received respose from procedure: ' + (C1219_PROC_RESULT_CODES.get(errCode) or 'UNKNOWN'))
		if len(data):
			self.frmwk.print_status('Received data output from procedure: ')
			self.frmwk.print_hexdump(data)
		return
	def run(self, frmwk, args):
		logger = frmwk.get_module_logger(self.name)
		if not frmwk.serial_login():	# don't alert on failed logins
			logger.warning('meter login failed')
			frmwk.print_error('Meter login failed, can not execute procedure')
			return
		
		data = self.options['PARAMS']
		if self.options['USEHEX']:
			data = unhexlify(data)
		
		conn = frmwk.serial_connection
		errCode, data = conn.runProcedure(self.options['PROCNBR'], self.advanced_options['STDVSMFG'], data)
		conn.stop()
		
		frmwk.print_status('Finished running procedure #' + str(self.options['PROCNBR']))
		frmwk.print_status('Received respose from procedure: ' + (C1219_PROC_RESULT_CODES.get(errCode) or 'UNKNOWN'))
		if len(data):
			frmwk.print_status('Received data output from procedure: ')
			frmwk.print_hexdump(data)
		return
Esempio n. 6
0
	def run(self):
		conn = self.frmwk.serial_connection

		data = self.options['PARAMS']
		if self.options['USE_HEX']:
			data = data.replace(' ', '')
			hex_regex = re.compile('^([0-9a-fA-F]{2})+$')
			if hex_regex.match(data) is None:
				self.frmwk.print_error('Non-hex characters found in \'PARAMS\'')
				return
			data = binascii.a2b_hex(data)
		else:
			data = data.encode('utf-8')

		self.frmwk.print_status('Initiating procedure ' + (C1219_PROCEDURE_NAMES.get(self.options['PROC_NUMBER']) or '#' + str(self.options['PROC_NUMBER'])))

		error_code, data = conn.run_procedure(self.options['PROC_NUMBER'], self.advanced_options['STD_VS_MFG'], data)

		self.frmwk.print_status('Finished running procedure #' + str(self.options['PROC_NUMBER']))
		self.frmwk.print_status('Received response from procedure: ' + (C1219_PROC_RESULT_CODES.get(error_code) or 'UNKNOWN'))
		if len(data):
			self.frmwk.print_status('Received data output from procedure: ')
			self.frmwk.print_hexdump(data)
Esempio n. 7
0
	def run(self):
		conn = self.frmwk.serial_connection
		logger = self.logger
		mode = self.options['MODE']
		mode = mode.upper()
		mode = mode.replace('_', '')
		mode = mode.replace(' ', '')
		if mode[-4:] == 'MODE':
			mode = mode[:-4]
		mode_dict = C1219_METER_MODE_NAMES
		if not mode in mode_dict:
			self.frmwk.print_error('unknown mode, please use METERING, TEST, METERSHOP, or FACTORY')
			return

		logger.info('setting mode to: ' + mode)
		self.frmwk.print_status('Setting Mode To: ' + mode)

		mode = mode_dict[mode]
		try:
			result_code, response_data = conn.run_procedure(6, False, struct.pack('B', mode))
		except C1218ReadTableError as error:
			self.frmwk.print_exception(error)
			return
		except C1218WriteTableError as error:
			if error.code == 4:  # onp/operation not possible
				self.frmwk.print_error('Meter responded that it can not set the mode to the desired type')
			else:
				self.frmwk.print_exception(error)
			return
		except C1219ProcedureError as error:
			self.frmwk.print_exception(error)
			return

		if result_code < 2:
			self.frmwk.print_good(C1219_PROC_RESULT_CODES[result_code])
		else:
			self.frmwk.print_error(C1219_PROC_RESULT_CODES.get(result_code, "Unknown status code: {0}".format(result_code)))