访问串行端口在平台无关的方式 [英] Access the serial port in a platform-independant way

查看:143
本文介绍了访问串行端口在平台无关的方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有个任务要创建一个程序,即从桌面工作站控制设备通过RS-232。目前我在规划阶段,需要选择语言和整体解决问题的方法的一般帮助。

I have a task to create a program, that control a device over RS-232 from a desktop station. Currently I am at the planning stage and need some general help selecting a language and overall approach to the problem.

该计划应建立和Linux(Ubuntu的大部分)和Windows(XP,7)在32位和64位Intel处理器下运行。工作站可能有物理COM端口或(更可能的)USB-RS232转换器。

The program should build and run under Linux (mostly Ubuntu) and Windows (XP, 7) on 32 and 64 bit Intel processors. The workstation might have physical COM ports or (more probably) USB-RS232 converter.

目前我最好的选择是一个C ++程序,用CMake的构建条件。有没有一些方法,使用一些语言,配置和访问串行端口(包括通过USB仿真),即独立于平台的?如果没有,这将是一个很好的办法解决这个问题?

Currently my best bet is a C++ program, built with CMake conditionally. Is there some way, using some language, to configure and access serial ports (including emulated through a USB), that is platform-independent? If no, what would be a good approach to this problem?

建议到现在的:结果
 * C ++与提升结果
 * 与pySerial 蟒蛇

推荐答案

使用升压短耳(用C ++)!

Use Boost Asio (using C++)!

http://www.boost.org/doc /libs/1_51_0/doc/html/boost_asio.html

它保证是独立的平台:的http:/ /www.boost.org/doc/libs/1_51_0/doc/html/boost_asio/using.html

It's guaranteed to be platform independent: http://www.boost.org/doc/libs/1_51_0/doc/html/boost_asio/using.html

虽然什么使得它远远超过任何其他库更好的是,它支持异步通信。我觉得这个功能使得它在你的设备控制软件非常有用。而且不要忘了,这是加速的库是非常可靠的组成部分。

Though what makes it much better than any other libraries is that it supports asynchronous communications. I think that feature makes it very useful in your device-control software. And don't forget that it is part of Boost whose libraries are very reliable.

我(使用AT通过串口/ COM端口发送命令)用它在我的短信程序。

I've used it on my sms messaging program (using AT commands sent through serial/COM ports).

希望,因为它解决了我的问题得以解决。

Hope this solves your problem as it has solved mine.

这篇关于访问串行端口在平台无关的方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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