Go Down

Topic: Behaviour of Serial monitor after a lot of reading loop following shell commands (Read 3728 times) previous topic - next topic

tragnutz

Hi,
I run shell commands and retrieves results in a loop.
It works perfectly a few times then suddenly the answers are totally unreadable.

Responses on the serial console:

Here all is well (loop 1 to 60).

>
          Mode:Managed  Frequency:2.442 GHz  Access Point: 00:27:22:A2:45:2A   
          inet addr:192.168.65.120  Bcast:192.168.65.255  Mask:255.255.255.0
59
>
          Mode:Managed  Frequency:2.442 GHz  Access Point: 00:27:22:A2:45:2A   
          inet addr:192.168.65.120  Bcast:192.168.65.255  Mask:255.255.255.0
60
>
          Mode:Managed  Frequency:2.442 GHz  Access Point: 00:27:22:A2:45:2A   
          inet addr:192.168.65.1          inet addr:192.168.65.1Ö


And after 60 loops, it is unreadable (number of good loops are random).

monitor send something that looks like:  LMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|} (strange response plus some non-printable characters)

Is it a monitor problem, a Yun problem, or a error on my code (Most Probable).

Any ideas or suggestions are welcome.

Thanks in advance.

Charles


My code is as follows, to test it you need to connect your 'Yun' on access point as a client, the code will give you some information about the connection.

//

#include <Process.h>
#include <Bridge.h>
#include <HttpClient.h>

int compteur = 0;

void setup() {
  Serial.begin(115200);  // initialize serial communication
  while(!Serial);      // do nothing until the serial monitor is opened

  Serial.println("Starting bridge...\n");
  pinMode(13,OUTPUT); 
  digitalWrite(13, LOW); 
  Bridge.begin();  // make contact with the linux processor
  digitalWrite(13, HIGH);  // Led on pin 13 turns on when the bridge is ready

  delay(2000);  // wait 2 seconds
}

void loop() {
  Process wifiCheck;  // initialize a new process


  //

  wifiCheck.runShellCommand("iwconfig wlan0  | grep 'Mode' 2>&1");  // command you want to run
delay(500);
  while (wifiCheck.available() > 0) {
    char c = wifiCheck.read();
    Serial.print(c);
  }
  //wifiCheck.runShellCommand("help");  // command you want to run
  wifiCheck.runShellCommand("ifconfig wlan0 | grep 'inet'");  // command you want to run
 
  delay(500);
  while (wifiCheck.available() > 0) {
    char c = wifiCheck.read();
    Serial.print(c);
  }
  ++compteur;
  Serial.println(compteur);
  Serial.println(">");
  delay(1000);

  // while there's any characters coming back from the
  // process, print them to the serial monitor:

}





cmaglie

Thanks for the example that reliably trigger the bug, this one was really hard to track down.

It seems that under certain circumstances the python side of the bridge delays the transmission of data, so I raised a bit the timeout.

https://github.com/arduino/Arduino/commit/ca90bf75cb1e256f728e879dc83d17bf3e02197b

If you want to try the fix, you can change the Bridge.cpp file in your arduino installation, or wait for the next nightly build.
C.

tragnutz

Tested in loop for 2 days without any problem!
Thanks maglie for this quick fix on the Bridge.cpp !


Leonzio

I read this thread only after writing my post on a similar problem that I was facing by simply running the standard Bridge\HttpClient sample.
See "Weird output from Bridge" http://forum.arduino.cc/index.php?topic=189834.0

Now I'm going to get the new Bridge.cpp file and test it to see if it solves the issue.

AndersJJ


Thanks for the example that reliably trigger the bug, this one was really hard to track down.

It seems that under certain circumstances the python side of the bridge delays the transmission of data, so I raised a bit the timeout.

https://github.com/arduino/Arduino/commit/ca90bf75cb1e256f728e879dc83d17bf3e02197b

If you want to try the fix, you can change the Bridge.cpp file in your arduino installation, or wait for the next nightly build.



I found the same issue today, with all code downloaded recently. Do I have to recompile and/or reinstall anything more than the Arduino application?

federicofissore

@AndersJJ you can either:
- replace your copy of Bridge.cpp (located at IDE_FOLDER/libraries/Bridge/src) and replace it with this one
- Download one of the nightly builds of the IDE from http://arduino.cc/en/Main/Software. These are built every day with the latest code available on github

AndersJJ


@AndersJJ you can either:
- replace your copy of Bridge.cpp (located at IDE_FOLDER/libraries/Bridge/src) and replace it with this one
- Download one of the nightly builds of the IDE from http://arduino.cc/en/Main/Software. These are built every day with the latest code available on github


Tip #1 is reported by others to work, but #2 does not.

Go Up