예제 #1
0
 internal DiscreteEvent(EventLogMsgType MsgType, byte sensorType, byte eventType, byte[] eventPayload)
     : base(MsgType, sensorType, eventType, eventPayload)
 {
     if (MsgType == EventLogMsgType.SensorSpecific &&
         sensorType == 42)    // add exception for user Id
     {
         byte[] evtData2 = IpmiSharedFunc.ByteSplit(eventPayload[1], new int[2] {
             6, 0
         });
         evtByte2Severity = evtData2[0];
         evtByte2Reading  = evtData2[1];
     }
     else if (MsgType == EventLogMsgType.SensorSpecific &&
              sensorType == 43) // add exception for Version Change Type
     {
         evtByte2Reading = eventPayload[1];
     }
     else if (MsgType == EventLogMsgType.SensorSpecific &&
              sensorType == 40 && base.Offset == 5) // add exception for FRU device Id
     {
         // swap event payload with payload 2.
         byte temp = eventPayload[1];
         eventPayload[1] = eventPayload[2];
         eventPayload[2] = temp;
     }
     else
     {
         byte[] evtData2 = IpmiSharedFunc.ByteSplit(eventPayload[1], new int[2] {
             4, 0
         });
         evtByte2Severity = evtData2[0];
         evtByte2Reading  = evtData2[1];
     }
 }
예제 #2
0
 internal OemEvent(EventLogMsgType MsgType, byte sensorType, byte eventType, byte[] eventPayload)
     : base(MsgType, sensorType, eventType, eventPayload)
 {
     byte[] evtData2 = IpmiSharedFunc.ByteSplit(eventPayload[1], new int[2] {
         4, 3
     });
     evtByte2Severity = evtData2[0];
     evtByte2Reading  = evtData2[1];
 }
예제 #3
0
        protected EventData(EventLogMsgType MsgType, byte sensorType, byte eventTypeCode, byte[] payload)
        {
            this.messageType  = MsgType;
            this.eventType    = Convert.ToInt32(eventTypeCode);
            this.eventPayload = payload;
            this.sensorType   = Convert.ToInt32(sensorType);

            byte[] evtData1 = IpmiSharedFunc.ByteSplit(eventPayload[0], new int[3] {
                6, 4, 0
            });

            this.evtData1Part1 = Convert.ToInt32(evtData1[0]);
            this.evtData1Part2 = Convert.ToInt32(evtData1[1]);
            this.offset        = Convert.ToInt32(evtData1[2]);
        }
예제 #4
0
        /// <summary>
        /// DCMI Get Power Reading Command
        /// </summary>
        public virtual List <PowerReading> GetAdvancedPowerReading()
        {
            // Return item
            List <PowerReading> returnlist = new List <PowerReading>();

            // Index Offset of 0 into ResponseData
            int index = 0;

            // Get DCMI Capabilities to check if power management is supported, if so
            // check if advanced power stats are supported.
            GetDcmiCapabilitiesResponse response = (GetDcmiCapabilitiesResponse)this.IpmiSendReceive(
                new GetDcmiCapabilitiesRequest(0x01), typeof(GetDcmiCapabilitiesResponse));

            byte[] powerSupport = new byte[2] {
                0x00, 0x00
            };

            if (response.CompletionCode == 0)
            {
                // power management support byte array.  response.ResponseData[1] = platform capabilities.
                // [7-1]  Reserved, Power Management.
                byte[] tempArray = IpmiSharedFunc.ByteSplit(response.ResponseData[1], new int[2] {
                    1, 0
                });
                Buffer.BlockCopy(tempArray, 0, powerSupport, 0, 2);
            }

            if (powerSupport[1] == 0x01)
            {
                // Check DCMI paramater revision 0x02 = DCMI errata for advanced
                // power management.  If the paramater version is 2, it should
                // support advanced power management.
                if (response.ParameterRevision == 0x02)
                {
                    // Get DCMI Capabilities for advanced power averages
                    response = (GetDcmiCapabilitiesResponse)this.IpmiSendReceive(
                        new GetDcmiCapabilitiesRequest(0x05), typeof(GetDcmiCapabilitiesResponse));

                    if (response.CompletionCode == 0)
                    {
                        // GetDcmiCapabilitiesResponse Response Data
                        byte[] capabilities = response.ResponseData;

                        // The number of supported rolling average time periods
                        int averages = (int)capabilities[0];

                        if (averages > 0)
                        {
                            // Loop through the available averages
                            for (int i = 0; i < averages; i++)
                            {
                                // Increment the Index Offset
                                index++;

                                //[7:6]: Time duration units 
                                //[5-0]: Time duration (Maximum of 63 units)
                                byte[] timeperiod = IpmiSharedFunc.ByteSplit(capabilities[index], new int[2] {
                                    6, 0
                                });

                                // Get Power Readings Array (DCMI spec)
                                // Reading mode: 0x01 = standard, 0x02 = advanced
                                PowerReadingSupport powerreadings = PowerReadingSupport(0x02, capabilities[index]);

                                // create a new instance of the power reading class
                                PowerReading pwr = new PowerReading(powerreadings.CompletionCode);

                                if (pwr.CompletionCode == 0)
                                {
                                    pwr.SetParamaters(powerreadings.Readings);

                                    // Units of time (number of units)
                                    pwr.TimeNumber = Convert.ToInt32(timeperiod[1]);

                                    // time sample (hours, minutes etc)
                                    pwr.TimeUnit = Convert.ToInt16(timeperiod[0]);
                                }
                                // add pwr to the return list
                                returnlist.Add(pwr);
                            }
                        }
                        else // get standard power statistics
                        {
                            return(GetPowerReading());
                        }
                    }
                    else
                    {
                        // create a new instance of the power reading class
                        PowerReading pwr = new PowerReading(response.CompletionCode);
                        // add ERROR pwr to the return list
                        returnlist.Add(pwr);
                    }
                }
                else // standard power statistics
                {
                    return(GetPowerReading());
                }
            }
            else
            {
                // power management is unsupported
                // create a new instance of the power reading class
                PowerReading pwr = new PowerReading(response.CompletionCode);

                // system does not support power readings
                pwr.PowerSupport = false;

                // add pwr to the return list
                returnlist.Add(pwr);
            }

            return(returnlist);
        }
예제 #5
0
        /// <summary>
        /// Formats System Event (Standard Range) SEL Records
        /// </summary>
        /// <param name="EventMessageData">Event Message Data</param>
        /// <param name="RecordCount">SEL Record Type</param>
        internal static void StandardSelFormat(ref SystemEventLogMessage message, byte[] messageData)
        {
            // convert data bytes from messageData byte[] to int using Shift operation
            int totalSeconds = TimeStampFromBytes(messageData);

            // calculate Recorded date
            message.EventDate = IpmiSharedFunc.SecondsOffSet(totalSeconds);

            // SEL Event Message
            if (Enum.IsDefined(typeof(MsgVersion), messageData[6]))
            {
                message.EventVersion = (MsgVersion)messageData[6];
            }
            else
            {
                message.EventVersion = MsgVersion.Unknown;
            }

            // Sensor Type
            byte sensorType = messageData[7];

            // add sensor type to attribute class
            if (Enum.IsDefined(typeof(SensorType), sensorType))
            {
                message.SensorType = (SensorType)sensorType;
            }
            else
            {
                message.SensorType = SensorType.Unknown;
            }

            // add sensor type to message
            message.RawSensorType = messageData[7];

            // add sensor number to the message class
            message.SensorNumber = messageData[8];

            // Event Data Byte
            byte[] eventDataByte = IpmiSharedFunc.ByteSplit(messageData[9], new int[2] {
                7, 0
            });
            // Event Dir. Asersion/Deserstion Bit 7
            byte eventDir = eventDataByte[0];
            // EventType [6:0]
            byte eventTypeCode = eventDataByte[1];

            message.EventTypeCode = eventTypeCode;

            // Event Dir
            if (Enum.IsDefined(typeof(EventDir), eventDir))
            {
                message.EventDir = (EventDir)eventDir;
            }
            else
            {
                message.EventDir = EventDir.Unknown;
            }

            // copy event message payload to the response raw payload array
            Buffer.BlockCopy(messageData, 10, message.RawPayload, 0, 3);

            // Add the raw payload as hex string to the user return class.
            message.EventPayload = IpmiSharedFunc.ByteArrayToHexString(message.RawPayload);
        }
예제 #6
0
        /// <summary>
        ///  Get Sensor Data Repository. Returns SDR Info.
        /// </summary>
        public virtual SdrCollection GetSdr()
        {
            // Default Record Off Set
            int offSet = 0;

            // Number of Bytes to Read. 0xFF for entire record.
            byte bytesToRead = 0xFF;

            // SDR RecordId (0000h for entry point)
            ushort recordId = 0;

            // Last SDR RecordId (aborts event log Loop)
            ushort lastRecordId = 65535;

            // security mech to step out of loop.
            int pass = 0;

            // create sdr record collection for raw SDR records.
            IpmiSdrCollection records = new IpmiSdrCollection();

            // reserve the SDR for partial reads
            ReserveSdrResponse reserve = (ReserveSdrResponse)this.IpmiSendReceive(
                new ReserveSdrRequest(), typeof(ReserveSdrResponse));

            if (reserve.CompletionCode == 0)
            {
                // reserved LS byte
                byte reserveLs = reserve.ReservationLS;

                // reserved MS byte
                byte reserveMs = reserve.ReservationMS;

                // retrieve all records while connected by recursively calling the SDR entry command
                while (recordId != lastRecordId || pass > 1000)
                {
                    // create SDR record
                    SdrRecord sdr = new SdrRecord();
                    {
                        // get the SEL record
                        GetSdrPartialResponse response = (GetSdrPartialResponse)this.IpmiSendReceive(
                            new GetSdrPartialRequest(reserveLs, reserveMs, recordId, offSet, bytesToRead), typeof(GetSdrPartialResponse));

                        if (response.CompletionCode == 0)
                        {
                            sdr.completionCode = response.CompletionCode;

                            // set record id
                            sdr.RecordId = new byte[2] {
                                response.RecordData[1], response.RecordData[0]
                            };

                            // set the record version
                            sdr.RecordVersion = response.RecordData[2];

                            // set record type
                            sdr.RecordType = response.RecordData[3];

                            // set record lenght
                            sdr.RecordLenght = response.RecordData[4];

                            // set the record data to record data
                            sdr.RecordData = response.RecordData;

                            // update the record Id (signals loop exit)
                            recordId = BitConverter.ToUInt16(new byte[2] {
                                response.RecordIdMsByte, response.RecordIdLsByte
                            }, 0);
                        }
                        else
                        {
                            sdr.completionCode = response.CompletionCode;
                            break;
                        }
                    }

                    pass++;

                    // add the record to the collection
                    records.Add(sdr);
                }
            }

            // return collection
            SdrCollection sdrMessages = new SdrCollection();

            // check response collection holds values
            if (records.Count > 0)
            {
                // sdr version array
                byte[] verarr = new byte[2];

                // record id
                short id;

                foreach (SdrRecord record in records)
                {
                    if (record.completionCode == 0)
                    {
                        // set the sdr collection completion code to indicate a failure occurred
                        sdrMessages.completionCode = record.completionCode;

                        // record Id
                        id = BitConverter.ToInt16(record.RecordId, 0);

                        // populdate version array
                        Buffer.BlockCopy(IpmiSharedFunc.ByteSplit(record.RecordVersion, new int[2] {
                            4, 0
                        }), 0, verarr, 0, 2);

                        string sVersion = Convert.ToUInt16(verarr[1]).ToString(CultureInfo.InvariantCulture) + "." + Convert.ToInt16(verarr[0]).ToString(CultureInfo.InvariantCulture);

                        // set version
                        Decimal version = 0;
                        // sdr record version number
                        if (!decimal.TryParse(sVersion, out version))
                        {
                            version = 0;
                        }

                        GetSdrMetatData(id, version, record.RecordType, record, ref sdrMessages);
                    }
                    // set the sdr completion code to indicate a failure occurred
                    sdrMessages.completionCode = record.completionCode;
                }
            }

            return(sdrMessages);
        }
예제 #7
0
        /// <summary>
        ///  Get Sensor Data Repository Information Incrementally. Returns SDR Info.
        /// </summary>
        public virtual SdrCollection GetSdrIncrement()
        {
            // Default Record Off Set
            int offSet = 0;

            // Number of Bytes to Read. 0xFF for entire record.
            int bytesToRead = 0;

            // SDR RecordId (0000h for entry point)
            ushort recordId = 0;

            // Last SDR RecordId (aborts event log Loop)
            ushort lastRecordId = 65535;

            // security mech to step out of loop.
            int pass = 0;

            // create sdr record collection for raw SDR records.
            IpmiSdrCollection records = new IpmiSdrCollection();

            // reserve the SDR for partial reads
            ReserveSdrResponse reserve = (ReserveSdrResponse)this.IpmiSendReceive(
                new ReserveSdrRequest(), typeof(ReserveSdrResponse));

            if (reserve.CompletionCode == 0)
            {
                // reserved LS byte
                byte reserveLs = reserve.ReservationLS;

                // reserved MS byte
                byte reserveMs = reserve.ReservationMS;

                // lenght of the SDR record
                int recordLenght = 0;

                // sdr record index
                int index = 0;

                // retrieve all records while connected by recursively calling the SDR entry command
                while (recordId != lastRecordId || pass > 1000)
                {
                    // create SDR record
                    SdrRecord sdr = new SdrRecord();
                    {
                        // initialize offset to zero for new record
                        offSet = 0;

                        // initialize to the minimum read size of 5 bytes. (extended to 14 on incremental read)
                        bytesToRead = 5;

                        // get the SEL record
                        GetSdrPartialResponse response = (GetSdrPartialResponse)this.IpmiSendReceive(
                            new GetSdrPartialRequest(reserveLs, reserveMs, recordId, offSet, bytesToRead), typeof(GetSdrPartialResponse));

                        // set the sdr completion code.
                        sdr.completionCode = response.CompletionCode;

                        if (response.CompletionCode == 0)
                        {
                            // set record id
                            sdr.RecordId = new byte[2] {
                                response.RecordData[1], response.RecordData[0]
                            };

                            // set the record version
                            sdr.RecordVersion = response.RecordData[2];

                            // set record type
                            sdr.RecordType = response.RecordData[3];

                            // set record lenght
                            sdr.RecordLenght = response.RecordData[4];

                            // convert record lenght to int & add the initial 5 bytes.
                            recordLenght = (Convert.ToInt32(response.RecordData[4])) + 5;

                            // create SDR byte array to hold record data.
                            byte[] sdrDataRecord = new byte[recordLenght];

                            // initilize sdr array index to zero
                            index = 0;

                            // copy SDR data to the sdr data record array and increase the index
                            Buffer.BlockCopy(response.RecordData, 0, sdrDataRecord, index, bytesToRead);
                            index += bytesToRead;

                            // increase the offset by bytes already read
                            offSet += bytesToRead;

                            int offsetPass = 0;

                            // recursively get partial sdr record until the offset reaches the recordlenght
                            while (offSet < recordLenght || offsetPass > 100)
                            {
                                // get maximum read chunk (14 bytes or less).
                                bytesToRead = (recordLenght - offSet);
                                // the size to 14 byte increments
                                bytesToRead = (bytesToRead > 14) ? 14 : bytesToRead;

                                // get partial SDR record
                                GetSdrPartialResponse partialResponse = (GetSdrPartialResponse)this.IpmiSendReceive(
                                    new GetSdrPartialRequest(reserve.ReservationLS, reserve.ReservationMS, recordId, offSet, bytesToRead), typeof(GetSdrPartialResponse));

                                if (partialResponse.CompletionCode == 0)
                                {
                                    // copy SDR data to the sdr data array and increase the index size by bytes read.
                                    Buffer.BlockCopy(partialResponse.RecordData, 0, sdrDataRecord, index, bytesToRead);
                                    index += bytesToRead;

                                    // increase the offset by the bytes read
                                    offSet += bytesToRead;
                                }
                                else
                                {
                                    // set the sdr completion code.
                                    sdr.completionCode = partialResponse.CompletionCode;
                                    break;
                                }

                                offsetPass++;
                            }

                            // set the record data to the fully populdated sdrDataRecord array
                            sdr.RecordData = sdrDataRecord;

                            // update the record Id (signals loop exit)
                            recordId = BitConverter.ToUInt16(new byte[2] {
                                response.RecordIdMsByte, response.RecordIdLsByte
                            }, 0);
                        }
                        else
                        {
                            break;
                        }
                    }

                    pass++;

                    // add the record to the collection
                    records.Add(sdr);
                }
            }

            // return collection
            SdrCollection sdrMessages = new SdrCollection();

            sdrMessages.completionCode = reserve.CompletionCode;

            if (reserve.CompletionCode != 0)
            {
                sdrMessages.command = typeof(ReserveSdrResponse).ToString();
            }

            // check response collection holds values
            if (records.Count > 0)
            {
                // sdr version array
                byte[] verarr = new byte[2];

                // record id
                short id;

                foreach (SdrRecord record in records)
                {
                    if (record.completionCode == 0)
                    {
                        // record Id
                        id = BitConverter.ToInt16(record.RecordId, 0);

                        // populdate version array
                        Buffer.BlockCopy(IpmiSharedFunc.ByteSplit(record.RecordVersion, new int[2] {
                            4, 0
                        }), 0, verarr, 0, 2);

                        string sVersion = Convert.ToUInt16(verarr[1]).ToString(CultureInfo.InvariantCulture) + "." + Convert.ToInt16(verarr[0]).ToString(CultureInfo.InvariantCulture);

                        // set version
                        Decimal version = 0;
                        // sdr record version number
                        if (!decimal.TryParse(sVersion, out version))
                        {
                            version = 0;
                        }

                        GetSdrMetatData(id, version, record.RecordType, record, ref sdrMessages);
                    }
                    else
                    {
                        sdrMessages.command       += " : " + sdrMessages.completionCode + ". RecordId:" + record.RecordId.ToString();
                        sdrMessages.completionCode = record.completionCode;
                    }
                }
            }

            return(sdrMessages);
        }