none
Call OnGetSupportedSensorObjects function in WDK SensorSkeleton sample RRS feed

  • Question

  • I am writing a program to get temperature sensors properties and fan speed.

    For that reason I use WDK SensorSkeleton sample.

    To get sensor objects I need to call OnGetSupportedSensorObjects(__out IPortableDeviceValuesCollection** ppSensorObjectCollection)

    function and pass as argument dynamic array of abstract type IPortableDeviceValuesCollection.

    How can I initialize that array before function call?




    • Edited by Arus_h Tuesday, September 25, 2012 1:35 PM
    Tuesday, September 25, 2012 12:53 PM

Answers

All replies

  • are you trying to report the motherboard temp through the sensors stack? that is not typically how it is done.  usually you expose this via acpi and wmi.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, September 25, 2012 4:51 PM
  • Besides the answer given by Doron I wonder why you are calling OnGetSupportedSensorObjects?  Notice that in Device.cpp an instance of ISensorClassExtension is created and initialized.  The sensor class extension will make this call for you so the Sensor API can enumerate the sensors on the device.  The Sensor API will get you the sensor objects.

    Wednesday, September 26, 2012 12:35 AM
  • That means I need just call OnPrepareHardware() method of Device.cpp?

    Or what changes should I make in DllMain to get the driver work and get sensor properties, what DllMain functions are necessary to call, because I run dll file and get no result. I load the driver using LoadLibrary() method from .cpp file.

    Regarding WMI: classes for getting hardware temperature do not work on some machines as these classes are vendor dependent.



    • Edited by Arus_h Wednesday, September 26, 2012 11:16 AM
    Wednesday, September 26, 2012 9:07 AM
  • The WDK SkeletonSample is a driver, not a standalone DLL.  You don't call into it, the UMDF framework will make all of the PnP callbacks, and the sensor class extension will call the sensor DDI callbacks.  In order to deploy it as a driver, you need to use devcon:  http://msdn.microsoft.com/en-us/library/windows/hardware/ff544707(v=vs.85).aspx

    This is a very old sample, though.  I recommend you start with the most recent WDK sample for Windows 8, the GeoLocation sample:  http://code.msdn.microsoft.com/windowshardware/Sensors-Geolocation-Driver-5f2a11d6

    You can also refer to the HID Sensor sample for how to expose properties for different sensors:  http://code.msdn.microsoft.com/windowshardware/Sensors-HID-Driver-Sample-1a440438


    This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by Doron Holan [MSFT] Wednesday, September 26, 2012 10:57 PM
    • Unmarked as answer by Arus_h Thursday, September 27, 2012 9:05 AM
    • Marked as answer by Doron Holan [MSFT] Thursday, September 27, 2012 4:18 PM
    Wednesday, September 26, 2012 6:12 PM
  • Thanks a lot!

    If I install the driver, how can I get sensor readings periodically?

    I'm wondering if this solution will work: add a getProperties() function to the driver and call this function periodically from a helper application and when the application is closing, remove the driver.

    What do you think about such kind of solution? How is it possible to implement the mechanism of getting properties?

    And one more question. How can SkeletonSample driver be converted into standalone dll or is it possible to create standalone dll using WDK?

    Thanks in advance.





    • Edited by Arus_h Wednesday, September 26, 2012 8:05 PM
    Wednesday, September 26, 2012 6:22 PM
  • From your question it sounds like you are wondering how to get the sensor data from the driver.  For that you need to write a program using the Sensor API.  Using the ISensor interface you can get properties and data from the sensor.

    To get periodic readings you will want your sensor to post events -- take a look at the GeoLocation sample to see how it is done.

    Wednesday, September 26, 2012 8:09 PM
  • a sensor driver is not going to solve your vendor specific problems that some vendors do not provide temp and fan data.  a umdf driver is not going to make it magically work.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, September 26, 2012 10:57 PM
  • But there are third party applications which get hardware temperature using a dll file.

    It would be much appreciated if somebody could tell how to create such dll using WDK or get temperature readings from installed driver. 


    • Edited by Arus_h Thursday, September 27, 2012 9:05 AM
    Thursday, September 27, 2012 8:56 AM
  • it is custom code and interfaces to get the data if they are not exposing them in the expected way via acpi. there is no magic in a dll or the wdk, you are asking for proprietary information and implementation...neither of which are appropriate for this forum.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, September 27, 2012 4:20 PM