完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,
我正在编写一个具有多个进程的应用程序。一个过程是用C语言编写的,使用CyUSB .NET来发现连接的CyPress USB设备。然后,我用CyAPI写了另一个进程,它访问了UBS设备。这个C++进程是由C语言进程启动的,并被告知使用哪个UBB设备。 我的设备没有唯一的序列号。 我能用什么来识别C和C++进程中的同一个设备? 从C.y/CyUSB .NET中,我可以遍历UBDeVICELIST中的每个USB设备并获得路径、USB地址和序号(这不是唯一的)。 从C++/CyAPI中,我可以调用cCysButo::打开并告诉它打开一个特定的设备号。这个设备的数量与CYUSB .NET返回的USB地址相同吗?或者它与CyUSB .NET接口中的其他东西相匹配? 或者,在CyApi,CysUbDebug::UbStAdvices匹配CyUSB .NET USB地址吗? 或者我可以使用CyUSB .NET路径来获取CyApi中的相同设备吗? 谢谢, 本 以上来自于百度翻译 以下为原文 Hi, I'm writing an application that has multiple processes. One process is written in C# and uses CyU***.Net to discover the Cypress USB devices that are connected. I then have another process written in C++ using CyApi that accesses the USB device. This C++ process is started by the C# process and is told which USB device to use. My devices do not have unique serial numbers. What can I use to identify the same device in the C# and C++ processes? From C# / CyU***.Net I can go through each USBDevice in USBDeviceList and obtain the Path, USBAddress and SerialNumber (which is not unique). From C++ / CyApi I can call CCyUSBDevice::Open and tell it to open a particular device number. Is this device number the same as the USBAddress that CyU***.Net returns? Or does it match something else in the CyU***.Net interface? Alternatively, in CyApi, does the CCyUSBDevice::USBAddress match the CyU***.Net USBAddress? Or can I use the CyU***.Net Path to get hold of the same device in CyApi? Thanks, Ben |
|
相关推荐
5个回答
|
|
CyAPI和CysB.DLL都以类似的方式打开句柄,因此设备处理编号应该是相同的。在触发C++应用程序时,必须记住设备移除的场景。编号可能会根据删除的设备而改变,因此有一种区别于固件的方法(如唯一的序列号)是个好主意。
USB地址应该是方便的,因为它是总线地址(在CyAPI和CyUSB中都是相同的),并且不必基于设备移除而改变。如果你正在寻址的设备被移除,一个新的设备很快地接通,主机将总线地址设置为新设备,那么可能会出现问题。 当做, 阿南德 以上来自于百度翻译 以下为原文 Both CyAPI and CyUSB.dll open handle in a similar manner so the device handle numbering should be the same. You'll have to keep in mind the scenario of device removal while you're triggering the C++ app. The numbering might change based on the device removed so having a way of distinguishing from the firmware (like unique serial number) is a good idea. USBAddress should come in handy since it is the bus address (will be same in both CyAPI and CyUSB) and is not bound to change based on device removal. There might a issue if the device you're addressing is removed and a new device plugged in at very quick succession and the host sets the bus address to the new device. Regards, Anand |
|
|
|
谢谢阿南德,
因此,C++应用程序需要遍历所有设备来查找相关设备。在一个可能被另一个进程使用的设备上调用open有什么问题吗? 例如,我的C++代码是这样的: UCHAR FindCyDevice(UCHAR USB地址,布尔和放大器) { CysUbStudio*UsButoDe=新CysUbDebug(NULL); / /遍历所有设备以找到匹配的USB地址 Debug发现= FALSE; UCHAR DeVICECONTU= UBDebug和GT;DeVICECONTUTE(); 对于(uChar DeVeCeNeNm=0;DeViCeNeN& lt;DeVeCeCut;+ + DeCeNeNUM) { 如果(USB设备-gt;打开(DeCeNeNm)&和;UBS-设备& gt;UbStave==USB地址) { USB设备-Gt;Clute(); Deice发现=真; 返回装置; } } 返回0; } 因此,如果设备在另一个进程中打开,那么()返回false吗?从阅读文档来看,这对我来说并不清楚。谢谢,本 以上来自于百度翻译 以下为原文 Thanks Anand, So the C++ application will need to iterate over all devices to find the relevant device. Are there any issues with calling Open on a device that might be in use by another process? e.g. My C++ code would be something like: UCHAR FindCyDevice(UCHAR u***Address, bool& deviceFound) { CCyUSBDevice* u***Device = new CCyUSBDevice(NULL); // iterate over all devices to find the matching USB address deviceFound = false; UCHAR deviceCount = u***Device->DeviceCount(); for (UCHAR deviceNum = 0; deviceNum < deviceCount; ++deviceNum) { if (u***Device->Open(deviceNum) && u***Device->USBAddress == u***Address) { u***Device->Close(); deviceFound = true; return deviceNum; } } return 0; } So will Open() return false if the device is open in another process? This isn't clear to me from reading the documentation. Thanks, Ben |
|
|
|
不。它会打开把手。
在同一个应用程序可以检查是否有处理已经使用功能isopen()开放。 打开一个句柄枚举器再次获得描述符构建描述符结构。所以,只要你不要打扰其他进程发送一个传输或做其他业务工作(因为其他进程不会知道这个过程引发的事情),可能会影响其他进程的工作,它应该被罚款。 当做, 阿南德 以上来自于百度翻译 以下为原文 Nope. It will open a handle. In the same application you should be able to check whether a handle is already open using the function IsOpen(). Opening a handle enumerates the device again to get the descriptors and build the descriptor structure. So as long as you don't interrupt the other process working by sending a transfer or doing other operations (since the other process won't know the things triggered by this process) that could affect the working of the other process, it should be fine. Regards, Anand |
|
|
|
如果您希望在一个时间点只有一个句柄可用于该设备,您可能需要查看这个HTTP://www. CyPur.com/?ID=4和;RID=40554。
当做, 阿南德 以上来自于百度翻译 以下为原文 If you want only one handle to be openable to the device at a point of time you might want to take a look at this http://www.cypress.com/?id=4&rID=40554 . Regards, Anand |
|
|
|
嗨,阿南德,
因此,只要您的描述不修改共享数据结构或启动任何UBS传输,那么我就可以了。 这意味着从多个进程查询USB地址或序列号(如果它可以是唯一的)应该很好。在代码的C++版本中,我只需要更加小心地关闭句柄。 如果我有任何问题,我会告诉你的。 谢谢,本 以上来自于百度翻译 以下为原文 Hi Anand, So from your description as long as the processes don't modify a shared data structure or initiate any USB transfer then I should be fine. This means that querying the USB address or serial number (if it can be unique) from multiple processes should be fine. I just need to be more careful with closing handles in the C++ version of the code. I'll give this a go and let you know if I have any issues. Thanks, Ben |
|
|
|
只有小组成员才能发言,加入小组>>
740个成员聚集在这个小组
加入小组1987 浏览 1 评论
1749 浏览 1 评论
3527 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1678 浏览 6 评论
1455 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
240浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
145浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
335浏览 2评论
284浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
468浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-9-2 07:22 , Processed in 0.926967 second(s), Total 85, Slave 68 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191