Esempio n. 1
0
        public FruChassisInfo(byte[] data)
            : base(data)
        {
            // default constructor
            this.PartNumber = new FruByteString();
            // default constructor
            this.SerialNumber = new FruByteString();

            if (data != null)
            {
                //Cassis type
                if (data.Length >= FruChassisInfo.ChassisTypeIndex)
                {
                    this.ChassisType = data[FruChassisInfo.ChassisTypeIndex];
                }

                //Chassis part number
                if (data.Length > FruChassisInfo.ChassisPartNumberIndex)
                {
                    if (data.Length >= FruChassisInfo.ChassisPartNumberIndex + FruByteString.LengthInfo(data[FruChassisInfo.ChassisPartNumberIndex]))
                    {
                        this.PartNumber = FruByteString.ReadByteString(FruByteString.defaultLang, data, FruChassisInfo.ChassisPartNumberIndex, out this.serialNumberIndex);
                    }
                }
                //Serial number
                if (data.Length > this.serialNumberIndex)
                {
                    if (data.Length >= this.serialNumberIndex + FruByteString.LengthInfo(data[this.serialNumberIndex]))
                    {
                        this.SerialNumber = FruByteString.ReadByteString(FruByteString.defaultLang, data, this.serialNumberIndex);
                    }
                }
            }
        }
Esempio n. 2
0
        public FruMultiRecordInfo(byte[] data)
            : base(data)
        {
            // default constructor
            this.Manufacturer = string.Empty;

            if (data != null)
            {
                if (data.Length >= HeaderSize) // header length is defined as 10.
                {
                    this.LanguageCode    = data[FruMultiRecordInfo.LanguageCodeIndex];
                    this.WritesRemaining = data[FruMultiRecordInfo.WritesRemainingIndex];
                    this.RecordTypeId    = data[FruMultiRecordInfo.RecordTypeIdIndex];
                    this.RecordFormat    = data[FruMultiRecordInfo.RecordFormatIndex];
                    this.RecordLength    = data[FruMultiRecordInfo.RecordLengthIndex];

                    byte[] manufactureArray = new byte[FruMultiRecordInfo.ManufacturerLength];
                    Array.Copy(data, FruMultiRecordInfo.ManufacturerIndex, manufactureArray, 0, FruMultiRecordInfo.ManufacturerLength);
                    this.Manufacturer = IpmiSharedFunc.ByteArrayToHexString(manufactureArray);

                    // add fields
                    if (data.Length > FieldStartIndex)
                    {
                        // start field offset
                        int fieldIndex = FieldStartIndex;

                        // abort counter.
                        int abortCnt = 0;

                        while (fieldIndex < data.Length || abortCnt > MaximumFields)
                        {
                            // data fields are limited to 63 bytes in length, as length is 6 bit encouded in FRU specification.
                            if (data.Length >= fieldIndex + FruByteString.LengthInfo(data[fieldIndex]) && data[fieldIndex] != 0xC1)
                            {
                                Fields.Add(FruByteString.ReadByteString(this.LanguageCode, data, fieldIndex, out fieldIndex));
                            }
                            else
                            {
                                // escape while as fru space has ended.
                                break;
                            }

                            abortCnt++;
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public FruProductInfo(byte[] data)
            : base(data)
        {
            // default constructor
            this.ManufacturerName = new FruByteString();
            this.ProductName      = new FruByteString();
            this.PartModelNumber  = new FruByteString();
            this.ProductVersion   = new FruByteString();
            this.SerialNumber     = new FruByteString();
            this.AssetTag         = new FruByteString();
            this.FruFileId        = new FruByteString();

            if (data != null)
            {
                // Language code
                if (data.Length > FruProductInfo.LanguageCodeIndex)
                {
                    this.LanguageCode = data[FruProductInfo.LanguageCodeIndex];
                }

                // Product Manufacturer
                if (data.Length > FruProductInfo.ManufacturerIndex)
                {
                    if (data.Length >= FruProductInfo.ManufacturerIndex + FruByteString.LengthInfo(data[FruProductInfo.ManufacturerIndex]))
                    {
                        this.ManufacturerName = FruByteString.ReadByteString(this.LanguageCode, data, FruProductInfo.ManufacturerIndex, out this.productNameIndex);
                    }
                }
                // Product Name
                if (data.Length > this.productNameIndex)
                {
                    if (data.Length >= this.productNameIndex + FruByteString.LengthInfo(data[this.productNameIndex]))
                    {
                        this.ProductName = FruByteString.ReadByteString(this.LanguageCode, data, this.productNameIndex, out this.productPartModelNumberIndex);
                    }
                }
                // Product Part/Model Number
                if (data.Length > this.productPartModelNumberIndex)
                {
                    if (data.Length >= this.productPartModelNumberIndex + FruByteString.LengthInfo(data[this.productPartModelNumberIndex]))
                    {
                        this.PartModelNumber = FruByteString.ReadByteString(this.LanguageCode, data, this.productPartModelNumberIndex, out this.productVersionIndex);
                    }
                }
                // Product Version
                if (data.Length > this.productVersionIndex)
                {
                    if (data.Length >= this.productVersionIndex + FruByteString.LengthInfo(data[this.productVersionIndex]))
                    {
                        this.ProductVersion = FruByteString.ReadByteString(this.LanguageCode, data, this.productVersionIndex, out this.productSerialNumberIndex);
                    }
                }
                // Product Serial Number
                if (data.Length > this.productSerialNumberIndex)
                {
                    if (data.Length >= this.productSerialNumberIndex + FruByteString.LengthInfo(data[this.productSerialNumberIndex]))
                    {
                        this.SerialNumber = FruByteString.ReadByteString(FruByteString.defaultLang, data, this.productSerialNumberIndex, out this.assetTagIndex);
                    }
                }
                // Product Asset tag
                if (data.Length > this.assetTagIndex)
                {
                    if (data.Length >= this.assetTagIndex + FruByteString.LengthInfo(data[this.assetTagIndex]))
                    {
                        this.AssetTag = FruByteString.ReadByteString(this.LanguageCode, data, this.assetTagIndex, out this.fruFileIdIndex);
                    }
                }
                // FRU File ID
                if (data.Length > this.fruFileIdIndex)
                {
                    if (data.Length >= this.fruFileIdIndex + FruByteString.LengthInfo(data[this.fruFileIdIndex]))
                    {
                        this.FruFileId = FruByteString.ReadByteString(this.LanguageCode, data, this.fruFileIdIndex);
                    }
                }
            }
        }
Esempio n. 4
0
        public FruBoardInfo(byte[] data)
            : base(data)
        {
            // default constructor
            this.MfgDateTime       = new DateTime(1996, 1, 1);
            this.Maufacturer       = new FruByteString();
            this.ProductName       = new FruByteString();
            this.ProductPartNumber = new FruByteString();
            this.SerialNumber      = new FruByteString();
            this.FruFileId         = new FruByteString();

            if (data != null)
            {
                // Language code
                if (data.Length > FruBoardInfo.LanguageCodeIndex)
                {
                    this.LanguageCode = data[FruBoardInfo.LanguageCodeIndex];
                }

                if (data.Length > FruBoardInfo.MfgDateTimeIndex)
                {
                    // Mfg. Date / Time
                    // Number of minutes from 0:00 hrs 1/1/96.
                    // LSbyte first (little endian)
                    long minutes = 0;
                    for (int i = 2; i >= 0; i--)
                    {
                        minutes = (minutes << 8) + data[FruBoardInfo.MfgDateTimeIndex + i];
                    }

                    // Time when computers started to be built ;)
                    DateTime mfgDataTime = new DateTime(1996, 1, 1);

                    // convert minutes in 100s of nanoseconds
                    long ticks = minutes * 60 * 1000 * 1000 * 10;
                    this.MfgDateTime = mfgDataTime.AddTicks(ticks);
                }
                // Board Manufacturer
                if (data.Length > FruBoardInfo.ManufacturerIndex)
                {
                    if (data.Length >= FruBoardInfo.ManufacturerIndex + FruByteString.LengthInfo(data[FruBoardInfo.ManufacturerIndex]))
                    {
                        this.Maufacturer = FruByteString.ReadByteString(this.LanguageCode, data, FruBoardInfo.ManufacturerIndex, out this.productNameIndex);
                    }
                }
                // Board Product Name
                if (data.Length > this.productNameIndex)
                {
                    if (data.Length >= this.productNameIndex + FruByteString.LengthInfo(data[this.productNameIndex]))
                    {
                        this.ProductName = FruByteString.ReadByteString(this.LanguageCode, data, this.productNameIndex, out this.serialNumberIndex);
                    }
                }
                // Board Serial Number
                if (data.Length > this.serialNumberIndex)
                {
                    if (data.Length >= this.serialNumberIndex + FruByteString.LengthInfo(data[this.serialNumberIndex]))
                    {
                        this.SerialNumber = FruByteString.ReadByteString(FruByteString.defaultLang, data, this.serialNumberIndex, out this.partNumberIndex);
                    }
                }
                // Board Part Number
                if (data.Length > this.partNumberIndex)
                {
                    if (data.Length >= this.partNumberIndex + FruByteString.LengthInfo(data[this.partNumberIndex]))
                    {
                        this.ProductPartNumber = FruByteString.ReadByteString(this.LanguageCode, data, this.partNumberIndex, out this.fruFileIdIndex);
                    }
                }
                // FRU File ID
                if (data.Length > this.fruFileIdIndex)
                {
                    if (data.Length >= this.fruFileIdIndex + FruByteString.LengthInfo(data[this.fruFileIdIndex]))
                    {
                        this.FruFileId = FruByteString.ReadByteString(FruByteString.defaultLang, data, this.fruFileIdIndex);
                    }
                }
            }
        }