Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

RESTDuino hangs when reading analog values #1

Closed
jeroavf opened this Issue · 11 comments

7 participants

@jeroavf

Hi ,
I made a shell script that reads the analog pin 0 constantly with a delay of 10 seconds, using the curl command.
After the third reading , the arduino hangs out and the program only returns to function if I reset the arduino.
The same thing does not happen if I use a script that switches a led, on and off, with the same frequency.
I am using the following script on a MAC OSX 10.6:
while true
do
curl http://192.169.1.201/a0
sleep 10
done

Is there a minimum delay between readings ?
Thanks in advance

@darcysabatino

I noticed similar behavior, and it seems to be some kind of memory issue with the Arduino. I improved the performance by doing the following:

-moving most of the String variable declarations to the beginning of the loop() function (rather than having them re-declared in the body of the loop() function)
-reducing the BUFSIZE to something like 30
-changing the URL buffer read-in code block to:

// fill url the buffer
if(c != '\n' && c != '\r'){
if(index < BUFSIZE) {
clientline[index] = c;
index++;
}

-also, in the "assemble the json output" block, I changed the first line FROM
jsonOut += "{\"";
TO
jsonOut = "{\"";

-and finally, I set the delay at the end of the loop() function to
delay(100)

I'm really not sure exactly what step caused the improvement, but it seems to behave with a lot more stability now. Hope this helps...

UPDATE:
After further testing, it still is not reliable in Analog Read mode. The Arduino hangs every once in a while and I'm not sure where. My above comments did make the Digital Read and Digital Write methods more reliable, just not Analog... odd.

@jjg
Owner

Sorry for the delay guys, I'm still getting the hang of github...

Yes offhand I'm not sure what might be causing this but when I get a chance I'll setup the test you described and see if I can observe similar behavior. I'm using an Uno for my testing, out of curiosity is this the unit you're seeing the problem with?

Thanks!

@jeroavf

I have tested with an Arduino DuemilaNove and with a home built Severino and found the same glitches.
Regards,

@sirleech
Collaborator

Hmm I wonder if this is the same bug as #3. I've had reliability issues as well.

@EdwardMGoldberg

Please see the new version that "opts out" the Serial code.

With the Serial lines all removed the service is very fast and keeps up for me.

The issue is that the Serial at 9600 BAUD is VERY SLOW..... Nice for the DEBUG stage.

Please review the code and remove all Serial lines. I just provided a "#ifdef DEBUG" version for the project.

Please call any time:
Cell:     916-202-1600
Skype:  EdwardMGoldberg

Edward M. Goldberg
http://myCloudWatcher.com/
e.m.g.

@sirleech
Collaborator

I've pulled Edward's changes into the 'dev' branch of jjg/RESTduino. Let's give it a test! Please report back with your results when sending analogue reads (quickly) to the Arduino + Ethernet.

@betz

I am still experiencing this issue

@wiesson

Same issue here. If i hit [cmd]+r in my Browser to fast the Arduino will hang up and i have to restart it. I think it is okay to have some small dalay between the measurements but it should not kill the arduino ;)

@jjg
Owner

Finally getting a chance to debug this!

I created a simple js that reads A0 every 5 sec after about 30-60sec it stops responding. Interestingly enough the board still responds to pings in this condition.

@jjg jjg referenced this issue from a commit
@jjg Issue #1 - added client session check to client teardown step to prev…
…ent connection count from growing.
69045bb
@jjg
Owner

Alright I think I have this one fixed.

I added a check to the end of the sketch to wait until the client connection is closed. The reason this helps is that apparently the board can only handle 4 connections at once, after that, kabloowie!

More information can be found here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1235991468

Anyway I'm now able to pull analog data from the board much faster w/o crashing it. I've only tested it for awhile though so let me know if the problem crops back up (or if there are other side-effects :)

@jjg jjg closed this
@wiesson

Thank you! i've pushed the "curl-command" from the first post to the 6 analog ports (a0-a5) and i've written HIGH/LOW to all the LED ports with another simple bash. The Arduino becomes very slow from times to times but it still works with no error. Looks good!

#!/bin/bash

set schlummern=0.01

while True; 
do
curl http://192.168.3.4/9/HIGH; 
sleep schlummern;
curl http://192.168.3.4/9/LOW; 
sleep schlummern;
curl http://192.168.3.4/8/HIGH; 
sleep schlummern;
curl http://192.168.3.4/8/LOW; 
sleep schlummern;
curl http://192.168.3.4/7/HIGH; 
sleep schlummern;
curl http://192.168.3.4/7/LOW; 
sleep schlummern;
curl http://192.168.3.4/6/HIGH; 
sleep schlummern;
curl http://192.168.3.4/6/LOW; 
sleep schlummern;
curl http://192.168.3.4/5/HIGH; 
sleep schlummern;
curl http://192.168.3.4/5/LOW; 
sleep schlummern;
curl http://192.168.3.4/4/HIGH; 
sleep schlummern;
curl http://192.168.3.4/4/LOW; 
sleep schlummern;
curl http://192.168.3.4/3/HIGH; 
sleep schlummern;
curl http://192.168.3.4/3/LOW; 
sleep schlummern;
curl http://192.168.3.4/2/HIGH; 
sleep schlummern;
curl http://192.168.3.4/2/LOW; 
sleep schlummern;

done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.