66 lines
1.3 KiB
C
66 lines
1.3 KiB
C
|
|
|||
|
/*
|
|||
|
* ====================================================
|
|||
|
|
|||
|
* 功能:linux USB device USB通信 底层端点抽象
|
|||
|
* 作者:彭明
|
|||
|
* 生成时间:2020/8/18
|
|||
|
* 版本号:v1.0
|
|||
|
|
|||
|
* ====================================================
|
|||
|
*/
|
|||
|
|
|||
|
#ifndef IUSBENDPOINT_H
|
|||
|
#define IUSBENDPOINT_H
|
|||
|
|
|||
|
#include <unistd.h>
|
|||
|
#include <sys/types.h>
|
|||
|
#include <sys/stat.h>
|
|||
|
#include <fcntl.h>
|
|||
|
#include <map>
|
|||
|
#include <errno.h>
|
|||
|
#include "scanservices_utils.h"
|
|||
|
|
|||
|
using namespace std;
|
|||
|
|
|||
|
enum class HGUSB_ErrorCode
|
|||
|
{
|
|||
|
HG_USBSuccess=-1,
|
|||
|
HG_USBOpenFailed,
|
|||
|
HG_USBInvalidePtr,
|
|||
|
HG_USBPCUnConnected
|
|||
|
};
|
|||
|
|
|||
|
class UsbEndPoint
|
|||
|
{
|
|||
|
public:
|
|||
|
enum class EndpointType
|
|||
|
{
|
|||
|
EP_Undefine,
|
|||
|
EP_Control,
|
|||
|
EP_Bulk_In,
|
|||
|
EP_Bulk_Out,
|
|||
|
Ep_Int
|
|||
|
};
|
|||
|
|
|||
|
public:
|
|||
|
UsbEndPoint(EndpointType eptype);
|
|||
|
~UsbEndPoint();
|
|||
|
int open();
|
|||
|
void close();
|
|||
|
int read(void* pdata,int length);
|
|||
|
int write(void* pdata,int length);
|
|||
|
int getEndpointType();
|
|||
|
bool is_open();
|
|||
|
private:
|
|||
|
int m_fd;
|
|||
|
EndpointType m_endpointtype;
|
|||
|
std::map<EndpointType,std::string> map_endpoints={
|
|||
|
{EndpointType::EP_Bulk_In,BULK_IN_PATH},
|
|||
|
{EndpointType::EP_Bulk_Out,BULK_OUT_PATH},
|
|||
|
{EndpointType::EP_Control,BULK_CTL_PATH},
|
|||
|
{EndpointType::Ep_Int,BULK_INT_PATH}
|
|||
|
};
|
|||
|
};
|
|||
|
|
|||
|
#endif //IUSBENDPOINT_H
|