Code help request:
Hello everyone,
I'm trying to modify the classic code used for managing the shots with VC0706 that
are sent via HTTP Post, so that the shot is saved on SD and then sent.
What I wanted to do is send my target file "myFile = SD.open (fileName, FILE_READ);"
but when i have to manage the buffer i don't understand how to replace this part:
uint16_t jpglen = cam.frameLength ();
And
buffer = cam.readPicture (bytesToRead);
the code is always in error because they point to the camera which in theory is not available for the tests and therefore I must necessarily point to the file on SD put on purpose for the tests.
Thanks for your help, here is the part of the code in question:
if (client.connect(serverName, 80)) {
Serial.println("connected");
uint16_t jpglen = cam.frameLength(); // <<<<<<<<<<<<<<
Serial.print("Storing ");
Serial.print(jpglen, DEC);
Serial.print(" byte image.");
uint32_t len = jpglen + 177; // 177 is the content without the image data
....codice tagliato
// Read all the data up to # bytes!
byte wCount = 0; // For counting # of writes
while (jpglen > 0) {
// read 32 bytes at a time;
uint8_t *buffer;
uint8_t bytesToRead = min(32, jpglen); // change 32 to 64 for a speedup but may not work with all setups!
buffer = cam.readPicture(bytesToRead); //<<<<<<<<<<<<<<
//Scrittura
client.write(buffer, bytesToRead);
if (++wCount >= 64) { // Every 2K, give a little feedback so it doesn't appear locked up
Serial.print('.');
wCount = 0;
}
jpglen -= bytesToRead;
}
Thanks JML, in theory because the cam is mounted on MKR1400 board and I'm testing the code on MKR1010 but in both side the file be stored on the SD card. So now using MKR1010 i need to pick up the file from SD and test the code HTTP post.
Let me try to follow your suggestion, I hope to solve my doubt!
if (client.connect(serverName, 80)) {
Serial.println("connected");
uint16_t jpglen = myFile.size();
but note here:
// Read all the data up to # bytes!
byte wCount = 0; // For counting # of writes
while (jpglen > 0) {
// read 32 bytes at a time;
uint8_t *buffer;
uint8_t bytesToRead = min(32, jpglen); // change 32 to 64 for a speedup but may not work with all setups!
buffer = myFile.size(bytesToRead); // <<<<<<<<<<<<<<< error here!
The message is: no matching function for call to 'SDLib::File::size(uint8_t&)'