简体   繁体   English

如何在JAVA中读取USB串口?

[英]How to read a usb serial port in JAVA?

I add some detail to my question. 我在我的问题中添加了一些细节。 I receive on my Xbee device a flow of GPS coordinates but I'm unable to read and stock these data on a buffer. 我在Xbee设备上收到GPS坐标流,但我无法读取并将这些数据存储在缓冲区中。

My Xbee device is connected to my laptop on a usb serial port, that's why I want to create a program java to read and use my data flow sending by the serial port. 我的Xbee设备连接到我的笔记本电脑的USB串口,这就是为什么我要创建一个程序java来读取和使用我的串行端口发送的数据流。

I'm searching on internet some code example or tutorials , without enought advices for my understanding, or I just find some dead projects. 我在互联网上搜索一些代码示例或教程,没有为我的理解提出建议,或者我只是找到一些死的项目。

I found that it's possible to use jssc library or javax.comm (but I can't download the javax.zip on sun). 我发现可以使用jssc库或javax.comm(但我不能在sun上下载javax.zip)。 Do you know an other better USB API ? 你知道其他更好的USB API吗? Could you help me to understand how I can manage to read and stock my Flow of GPS cordinate ? 你能帮我理解我是如何设法阅读和存储我的GPS流量的吗?

Forget abut USB, it acts as transparent bridge. 忘记连接USB,它充当透明桥。 What you need is a way to read from the serial port. 您需要的是一种从串口读取的方法。 javax.comm is not (officially) available any more. javax.comm不再(正式)可用。 I have been successfull dealing with the arduino serial port with the RXTX library. 我已成功处理带有RXTX库的arduino串口。

First make sure you see the serial port on your dev machine. 首先确保您在开发机器上看到串行端口。 This might require to install a driver. 这可能需要安装驱动程序。 Then use a terminal program to connect to the serial port. 然后使用终端程序连接到串行端口。

Once this is working go on and get RXTX working. 一旦这个工作继续,让RXTX工作。

Just in case: You can have only one connection at a time. 以防万一:您一次只能有一个连接。 Make sure that only one of IDE, terminal programm and RXTX is connecting to the serial port at the same time. 确保IDE,终端程序和RXTX中只有一个同时连接到串行端口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM