cypress API测试程序调试

一  驱动安装、cyapi.lib库的使用

1 接入开发板,安装驱动程序:在设备管理器中选中未识别的USB设备->更新驱动程序->选择驱动程序所在目录

2 安装Cypress SDK(下载地址:http://dlm.cypress.com.edgesuite.net/akdlm/downloadmanager/software/FX3SDKSetup_1.3.4.exe)

SDK中包含所有需要的库、头文件、帮助文档、案例等。

3 参考Cypress USBSuite Application Development Guide中C++ Library CyAPI.lib的使用教程,利用vs构建测试程序。

4 构建Visual C++ > Windows Forms Application工程时,vs2012版本不支持,解决方案:

1. Make a "CLR Empty Project".
2. Press Ctrl-Shift-A and create a Windows Form (under UI).
4. Inside the CPP file that is created, paste this code, replacing anything in square brackets except "[STAThread]" with the appropriate names:
1
2
3
4
5
6
7
8
9
10
11
12
#include "[FORM NAME].h"

using namespace System;
using namespace System::Windows::Forms;

[STAThread]//leave this as is
void main(array<String^>^ args) {
	Application::EnableVisualStyles();
	Application::SetCompatibleTextRenderingDefault(false);
	[PROJECT NAME]::[FORM NAME] form;
	Application::Run(%form);
}

Edit & Run


5. Right click your project in the Solution Explorer and click Properties.
6. Under Configuration Properties > Linker > Advanced, change Entry Point to "main" (without quotation marks).
7. Under Configuration Properties > Linker > System, change SubSystem to "Windows (/SUBSYSTEM/WINDOWS)".

或者

  1. Click File-New-Project
  2. Click online
  3. Click/ Expand Visual C++
  4. Click windows form application
  5. Click C++/CLR Windows Forms fur Visual Studio 201..

5 按照教程中操作完毕后,编译报如下错误:

1>MyForm.cpp(7): warning C4829: 函数 main 的参数可能不正确。请考虑使用“int main(Platform::Array<Platform::String^>^ argv)”
1>  .NETFramework,Version=v4.5.AssemblyAttributes.cpp
1>MyForm.obj : error LNK2028: 无法解析的标记(0A00005C) "public: __thiscall CCyUSBDevice::CCyUSBDevice(void *,struct _GUID,int)" (??0CCyUSBDevice@@$$FQAE@PAXU_GUID@@H@Z),该标记在函数 "public: void __clrcall Project2::MyForm::GetDevice(void)" (?GetDevice@MyForm@Project2@@$$FQ$AAMXXZ) 中被引用
1>MyForm.obj : error LNK2028: 无法解析的标记(0A00005D) "public: unsigned char __thiscall CCyUSBDevice::DeviceCount(void)" (?DeviceCount@CCyUSBDevice@@$$FQAEEXZ),该标记在函数 "public: void __clrcall Project2::MyForm::GetDevice(void)" (?GetDevice@MyForm@Project2@@$$FQ$AAMXXZ) 中被引用
1>MyForm.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall CCyUSBDevice::CCyUSBDevice(void *,struct _GUID,int)" (??0CCyUSBDevice@@$$FQAE@PAXU_GUID@@H@Z),该符号在函数 "public: void __clrcall Project2::MyForm::GetDevice(void)" (?GetDevice@MyForm@Project2@@$$FQ$AAMXXZ) 中被引用
1>MyForm.obj : error LNK2019: 无法解析的外部符号 "public: unsigned char __thiscall CCyUSBDevice::DeviceCount(void)" (?DeviceCount@CCyUSBDevice@@$$FQAEEXZ),该符号在函数 "public: void __clrcall Project2::MyForm::GetDevice(void)" (?GetDevice@MyForm@Project2@@$$FQ$AAMXXZ) 中被引用
1>F:\test\Project2\Debug\Project2.exe : fatal error LNK1120: 4 个无法解析的外部命令
========== 全部重新生成: 成功 0 个,失败 1 个,跳过 0 个 ==========

6 新建x64调试器,重新编译,报如下错误:

1>------ 已启动全部重新生成: 项目: Project2, 配置: Debug x64 ------
1>  MyForm.cpp
1>MyForm.cpp(7): warning C4829: 函数 main 的参数可能不正确。请考虑使用“int main(Platform::Array<Platform::String^>^ argv)”
1>  .NETFramework,Version=v4.5.AssemblyAttributes.cpp
1>CyAPI.lib(CyAPI.obj) : error LNK2019: 无法解析的外部符号 __imp_SetupDiDestroyDeviceInfoList,该符号在函数 "public: unsigned char __cdecl CCyUSBDevice::DeviceCount(void)" (?DeviceCount@CCyUSBDevice@@QEAAEXZ) 中被引用
1>CyAPI.lib(CyAPI.obj) : error LNK2019: 无法解析的外部符号 __imp_SetupDiEnumDeviceInterfaces,该符号在函数 "public: unsigned char __cdecl CCyUSBDevice::DeviceCount(void)" (?DeviceCount@CCyUSBDevice@@QEAAEXZ) 中被引用
1>CyAPI.lib(CyAPI.obj) : error LNK2019: 无法解析的外部符号 __imp_SetupDiGetClassDevsA,该符号在函数 "public: unsigned char __cdecl CCyUSBDevice::DeviceCount(void)" (?DeviceCount@CCyUSBDevice@@QEAAEXZ) 中被引用
1>CyAPI.lib(CyAPI.obj) : error LNK2019: 无法解析的外部符号 __imp_SetupDiGetDeviceInterfaceDetailA,该符号在函数 "public: bool __cdecl CCyUSBDevice::CreateHandle(unsigned char)" (?CreateHandle@CCyUSBDevice@@QEAA_NE@Z) 中被引用
1>F:\test\Project2\x64\Debug\Project2.exe : fatal error LNK1120: 4 个无法解析的外部命令
========== 全部重新生成: 成功 0 个,失败 1 个,跳过 0 个 ==========

7 在项目属性页  链接器->输入中加入 User32.Lib;setupapi.lib,编译通过,运行结果如下:
ad234811f75c27b10aff10c82f30d7d8285.jpg

 

二 cyapi.lib的使用

 

转载于:https://my.oschina.net/u/3732258/blog/3081226

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
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 CyUsb.sys device driver. The library is only able to communicate with USB devices that are served by (i.e. matched to) this driver. Rather than communicate with the driver via Windows API calls such as SetupDiXxxx and DeviceIoControl, applications call simpler CyAPI methods such as Open, Close, and XferData to communicate with 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 file are available for use with Microsoft Visual C++ 6 and 7, and Borland C++ Builder 6.0. 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 CyUsb.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 peforming 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/WaitForXfer/FinishDataXfer methods allow queueing of multiple data transfer requests on a single endpoint, thus enabling data streaming from the application level.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值