简体   繁体   English

当端口正忙于另一个Java程序时使用arduino串行监视器?

[英]Using arduino serial monitor while the port is busy with another java program?

In one of the projects I am doing, I need to send some data from a Java program to an Arduino board. 在我正在执行的项目之一中,我需要将一些数据从Java程序发送到Arduino板。 I am using serial communication with the JSerialComm library. 我正在使用与JSerialComm库的串行通信。

I need to debug my program to see whether the Arduino is receiving the correct data or not and I cannot find a way to do it because while sending the data, the Java program is using the serial port, therefore I cannot open the serial monitor and print information in the Arduino IDE. 我需要调试程序以查看Arduino是否接收到正确的数据,并且找不到方法,因为在发送数据时,Java程序正在使用串行端口,因此无法打开串行监视器,并且在Arduino IDE中打印信息。

Do you have any other idea to check the data getting to the Arduino from the serial port? 您还有其他想法来检查从串行端口到达Arduino的数据吗?

Just print the data which you are receiving from the Java program in your C/C++ program (assumption) which is uploaded to the Arduino. 只需在上传到Arduino的C / C ++程序(假设)中打印从Java程序接收的数据即可。 Also in the Java program once you are done sending data, just listen to the serial port to check if the data sent is same as data received. 同样,在Java程序中,一旦完成发送数据,只需侦听串行端口以检查发送的数据是否与接收的数据相同。

Refer to this for Usage examples for JSerialComm library, Link 请参阅此以获取JSerialComm库的用法示例( 链接)

Update: You can print data in your Arduino program using Serial.print() (if it is C/C++ program). 更新:您可以使用Serial.print()在Arduino程序中打印数据(如果它是C / C ++程序)。 You don't have to use the serial monitor. 您不必使用串行监视器。 You can directly read data from the serial port in Java using JSerialComm library, once you are done sending data to Arduino 将数据发送到Arduino后,您可以使用JSerialComm库直接从Java的串行端口读取数据。

If you want something different from the obvious but probably best answer given by Saurabh P Bhandari you can try with a port sniffer. 如果您想要与Saurabh P Bhandari给出的明显但最好的答案有所不同,则可以尝试使用端口嗅探器。 Maybe not your case, but I can imagine a scenario where you don't have access to the source code of the program using the serial port. 也许不是您的情况,但是我可以想象一个场景,您无法使用串行端口访问程序的源代码。

Those are expensive, so if you want to go for the cheap you can take a look at the software alternative I proposed here , which exploits port forwarding to monitor the traffic. 它们很贵,所以如果您想便宜一点,可以看看我在这里提出的替代软件,该软件利用端口转发来监视流量。

If you're on Linux there are also ways to do the same. 如果您使用的是Linux,则还有其他方法可以做到这一点。

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

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