当前位置:   article > 正文

USB3014-应用程序开发_begindataxfer(buffer, length, &outovlap);

begindataxfer(buffer, length, &outovlap);

简介:

使用VC6++开发:

出现如下问题

  (1)添加对应的头文件

#include <iostream>
#include <string>
using namespace std;

#include <wtypes.h>
#include <dbt.h>


 

(2)

libcmt.lib(_file.obj) : error LNK2005: ___initstdio already defined in LIBCD.lib(_file.obj)

LINK : warning LNK4098: defaultlib "LIBCMT" conflicts with use of other libs

设置为多线程DLL

添加setupapi.lib

忽略libcmt

  (3) CyAPI.lib(CyAPI.obj) : error LNK2001: unresolved external symbol ___security    ...

根本原因是官方的lib需要使用VS2008以上环境开发,如果替换老版的CyAPI.lib可以成功生成但,数据读取结果不一定对。虽然迷恋VC6的小巧,也只能跟换VS2008,Windows

的开发环境版本越高越占内存。

https://community.cypress.com/t5/Knowledge-Base-Articles/Additional-CyAPI-lib-libraries-besides-Visual-C-2008/ta-p/248218

(4)其它

#pragma comment(lib, "test.lib")

VS2008开发:直接打开开发环境中的参考设计:注意lib路径中的Debug改成lib即可

D:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\application\cpp\streamer

同VC6一样遇到类似问题,需要添加setupapi.lib并设置忽略libcmt,如下:

数据发送:

  1. //BeginDataXfer is an advanced method for performing asynchronous IO
  2. // This example assumes that the device automatically sends back,
  3. // over its bulk-IN endpoint, any bytes that were received over its
  4. // bulk-OUT endpoint (commonly referred to as a loopback function)
  5. //CCyUSBDevice *USBDevice = new CCyUSBDevice(NULL);
  6. OVERLAPPED outOvLap, inOvLap;
  7. //outOvLap.hEvent = CreateEvent(NULL, false, false, L"CYUSB_OUT");
  8. outOvLap.hEvent = CreateEvent(NULL, false, false, "CYUSB_OUT");
  9. //inOvLap.hEvent = CreateEvent(NULL, false, false, L"CYUSB_IN");
  10. //unsigned char inBuf[128];
  11. //ZeroMemory(inBuf, 128);
  12. unsigned char buffer[28];
  13. LONG length = 28;
  14. buffer[0] = 0xa0;
  15. buffer[1] = 0x10;
  16. buffer[2] = 0x20;
  17. buffer[3] = 0x30;
  18. buffer[24] = 0xc0;
  19. buffer[25] = 0x10;
  20. buffer[26] = 0x20;
  21. buffer[27] = 0x30;
  22. // Request the return data before initiating the loopback
  23. //UCHAR *inContext = USBDevice->BulkInEndPt->BeginDataXfer(inBuf, length,&inOvLap);
  24. UCHAR *outContext = USBDevice->BulkOutEndPt->BeginDataXfer(buffer, length,&outOvLap);
  25. USBDevice->BulkOutEndPt->WaitForXfer(&outOvLap,100);
  26. //USBDevice->BulkInEndPt->WaitForXfer(&inOvLap,100);
  27. USBDevice->BulkOutEndPt->FinishDataXfer(buffer, length, &outOvLap,outContext);
  28. //USBDevice->BulkInEndPt->FinishDataXfer(inBuf, length, &inOvLap, inContext);
  29. CloseHandle(outOvLap.hEvent);
  30. //CloseHandle(inOvLap.hEvent);

 

 

参考:

Cypress USBSuite Application Development Guide Version 1.2.3.20

CyAPI.pdf
 

 

 

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/49142
推荐阅读
相关标签
  

闽ICP备14008679号