/// <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; }

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

            return sdrMessages;
        }
예제 #2
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);
        }
        /// <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 length
                            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; }

                        GetSdrMetaData(id, version, record.RecordType, record, ref sdrMessages);

                    }
                    // set the sdr completion code to indicate a failure occurred
                    sdrMessages.completionCode = record.completionCode;
                }
            }

            return sdrMessages;
        }
예제 #4
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);
        }