-->
Page 1 of 1

Exception 9 with writeToStream

PostPosted: Mon Feb 26, 2018 7:34 am
by WillemR
Hi Guys
I spent the whole day struggling with an Exception 9 when I writeToStream(). This is a method in the HTTPClient library.
I can not see what I am doing wrong.
Maybe someone has some insight.

If I comment out the writeToStream line, there is no exception.

Look forward to hearing from you.


do
{
int httpCode = http.GET();
Serial.print("httpCode : ");
Serial.println(httpCode);
if (httpCode)
{
if (httpCode == 200)
{
String payload = http.getString();
Serial.println(payload);
fileRemain=http.getSize();
Serial.print("getSize : ");
Serial.println(fileRemain);

picFile=SD.open(filePath,FILE_WRITE);
sent=http.writeToStream(&picFile); //<----------------- PROBLEM IS HERE

Serial.print("Bytes: ");
Serial.println(sent);


picFile.close();

if(SD.exists(filePath))
{
Serial.println("File written !!!");
}
else
{
Serial.println("File NOT OK !!!");
}



break;
}
}
// delay(50);
}while(++count<10);





// Serial.println("closing connection");
http.end();
// WiFi.disconnect();
}

Re: Exception 9 with writeToStream

PostPosted: Thu Mar 01, 2018 4:25 pm
by tfry
Did you check whether picFile was opened, successfully? Can you write anything else to it? E.g.:
Code: Select allpicFile.write("test", 4);