This CLSID returns the voltage of the oxygen sensors in the vehicle.
Oxygen sensor
Read, shareable or exclusive
Type: | VT_UI4 (unsigned long) |
Low: | Low-order word: 0.000, High-order word: Number of supported banks |
High: | Low-order word: 4.095, High-order word: Number of sensors per supported bank |
Type: | VT_UI4 (unsigned long) |
Low-order word: | Sensor number |
High-order word: | Cylinder bank number (range 0-n) |
Type: | VT_UI2 (unsigned short fixed point decimal) |
Measurement: | VIOMEASUREMENT_VOLTAGE |
Units: | VIOUNITS_VOLTS |
The information from this CLSID is used by the engine controller to optimize fuel flow for emissions purposes.
API device objects expect the following data types and sizes when sending data to and from the mini-drivers:
Type: | DWORD * |
Size: | 4 bytes |
Low-order word: | Oxygen sensor number |
High-order word: | Cylinder bank number |
Type: | USHORT * |
Size: | 2 bytes |
Low-order word: | Oxygen sensor voltage in 0.001 volt increments |
High-order word: | Number of supported sensors per bank |
HRESULT hr;
VIODEVICEMETRICS dmO2Sensor;
IVIO_Device *pFuelTrim;
VARIANT vDeviceData;
float fO2SensorVoltage;
WORD j, k;
//Create an instance of the oxygen sensor device and get its
//IVIO_Device interface.
hr = CoCreateInstance(CLSID_VIO_O2_SENSOR, NULL,
CLSCTX_INPROC_SERVER, IID_VIODEVICE,
&pO2Sensor);
for(j = 0; j < HIWORD(dmO2Sensor.vRangeLow.ulVal); j++)
{//Iterate through each bank.
for(k = 0; k < HIWORD(dmO2Sensor.vRangeLow.ulVal); k++)
{//Iterate through each sensor in the bank.
//Initialize the VARIANT for the input value.
VariantInit(&vDeviceData);
vDeviceData.vt = VT_UI4;
//Set input data for the current bank and sensor.
vDeviceData.ulVal = MAKELONG(k, j);
//Ask the device for the O2Sensor voltage.
pO2Sensor->GetData(&vDeviceData, 3000);
//Convert the fixed-point percentage to a floating point value.
fO2SensorVoltage = ((float) vDeviceData.usVal) * (10.0 ^
dmO2Sensor.lExponent);
}//End for each sensor
}//End for each bank
//Release the reference to the interface.
pO2Sensor->Release();