使用FTDI库时出现问题 [英] Problem using the FTDI library

查看:254
本文介绍了使用FTDI库时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试编译此代码,但是编译器一直在说从const void *到void *的无效转换".我将库文件和头文件放在正确的目录中.我不确定我想念的是什么.这是代码

I keep trying to compile this code but the compiler keeps saying "invalid conversion from const void* to void*". I put library and header files in the right directories. i''m not sure what i''m missing. here''s the code

#include<windows.h>
#include<ftd2xx.h>
#include<iostream>
using namespace std;
int main()
{
	FT_STATUS ftStatus;
	FT_HANDLE ftHandle;
	ftStatus = FT_OpenEx("FT232R USB UART",FT_OPEN_BY_DESCRIPTION,&ftHandle);
	if (ftStatus == FT_OK) 
	{
		cout << "it worked!" << endl;
	}
	else 
	{
		cout << "it didn't work! : ( " << endl;
	}
	return 0;
}



在FTDI驱动程序文件夹中,还有一些.sys文件和.dll文件.我不确定如何处理它们,所以将它们复制到程序文件夹中.



In the FTDI driver folder, there''s also some .sys files and .dll files. I wasn''t sure what to do with them so I copied them to the program folder.

推荐答案

FT_OpenEx的第一个参数的类型为LPVOID根据第二个参数传递不同的类型(integerchar *).因此,您必须使用casting:
The first parameter of FT_OpenEx is of type LPVOID to pass different types (integer and char *) according to the second parameter. So you must use casting:
ftStatus = FT_OpenEx((LPVOID)"FT232R USB UART",FT_OPEN_BY_DESCRIPTION,&ftHandle);



如果系统上存在FTDI DLL(在安装设备时将FTDI DLL安装到系统文件夹中),则所需的只是头文件ftd2xx.h(用于包括)和库ftd2xx.lib(用于链接).



If the FTDI DLL is present on your system (it is installed to the system folder when installing the device), all you need are the header file ftd2xx.h for including and the library ftd2xx.lib for linking.


所拥有的.lib文件也应该是链接程序的一部分;只需将.lib文件添加到VC项目层次结构中(通过添加现有文件)
The .lib files you have should also be part of the linker process; just add the .lib files into the VC project hierarchy (via Add Existing File)


这篇关于使用FTDI库时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆