The WpdBasicHardwareDriver Protocol

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.

Sensor Sensor ID Element count Element size Elements Interval
Compass 1 1 3 Heading (3 bytes) 6 bytes
Sensiron 2 1 7 Temp (4 bytes)

Humidity (3 bytes)

6 bytes
Flex Force 3 1 5 Force (5 bytes) 6 bytes
Ultrasonic Ping 4 1 5 Distance (5 bytes) 6 bytes
Passive Infrared 5 1 1 State (1 byte) 6 bytes
Memsic 6 1 8 x-axis G (4 bytes)

y-axis G (4 bytes)

6 bytes
QTI 7 1 4 Light measurement (4 bytes) 6 bytes
Piezo Vibration 8 1 1 State (1 byte) 6 bytes
Hitachi 9 3 4 x-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