def _read_vpd()

in pci_vpd_lib/pci_vpd_lib.py [0:0]


    def _read_vpd(self, f):
        tag = 0
        checksum = 0
        while tag != 0xF:
            (tag, l, header_sum) = self._read_resource_dt_header(f)
            if tag == 0x02:
                # 0x02 is an identifier string tag
                value = f.read(l)
                if len(value) < l:
                    raise VPDDataException('VPD data is truncated!')
                checksum =\
                    self._combine_checksum(checksum, bytearray([header_sum]))
                checksum =\
                    self._combine_checksum(checksum, bytearray(value))

                value = self._value_to_str(value).strip()
                self.identifier_string = value
            elif tag == 0x10:
                # This is a VPD-R tag (i.e. read only data), read the data and
                # parse the fields.
                data = f.read(l)
                if len(data) < l:
                    raise VPDDataException('VPD data is truncated!')
                checksum =\
                    self._combine_checksum(checksum, bytearray([header_sum]))
                checksum =\
                    self._combine_checksum(checksum, bytearray(data))

                if checksum != 0:
                    raise VPDDataException('VPD-R checksum failed!')

                self._process_vpd_list(data)
            elif tag == 0x11:
                # This is a VPD-W tag (i.e. read/write data, skip it).
                f.seek(l, io.SEEK_CUR)
            elif tag != 0xF:
                raise VPDDataException('Unknown VPD tag {}!'.format(tag))