/// <summary>
        /// Returns a byte array with all bytes from a specific area of the fru: Chassis, Baseboard, Product
        /// </summary>
        private byte[] ReadFruAreaBytes(int deviceId, ushort offset, bool maxLenght, out byte completionCode)
        {
            byte countToRead = 0x10;
            byte loOffset;
            byte hiOffset;

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

            IpmiSharedFunc.SplitWord(offset, out loOffset, out hiOffset);

            ushort totalDataRead = countToRead;
            GetFruDataRequest fruRequest =
                new GetFruDataRequest(loOffset, hiOffset, countToRead) { DeviceId = (byte)deviceId };

            GetFruDataResponse fruResponse = IpmiSendReceive<GetFruDataResponse>(fruRequest);

            completionCode = fruResponse.CompletionCode;

            if (completionCode == 0x00)
            {
                ushort dataSize = FruArea.AreaLength(fruResponse.DataReturned);
                totalDataRead = Math.Min(countToRead, dataSize);
                IpmiSharedFunc.AppendArrayToList(fruResponse.DataReturned, areaBytes, totalDataRead);
                offset += totalDataRead;
                int pass = 0;
                const int readLimit = 12;

                while (dataSize > totalDataRead && pass <= readLimit)
                {
                    IpmiSharedFunc.SplitWord(offset, out loOffset, out hiOffset);

                    if (!maxLenght)
                        countToRead = (byte)Math.Min(countToRead, dataSize - totalDataRead);
                    else
                        countToRead = (byte)Math.Min(byte.MaxValue, dataSize - totalDataRead);

                    fruRequest = new GetFruDataRequest(loOffset, hiOffset, countToRead) { DeviceId = (byte)deviceId };
                    // send request for more data
                    fruResponse = IpmiSendReceive<GetFruDataResponse>(fruRequest);
                    totalDataRead += countToRead;
                    offset += countToRead;

                    completionCode = fruResponse.CompletionCode;

                    if (completionCode == 0x00)
                    {
                        IpmiSharedFunc.AppendArrayToList(fruResponse.DataReturned, areaBytes, countToRead);
                    }
                    else
                    {
                        break;
                    }

                    pass++;
                }

                if (pass > 12)
                {
                    completionCode = 0xEF;
                }
            }

            return areaBytes.ToArray();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a byte array with all bytes from a specific area of the fru: Chassis, Baseboard, Product
        /// </summary>
        private byte[] ReadFruAreaBytes(int deviceId, ushort offset, bool maxLenght, out byte completionCode)
        {
            byte countToRead = 0x10;
            byte loOffset;
            byte hiOffset;

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

            IpmiSharedFunc.SplitWord(offset, out loOffset, out hiOffset);

            ushort            totalDataRead = countToRead;
            GetFruDataRequest fruRequest    =
                new GetFruDataRequest(loOffset, hiOffset, countToRead)
            {
                DeviceId = (byte)deviceId
            };

            GetFruDataResponse fruResponse = IpmiSendReceive <GetFruDataResponse>(fruRequest);

            completionCode = fruResponse.CompletionCode;

            if (completionCode == 0x00)
            {
                ushort dataSize = FruArea.AreaLength(fruResponse.DataReturned);
                totalDataRead = Math.Min(countToRead, dataSize);
                IpmiSharedFunc.AppendArrayToList(fruResponse.DataReturned, areaBytes, totalDataRead);
                offset += totalDataRead;
                int pass = 0;

                while (dataSize > totalDataRead || pass > 12)
                {
                    IpmiSharedFunc.SplitWord(offset, out loOffset, out hiOffset);

                    if (!maxLenght)
                    {
                        countToRead = (byte)Math.Min(countToRead, dataSize - totalDataRead);
                    }
                    else
                    {
                        countToRead = (byte)Math.Min(byte.MaxValue, dataSize - totalDataRead);
                    }

                    fruRequest = new GetFruDataRequest(loOffset, hiOffset, countToRead)
                    {
                        DeviceId = (byte)deviceId
                    };
                    // send request for more data
                    fruResponse    = IpmiSendReceive <GetFruDataResponse>(fruRequest);
                    totalDataRead += countToRead;
                    offset        += countToRead;

                    completionCode = fruResponse.CompletionCode;

                    if (completionCode == 0x00)
                    {
                        IpmiSharedFunc.AppendArrayToList(fruResponse.DataReturned, areaBytes, countToRead);
                    }
                    else
                    {
                        break;
                    }

                    pass++;
                }

                if (pass > 12)
                {
                    completionCode = 0xEF;
                }
            }

            return(areaBytes.ToArray());
        }