1

我用 java 编写了一个代码来与我的 Arduino 板通信。它运作良好。我也可以使用串行监视器与 Arduino 板通信。

但是当我尝试打开串行监视器时,当 java 程序正在运行时(监听连接到你的板的端口,PORT 32),它没有说,

Serial port 'COM 32' already in use. Try quitting any programs that may be using it.

这是完整的消息(只是为了完整起见)

Binary sketch size: 3,994 bytes (of a 258,048 byte maximum)
processing.app.SerialException: Serial port 'COM32' already in use. Try quiting any programs that may be using it.
    at processing.app.Serial.<init>(Serial.java:171)
    at processing.app.Serial.<init>(Serial.java:92)
    at processing.app.SerialMonitor.openSerialPort(SerialMonitor.java:207)
    at processing.app.Editor.handleSerial(Editor.java:2447)
    at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:353)
    at java.awt.Component.processMouseEvent(Component.java:6260)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at java.awt.Component.processEvent(Component.java:6028)
    at java.awt.Container.processEvent(Container.java:2041)
    at java.awt.Component.dispatchEventImpl(Component.java:4630)
    at java.awt.Container.dispatchEventImpl(Container.java:2099)
    at java.awt.Component.dispatchEvent(Component.java:4460)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4235)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
    at java.awt.Container.dispatchEventImpl(Container.java:2085)
    at java.awt.Window.dispatchEventImpl(Window.java:2475)
    at java.awt.Component.dispatchEvent(Component.java:4460)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

是的,我知道,它是我的 java 程序,它正在使用该端口。但这是否意味着我不能同时使用这两个程序来访问 PORT32?

希望有人能告诉我解决这个问题的方法。任何帮助是极大的赞赏。谢谢!

4

1 回答 1

1

您的观察是正确的,串行端口一次只能由一个应用程序打开。有可用于拆分串行端口或监控它们的软件解决方案,但我没有足够的经验来提供任何建议。

于 2012-08-14T15:39:54.237 回答