Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Muhammad_S_1
Beginner
143 Views

Sensor Information using Intel AMT HLAPI

Hi,

Am using HLAPI of Intel AMT 9.5 SDK. When i try to retrieve Sensor information using Hardware Assets API am getting 3 items but the name and id of all those items is unknown. Any suggestions why am getting this behavior ?


Processor: i5-4670
Board: DQ87PG

0 Kudos
7 Replies
Colleen_C_Intel
Employee
143 Views

can you supply a sample of the information you are getting, please?

Muhammad_S_1
Beginner
143 Views

CurrentState, DataValid'ID,Name,SensorType,PossibleStates

Unknown,True,Unknown,Unknown,Unknown,Bad,Good,Unknown,
Unknown,True,Unknown,Unknown,Unknown,Bad,Good,Unknown,
Unknown,True,Unknown,Unknown,Unknown,Bad,Good,Unknown,

 


=======================================================================================================
Actual working code example with exception handling and referenced types
=======================================================================================================
IAMTInstance amt = ConnectToMachine(AssetID);

Sensor[] Sensors = amt.HardwareAsset.Sensors;
List<AMTSensor> amtSensors = new List<AMTSensor>();

foreach (Sensor sensor in Sensors)
{
    AMTSensor amtSensor = new AMTSensor();

    amtSensor.CurrentState = sensor.CurrentState;
    amtSensor.DataValid = sensor.DataValid;
    amtSensor.ID = sensor.ID;
    amtSensor.Name = sensor.Name;
    amtSensor.PossibleStates = sensor.PossibleStates;
    //sensor.PossibleStates.CopyTo(amtSensor.PossibleStates ,0);
    amtSensor.SensorType = (AMTSensorTypeEnum)((int)sensor.SensorType);
    
    AssetComponent assetComp = new AssetComponent();
    assetComp.InsertAssetAuditLogRow(AssetID, (int)sensor.SensorType, sensor.CurrentState);

    amtSensors.Add(amtSensor);
}

return amtSensors;

Colleen_C_Intel
Employee
143 Views

Well it looks like it's retrieving data, just doesn't know what to name it - Do you have the CIM/MOF files loaded that would define your available sensors?

Are the other HW Assets all reading out correctly?

Muhammad_S_1
Beginner
143 Views

 

Yes all the hardware information is being retrieved perfectly well. No issues in any one just the sensors details. Regarding CIM/MOF files loading can you explain further what needs to be done if i am using HLAPI.

Colleen_C_Intel
Employee
143 Views

The sensors have to be named somewhere for the readout to pick up those names
For WMI, those names come from MOF files. If you look in the AMT SDK under \DOCS\WS-Management\MOF folder you will see one CIM_Sensor.mof  (but you can also see others and compare those to names you are getting for other hardware)
Also see (AMTSDK)\Windows\Common\WS-Management\C++\CimFramework\CPPClasses\Include  for the CIM_sensor.h

Muhammad_S_1
Beginner
143 Views

Colleen i did checked the presence of MOF files as well as header files. All are present at there respective locations. I also tested the sensor info using the HLAPI samples and debugging the HLAPI source while running the samples. Following is the XML output of the GetSensors method of HardwareAssetWSMAN.cs on HLAPI. Need some guidance what needs to be done more ?

XML Output

========================================================================================

<h:CIM_Sensor xmlns:h=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Sensor\">
<h:CreationClassName>CIM_Sensor</h:CreationClassName>
<h:CurrentState>Unknown</h:CurrentState>
<h:DeviceID>Sensor1</h:DeviceID>
<h:ElementName>Sensor</h:ElementName>
<h:EnabledState>5</h:EnabledState>
<h:HealthState>5</h:HealthState>
<h:OperationalStatus>2</h:OperationalStatus>
<h:PossibleStates>Bad</h:PossibleStates><h:PossibleStates>Good</h:PossibleStates><h:PossibleStates>Unknown</h:PossibleStates>
<h:RequestedState>12</h:RequestedState>
<h:SensorType>0</h:SensorType>
<h:SystemCreationClassName>CIM_ComputerSystem</h:SystemCreationClassName>
<h:SystemName>ManagedSystem</h:SystemName>
</h:CIM_Sensor>

<h:CIM_Sensor xmlns:h=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Sensor\">
<h:CreationClassName>CIM_Sensor</h:CreationClassName>
<h:CurrentState>Unknown</h:CurrentState>
<h:DeviceID>Sensor2</h:DeviceID>
<h:ElementName>Sensor</h:ElementName>
<h:EnabledState>5</h:EnabledState>
<h:HealthState>5</h:HealthState>
<h:OperationalStatus>2</h:OperationalStatus>
<h:PossibleStates>Bad</h:PossibleStates><h:PossibleStates>Good</h:PossibleStates><h:PossibleStates>Unknown</h:PossibleStates>
<h:RequestedState>12</h:RequestedState>
<h:SensorType>0</h:SensorType>
<h:SystemCreationClassName>CIM_ComputerSystem</h:SystemCreationClassName>
<h:SystemName>ManagedSystem</h:SystemName>
</h:CIM_Sensor>

<h:CIM_Sensor xmlns:h=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Sensor\">
<h:CreationClassName>CIM_Sensor</h:CreationClassName>
<h:CurrentState>Unknown</h:CurrentState>
<h:DeviceID>Sensor3</h:DeviceID>
<h:ElementName>Sensor</h:ElementName>
<h:EnabledState>5</h:EnabledState>
<h:HealthState>5</h:HealthState>
<h:OperationalStatus>2</h:OperationalStatus>
<h:PossibleStates>Bad</h:PossibleStates><h:PossibleStates>Good</h:PossibleStates><h:PossibleStates>Unknown</h:PossibleStates>
<h:RequestedState>12</h:RequestedState>
<h:SensorType>0</h:SensorType>
<h:SystemCreationClassName>CIM_ComputerSystem</h:SystemCreationClassName>
<h:SystemName>ManagedSystem</h:SystemName>
</h:CIM_Sensor>

=================================================================================================

HLAPI Code

public void GetSensors(ref Sensor[] Sensors)
        {
            IManagedReference sensorRef = Connection.NewReference("SELECT * FROM CIM_Sensor");
            List<Sensor> sensorsList = new List<Sensor>();

            try
            {
                foreach (IWsmanItem sensorItem in sensorRef.Enumerate("http://schemas.dmtf.org/wbem/wsman/1/wsman/SelectorFilter", null))
                {
                    Sensor s = new Sensor();
                    s.CurrentState = sensorItem.Object.GetProperty("CurrentState").ToString();

                    if (!sensorItem.Object.GetProperty("InstanceID").IsNull)
                        s.ID = sensorItem.Object.GetProperty("InstanceID").ToString();


                    if (!sensorItem.Object.GetProperty("Name").IsNull)
                        s.Name = sensorItem.Object.GetProperty("Name").ToString();
                    IWsmanItem possibleStates = sensorItem.Object.GetProperty("PossibleStates");
                    s.PossibleStates = new string[possibleStates.Count];
                    int j = 0;
                    foreach (IWsmanItem possibleState in possibleStates)
                    {
                        s.PossibleStates[j++] = possibleState.ToString();
                    }
                    s.SensorType =
                        SensorTypeEnumFromInt(int.Parse(sensorItem.Object.GetProperty("SensorType").ToString()));
                    s.DataValid = true;
                    sensorsList.Add(s);
                }
                Sensors = sensorsList.ToArray();
            }
            catch (ManageabilityException ex)
            {
                throw new HardwareAssetManagabilityException(ex.Message, "GetSensors", machineAddress, HardwareAssetFailure.GeneralError, "");
            }
        }

 

 

Colleen_C_Intel
Employee
143 Views

The only suggestion I have is to read thru 

Implementation and Reference Guide/WordDocuments/sensorsAndSensorEvents.htm
and
https://msdn.microsoft.com/en-us/library/aa387235%28v=vs.85%29.aspx

Reply