cyapi中同时打开多台设备,并且他的输出节点和输出节点怎么定义

qq_37943633 2020-02-04 11:34:42
USBDevice = new CCyUSBDevice();
int devices = USBDevice->DeviceCount();//计算设备数量
int d = 0;
if (devices)
{
do {
USBDevice->Open(d);
//device_names[d] = USBDevice->DeviceName;
device_names << USBDevice->DeviceName;
找到USBDevice->EndPoints[i]中的in端点和out端点
这里对当前设备的in_endpoint 和out_endpoint进行赋值

USBDevice->Close();
d++;
} while (d < devices);

}
假如我有四台设备,那么是不是要定义8个endpoint分别对应四个设备的输入输出节点。然后以后通信都是着8个端点进行
然后对设备1的端点初始化好以后,再对设备2的端点初始化需要close设备1吗,还是直接open设备2,然后usbdevice->EndPointCount()和USBDevice->EndPoints都是设备2 的了
...全文
339 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_37943633 2020-02-23
  • 打赏
  • 举报
回复
现在我遇到一个问题,就是在open(i)的时候我怎么知道打开的是哪一台设备,还有假如我同时连了4台设备,如果拔掉再插上,如果原本这台设备是open(0),那么插上以后还是open(0)吗,还是说其他设备会依次往前,重新插上以后这台设备就变成open(3)了
zgl7903 2020-02-09
  • 打赏
  • 举报
回复
USBDevice->Open(d); 这个是打开一个设备, 不是打开所有设备 cyapi的SDK中有例子的,可以参考下
qq_37943633 2020-02-08
  • 打赏
  • 举报
回复
device的类已经写好了,但是据我所知ccyusbdevice *usbdevice这个类初始化以后他是检测到所有已经连接的usb设备的,那我怎么获取每个设备的endpoint呢
zgl7903 2020-02-06
  • 打赏
  • 举报
回复
写好一个设备的通信类,然后创建N个实例

CyAPI原版资料, CyAPI.lib provides a simple, powerful C++ programming interface to USB devices. More specifically, it is a C++ class library that provides a high-level programming interface to the CyUsb3.sys device driver. The library is only able to communicate with USB devices that are served by (i.e. bound to) this driver. Rather than communicate with the driver via Windows API calls such as SetupDiXxxx and DeviceIoControl, applications can call simpler CyAPI methods such as Open, Close, and XferData to communicate with these USB devices. To use the library, you need to include the header file, CyAPI.h, in files that access the CCyUSBDevice class. In addition, the statically linked CyAPI.lib file must be linked to your project. Versions of the .lib files are available for use with Microsoft Visual Studio 2008. The library employs a Device and EndPoints use model. To use the library you must create an instance of the CCyUSBDevice class using the new keyword. A CCyUSBDevice object knows how many USB devices are attached to the CyUsb3.sys driver and can be made to abstract any one of those devices at a time by using the Open method. An instance of CCyUSBDevice exposes several methods and data members that are device-specific, such as DeviceName, DevClass, VendorID, ProductID, and SetAltIntfc. When a CCyUSBDevice object is open to an attached USB device, its endpoint members provide an interface for performing data transfers to and from the device's endpoints. Endpoint-specific data members and methods such as MaxPktSize, TimeOut, bIn, Reset and XferData are only accessible through endpoint members of a CCyUSBDevice object. In addition to its simplicity, the class library facilitates creation of sophisticated applications as well. The CCyUSBDevice constructor automatically registers the application for Windows USB Plug and Play event notification. This allows your application to support "hot plugging" of devices. Also, the asynchronous BeginDataXfer/

2,640

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 硬件/系统
社区管理员
  • 硬件/系统社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧