none
Sensor driver properties for an accelerometer not reported?

    Question

  • Hi,

    I am in the process of writing a sensor driver for an accelerometer device and everything seems to going fine on the driver side.  On the client application side however some of the "ISensor" methods don't seem to be working right.  When the sensor initializes on the driver side it sets up values for the following properties:

    • WPD_OBJECT_ID
    • WPD_OBJECT_NAME
    • WPD_OBJECT_PERSISTENT_UNIQUE_ID
    • WPD_OBJECT_PARENT_ID
    • WPD_OBJECT_FORMAT
    • WPD_OBJECT_CONTENT_TYPE
    • WPD_OBJECT_CAN_DELETE
    • WPD_FUNCTIONAL_OBJECT_CATEGORY
    • SENSOR_PROPERTY_TYPE
    • SENSOR_PROPERTY_MANUFACTURER
    • SENSOR_PROPERTY_MODEL
    • SENSOR_PROPERTY_SERIAL_NUMBER
    • SENSOR_PROPERTY_FRIENDLY_NAME
    • SENSOR_PROPERTY_DESCRIPTION
    • SENSOR_PROPERTY_MIN_REPORT_INTERVAL
    • SENSOR_PROPERTY_CURRENT_REPORT_INTERVAL
    • SENSOR_PROPERTY_CONNECTION_TYPE
    • SENSOR_PROPERTY_PERSISTENT_UNIQUE_ID

    Now, I am thinking that when someone calls "ISensor::GetType" on the client side the platform should automatically map this to the property "SENSOR_PROPERTY_TYPE".  What I am observing however is that the call to "GetType" fails with "E_UNEXPECTED".  When I try looking at the properties of the sensor via the "SensorDiagnosticTool", I am in fact able to see all of the above properties being listed.  Is there anything else that one needs to do to get the client side end of the sensor API to work correctly?

    As things stand, the "SensorDiagnosticTool" treats the sensor as an "unknown sensor" even though the "SENSOR_PROPERTY_TYPE" mapping should have caused it to treat it as a 3D accelerometer.  The same thing happens when I create a new client using the Windows 7 API code pack for .NET.

    Please help!

    Thanks.

    -- 
    Ranju. V
    --

    Monday, January 18, 2010 1:25 AM

Answers

  • Hello Ranju,

    If ISensor::GetType is failing with E_UNEXPECTED, that means that the variant type of the data returned by the driver is different than what is expected (as documented at
    http://msdn.microsoft.com/en-us/library/cc974543.aspx). The variant type of the SENSOR_PROPERTY_TYPE property is expected to be VT_CLSID. Can you confirm that your driver is returning the data in this variant type?

    Also, when you say that all of the properties are listed by the Sensor Diagnostic Tool, is the tool also listing the values that are returned by your driver? From what you have described, I would expect that the diagnostic tool would not list any values (since the diagnostic tool is simply using the Sensor API to query the value and you have said that the API is returning error).

    Thanks,
    Prasanna
    Monday, January 18, 2010 1:58 AM
    Answerer

All replies

  • Hello Ranju,

    If ISensor::GetType is failing with E_UNEXPECTED, that means that the variant type of the data returned by the driver is different than what is expected (as documented at
    http://msdn.microsoft.com/en-us/library/cc974543.aspx). The variant type of the SENSOR_PROPERTY_TYPE property is expected to be VT_CLSID. Can you confirm that your driver is returning the data in this variant type?

    Also, when you say that all of the properties are listed by the Sensor Diagnostic Tool, is the tool also listing the values that are returned by your driver? From what you have described, I would expect that the diagnostic tool would not list any values (since the diagnostic tool is simply using the Sensor API to query the value and you have said that the API is returning error).

    Thanks,
    Prasanna
    Monday, January 18, 2010 1:58 AM
    Answerer
  • Hi Prasanna,

    You were absolutely right!  I was indeed using the wrong VT for the SENSOR_PROPERTY_TYPE property.  I had used the "InitPropVariantFromGUIDAsBuffer" API to intialize GUID values and that was of course not using VT_CLSID as the variant type.  Once I changed it to use "InitPropVariantFromCLSID" it started working perfectly!  The Sensor Diagnostic Tool and my own sample client is now correctly recognizing the sensor as a 3D accelerometer and the event notifications are working perfectly!

    Thanks a bunch for pointing me in the right direction!  I am writing this driver for an article that I intend to put up on CodeProject.com.  I have come up with a little framework as well that will hopefully somewhat ease writing new sensor drivers.  I'll post a follow up here once that article is ready.  Thanks again!  You're a life saver!

    -- 
    Ranju. V
    --

    Monday, January 18, 2010 3:30 AM
  • Which is that accelerometer device you are writing a driver for ?


    Michael
    Tuesday, January 19, 2010 3:15 PM
  • For the Nintendo Wiimote.

    -- 
    Ranju. V
    --

    Thursday, February 04, 2010 3:41 AM
  • The article is now up on CodeProject.  See here:


    -- 
    Ranju. V
    --

    Friday, February 05, 2010 1:48 AM
  • I am implementing the sensor driver on windows 10.

    in sensor info app the values are showing properly but i am Error debug logs.

    detailed explanation on another thread, link given below. 

    link:https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/505763e4-fe06-4a4d-ad3c-0f0ffc16ce57/sensor-driver-showing-some-debug-log-errors-but-sensors-are-able-to-retrieve-sensor-values-and?forum=wdk#505763e4-fe06-4a4d-ad3c-0f0ffc16ce57

    it looks similar, could provide your thought on the same thread?


    • Edited by siddharam Thursday, August 18, 2016 12:19 PM
    Thursday, August 18, 2016 12:19 PM