Developing Device Drivers for the Sensor and Location










































- Slides: 42


Developing Device Drivers for the Sensor and Location Platform Gavin Gear Program Manager Microsoft Corporation

Agenda Sensor and Location Platform Overview Sensor Device Driver Interface (DDI) walkthrough Demo: Building and debugging sensor drivers Getting started writing sensor drivers

About Sensors measure a physical phenomenon or a physical interaction Sensors of interest Location sensors GPS, Wi-Fi/cell tower triangulation, IP resolver Ambient Light Sensors (ALS) Other sensors Accelerometers, Human presence, RFID, others

Why Integrate with The Sensor and Location Platform? Application compatibility Security for sensor and location devices Ease of development Component-based approach

Sensor Components Application Sensor API Location and other sensors CPL Software Device UMDF sensor driver Sensor MCU Sensor class extension Sensor hardware Developer tools Windows 7 WDK Windows 7 SDK

Location Components Gadget or script Application Location Scripting Interface Location API Sensor API Software Device UMDF sensor driver Sensor class extension Location and other sensors CPL Developer tools Sensor MCU Location hardware Windows 7 SDK Windows 7 WDK

The Sensor Class Extension Sensor Driver Process ISensor. Class. Extension UMDF sensor driver Implementation Sensor MCU Sensor hardware Sensor class extension ISensor. Driver

Sensor Data Flow IOCTL Incoming Sensor Driver Process Forward UMDF sensor driver Implementation WPD IOCTL Sensor class extension Callback Underlying Transport (HID, USB, others) Sensor MCU Sensor hardware

Sensor Driver Concepts Sensor drivers: Are UMDF drivers Use Sensor Driver Class Extension Leverage Windows Portable Devices (WPD) framework which offers: Serialization/Deserialization functionality Device object hierarchy Containers and other data types

WPD Objects Used by Sensor Drivers IPortable. Device. Key. Collection A collection of PROPERTYKEY values IPortable. Device. Values A container used to store multiple PROPERTYKEY/PROPVARIANT pairs IPortable. Device. Values. Collection A collection of multiple IPortable. Device. Values objects

Sensor Objects Sensors are comprised of: Properties Examples: Manufacturer, Model, Serial Number Data Fields Individual sensor readings Events Examples: Data Updated, State Changed A device can expose multiple sensors

Sensor Objects (continued) Requires a device object, similar to a WPD root object Has the name WPD_DEVICE_OBJECT_ID Contains device properties Each sensor is represented using a sensor object, similar to a WPD functional object Contains sensor properties and data

Example Sensor Properties Data Fields Events Manufacturer: Model: Serial Number … GPS-TRONIX GPST-3000 010263549 … Latitude Longitude Altitude … Data Updated State Changed Accuracy Changed …

demo Building and debugging sensor drivers

Sensor Driver Class Extension Overview Co. Created as in-proc COM object Implements common sensor driver functionality Exposes a single interface: ISensor. Class. Extension Requires a callback object that implements the ISensor. Driver interface

Sensor Driver Class Extension Overview (continued) Handles Windows portable devices (WPD) control requests De-serializes input data buffer Serializes output data Enforces access control for location and sensor data Checks location and sensor data access permission Secures event data

ISensor. Class. Extension methods Method: Description: Initialize() Performs class extension object initialization Uninitialize() Performs class extension object cleanup Cleanup. File() Cleans up file handles Process. Io. Control() Handles WPD I/O requests Post. State. Change() Raises state change events to applications Post. Event() Raises data events and custom events to applications

ISensor. Driver Overview Enumerates sensor objects Returns sensor properties and data Changes sensor configuration Tracks client applications and event sinks Processes other WPD messages

ISensor. Driver methods Method: Called when: On. Client. Connect() On. Client. Disconnect() A client has connected to or disconnected from a sensor On. Client. Subscribe. To. Events() On. Client. Unsubscribe. From. Events() A client has set or released a sensor event sink On. Get. Data. Fields() A client has requested one or more data values for a sensor On. Get. Properties() A client has requested one or more properties for a sensor On. Get. Supported. Data. Fields() A client has requested the data fields supported by a sensor On. Get. Supported. Events() A client has requested the list of data fields for a sensor

ISensor. Driver methods (continued) Method: Called when: On. Get. Supported. Properties() A client has requested the list of properties supported by a sensor On. Get. Supported. Sensor. Objects() The class extension needs the list of sensors exposed by the device driver On. Process. Wpd. Message() WPD message has not been handled in the sensor class extension. On. Set. Properties() One or more properties has been set by the client

Sensor Platform Integration Activity Where you implement Initializing class extension IPnp. Callback. Hardware: : On. Prepare. Hardware() Releasing class extension IPnp. Callback. Hardware: : On. Release. Hardware() Handle incoming IOCTLs Incoming sensor related calls IQueue. Callback. Device. Io. Control: : On. Device. Io. Control() ISensor. Driver implementation

Logo Requirements And Tests Requirements are listed under Input 048 Apply to all sensor devices Input 049 Apply to location devices only Input 050 Apply to ambient light sensor devices only Requirements are focused around Exposing proper data fields Exposing properties correctly

Sensor Development Kit Based on Freescale JM 128 Badge Board (HID) Sensors Ambient light sensor 3 D accelerometer Dual touch strip sensors Developer tools Sample firmware code Sample driver code Diagnostic and sample applications Light-aware MSDN reader Marble game **Additional units will be available in early 2009

Call To Action Install the Windows 7 WDK Explore, build, and run the sensor driver sample Support your sensor hardware with a sensor driver for Windows 7 Review the logo requirements for sensor drivers, and make sure your driver passes the logo tests

Resources Location and sensors WHDC site www. microsoft. com/whdc/sensors Whitepapers News and announcements Links (MSDN developer forum, and more) Inquiry aliases sensext@microsoft. com locext@microsoft. com Logo requirements and tests: https: //winqual. microsoft. com

Appendix

Raising Data Updated Events ISensor. Class. Extension: : Post. Event() is used to raise data updated events HRESULT Post. Event( LPWSTR pwsz. Sensor. ID, IPortable. Device. Values. Collection* p. Event. Collection); Each data event consists of: Event ID Timestamp Sensor data values

Post. Event() Code Sample CCom. Ptr<IPortable. Device. Values> p. Event. Params; Co. Create. Instance(CLSID_Portable. Device. Values, NULL, CLSCTX_INPROC_SERVER, IID_IPortable. Device. Values, (VOID**) p. Event. Params); p. Event. Params->Set. Guid. Value(SENSOR_EVENT_PARAMETER_EVENT_ID, SENSOR_EVENT_DATA_UPDATED); p. Event. Params->Set. Float. Value(SENSOR_DATA_TYPE_ACCELERATION_X_G, (FLOAT)acceleration. X); SYSTEMTIME st; : : Get. System. Time(&st); FILETIME ft; : : System. Time. To. File. Time(&st, &ft))

Post. Event() Code Sample (continued) var. vt = VT_FILETIME; var. filetime. dw. Low. Date. Time = ft. dw. Low. Date. Time; var. filetime. dw. High. Date. Time = ft. dw. High. Date. Time; p. Values->Set. Value(SENSOR_DATA_TYPE_TIMESTAMP, &var); IPortable. Device. Values. Collection* p. Event. Collection; hr = Co. Create. Instance(CLSID_Portable. Device. Values. Collection, NULL, CLSCTX_INPROC_SERVER, IID_IPortable. Device. Values. Collection, (VOID**) &p. Event. Collection); p. Event. Collection->Add(p. Event. Params); p. Class. Extension->Post. Event(accelerometer. ID, p. Event. Collection);

Power. Point Guidelines Font, size, and color for text have been formatted for you in the Slide Master Use the color palette shown below See next slide for additional guidelines Sample Fill Sample Fill

Using Subtitles Subtitle color Example of a slide with a subtitle Set the slide title in “Title Case” Set subtitle in “Sentence case” Generally set subtitle to 36 pt or smaller so it will fit on a single line The subtitle color is defined for this template but must be selected; On the font color palette, select the color to the right of title color

Code Sample How to show code in a slide Call out in a box Use 14 pt Lucida Console Make sure your code will compile using System; public class Class 1 { public static void Main () { Console. Write. Line (“Hello World!”); } }

Example Diagram Applications Provided by: Microsoft User ISV Device Class Driver Kernel Device Class Driver IHV Device Class Driver Minidriver ACPI Driver Core (Fixed) System hardware Value-added System hardware Non-std. Dev. Bus Class Driver Non-std Dev. Std Dev. OEM

demo Demo Title Name Title Group

partner Partner Title Name Title Group

announcing Announcement Title Name Title Group

video Video Title Name Title Group

customer Customer Title Name Title Group

Call To Action All presentations should contain a “Call to Action” slide that describes, in a few bullet points, the actions you want the audience to take as a result of the presentation Example: “Ensure that your device and driver work on ALL 64 -bit enable Windows operating systems”

Additional Resources Replace this slide’s content with resources appropriate to your presentation Web Resources: Specs: http: //www. specexample. com (example) Whitepapers: http: //www. whitepaperexample. com (example) Other Resources: http: //www. otherresourceexample. com (example) Related Sessions Session name For Email addresses: DO create an alias. DON’T use your individual mail address Note that the email addresses should be in a text field (not in the bullet-point outline) to avoid being caught by search engines. Align to look like other bullet-points Example: youremail@company. com

© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U. S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.