📄 atlasusbdev.h
字号:
// PalmDev.h: interface for the CAtlasUsbDev class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_PALMDEV_H__8752CFFA_8C50_11D3_84F4_E63B9D56EF57__INCLUDED_)
#define AFX_PALMDEV_H__8752CFFA_8C50_11D3_84F4_E63B9D56EF57__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "afxmt.h"
#pragma warning(disable:4200)
#include "..\\DDKINC\\devioctl.h"
#include <setupapi.h>
#include <basetyps.h>
#include "..\\DDKINC\\usbdi.h"
#include "..\inc\AtlasUsbIO.h"
#define MAX_PIPES 32
class __declspec(dllexport) CAtlasUsbDev
{
public:
CAtlasUsbDev();
virtual ~CAtlasUsbDev();
//Initialize the device before any operations
BOOL Init();
//Open the device
BOOL OpenDevice();
//Close the device
void CloseDevice();
//Close all pipes
void CloseAllPipes();
//Open a single pipe
BOOL OpenPipe(DWORD iPipe);
//Close a single pipe
void ClosePipe(DWORD iPipe);
//Write to an pipe
BOOL WritePipe(DWORD iPipe, BYTE * pBuf, UINT iLength, UINT &nBytesWritten);
//Read from an pipe
BOOL ReadPipe(DWORD iPipe, BYTE * pBuf, UINT iLength, UINT &nBytesRead);
//Send vendor command via control pipe
//This function should be called when one or more pipes are opened.
//If no pipes are open, the driver will suspend the device, which will fail this function call
BOOL SendVendorCommand(PATLAS_USB_MESSAGE vendorMsg);
//Check is it still connected
BOOL IsConnected();
#ifdef _DEBUG
//Dump all descriptors
void DumpDescriptors();
//Dump config descriptor
void DumpConfigDescriptor(PUSB_CONFIGURATION_DESCRIPTOR cd);
//Dump interface descriptor
void DumpInterfaceDescriptor(PUSB_INTERFACE_DESCRIPTOR id, UINT ix);
//Dump endpoint descriptor
void DumpEndpointDescriptor(PUSB_ENDPOINT_DESCRIPTOR ed, int i);
//Translate descriptor type to string
char * DumpDescriptorType(UCHAR bDescriptorType);
//Translate endpoint type to string
char * DumpEndpointType(UCHAR bmAttributes);
//Translate config attributes to string
char * DumpConfigAttributes(UCHAR bmAttributes);
#endif//#ifdef _DEBUG
protected:
//There may be multiple palm devices, open the correct one from the PnP dev list.
BOOL OpenOneDevice(IN HDEVINFO HardwareDeviceInfo,
IN PSP_INTERFACE_DEVICE_DATA DeviceInfoData);
protected:
//Handle of the device
HANDLE m_hDev;
//Hanlde of the pipes
HANDLE m_hPipe[MAX_PIPES];
//Gloable unique ID of the device
LPGUID m_pGuid;
//Device name
CString m_strDevName;
//Is device initiated?
BOOL m_bInit;
CCriticalSection m_critical;
};
#endif // !defined(AFX_PALMDEV_H__8752CFFA_8C50_11D3_84F4_E63B9D56EF57__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -