赞
踩
简介:



使用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
的开发环境版本越高越占内存。

(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,如下:


数据发送:

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

参考:
Cypress USBSuite Application Development Guide Version 1.2.3.20
CyAPI.pdf
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。