如何使用JAVA将数据发送到COM PORT?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/900950/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 20:50:14  来源:igfitidea点击:

How to send data to COM PORT using JAVA?

javaserial-port

提问by Srinivasan__

Possible Duplicate:
Java Serial Communication on Windows

可能的重复:
Windows 上的 Java 串行通信

Friends, I want to connect and transfer data to COM PORT (either virtual or original) in JAVA?

朋友,我想在JAVA中连接并传输数据到COM PORT(虚拟或原始)?

采纳答案by Lawrence Dol

This question has been asked and answered many times:

这个问题已经被问过和回答过很多次了:

Read file from serial port using Java

使用Java从串口读取文件

Reading serial port in Java

用Java读取串口

Reading file from serial port in Java

用Java从串口读取文件

Is there Java library or framework for accessing Serial ports?

是否有用于访问串行端口的 Java 库或框架?

Java Serial Communication on Windows

Windows 上的 Java 串行通信

to reference a few.

参考几个。

Personally I recommend SerialPort from http://serialio.com- it's not free, but it's well worth the developer (no royalties) licensing fee for any commercial project. Sadly, it is no longer royalty free to deploy, and SerialIO.com seems to have remade themselves as a hardware seller; I had to search for information on SerialPort.

我个人推荐来自http://serialio.com 的SerialPort -它不是免费的,但对于任何商业项目,开发人员(无版税)许可费非常值得。可悲的是,部署不再免版税,SerialIO.com 似乎已经将自己改造成硬件销售商;我不得不搜索有关 SerialPort 的信息。

From personal experience, I strongly recommend againstthe Sun, IBM and RxTx implementations, all of which were unstable in 24/7 use. Refer to my answers on some of the aforementioned questions for details. To be perfectly fair, RxTx may have come a long way since I tried it, though the Sun and IBM implementations were essentially abandoned, even back then.

根据个人经验,我强烈建议不要使用 Sun、IBM 和 RxTx 实现,它们在 24/7 的使用中都不稳定。有关详细信息,请参阅我对上述一些问题的回答。公平地说,自从我尝试 RxTx 以来,它可能已经走了很长一段路,尽管 Sun 和 IBM 实现基本上被放弃了,即使在那时也是如此。

A newer free option that looks promising and may be worth trying is jSSC (Java Simple Serial Connector), as suggested by @Jodes comment.

正如@Jodes 评论所建议的那样,一个看起来很有前景并且可能值得尝试的更新的免费选项是jSSC (Java Simple Serial Connector)

回答by Robert Harvey

The Java Communications API (also known as javax.comm) provides applications access to RS-232 hardware (serial ports): http://www.oracle.com/technetwork/java/index-jsp-141752.html

Java Communications API(也称为 javax.comm)提供对 RS-232 硬件(串行端口)的应用程序访问:http: //www.oracle.com/technetwork/java/index-jsp-141752.html

回答by freespace

An alternative to javax.commis the rxtxlibrary which supports more platforms than javax.comm.

一个替代方案javax.commrxtx支持比javax.comm.