SerialSocketEvent 未触发 [英] SerialSocketEvent not firing

查看:27
本文介绍了SerialSocketEvent 未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已复制此代码:http://playground.arduino.cc/Interface/Java 到一个 java 项目,我试过这个:

I have copied this code:http://playground.arduino.cc/Interfacing/Java to a java project, and i tried this:

void setup(){
Serial.begin(9600);
while(!Serial);
}

void loop(){
Serial.println("Test");
}

在我的 arduino UNO 上,效果很好,但是当我在 esplora 上尝试时,该程序甚至没有触发 java 项目的事件侦听器.

on my arduino UNO, with great results, but when i tried it on my esplora, the program did not even fire the event listener for the java project.

推荐答案

Esplora 和 leonardo(均使用 ATmega32u4)要求您等到 cdc 序列准备就绪.Uno 有一个专用的 Atmega8/16u2 控制串行/USB 通信.

An Esplora and leonardo (both use ATmega32u4) require you to wait until the cdc serial is ready. The Uno has a dedicated Atmega8/16u2 controlling the Serial/USB comms.

在您的代码中,在您的 Serial.begin() 调用之后,添加一个循环以等待就绪:

In your code, after your Serial.begin() call, add a loop to wait until ready:

Serial.begin(9600);

while (!Serial) {
  ; // wait for serial port to connect.
}

干杯

这篇关于SerialSocketEvent 未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆