Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 最简单的桥梁示例无法工作-Arduino Yun_C_Linux_Ssh_Arduino_Arduino Yun - Fatal编程技术网

C 最简单的桥梁示例无法工作-Arduino Yun

C 最简单的桥梁示例无法工作-Arduino Yun,c,linux,ssh,arduino,arduino-yun,C,Linux,Ssh,Arduino,Arduino Yun,我试图修改arduino-1.5.6-rw/libraries/Bridge/examples/TemperatureWebPanel中关于光传感器的示例。不幸的是,即使是最简单的wifi接收和传输结果也不起作用!我甚至注释掉了工作部件,只将一些文本发送回浏览器,如您所见,但我在浏览器中仍然看不到任何内容: #include <Bridge.h> #include <YunServer.h> #include <YunClient.h> // Listen

我试图修改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中从未看到任何内容,只是一个空白响应


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

在我自己的配置上逐步调试之后,我发现代码从未经过Bridge.begin

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

更改为:Bridge.begin115200。。。为我解决了这个问题

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

有关更多信息,请参阅此链接:


如果这不是你的问题,考虑添加调试信息IE.在Bridge.cpp等的实际源文件中打印Serial.print。不幸的是,Arduino/Linino开发人员似乎经常进行破坏性的更改,并且没有更新文档、示例等的资源。

替换Serial.begin115。。。通过Bridge.begin.

如果您在Windows上,请不要使用“arduino.local”,因为Windows在解决此主机问题时遇到问题。 你试过IP地址了吗? 您必须通过wifi,而不是通过arduino Ide中的串行方式对脚本进行电传转换。您必须更改端口 您是否创建了“arduino/www/”路径

你需要一个微型SD卡插入你的Yún,根目录下有一个名为“arduino”的文件夹。在“arduino”文件夹中,必须有一个名为“www”的目录。您需要通过WiFi上传草图,以传输本地“www”文件夹的内容。您不能通过USB传输文件。上传后,您可以打开喜爱的浏览器并转到


如果您使用的是Yun Shield,则必须打开

,因为网桥和串行端口共享相同的串行硬件,您需要注释掉串行命令或删除对串行的所有引用。我也遇到了同样的问题,没有联系。

while!电视连续剧等待串行端口准备就绪,最好将其保留在中。但我不知道真正的问题是什么。@monty0这不是在等待您打开Arduino IDE的串行控制台吗?是的,但我不知道如果您尝试在串行端口准备就绪并在此基础上扩展之前写入串行端口会发生什么。解释为什么这样做会帮助提问者,否则这是一个美化的评论。