gpt4 book ai didi

c - 最简单的桥接示例不起作用 - Arduino Yun

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:32:33 26 4
gpt4 key购买 nike

我试图修改 Temperature Web Panel光传感器示例(在 arduino-1.5.6-rw/libraries/Bridge/examples/TemperatureWebPanel 中找到)。不幸的是,即使是最简单的通过 wifi 接收和传输结果似乎也不起作用!我什至注释掉了工作部分,只是将一些文本发送回浏览器,如您所见,但我仍然在浏览器中看不到任何内容:

#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>

// Listen on default port 5555, the webserver on the Yun
// will forward there all the HTTP requests for us.
YunServer server;
String startString;
long hits = 0;

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

// For debugging, wait until the serial console is connected.
/*delay(4000);
while(!Serial);
Bridge.begin();
*/
// Bridge startup
pinMode(13, OUTPUT);
Bridge.begin();
digitalWrite(13, HIGH);

pinMode(A0, INPUT);


// Listen for incoming connection only from localhost
// (no one from the external network could connect)
server.listenOnLocalhost();
server.begin();

// get the time that this sketch started:
Process startTime;
startTime.runShellCommand("date");
while (startTime.available()) {
char c = startTime.read();
startString += c;
}

Serial.println("yeah\n");
Serial.println(startTime);
}

void loop() {
// Get clients coming from server
Serial.println("a\n");
YunClient client = server.accept();

// There is a new client?
if (client) {
Serial.println("Client!\n");
// read the command
String command = client.readString();
client.print('(This should definitely be sent over bridge)');
/*command.trim(); //kill whitespace
Serial.println(command);
// is "temperature" command?
if (command == "temperature") {

// get the time from the server:
Process time;
time.runShellCommand("date");
String timeString = "";
while (time.available()) {
char c = time.read();
timeString += c;
}
Serial.println(timeString);
int sensorValue = analogRead(A0);
// convert the reading to millivolts:
client.print("Current time on the Yún: ");
client.println(timeString);
client.print("<br>Current value: ");
client.print(sensorValue);
client.print("<br>This sketch has been running since ");
client.print(startString);
client.print("<br>Hits so far: ");
client.print(hits);
}*/

// Close connection and free resources.
client.stop();
hits++;
}

delay(50); // Poll every 50ms
}

我在串行监视器中多次看到“a”,但在 arduino.local/arduino/temperature url 中从未看到任何内容,只是一个空白响应。

此外,一段时间后,Yun 似乎断开了网络连接,无法通过 http 或 ssh 访问。考虑到 ssh 是与这台计算机通信的主要方式,如何调试这样的问题?

最佳答案

在自己的配置上一步步调试后,发现代码一直没有超过Bridge.begin()。

经过进一步调查,我发现默认的 250000 桥接波特率不再匹配内核波特率 115200。

更改为:Bridge.begin(115200) ... 为我解决了这个问题。

要确定您的内核速度,请从终端运行 cat/proc/cmdline 到您的 Yun

有关详细信息,请参阅此链接:https://groups.google.com/forum/#!msg/linino/-rSmpjX4UOM/Cnjv-uzrlfgJ

如果这不是您的问题,请考虑在 Bridge.cpp 等的实际源文件中添加调试信息(即 ..Serial.print())。不幸的是,Arduino/Linino 开发人员似乎经常做出重大更改并且没有更新文档、示例等的资源。

关于c - 最简单的桥接示例不起作用 - Arduino Yun,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24581659/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com