java Java中与RS232端口的通信
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14947417/
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
Communication with RS232 port in Java
提问by Stuci
I'm trying to solve one problem with the "communication with RS232" port using Java, because my skills on C are not so great!
我正在尝试使用 Java 解决“与 RS232 通信”端口的一个问题,因为我的 C 技能不是很好!
The problem:
问题:
I have a dynamometer (if you care what is the machine that I'm using) that send the data to my pc through RS232. The main idea is that when I send the ASCII code 'S' to it, the dynamometer should return me -
我有一个测功机(如果你关心我使用的是什么机器),它通过 RS232 将数据发送到我的电脑。主要思想是,当我向它发送 ASCII 代码“S”时,测功机应该返回我 -
18 bytes as follows: 0,1,2,3,4 - the messured force F; 5,6,7,8,9 - Fmax; 10,11,12,13,14 - the messured speed dF/dT and bytes 15,16,17 - status (0/1 for each - MaxHold, Nulled, Overload). All the bytes are standard ASCII strings.
18 字节如下: 0,1,2,3,4 - 受力 F;5,6,7,8,9 - Fmax;10,11,12,13,14 - 测量速度 dF/dT 和字节 15,16,17 - 状态(每个 0/1 - MaxHold、Nulled、Overload)。所有的字节都是标准的 ASCII 字符串。
So my problem is that I will make the rest of the code, the loops for sending the 'S', the Null command to the machine at the beginning... I have no problems to safe this info into a file for example .txt either.
所以我的问题是我将制作其余的代码,在开始时向机器发送“S”的循环,Null 命令......我没有问题将这些信息安全地保存到一个文件中,例如 .txt任何一个。
My problem isthat I cant understand and I cant find maybe an already done and known method for simple sending/receiving commands or information through this RS232.
我的问题是我无法理解,我无法找到一种已经完成的已知方法,用于通过此 RS232 简单地发送/接收命令或信息。
As far as I saw... I will have to use the class javax.comm that is not supported since... ages and the other way is to use rxtx libs that I cant find in google because it says to me that their webpage is somehow... not working. I'm afraid that there won't be any good doc for this lib and I will fail with the use whether I get it or not.
就我所见......我将不得不使用自......以来不受支持的类 javax.comm ,另一种方法是使用我在谷歌中找不到的 rxtx 库,因为它告诉我他们的网页不知何故......不工作。我担心这个库不会有任何好的文档,无论我是否得到它,我都会失败。
I know that my problem is not so easy maybe but this is part from my final educational exam and I really need help. I will appreciate it BIG TIME!
我知道我的问题可能并不那么容易,但这是我期末教育考试的一部分,我真的需要帮助。我会很感激的!
Thanks a lot from now on to the ppl that will try to help me!
从现在开始非常感谢那些会尽力帮助我的人!
PS: Sorry for my bad grammar.
PS:对不起,我的语法不好。
回答by Brian Agnew
java-simple-serial-connectorlooks like a suitable alternative to RxTx
java-simple-serial-connector看起来像是 RxTx 的合适替代品