示例#1
0
def read_cartridge_template(path):
    catridge = None

    with open(path, "r") as f:
        cartridge = cartridge_pb2.Cartridge()
        Merge(f.read(), cartridge)

    return cartridge
示例#2
0
    def command_eeprom_create(self, args):
        cartridge = cartridge_pb2.Cartridge()

        cartridge.serial_number = args.serial_number
        cartridge.material_name = args.material_name
        cartridge.manufacturing_lot = args.manufacturing_lot
        cartridge.manufacturing_date.FromDatetime(args.manufacturing_date)
        cartridge.last_use_date.FromDatetime(args.use_date)
        cartridge.initial_material_quantity = args.initial_material_quantity
        cartridge.current_material_quantity = args.current_material_quantity
        cartridge.key_fragment = args.key_fragment
        cartridge.version = args.version
        cartridge.signature = args.signature

        args.output_file.write((MessageToString(cartridge)))
示例#3
0
    def command_eeprom_encode(self, args):
        cartridge = cartridge_pb2.Cartridge()

        Merge(args.input_file.read(), cartridge)

        machine_number = machine.get_number_from_type(args.machine_type)

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

        if args.use_ascii:
            eeprom = self._make_ascii(cartridge, eeprom, args.eeprom_uid,
                                      args.machine_number)

        if args.diag_format:
            eeprom = self.diag_formatter.to_destination(eeprom)

        args.output_file.write(eeprom)

        return