最后总结这个示波器一下wince下USB HOST驱动程序,批量输入、输出、厂商请求3个函数,其他资料网上都能找到。
1、在SOURCES文件TARGETLIBS中添加:
$(_COMMONSDKROOT)\lib\$(_CPUINDPATH)\coredll.lib\
$(_SYSGENOAKROOT)\lib\$(_CPUINDPATH)\usbd.lib\
$(_SYSGENOAKROOT)\lib\$(_CPUINDPATH)\usbdlient.lib
2、在XXX_IoControl函数中定义以下变量
DWORD dwErr0;
DWORD dwUsbErr=0;
BYTE bDir=0;
LPUSB_DEVICE_REQUEST lpRequest=NULL;
3、批量输入:
dwErr = IssueBulkTransfer(pUSBD->usbFuncs,
pUSBD->Bulk.hPipe,
NULL,
NULL,
USB_IN_TRANSFER | USB_SHORT_TRANSFER_OK,
pBufOut,
NULL,
dwLenOut,
pdwActualOut,
INFINITE,
&dwUsbErr);
if ((ERROR_SUCCESS != dwErr) || (USB_NO_ERROR != dwUsbErr))
{
RETAILMSG(1, (TEXT("Bulk In transfer error : %d\r\n"), GetLastError()));
//推出缓冲区
return FALSE;
}
4、批量输出
dwErr = IssueBulkTransfer(pUSBD->usbFuncs,
pUSBD->BulkOut.hPipe,
NULL,
NULL,
USB_OUT_TRANSFER | USB_SHORT_TRANSFER_OK,
pBufIn,
NULL,
dwLenIn,
pdwActualOut,
INFINITE,
&dwUsbErr);
//判断有没有成功同批量输入
5、厂商请求
lpRequest = (LPUSB_DEVICE_REQUEST)pBufIn;//厂商请求通过pBufIn传入
bDir = (lpRequest->bmRequestType) & 0x80;//D7: [0:host to device, 1:device to host]
dwErr = IssueVendorTransfer(pUSBD->usbFuns,
pUSBD->hUSBDevice,
NULL,
NULL,
((bDir? USB_IN_TRANSFER : USB_OUT_TRANSFER) | USB_SHORT_TRANSFER_OK),
lpRequest,
pBufOut,
0,
pdwActualOut,
INFINITE,
&dwUsbErr);
//传输错误判断同批量输入最后总结这个示波器一下wince下USB HOST驱动程序,批量输入、输出、厂商请求3个函数,其他资料网上都能找到。
1、在SOURCES文件TARGETLIBS中添加:
$(_COMMONSDKROOT)\lib\$(_CPUINDPATH)\coredll.lib\
$(_SYSGENOAKROOT)\lib\$(_CPUINDPATH)\usbd.lib\
$(_SYSGENOAKROOT)\lib\$(_CPUINDPATH)\usbdlient.lib
2、在XXX_IoControl函数中定义以下变量
DWORD dwErr0;
DWORD dwUsbErr=0;
BYTE bDir=0;
LPUSB_DEVICE_REQUEST lpRequest=NULL;
3、批量输入:
dwErr = IssueBulkTransfer(pUSBD->usbFuncs,
pUSBD->Bulk.hPipe,
NULL,
NULL,
USB_IN_TRANSFER | USB_SHORT_TRANSFER_OK,
pBufOut,
NULL,
dwLenOut,
pdwActualOut,
INFINITE,
&dwUsbErr);
if ((ERROR_SUCCESS != dwErr) || (USB_NO_ERROR != dwUsbErr))
{
RETAILMSG(1, (TEXT("Bulk In transfer error : %d\r\n"), GetLastError()));
//推出缓冲区
return FALSE;
}
4、批量输出
dwErr = IssueBulkTransfer(pUSBD->usbFuncs,
pUSBD->BulkOut.hPipe,
NULL,
NULL,
USB_OUT_TRANSFER | USB_SHORT_TRANSFER_OK,
pBufIn,
NULL,
dwLenIn,
pdwActualOut,
INFINITE,
&dwUsbErr);
//判断有没有成功同批量输入
5、厂商请求
lpRequest = (LPUSB_DEVICE_REQUEST)pBufIn;//厂商请求通过pBufIn传入
bDir = (lpRequest->bmRequestType) & 0x80;//D7: [0:host to device, 1:device to host]
dwErr = IssueVendorTransfer(pUSBD->usbFuns,
pUSBD->hUSBDevice,
NULL,
NULL,
((bDir? USB_IN_TRANSFER : USB_OUT_TRANSFER) | USB_SHORT_TRANSFER_OK),
lpRequest,
pBufOut,
0,
pdwActualOut,
INFINITE,
&dwUsbErr);
//传输错误判断同批量输入