OK, I understand. Thanks for the lesson. That was one thing I didn't know.
Your code works perfect. This is de output:
 
test: [0], [0] , [0] , [0]
times: request=3261 / read=0 / calc=0 / print=29
test: [0], [0] , [0] , [0]
times: request=417 / read=0 / calc=0 / print=28
test: [0], [0] , [0] , [0]
times: request=417 / read=0 / calc=0 / print=28
test: [0], [0] , [0] , [0]
times: request=465 / read=0 / calc=0 / print=28
test: [0], [0] , [0] , [0]
times: request=377 / read=0 / calc=0 / print=29
test: [0], [0] , [0] , [0]
times: request=420 / read=0 / calc=0 / print=28
test: [0], [0] , [0] , [0]
times: request=419 / read=0 / calc=0 / print=28
test: [0], [0] , [0] , [0]
times: request=419 / read=0 / calc=0 / print=29
test: [0], [0] , [0] , [0]
times: request=424 / read=0 / calc=0 / print=28
test: [0], [0] , [0] , [0]
times: request=415 / read=0 / calc=0 / print=29
test: [0], [0] , [0] , [0]
times: request=425 / read=0 / calc=0 / print=28
test: [0], [0] , [0] , [0]
times: request=414 / read=0 / calc=0 / print=29
test: [0], [0] , [0] , [0]
times: request=420 / read=0 / calc=0 / print=28
test: [0], [0] , [0] , [0]
times: request=420 / read=0 / calc=0 / print=28
test: [0], [0] , [0] , [0]
times: request=418 / read=0 / calc=0 / print=28
test: [0], [0] , [0] , [0]
times: request=421 / read=0 / calc=0 / print=29
test: [0], [0] , [0] , [0]
times: request=421 / read=0 / calc=0 / print=28
test: [0], [0] , [0] , [0]
times: request=419 / read=0 / calc=0 / print=29
test: [0], [0] , [0] , [0]
times: request=421 / read=0 / calc=0 / print=29
test: [0], [0] , [0] , [0]
times: request=417 / read=0 / calc=0 / print=28
test: [0], [0] , [0] , [0]
times: request=420 / read=0 / calc=1 / print=28
test: [0], [0] , [0] , [0]
times: request=418 / read=0 / calc=0 / print=29
test: [0], [0] , [0] , [0]
times: request=420 / read=0 / calc=0 / print=28
test: [0], [0] , [0] , [0]
times: request=3419 / read=0 / calc=1 / print=28
test: [0], [0] , [0] , [0]
times: request=419 / read=0 / calc=0 / print=28
test: [0], [0] , [0] , [0]
times: request=420 / read=0 / calc=0 / print=28
test: [0], [0] , [0] , [0]
times: request=420 / read=0 / calc=0 / print=29
test: [0], [0] , [0] , [0]
times: request=419 / read=0 / calc=0 / print=28
test: [0], [0] , [0] , [0]
times: request=422 / read=0 / calc=0 / print=29
test: [0], [0] , [0] , [0]
times: request=417 / read=0 / calc=0 / print=28
test: [0], [0] , [0] , [0]
times: request=421 / read=0 / calc=1 / print=28
etc.
You can see that de request time is something about 420 ms, but the first request is more than 3 seconds. Here is it the first request, but sometimes (not often) it is somewhere in de middle at an random time....
I'll take al look at that Ticker and try something. I hope I can do multiple requests in parallel, just like that JavaScript example.
                    
                
Hi,
I have wrote this program:
main.cpp
#include "mbed.h" #include "EthernetNetIf.h" #include "HTTPClient.h" EthernetNetIf eth; HTTPClient http; DigitalOut led1(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); DigitalOut led4(LED4); int main() { printf("Setting up...\r\n"); led1 = true; //state 1 EthernetErr ethErr = eth.setup(); if (ethErr) { printf("Error %d in setup.\r\n", ethErr); return -1; } printf("Setup OK\r\n"); led2 = true; //state 2 HTTPText get_data; string data; int V1, V2, V3, V4; HTTPResult r; led3 = true; //state 3 while (1) { r = http.get("http://10.0.0.151:8080/data.txt", &get_data); if (r==HTTP_OK) { data = get_data.get(); V1 = atoi(data.substr(data.find("rr")+2,2).c_str()); V2 = atoi(data.substr(data.find("rl")+2,2).c_str()); V3 = atoi(data.substr(data.find("ch")+2,2).c_str()); V4 = atoi(data.substr(data.find("cv")+2,2).c_str()); printf("test: [%i], [%i] , [%i] , [%i] \r\n", V1, V2, V3, V4); led3 = !led3; led4 = !led4; //when led 3&4 change, the MBED has checked the values again. } else { printf("Error %d\r\n", r); } } }What this program does, is checking all the time 4 numbers in a file (data.txt) on my server (10.0.0.151:8080). This works excellent, this script does about two checks per second. (I've got two printf-results per second)
Is there any way to do is faster?? (It would be great if its something like 20 per second, but I'm happy if it's something like 10 per second)