コード例 #1
0
ファイル: ChassisFru.cs プロジェクト: waflores/ChassisManager
        /// <summary>
        /// Reads raw CM information - can be called individually if needed
        /// User level priority since this is not an internal call
        /// </summary>
        public ChassisFruReadResponse readRawChassisFru(ushort offset, ushort length)
        {
            byte deviceId = 1;
            ChassisFruReadResponse response = new ChassisFruReadResponse();

            try
            {
                response = (ChassisFruReadResponse)this.SendReceive(DeviceType.ChassisFruEeprom, deviceId, new ChassisFruReadRequest(offset, length),
                                                                    typeof(ChassisFruReadResponse), (byte)PriorityLevel.User);
            }
            catch (Exception ex)
            {
                Tracer.WriteWarning("Chassis Fru read had an exception", ex);
            }

            if (response.CompletionCode != (byte)CompletionCode.Success)
            {
                Tracer.WriteError("Fru read failed with completion code {0:X}", response.CompletionCode);
            }
            else
            {
                Tracer.WriteInfo("Chassis Fru info read: {0:X}", response.DataReturned.ToString());
            }
            return(response);
        }
コード例 #2
0
ファイル: ChassisFru.cs プロジェクト: waflores/ChassisManager
        /// <summary>
        /// Read function
        /// </summary>
        /// <param name="offset"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        public byte readChassisFru()
        {
            // Constants - TODO - move to config file
            ushort offset          = (ushort)ConfigLoaded.ChassisStartingOffset;
            ushort length          = (ushort)ConfigLoaded.ChassisFruLength;
            ushort internalUseSize = (ushort)ConfigLoaded.InternalUseSize; // bytes
            ushort chassisInfoSize = (ushort)ConfigLoaded.ChassisInfoSize; // bytes
            ushort boardInfoSize   = (ushort)ConfigLoaded.BoardInfoSize;   // bytes
            ushort productInfoSize = (ushort)ConfigLoaded.ProductInfoSize; // bytes

            try
            {
                ChassisFruReadResponse fruResponse = readRawChassisFru(offset, length);

                if (fruResponse.CompletionCode != 0 || fruResponse.DataReturned == null)
                {
                    Tracer.WriteInfo("Error in CM Fru Read {0}", fruResponse.CompletionCode);
                    this._completionCode = (byte)CompletionCode.UnspecifiedError;
                    return(this._completionCode);
                }

                Ipmi.FruCommonHeader commonHeader = new Ipmi.FruCommonHeader(fruResponse.DataReturned);
                ushort areaOffset;

                byte[] chassisInfoBytes = new byte[chassisInfoSize];
                byte[] boardInfoBytes   = new byte[boardInfoSize];
                byte[] productInfoBytes = new byte[productInfoSize];

                areaOffset = commonHeader.ChassisInfoStartingOffset;
                if (areaOffset != 0)
                {
                    Array.Copy(fruResponse.DataReturned, areaOffset, chassisInfoBytes, 0, chassisInfoSize);
                }

                areaOffset = commonHeader.BoardAreaStartingOffset;
                if (areaOffset != 0)
                {
                    Array.Copy(fruResponse.DataReturned, areaOffset, boardInfoBytes, 0, boardInfoSize);
                }

                areaOffset = commonHeader.ProductAreaStartingOffset;
                if (areaOffset != 0)
                {
                    Array.Copy(fruResponse.DataReturned, areaOffset, productInfoBytes, 0, productInfoSize);
                }

                this.PopulateChassisFru(commonHeader,
                                        chassisInfoBytes,
                                        boardInfoBytes,
                                        productInfoBytes, fruResponse.CompletionCode);
            }
            catch (Exception e)
            {
                Tracer.WriteError("CM Fru Read had exception {0}", e);
                this._completionCode = (byte)CompletionCode.UnspecifiedError;
            }
            return(this._completionCode);
        }
        internal FruDevice ReadFru(DeviceType deviceType, bool maxLenght = false)
        {
            byte countToRead = 8; //FRU common header size

            ChassisFruReadResponse fruResponse =
                SendReceive <ChassisFruReadResponse>(deviceType, this.DeviceId, (new ChassisFruReadRequest(0, 0, countToRead)));

            if (fruResponse.CompletionCode == 0x00)
            {
                FruCommonHeader commonHeader = new FruCommonHeader(fruResponse.DataReturned);

                ushort areaOffset;

                byte[] chassisInfo     = null;
                byte[] boardInfo       = null;
                byte[] productInfo     = null;
                byte[] multiRecordInfo = null;
                byte   completionCode  = fruResponse.CompletionCode;

                areaOffset = commonHeader.ChassisInfoStartingOffset;
                if (areaOffset != 0)
                {
                    chassisInfo = ReadFruAreaBytes(deviceType, this.DeviceId, areaOffset, maxLenght, out completionCode);
                }

                areaOffset = commonHeader.BoardAreaStartingOffset;
                if (areaOffset != 0)
                {
                    boardInfo = ReadFruAreaBytes(deviceType, this.DeviceId, areaOffset, maxLenght, out completionCode);
                }

                areaOffset = commonHeader.ProductAreaStartingOffset;
                if (areaOffset != 0)
                {
                    productInfo = ReadFruAreaBytes(deviceType, this.DeviceId, areaOffset, maxLenght, out completionCode);
                }

                areaOffset = commonHeader.MultiRecordAreaStartingOffset;
                if (areaOffset != 0)
                {
                    multiRecordInfo = ReadFruAreaBytes(deviceType, this.DeviceId, areaOffset, maxLenght, out completionCode);
                }


                return(new FruDevice(this.DeviceId,
                                     commonHeader,
                                     chassisInfo,
                                     boardInfo,
                                     productInfo,
                                     multiRecordInfo,
                                     completionCode));
            }
            else
            {
                return(new FruDevice(fruResponse.CompletionCode));
            }
        }
コード例 #4
0
ファイル: ChassisFru.cs プロジェクト: kewencai/ChassisManager
        /// <summary>
        /// Reads raw CM information - can be called individually if needed
        /// User level priority since this is not an internal call
        /// </summary>
        public ChassisFruReadResponse readRawChassisFru(ushort offset, ushort length)
        {
            byte deviceId = 1;
            ChassisFruReadResponse response = new ChassisFruReadResponse();

            try
            {
                response = (ChassisFruReadResponse)this.SendReceive(DeviceType.ChassisFruEeprom, deviceId, new ChassisFruReadRequest(offset, length),
                    typeof(ChassisFruReadResponse), (byte)PriorityLevel.User);
            }
            catch (Exception ex)
            {
                Tracer.WriteWarning("Chassis Fru read had an exception", ex);
            }

            if (response.CompletionCode != (byte)CompletionCode.Success)
            {
                Tracer.WriteError("Fru read failed with completion code {0:X}", response.CompletionCode);
            }
            else
            {
                Tracer.WriteInfo("Chassis Fru info read: {0:X}", response.DataReturned.ToString());
            }
            return response;
        }
        /// <summary>
        /// Returns a byte array with all bytes from a specific area of the fru: Chassis, Baseboard, Product
        /// </summary>
        private byte[] ReadFruAreaBytes(DeviceType deviceType, byte 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;
            ChassisFruReadRequest fruRequest =
                new ChassisFruReadRequest(loOffset, hiOffset, countToRead);

            ChassisFruReadResponse fruResponse = SendReceive <ChassisFruReadResponse>(deviceType, deviceId, (fruRequest));

            completionCode = fruResponse.CompletionCode;

            if (completionCode == (byte)CompletionCode.Success)
            {
                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 ChassisFruReadRequest(loOffset, hiOffset, countToRead);
                    // send request for more data
                    fruResponse    = SendReceive <ChassisFruReadResponse>(deviceType, deviceId, (fruRequest));
                    totalDataRead += countToRead;
                    offset        += countToRead;

                    completionCode = fruResponse.CompletionCode;

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

                    pass++;
                }

                if (pass > 12)
                {
                    completionCode = (byte)CompletionCode.InvalidIterationCount;
                }
            }

            return(areaBytes.ToArray());
        }