Go Down

Topic: HttpClient sketch, crashing after about three cycles. <possible solution> (Read 12743 times) previous topic - next topic

VideoLiam

Hi,

I have been having a play with my Yun and seem to be having an issue with the HttpClient sketch which once running seems to crach after about 3 cycles (sometimes 4 or 5). Basically this seem to happen even when running on my laptop:- windoz7 and main system:Xp connecting to the Yun via USB and monitoring the Yun via the IDE serial monitor (and third party 'Clear terminal' port monitoring softwear).

I have not modified the sketch in any way. It runs, for about 3 cycles, pauses, and then prints the same rubbish, again and again.

Is there a server limit on the file http://arduino.cc/asciilogo.txt ? I'd hate to do a fault finding exercise only to find there is a limit..

I'm also having some problems with USB uploading and the board dropping in and out of the USB system, but I'm going to do more research before deciding that is a problem, but I'll mention it here incase this is relivent.

Oh, yes the Yun is linked to the PC via USB, but it is connected to the internet wireless.
Also a strange one, turn on PC, for 20min. Plug in YUN and leave for 20min (the sketch should be running). start IDE and open serial monitor, skech runs for about 5 cycles and crashes. Close serial monitor leave 10 min and reopen, jiberishs on the monitor repeated every 5 sec. reclose monitor and reopen... repeating jibberish...

Even more tests. I have tried using Cat5  connection only and disabled my wire router and it still crashes. Now its being an unreliable pain in the arse to reactivate the wi-fi.

Any thoughts...

Has anone else manange to let the sketch run for 5 min or more?

Thanks

Liam

federicofissore

It seems like you're having the same issue as tragnutz
http://forum.arduino.cc/index.php?topic=188955.0

Can you do one of the following:
- 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

VideoLiam

Hi Federico,

Sorry it took so long to get back to you tonight, I had an Arduino robotics session at Google Campus London tonight, it felt really cool to be the only geek with a shiny new Yun... Got a few nods.... (Ok bragg over, back to play)

Right before I did any alterations I made sure the Yun was performing as expected, loading on the HttpClient sketch, watching it crash, and load up a blink test sketch to rest the Yun. Load up the HttpClient and watch it crash. All very much as expected and repeated it a few times to ensure things were repeatable...

Downloaded the bridge.ccp and inserted it into the scr directory for the bridge library, after renaming the old one' OLD_bridge.Xpp' for good measure. Resarted the IDE and loaded the HttpClient. Sat and watched for a moments or two.. and it just ran. went and got some biscuits and juice.. it was still running.... So I swapped back to the original Bridge.cpp file, cleared out the old HttpClient sketch with a blink sketch. restart the IDE and load up the HttpClient, and it crashed in the same old way... Swap back the new, restart the IDE and reload the HttpClient sketch, and its running away as I type this. So that must be 10min or so....I'm a slow typist and lousy speller.

That for me pretty much bags it as a defective bridge.cpp file.

Anyone else had the same results?

Liam


AndersJJ


It seems like you're having the same issue as tragnutz
http://forum.arduino.cc/index.php?topic=188955.0

Can you do one of the following:
- 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


I have had the same issue, and tip #2 above does not fix it. Evidently #1 does, but I've not tried it yet.

VideoLiam

Hi Federico,

I did read though the topic #188955, but they didn't seem to reply with any level of success, failure or even if they had given up. So my question was also to the bigger world who are reading in. Hopefully I have given you enough information to be of use. But clearly it is off assistance if others who might have had an issue tried this and found it was a fix as well. After all there could be a lot of people looking to use the Yun, So I guess all the feedback you can get helps :D

Liam

federicofissore

tragnutz said it worked, just as you did. http://forum.arduino.cc/index.php?topic=188955.msg1403190#msg1403190
I'm pretty sure the bug is fixed, at least with the amount of feedback we have received

Thank you very much for spotting, reporting and testing it :) That's exactly what we need to make it better and better :)

mundosimaginados

Same problem with HttpClient sketch and solved with success with new Bridge.cpp.
It works ok for me.


GinVan

Problem not solved:  I found the same issue with the old Bridge.cpp... It would cycle aprox 52 times before hanging on the client.get
I replaced the Bridge.cpp with the new version linked on this forum ... Now it works longer but hangs at aprox 132 cycles each time.

I sure hope this can get resolved ASAP!
This issue may make the board useless for my intended project but I have great hope that a solution is pending.

Update:
I have just tested several more times - the new Bridge.cpp will often go past the pervious 52 cycles... Howver I found now that it will hang on 28 and more or less just as before.
My test is running a cycle with a delay(10000) and fetching a one character page.

federicofissore

GinVan just to be sure, which version of the IDE are you using?
Can you post the sketch you're using?

GinVan

Code: [Select]
// This is a simplified version of the script (stripped of any string parsing, pointers or array issues)
// This program failed/hung a number of times (the last fail was at cycle 126)
// I am using the Bridge.cpp that was linked here in the forum
// Arduino IDE 1.5.5


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

int count;
int command;
int duration;
int zero;
HttpClient client;

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

void loop() {

 Serial.print(count);
 Serial.print(" Fetching posts ");

 client.get("http://..../posts.php");

 Serial.println("| Posts received");

// NOTES:
// This script failed after 126 cycles - after printing the serial output above (fetch and receive)
// Other times it fails before the serial output "Posts received"
// To simply the script - I am not parsing strings
// I simply parseInt (below) - which works great (as long the programs gets to that point)
// The content on the posts.php is changed dynamically
// In this last fail - posts.php was left blank through the full 0 - 125 cycles
// The second call to client.get simply calls a php script to clear text files stored in posts.php
// My hosting provider will not render .txt files
// If two int are saved on the posts.php the program will retreive both in the variables below, followed by a trailing nill (0)

 while (client.available()) {

   command = client.parseInt();
   duration = client.parseInt();
   zero = client.parseInt();

   Serial.println(command);
   Serial.println(duration);

 }

 Serial.flush();
 client.get("http://..../clearposts.php");
 count++;
 delay(10000);

}

PCWorxLA


// This is a simplified version of the script (stripped of any string parsing, pointers or array issues)
// This program failed/hung a number of times (the last fail was at cycle 126)
// I am using the Bridge.cpp that was linked here in the forum
// Arduino IDE 1.5.5
Considering that the 1.5.5 IDE was just released in early December (release notes from Nov.28), I am not sure if it is a good idea to replace the bridge.cpp file with one from a post in October or even earlier...

Ralf

GinVan

hmmm I don't know what to say... this time it ran for 995 cycles - still going.
I am not sure if there was a long delay on any of the cycles... I did not sit to watch.
Perhaps that could be the issue?  I should have put a timer on the reads...

GinVan

This is the fuller code to respond to page content and flash the led ... it stalled at 31 cycles ... and has not resumed after waiting 30 minutes.
I am new to programming in C ... is there any issues that would cause my code to fail randomly...?
The code ran for 18 cycles receiving blank content (as I was not yet updating the page with content) then stalled 14 cycles after receiving actual content of two integer numbers  (plus the trailimg null/0).

Code: [Select]
#include <Bridge.h>
#include <HttpClient.h>

int count;
int command;
int duration;
int zero;
HttpClient client;

void setup() {
 pinMode(13, OUTPUT);
 digitalWrite(13, LOW);
 Bridge.begin();
 Serial.begin(9600);


}
void loop() {
 Serial.print(count);
 Serial.print(" Fetching posts ");

 client.get("http://....../posts.php");
 Serial.println("| Posts received");

 while (client.available()) {
   command = client.parseInt();
   duration = client.parseInt();
   zero = client.parseInt();

   Serial.println(command);
   Serial.println(duration);

   checkcommand(command);

 }
 Serial.flush();
 client.get("http://....../clearposts.php");
 count++;
 delay(10000);
}


int checkcommand(int rc) {
 switch (rc) {
   case 0:
     break;
   case 1:
     break;
   case 2:
     break;
   case 3:
     flash(duration);
     break;
   case 4:
     break;
   case 5:
     break;
     return rc;
 }

}


int flash(int x) {

 Serial.print("Flash LED - number of times: ");
 Serial.println(x);
 for (int lp = 0; lp < x; lp++) {
   Serial.println(lp);
   digitalWrite(13, HIGH);
   delay(300);
   digitalWrite(13, LOW);
   delay(300);

 }
 return x;
}

GinVan

Quote
Considering that the 1.5.5 IDE was just released in early December (release notes from Nov.28), I am not sure if it is a good idea to replace the bridge.cpp file with one from a post in October or even earlier...


Good point Ralf... first day on the forum and in such a hopeful rush to solve the problem I was not observing dates.  Just now I downloaded the NIGHTLY ... which I am guessing contains both the latest IDE and Bridge.cpp

The yun stalled again at 39 cycles of the above code.

Go Up