def command_info(self, args):
        f = open(args.input_file, "rb")
        cartridge_crypted = bytearray(f.read())
        f.close()

        machine_number = machine.get_number_from_type(args.machine_type)

        m = manager.Manager(crypto.Desx_Crypto(), checksum.Crc16_Checksum())
        cartridge = m.decode(machine_number, args.eeprom_uid,
                             cartridge_crypted)
        eedat = open("./eedat", "w")
        eedat.write("Canister S/N: " + str(cartridge.serial_number) + "\n")
        eedat.write("Material type: " + cartridge.material_name + "\n")
        eedat.write("Manufacturing lot: " + str(cartridge.manufacturing_lot) +
                    "\n")
        eedat.write("Manufacturing date: " +
                    str(cartridge.manufacturing_date) + "\n")
        eedat.write("Use date: " + str(cartridge.use_date) + "\n")
        eedat.write("Initial material qty: " +
                    str(cartridge.initial_material_quantity) + "\n")
        eedat.write("Current material qty: " +
                    str(cartridge.current_material_quantity) + "\n")
        eedat.close()
        print("Cartridge - '" + args.input_file + "'")
        print("-" * 79)
        print("Serial number\t\t" + str(cartridge.serial_number))
        material_id = material.get_id_from_name(cartridge.material_name)
        print("Material type: " + cartridge.material_name + " (" +
              str(material_id) + " - " + hex(material_id) + ")")
        print("Manufacturing lot\t" + str(cartridge.manufacturing_lot))
        print("Manufacturing date\t" + str(cartridge.manufacturing_date))
        print("Last use date\t\t" + str(cartridge.use_date))
        print("Initial quantity\t" + str(cartridge.initial_material_quantity))
        print("Current quantity\t" + str(cartridge.current_material_quantity))
        print("Key fragment\t\t" + str(cartridge.key_fragment))
        print("Version\t\t\t" + str(cartridge.version))
        print("Signature\t\t" + str(cartridge.signature))
        print("")
        print("Machine type:\t\t" + str(args.machine_type) + " " +
              str(machine_number))
        print("EEPROM uid:\t\t" + str(args.eeprom_uid))

        if args.recreate_input_file:
            print("\nTo recreate this cartridge:")
            print("--output-file XXX_REPLACE_ME_XXX " \
                    + "--machine-type " + str(args.machine_type) \
                    + " --eeprom-uid " + str(args.eeprom_uid).encode("hex") \
                    + " --serial-number " + str(cartridge.serial_number) \
                    + " --material-name " + str(cartridge.material.name) \
                    + " --manufacturing-lot " + str(cartridge.manufacturing_lot) \
                    + " --manufacturing-date \"" + str(cartridge.manufacturing_date) + "\"" \
                    + " --use-date \"" + str(cartridge.use_date) + "\"" \
                    + " --initial-material " + str(cartridge.initial_material_quantity) \
                    + " --current-material " + str(cartridge.current_material_quantity) \
                    + " --key-fragment " + str(cartridge.key_fragment).encode("hex") \
                    + " --version " + str(cartridge.version) \
                    + " --signature " + str(cartridge.signature))
Example #2
0
    def command_info(self, args):
        f = open(args.input_file, "rb")
        cartridge_crypted = bytearray(f.read())
        f.close()

        machine_number = machine.get_number_from_type(args.machine_type)

        m = manager.Manager(crypto.Desx_Crypto(), checksum.Crc16_Checksum())
        cartridge = m.decode(machine_number, args.eeprom_uid, cartridge_crypted)

        print("Cartridge - '" + args.input_file + "'")
        print("-"*79)
        print("Serial number\t\t" + str(cartridge.serial_number))
        material_id = material.get_id_from_name(cartridge.material_name)
        print("Material\t\t" + cartridge.material_name + " (" + str(material_id) + " - " + hex(material_id) +")")
        print("Manufacturing lot\t" + str(cartridge.manufacturing_lot))
        print("Manufacturing date\t" + str(cartridge.manufacturing_date))
        print("Last use date\t\t" + str(cartridge.use_date))
        print("Initial quantity\t" + str(cartridge.initial_material_quantity))
        print("Current quantity\t" + str(cartridge.current_material_quantity))
        print("Key fragment\t\t" + str(cartridge.key_fragment))
        print("Version\t\t\t" + str(cartridge.version))
        print("Signature\t\t" + str(cartridge.signature))
        print("")
        print("Machine type:\t\t" + str(args.machine_type) + " " + str(machine_number))
        print("EEPROM uid:\t\t" + str(args.eeprom_uid))

        if args.recreate_input_file:
            print("\nTo recreate this cartridge:")
            print("--output-file XXX_REPLACE_ME_XXX " \
                    + "--machine-type " + str(args.machine_type) \
                    + " --eeprom-uid " + str(args.eeprom_uid).encode("hex") \
                    + " --serial-number " + str(cartridge.serial_number) \
                    + " --material-name " + str(cartridge.material.name) \
                    + " --manufacturing-lot " + str(cartridge.manufacturing_lot) \
                    + " --manufacturing-date \"" + str(cartridge.manufacturing_date) + "\"" \
                    + " --use-date \"" + str(cartridge.use_date) + "\"" \
                    + " --initial-material " + str(cartridge.initial_material_quantity) \
                    + " --current-material " + str(cartridge.current_material_quantity) \
                    + " --key-fragment " + str(cartridge.key_fragment).encode("hex") \
                    + " --version " + str(cartridge.version) \
                    + " --signature " + str(cartridge.signature))
Example #3
0
 def _make_info(self, args, cartridge, machine_number):
     l = []
     if args.input_file != None:
         l.append("Cartridge - '" + args.input_file + "'")
         l.append("-"*79)
     l.append("Serial number\t\t" + str(cartridge.serial_number))
     material_id = material.get_id_from_name(cartridge.material_name)
     l.append("Material\t\t" + cartridge.material_name + " (" + str(material_id) + " - " + hex(material_id) +")")
     l.append("Manufacturing lot\t" + str(cartridge.manufacturing_lot))
     l.append("Manufacturing date\t" + str(cartridge.manufacturing_date))
     l.append("Last use date\t\t" + str(cartridge.use_date))
     l.append("Initial quantity\t" + str(cartridge.initial_material_quantity))
     l.append("Current quantity\t" + str(cartridge.current_material_quantity))
     l.append("Key fragment\t\t" + str(cartridge.key_fragment))
     l.append("Version\t\t\t" + str(cartridge.version))
     l.append("Signature\t\t" + str(cartridge.signature))
     l.append("")
     l.append("Machine type:\t\t" + str(args.machine_type) + " " + str(machine_number))
     l.append("EEPROM uid:\t\t" + str(args.eeprom_uid))
     return l
Example #4
0
 def _make_info(self, args, cartridge, machine_number):
     l = []
     if args.input_file != None:
         l.append("Cartridge - '" + args.input_file + "'")
         l.append("-" * 79)
     l.append("Serial number\t\t" + str(cartridge.serial_number))
     material_id = material.get_id_from_name(cartridge.material_name)
     l.append("Material\t\t" + cartridge.material_name + " (" +
              str(material_id) + " - " + hex(material_id) + ")")
     l.append("Manufacturing lot\t" + str(cartridge.manufacturing_lot))
     l.append("Manufacturing date\t" + str(cartridge.manufacturing_date))
     l.append("Last use date\t\t" + str(cartridge.use_date))
     l.append("Initial quantity\t" +
              str(cartridge.initial_material_quantity))
     l.append("Current quantity\t" +
              str(cartridge.current_material_quantity))
     l.append("Key fragment\t\t" + str(cartridge.key_fragment))
     l.append("Version\t\t\t" + str(cartridge.version))
     l.append("Signature\t\t" + str(cartridge.signature))
     l.append("")
     l.append("Machine type:\t\t" + str(args.machine_type) + " " +
              str(machine_number))
     l.append("EEPROM uid:\t\t" + str(args.eeprom_uid))
     return l