none
How to send the Orientation Sensor data type to Sample Compass Application ? RRS feed

  • Question

  • Hi,

    I made the orientation sensor driver to use the UMDF 1(no use HID).

    If I test to use the SensorDiagnostic Tool, Sensor Properity and data type is show as below.

    But,I tested to use the Sample compass application(https://github.com/Microsoft/Windows-universal-samples/blob/master/Samples/Compass/cpp/Scenario1_DataEvents.xaml.cpp)

    It did not get the DataEvent.

    I think that Application was called the "ReadingChanged()" function in "Scenario1_DataEvents.xaml.cpp". But it did not call.

    When Send the DataEvent in Driver layer , I use the "PostEvent()" function as below.

    --------------------------------------

    MIDL_INTERFACE("A31253BA-6F73-4BC9-ABAA-26C8833C58FF")

        ISensorClassExtension : public IUnknown

        {

        public:

                   

            virtual HRESULT STDMETHODCALLTYPE PostEvent(

                /* [in][string] */ __RPC__in_string LPWSTR pwszSensorID,

                /* [in] */ __RPC__in_opt IPortableDeviceValuesCollection *pEventCollection) = 0;

           

        };

    ----------------------------------

    What function is to send the DataEvent to call the "ReadingChanged()" in the Sample Application ?

    Monday, November 2, 2015 2:32 AM

All replies

  • Second, I tested to use the Sample compass application(https://github.com/Microsoft/Windows-universal-samples/blob/master/Samples/Compass/cpp/Scenario2_Polling.xaml.cpp)

    When call "CompassReading^ reading = compass->GetCurrentReading();" in "void Scenario2_Polling::DisplayCurrentReading()" ,

    "HRESULT CSensorDdi::OnGetDataFields()" is called in Device driver as below.

        HRESULT CSensorDdi::OnGetDataFields(
            _In_  IWDFFile* appId,
            _In_  LPWSTR wszObjectID,
            _In_  IPortableDeviceKeyCollection* pKeys,
            _Out_ IPortableDeviceValues** ppValues
            )

    I checked "appId","wszObjectID","pKeys" . All Parameter was correct.

     So, in this function , input all sensor data to "ppValues".

    and then check the "CompassReading^ reading " .

    "reading" is "NULL".

    I think that "CompassReading" class  can not get the data field value.


    • Edited by KyoungSuck.Ki Wednesday, November 4, 2015 6:13 AM wrong word
    Wednesday, November 4, 2015 6:10 AM
  • Third, I tested ISensorManager class and ISensor class as below.

    ------------------

    ISensorManager *manager;
    ISensorCollection *collection;
    ISensor *sensor;

    ISensorDataReport* ppdata;

     if (FAILED(CoCreateInstance(CLSID_SensorManager, NULL, CLSCTX_INPROC_SERVER, IID_ISensorManager, (void**)&manager)))
      return;

      if (FAILED(manager->GetSensorsByType(SENSOR_TYPE_AGGREGATED_DEVICE_ORIENTATION, &collection)))
       return;

     ULONG count = 0;
     collection->GetCount(&count);
     if (!count)
      return;
     
     collection->GetAt(0, &sensor);

     sensor->GetData(&ppdata);

    PROPVARIANT *tempdata = new PROPVARIANT;

    ppdata->GetSensorValue(SENSOR_DATA_TYPE_MAGNETIC_FIELD_STRENGTH_XMILLIGAUSS,tempdata);

    ----------------

    It was working fine.

    I think that WinRT Class is wrong.

    Friday, November 6, 2015 6:47 AM