Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Parse and extract Data from pachube on: February 12, 2011, 01:53:46 pm
Dear Zoomkat, thank you for your helpful code..
Firstly I've tested the code and got this result in Serial monitor:
starting simple arduino client test
Code:
connecting...
connected
Current data row:

#YY  MM DD hh mm WDIR WSPD GST  WVHT   DPD   APD MWD   PRES  ATMP  WTMP  DEWP  VIS PTDY  TIDE

DPD sec: PD
done
I think you wanted to extract a number not words which is for you (Column DPD , ROW 14) = 3
I checked the code (view all received data in serial monitor) and found that my get return result has more 3 extra line    
So I added more 3 number by hand to variable x ( 17 instead of 14, which means parse 3 more line) :
  
Code:
 if (x==17) readString += c;  
and got this result :

Code:
starting simple arduino client test

connecting...
connected
Current data row:

2011 02 12 16 50 210  8.0  9.0   0.6     3   2.8  MM 1007.3   3.3   3.5  -6.7   MM -3.4    MM

DPD sec:  3
done

As I understand although your code is very useful but it's may not suitable in situation when return http result may change (like my test)..
Is it true? How would you solve that?
2  Using Arduino / Programming Questions / Re: Parse and extract Data from pachube on: February 12, 2011, 10:58:50 am
Quote
When there is no more data to read, the String object will contain only the last line.
How can I check that there is no more data to read?
(only) by checking  client.available() ?

Quote
The indexOf() and substring() methods will let you extract substrings ("2", "5", "8", and "67").
So, sscanf function is  not useful for this problem?
3  Using Arduino / Programming Questions / Re: Parse and extract Data from pachube on: February 12, 2011, 10:18:47 am
Thank you PaulS for reply..

Quote
How is that data made to appear in the serial monitor?
Actually as you mentioned, this is simply result of printing the characters as they arrive...
 
Code:
if (client.available()) {
    char c = client.read();
    Serial.print(c);
     }

Quote
If you are simply printing the characters as they arrive, parsing the data will be the least of your problems.
So what is my first thing to do? store all received characters in an Array or string object?

Quote
If you are saving all the data in a String object, and then printing it, one method of parsing the data will work better.
Is this a true way :
a) define a string object : 
Code:
String buffer = "";
b) add every characters which received via client.read()  in to it : 
Code:
buffer += c;
Or there is better(true) way?
4  Using Arduino / Programming Questions / Parse and extract Data from pachube on: February 12, 2011, 08:24:29 am
Dear Friends,
I'm using ethernet shield to connect to pachube to retrieve data..
This is serial monitor result after HTTP GET from pachube feed:
Code:
HTTP/1.0 200 OK
Date: Fri, 11 Feb 2011 11:08:06 GMT
Content-Type: text/plain; charset=utf-8
Last-Modified: Tue, 08 Feb 2011 13:56:36 GMT
Vary: Accept-Encoding
Connection: close

2,5,8,67

the total number of lines may change but my desired data is the last line .
I want to store these received data (2,5,8,67) in separate variables...what is the solution for this?
How can I reach to last line which then I can use sscanf to extract data ?
5  Using Arduino / Installation & Troubleshooting / Re: Arduino interface with visual basic on: February 02, 2011, 01:37:13 pm
Hi
http://www.codeproject.com/KB/system/ArduinoVB.aspx
http://www.acraigie.com/programming/firmatavb/
http://www.instructables.com/answers/Can-you-control-an-Arduino-with-Visual-Basic/
http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvb/thread/1c8e1242-c627-4dcf-b1a8-d461fb82d6c7
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1209217094/all
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1290026038
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1276148899
and many other pages which you can find  yourself.. smiley
6  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Calculate execution time(Arduino-Ethernet shield)? on: December 02, 2010, 05:57:34 pm
AWOL :
Quote
 Define 'best'

robtillaart :
Quote
A1: create assembly listing and count the assembly instructions for a function.
A2: communication over ethernet depends on too much factors to be calculated in practice. Use statistics.
Welcome

Thank you robtillaart and AWOL for reply.
In this link there are some info...
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1275488765
but not sure is it ok or not.
Using timer ( mili before after a function )is a normal way?

i want to calculate execution time of my codes (in real time) when arduino directly connected to internet.

for example calculate execution time of specific part of ethernet sample code as you see below (reading received data ...) :


Code:
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10, 0, 0, 177 };
byte server[] = { 64, 233, 187, 99 };

Client client(server, 80);

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);

  delay(1000);

  Serial.println("connecting...");

  if (client.connect()) {
    Serial.println("connected");
    client.println("GET /search?q=arduino HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
 if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
      ;
  }
}


robtillaart , what do u mean by Using statistics?


7  Forum 2005-2010 (read only) / Frequently-Asked Questions / Calculate execution time(Arduino-Ethernet shield)? on: December 02, 2010, 05:14:29 pm
Hello  friends!
1.what is the best way to calculate execution time for each function in arduino?
2.What about ethernet shield?
for example calculate connection time, sending/receiving data...

Thanks
Pages: [1]