Table of contents
Collapse the table of content
Expand the table of content

The WpdBasicHardwareDriver Protocol

Last Updated: 1/24/2017

The WpdBasicHardwareDriver sample driver supports a simple protocol that includes a device identifier, packet size, and sensor data. The protocol defines a basic data format for sensor data that is transmitted by the programmable microcontroller and received by the sample driver. The sample driver parses the data packets and translates them into custom WPD events that are received by a WPD application.

After you install a device and the sample driver, you can view packets of this data by using the WpdMon tool that ships with the Windows Driver Kit (WDK). This tool monitors traffic (WPD commands and events) between a WPD driver and the WPD API. The following screenshot shows sensor data for the Sensiron Temperature and Humidity sensor that is being transmitted from the driver to the API as custom WPD events. The custom event GUID is defined by the WpdBasicHardwareDriver in Stdafx.h.

DEFINE_GUID (EVENT_SENSOR_READING_UPDATED, 0xada23b0b, 0xce13, 0x4e11, 0x9d, 0x2f, 0x15, 0xfe, 0x10, 0xd6, 0x63, 0x37);

the wpd monitor

Note The SENSOR_READING and SENSOR_UPDATE_INTERVAL event parameters are not part of the WPD schema. It is necessary to edit the WpdInfo Properties file to add the following entries. (If these entries are not added, the WpdMon and WpdInfo tools will display raw PROPERTYKEYs rather than friendly names.)

{a7ef4367-6550-4055-b66f-be6fdacf4e9f}.2, SENSOR_READING, VT_UI8
{a7ef4367-6550-4055-b66f-be6fdacf4e9f}.3, SENSOR_UPDATE_INTERVAL, VT_UI4

In the previous image, the SENSOR_READING line contains data that is sent by the sensor by using the driver to the WPD API. This data is a multibyte packet that has the format that is shown in the following image:

sensor packet

The first byte identifies the sensor, the second specifies a count of elements, the third specifies the size of an element, the fourth through (fourth + count) bytes contain the actual data elements, and the last six bytes specify the interval at which the sensor publishes its data to the computer.

The seven bytes of element data indicate that the current temperature is 72.6 degrees Fahrenheit and the relative humidity is 32.8 percent. The five bytes of interval data indicate that the sensor transmits data to the computer every 2,000 milliseconds (or, every two seconds).

The following table specifies the packet format for each of the nine sensors that are found in the Parallax Sensor Sample kit.

SensorSensor IDElement countElement sizeElementsInterval
Compass113Heading (3 bytes)6 bytes
Sensiron217Temp (4 bytes)

Humidity (3 bytes)

6 bytes
Flex Force315Force (5 bytes)6 bytes
Ultrasonic Ping415Distance (5 bytes)6 bytes
Passive Infrared511State (1 byte)6 bytes
Memsic618x-axis G (4 bytes)

y-axis G (4 bytes)

6 bytes
QTI714Light measurement (4 bytes)6 bytes
Piezo Vibration811State (1 byte)6 bytes
Hitachi934x-axis G (4 bytes)

y-axis G (4 bytes)

z-axis G (4 bytes)

6 bytes

The WpdBasicHardwareDriverSample

The WPD Driver Samples

Send comments about this topic to Microsoft

© 2017 Microsoft