Beispiel #1
0
 public BoardArea(CommonHeader ch, List <byte> b)
 {
     mfgTime = new byte[3] {
         0, 0, 0
     };
     GetBoardArea(ch, b);
 }
Beispiel #2
0
        public void GetBoardArea(CommonHeader ch, List <byte> b)
        {
            if (ch == null)
            {
                return;
            }

            if (b.Count < 8)
            {
                return;
            }

            int bI = 0;

            int bas = ch.bOffset * 8;

            this.formatVersion = b[bas + 0];
            this.length        = b[bas + 1];

            this.actualLength = this.length * 8;

            this.languageCode = (LanguageCode)b[bas + 2];

            this.mfgTime = new byte[3]
            {
                b[bas + 3],
                b[bas + 4],
                b[bas + 5]
            };

            this.mfgminutes = (mfgTime[0] << 16) | (mfgTime[1] << 8) | mfgTime[2];

            int      mfgt = (b[bas + 3] << 16) | (b[bas + 4] << 8) | b[bas + 5];
            DateTime dt   = Hel.timeStartOffset.AddMinutes(mfgt);

            List <byte> gl = new List <byte>();

            bI = 6;
            this.manufacuturer.typeLength = Hel.GetTypeLength(b[bas + bI]);
            bI++;
            for (int i = 0; i < this.manufacuturer.typeLength.length; i++)
            {
                gl.Add(b[bas + bI + i]);
            }

            this.manufacuturer.value = Encoding.UTF8.GetString(gl.ToArray());
            bI = bI + this.manufacuturer.typeLength.length;
            Console.WriteLine("Manufacturer Name: {0}", this.manufacuturer.value);

            this.productName.typeLength = Hel.GetTypeLength(b[bas + bI]);
            bI++;
            gl.Clear();
            for (int i = 0; i < this.productName.typeLength.length; i++)
            {
                gl.Add(b[bas + bI + i]);
            }
            this.productName.value = Encoding.UTF8.GetString(gl.ToArray());
            bI = bI + this.productName.typeLength.length;
            Console.WriteLine("Product Name: {0}", this.productName.value);

            this.serialNumber.typeLength = Hel.GetTypeLength(b[bas + bI]);
            bI++;
            gl.Clear();
            for (int i = 0; i < this.serialNumber.typeLength.length; i++)
            {
                gl.Add(b[bas + bI + i]);
            }
            this.serialNumber.value = Encoding.UTF8.GetString(gl.ToArray());
            bI = bI + this.serialNumber.typeLength.length;
            Console.WriteLine("Serial Number: {0}", this.serialNumber.value);

            this.partNumber.typeLength = Hel.GetTypeLength(b[bas + bI]);
            bI++;
            gl.Clear();
            for (int i = 0; i < this.partNumber.typeLength.length; i++)
            {
                gl.Add(b[bas + bI + i]);
            }
            this.partNumber.value = Encoding.UTF8.GetString(gl.ToArray());
            bI = bI + this.partNumber.typeLength.length;
            Console.WriteLine("Part Number: {0}", this.partNumber.value);

            this.fileID.typeLength = Hel.GetTypeLength(b[bas + bI]);
            bI++;
            gl.Clear();
            for (int i = 0; i < this.fileID.typeLength.length; i++)
            {
                gl.Add(b[bas + bI + i]);
            }
            this.fileID.value = Encoding.UTF8.GetString(gl.ToArray());
            bI = bI + this.fileID.typeLength.length;
            Console.WriteLine("FRU File ID: {0}", this.fileID.value);

            if (b[bas + bI] == 0xC1)
            {
                Console.WriteLine("Ended at Index {0}. {1} bytes are padding.", bas + bI, (actualLength - 1) - bI - 1);
            }

            this.checksum = b[bas + actualLength - 1];

            bI = actualLength - 2;
            byte calculatedChecksum = 0;

            for (int i = 0; i < (actualLength - 1); i++)
            {
                calculatedChecksum += b[bas + i];
            }
            calculatedChecksum = (byte)(256 - calculatedChecksum);
        }