Implement property support

The driver must provide callbacks to respond to property read and write requests. POS properties are hardware property values, which include hardware capability and the WinRT PointOfService client state. For example, the driver must be able to set or get the scanner’s IsEnabled property.

For a list of properties that your driver may support, see PosPropertyId.

POSUTIL_GET_PROPERTY

Driver developers must provide this callback to respond to property read requests. The callback should return STATUS_SUCCESS when the property get returns a valid value.

This example from the sample scanner driver, in the file device.c, shows how to respond to a request for the list of symbologies that the device supports.

_Use_decl_annotations_  
static   
NTSTATUS  
DeviceGetProperty(  
        WDFDEVICE Device,  
        PosPropertyId Property,  
        WDFMEMORY Value  
        )  
{  
    DEVICE_CONTEXT * Context = WdfObjectGet_DEVICE_CONTEXT(Device);  
    NTSTATUS Status;  
  
    PAGED_CODE();  
  
    switch (Property)  
    {  
    default:  
        Status = STATUS_NOT_SUPPORTED;  
        break;  
  
    case BarcodeScannerSupportedSymbologies:  
        WdfWaitLockAcquire(Context->Lock, NULL);  
  
        if (Context->SupportedSymbologies == NULL)  
        {  
            Status = STATUS_NOT_SUPPORTED;  
        }  
        else  
        {  
            void *Buffer;  
            size_t Size;  
  
            Buffer = WdfMemoryGetBuffer(Context->SupportedSymbologies, &Size);  
            Status = WdfMemoryCopyFromBuffer(Value, 0, Buffer, Size);  
        }  
  
        WdfWaitLockRelease(Context->Lock);  
        break;  
    }  
  
    return Status;  
}

The data formats for the values that you may get are documented in Encoding formats and IOCTL_POINT_OF_SERVICE_GET_PROPERTY.

POSUTIL_SET_PROPERTY

Driver developers must provide this callback to respond to property write requests. The callback should return STATUS_SUCCESS when the property get returns a valid value.

This example from the sample scanner driver, device.c, illustrates how to respond to a request to set properties such as IsEnabled or to set the list of symbologies that the device is actively handling.

_Use_decl_annotations_  
static  
NTSTATUS  
DeviceSetProperty(  
        WDFDEVICE Device,  
        PosPropertyId Property,  
        WDFMEMORY Value  
        )  
{  
    NTSTATUS Status = STATUS_INVALID_PARAMETER;  
    DEVICE_CONTEXT *Context = WdfObjectGet_DEVICE_CONTEXT(Device);  
  
    PAGED_CODE();  
  
    switch(Property)  
    {  
    case IsEnabled:  
        {  
            // Just return success since we are faking the driver it would always be enabled              
            Status = STATUS_SUCCESS;  
        }  
        break;  
    case BarcodeScannerActiveProfile:  
        {  
            Context->ActiveProfile = Value;  
            Status = STATUS_SUCCESS;  
        }  
        break;  
  
    default:  
        Status = STATUS_SUCCESS;  
        break;  
  
    case BarcodeScannerActiveSymbologies:  
        Status = HandleSetActiveSymbologies(Device, Value);  
        break;  
    }  
  
    return Status;  
}

The data formats for the values that you may set are documented in Encoding formats and IOCTL_POINT_OF_SERVICE_SET_PROPERTY.

Related topics

POSUTIL_GET_PROPERTY
POSUTIL_SET_PROPERTY
Encoding formats

 

 

Show: