如何在vc ++ 2013中使用简单的串口通信程序? [英] How to have a simple serial port communication program in vc++ 2013?

查看:119
本文介绍了如何在vc ++ 2013中使用简单的串口通信程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被分配编写一个在Windows上运行的简单串口通信程序。我可以从网络中找到的资源是整个示例程序项目或代码片段。我在使用资源时遇到了一些麻烦:

1.代码项目几乎在Win32中。这些太旧了,无法在最新版本的Visual Studio中使用;例如VC ++ 2012,2013,...

2.示例代码通常包含CreateFile(),ClosePort(),OpenPort()等函数,以及HANDLE等数据类型导致编译错误。我应该包含哪些头文件?

3.当我使用VC ++ 2013打开代码项目时,所有这些都失败了。



我习惯使用VC#,而不是VC ++。谁能告诉我如何获取我可以使用VC ++ 2010或更高版本立即构建它的示例代码?

I was assigned to write a simple serial port communication program running at Windows. The resources which I can find from network are either the whole sample program project or code pieces. I've got some trouble in using the resources:
1. The code projects are almost in Win32. Those are too old to be used in latest versions of Visual Studio; such as VC++ 2012, 2013, ...
2. The sample codes usual contains functions like CreateFile(), ClosePort(), OpenPort(), ... and data types like HANDLE, which usually causes compilation error. Which header files should I include?
3. When I open the code projects using VC++2013, all of them failed.

I get used to use VC#, not VC++. Could anyone tell me how to get the sample codes which I can build it immediately using VC++ 2010 or above?

推荐答案

1。 Win32(现在是WINAPI)仍然存在:Visual Studio 2013仍然具有Win32项目。



2.如果没有正确包含标题,则会出现编译错误文件,例如 CreateFile的文档 [ ^ 清楚地说明你必须在你的项目中加入 Windows.h



3.创建一个新应用程序并添加您在 MSDN 文档中找到的代码(例如:配置通信资源 [ ^ ])。
1. Win32 (now WINAPI) are still there: Visual Studio 2013 still features 'Win32 Projects'.

2. You get compilation error if you don't properly include the header files, for instance the documentation of CreateFile[^] clearly states you have to include Windows.h in your project.

3. Create a fresh application and add the code you find in MSDN documentation (for instance: "Configuring a Communications Resource"[^]).


你试过http://flounder.com/serial.htm [ ^ ]?


这篇关于如何在vc ++ 2013中使用简单的串口通信程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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