通过串口的Arduino和加工之间的通信是损坏 [英] Communication Between Arduino and Processing via Serial is Corrupted

查看:260
本文介绍了通过串口的Arduino和加工之间的通信是损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我上传到我的Arduino的乌诺Rev3型下面的草图:

I have the following sketch uploaded to my Arduino Uno Rev3:

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

void loop() {
    Serial.println("Hello, World!");
    delay(10);
}

当我运行它,你好,世界!不断向印像预期的那样串行监视器。

When I run it, Hello, World! is continually printed to the Serial Monitor as expected.

我有以下处理素描:

import processing.serial.*;

Serial port;

void setup() {
    port = new Serial(this, "/dev/cu.usbmodem1421", 9600);
}

void draw() {
}

当我运行处理草图,串口监听输出被损坏。线条简洁你好,世界!最终看起来是这样的:

When I run the Processing sketch, the Serial Monitor output gets corrupted. The clean lines of Hello, World! end up looking like this:

Hello, Wold!
Hell, Wrld!
He
Hello, o, Worlorld!
H
Hello,World!
ello World!
Hell, World!
Helo, orld
Hello,Worl!
Hello World!
d!
HellHello, W, World!

我想通过串行处理和Arduino的之间的沟通,但我可以在输出未损坏。可能是什么原因?

I would like to communicate between Processing and Arduino via the Serial, but I can't if the output is corrupt. What could be causing this?

推荐答案

你是说你有Arduino的串行监视器在同一时间运行处理草图打开?如果是这样,你不能那样做。你不能有两个应用程序试图在同一时间在同一端口与Arduino的通信

Are you saying that you have the Arduino Serial Monitor open at the same time as running the Processing sketch? If so, you can't do that: you can't have two apps trying to communicate with the Arduino over the same port at the same time.

另外,增加延迟(尝试100) - 你是泛滥的缓冲区。你不显示的处理code,它从串口读取;又在何方?

Also, increase the delay (try 100) - you are flooding the buffer. You don't show the Processing code that reads from the serial port; where is that?

这篇关于通过串口的Arduino和加工之间的通信是损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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