/* * ==================================================== * 功能:linux USB device USB通信 底层端点抽象 * 作者:彭明 * 生成时间:2020/8/18 * 版本号:v1.0 * ==================================================== */ #ifndef IUSBENDPOINT_H #define IUSBENDPOINT_H #include #include #include #include #include #include #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 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