I'm trying to make the following in a timer callback:
VOID
DpxMttCalibrationStateEvtTimerFunction(
IN WDFTIMER Timer
)
{
NTSTATUS status = STATUS_SUCCESS;
PDEVICE_EXTENSION devContext =
GetDeviceContext(WdfTimerGetParentObject(Timer));
UCHAR CalibrationState;
status = DpxMttGetCalibrationState(devContext,&CalibrationState);
if (status==STATUS_SUCCESS)
{
if (devContext->Context.State.Calibrated==0)
{
if (CalibrationState==1)
devContext->Context.State.Calibrated = 1;
else
devContext->Context.State.Calibrated = 0;
}
}
else
{
devContext->Context.State.Calibrated = 0;
}
}
where
NTSTATUS
DpxMttGetCalibrationState(
IN PDEVICE_EXTENSION devContext,
OUT PUCHAR CalibrationState
)
{
NTSTATUS status = STATUS_SUCCESS;
WDF_MEMORY_DESCRIPTOR memDesc;
WDF_USB_CONTROL_SETUP_PACKET controlSetupPacket;
ULONG bytesTransferred = 0;
WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR(&controlSetupPacket,
BmRequestDeviceToHost,
BmRequestToDevice,
0x03,
0,
0);
WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&memDesc,
CalibrationState,
sizeof(UCHAR));
status = WdfUsbTargetDeviceSendControlTransferSynchronously(
devContext->UsbDevice,
NULL, // Optional WDFREQUEST
NULL, //
PWDF_REQUEST_SEND_OPTIONS
&controlSetupPacket,
&memDesc,
&bytesTransferred
);
return status;
}
But this always results in a blue screen! why?
The same happens when I put it on the usb frame arrival callback.
The only place it worked in know was in device io control events handler.
I need to do this inside the kernel without being triggered from outside.
Any tips?
thanks,
Nuno
--
Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply
"sinosoidal" <sinos...@discussions.microsoft.com> wrote in message
news:A709505F-3663-4800...@microsoft.com...
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 4725 (20091229) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4725 (20091229) __________
The message was checked by ESET NOD32 Antivirus.
I have followed your suggestions and have made the following but it fails to
create the work item with the error:
c0200212
which i'm not sure what it really means because it doesnt appear in ntstatus.h
Ayn tips?
Thanks,
Nuno
VOID
ReadWriteWorkItem(
IN WDFWORKITEM WorkItem
)
{
PWORKITEM_CONTEXT pItemContext;
NTSTATUS status;
pItemContext = GetWorkItemContext(WorkItem);
status = DpxMttGetCalibrationState(pItemContext->DevContext);
if (!NT_SUCCESS(status))
{
//UsbSamp_DbgPrint(1, ("ResetPipe failed 0x%x\n", status));
}
WdfObjectDelete(WorkItem);
return;
}
NTSTATUS
QueuePassiveLevelCallback(
IN PDEVICE_EXTENSION devContext
)
{
NTSTATUS status = STATUS_SUCCESS;
PWORKITEM_CONTEXT context;
WDF_OBJECT_ATTRIBUTES attributes;
WDF_WORKITEM_CONFIG workitemConfig;
WDFWORKITEM hWorkItem;
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE(&attributes, WORKITEM_CONTEXT);
attributes.ParentObject = devContext->Device;
WDF_WORKITEM_CONFIG_INIT(&workitemConfig, ReadWriteWorkItem);
status = WdfWorkItemCreate( &workitemConfig,
&attributes,
&hWorkItem);
if (!NT_SUCCESS(status))
{
DebugPrint(("Failed to create work item %x\n", status));
return status;
}
context = GetWorkItemContext(hWorkItem);
context->DevContext = devContext;
//
// Execute this work item.
//
WdfWorkItemEnqueue(hWorkItem);
return STATUS_SUCCESS;
}
NTSTATUS
DpxMttGetCalibrationState(
IN PDEVICE_EXTENSION devContext
)
{
NTSTATUS status = STATUS_SUCCESS;
WDF_MEMORY_DESCRIPTOR memDesc;
WDF_USB_CONTROL_SETUP_PACKET controlSetupPacket;
ULONG bytesTransferred = 0;
UCHAR calibrationState;
WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR(&controlSetupPacket,
BmRequestDeviceToHost,
BmRequestToDevice,
0x03,
0,
0);
WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&memDesc,
&calibrationState,
sizeof(UCHAR));
status = WdfUsbTargetDeviceSendControlTransferSynchronously(
devContext->UsbDevice,
NULL, // Optional WDFREQUEST
NULL, //
PWDF_REQUEST_SEND_OPTIONS
&controlSetupPacket,
&memDesc,
&bytesTransferred
);
if (status==STATUS_SUCCESS)
{
if (calibrationState==1)
devContext->Context.State.Calibrated = 1;
else
devContext->Context.State.Calibrated = 0;
}
else
{
devContext->Context.State.Calibrated = 0;
}
return status;
}
VOID
DpxMttFrameArrivalEvtTimerFunction(
IN WDFTIMER Timer
)
{
NTSTATUS status = STATUS_SUCCESS;
PDEVICE_EXTENSION devContext =
GetDeviceContext(WdfTimerGetParentObject(Timer));
//
// Check is the device is calibrated
//
UCHAR CalibrationState;
if (devContext->Context.State.Calibrated==0)
{
QueuePassiveLevelCallback(devContext);
}
}
I have followed your suggestions and have made the following but it fails to
create the work item with the error:
c0200212
which i'm not sure what it really means because it doesnt appear in ntstatus.h
Ayn tips?
Thanks,
Nuno
VOID
ReadWriteWorkItem(
IN WDFWORKITEM WorkItem
)
{
PWORKITEM_CONTEXT pItemContext;
NTSTATUS status;
pItemContext = GetWorkItemContext(WorkItem);
status = DpxMttGetCalibrationState(pItemContext->DevContext);
if (!NT_SUCCESS(status))
{
//UsbSamp_DbgPrint(1, ("ResetPipe failed 0x%x\n", status));
}
WdfObjectDelete(WorkItem);
return;
}
NTSTATUS
QueuePassiveLevelCallback(
IN PDEVICE_EXTENSION devContext
)
{
NTSTATUS status = STATUS_SUCCESS;
PWORKITEM_CONTEXT context;
WDF_OBJECT_ATTRIBUTES attributes;
WDF_WORKITEM_CONFIG workitemConfig;
WDFWORKITEM hWorkItem;
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE(&attributes, WORKITEM_CONTEXT);
attributes.ParentObject = devContext->Device;
WDF_WORKITEM_CONFIG_INIT(&workitemConfig, ReadWriteWorkItem);
status = WdfWorkItemCreate( &workitemConfig,
&attributes,
&hWorkItem);
if (!NT_SUCCESS(status))
{
DebugPrint(("Failed to create work item %x\n", status));
return status;
}
context = GetWorkItemContext(hWorkItem);
context->DevContext = devContext;
//
// Execute this work item.
//
WdfWorkItemEnqueue(hWorkItem);
return STATUS_SUCCESS;
}
NTSTATUS
DpxMttGetCalibrationState(
IN PDEVICE_EXTENSION devContext
)
{
NTSTATUS status = STATUS_SUCCESS;
WDF_MEMORY_DESCRIPTOR memDesc;
WDF_USB_CONTROL_SETUP_PACKET controlSetupPacket;
ULONG bytesTransferred = 0;
UCHAR calibrationState;
WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR(&controlSetupPacket,
BmRequestDeviceToHost,
BmRequestToDevice,
0x03,
0,
0);
WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&memDesc,
&calibrationState,
sizeof(UCHAR));
status = WdfUsbTargetDeviceSendControlTransferSynchronously(
devContext->UsbDevice,
NULL, // Optional WDFREQUEST
NULL, //
PWDF_REQUEST_SEND_OPTIONS
&controlSetupPacket,
&memDesc,
&bytesTransferred
);
if (status==STATUS_SUCCESS)
{
if (calibrationState==1)
devContext->Context.State.Calibrated = 1;
else
devContext->Context.State.Calibrated = 0;
}
else
{
devContext->Context.State.Calibrated = 0;
}
return status;
}
VOID
DpxMttFrameArrivalEvtTimerFunction(
IN WDFTIMER Timer
)
{
NTSTATUS status = STATUS_SUCCESS;
PDEVICE_EXTENSION devContext =
GetDeviceContext(WdfTimerGetParentObject(Timer));
//
I have followed your suggestions and have made the following but it fails to
create the work item with the error:
c0200212
which i'm not sure what it really means because it doesnt appear in ntstatus.h
Ayn tips?
Thanks,
Nuno
VOID
ReadWriteWorkItem(
IN WDFWORKITEM WorkItem
)
{
PWORKITEM_CONTEXT pItemContext;
NTSTATUS status;
pItemContext = GetWorkItemContext(WorkItem);
status = DpxMttGetCalibrationState(pItemContext->DevContext);
if (!NT_SUCCESS(status))
{
//UsbSamp_DbgPrint(1, ("ResetPipe failed 0x%x\n", status));
}
WdfObjectDelete(WorkItem);
return;
}
NTSTATUS
QueuePassiveLevelCallback(
IN PDEVICE_EXTENSION devContext
)
{
NTSTATUS status = STATUS_SUCCESS;
PWORKITEM_CONTEXT context;
WDF_OBJECT_ATTRIBUTES attributes;
WDF_WORKITEM_CONFIG workitemConfig;
WDFWORKITEM hWorkItem;
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE(&attributes, WORKITEM_CONTEXT);
attributes.ParentObject = devContext->Device;
WDF_WORKITEM_CONFIG_INIT(&workitemConfig, ReadWriteWorkItem);
status = WdfWorkItemCreate( &workitemConfig,
&attributes,
&hWorkItem);
if (!NT_SUCCESS(status))
{
DebugPrint(("Failed to create work item %x\n", status));
return status;
}
context = GetWorkItemContext(hWorkItem);
context->DevContext = devContext;
//
// Execute this work item.
//
WdfWorkItemEnqueue(hWorkItem);
return STATUS_SUCCESS;
}
NTSTATUS
DpxMttGetCalibrationState(
IN PDEVICE_EXTENSION devContext
)
{
NTSTATUS status = STATUS_SUCCESS;
WDF_MEMORY_DESCRIPTOR memDesc;
WDF_USB_CONTROL_SETUP_PACKET controlSetupPacket;
ULONG bytesTransferred = 0;
UCHAR calibrationState;
WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR(&controlSetupPacket,
BmRequestDeviceToHost,
BmRequestToDevice,
0x03,
0,
0);
WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&memDesc,
&calibrationState,
sizeof(UCHAR));
status = WdfUsbTargetDeviceSendControlTransferSynchronously(
devContext->UsbDevice,
NULL, // Optional WDFREQUEST
NULL, //
PWDF_REQUEST_SEND_OPTIONS
&controlSetupPacket,
&memDesc,
&bytesTransferred
);
if (status==STATUS_SUCCESS)
{
if (calibrationState==1)
devContext->Context.State.Calibrated = 1;
else
devContext->Context.State.Calibrated = 0;
}
else
{
devContext->Context.State.Calibrated = 0;
}
return status;
}
VOID
DpxMttFrameArrivalEvtTimerFunction(
IN WDFTIMER Timer
)
{
NTSTATUS status = STATUS_SUCCESS;
PDEVICE_EXTENSION devContext =
GetDeviceContext(WdfTimerGetParentObject(Timer));
//
I have another problem now.
I now have a work item and i passed to the work item context a pointer to my
device context in which i have the pointer to wdfusbdevice.
The problem is that by the time I try to assign the devContext to my work
item context, the wdfusbdevice pointer is null and inside the callback is
also null and then I cant make call the usb control transfer function.
How do I sort this out?
In my last 3 repeated posts i have the code which i'm using now...
Any tips?
Thanks,
Nuno
"Don Burn" wrote:
> .
>