• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Pobranie ciągu ze strony WWW
#1
Question 
Próbuję pobrać dane ze strony WWW ale mi obcina początkowy ciąg znaków .  Sad


Kod:
....
// file found at server
if(httpCode == HTTP_CODE_OK) {

// get lenght of document (is -1 when Server sends no Content-Length header)
int len = http.getSize();

// create buffer for read
uint8_t buff[128] = { 0 };

// get tcp stream
WiFiClient * stream = http.getStreamPtr();

// read all data from server
while(http.connected() && (len > 0 || len == -1)) {
// get available data size
size_t size = stream->available();
if(size) {
// read up to 128 byte
int c = stream->readBytes(buff, ((size > sizeof(buff)) ? sizeof(buff) : size));
// write it to Serial
USE_SERIAL.write(buff, c);
if(len > 0) {
len -= c;
}
}
delay(1);
for(int x = 0;x < 25;x++){calosc += (char)buff[x]; } // pętla pobierająca ciąg
}
USE_SERIAL.print("[HTTP] connection closed or file end.\n");
}
} else {
printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
}
USE_SERIAL.println(calosc);
delay(6000);
calosc="";
....

Na serial monitorze otrzymuje taki wynik:

Cytat:..... 
[HTTP] connection closed or file end. 

wylacz 


lacz 
.....

A chciałbym aby cały ciąg był wyświetlony tj. 
 
Cytat:..... 
[HTTP] connection closed or file end. 

wylacz 


wylacz 
..... 

Proszę o naprowadzenie co robię nie tak że obcina mi ciąg znaków.
 
Odpowiedź
  


Skocz do:


Przeglądający: 1 gości