Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong read length on POST request #49

Closed
Fernando-Castilho opened this issue Aug 4, 2023 · 1 comment
Closed

Wrong read length on POST request #49

Fernando-Castilho opened this issue Aug 4, 2023 · 1 comment

Comments

@Fernando-Castilho
Copy link

Fernando-Castilho commented Aug 4, 2023

Hi, it's me again, first of all, sorry for not texting you back, I was awaiting for my arduino mega, since uno didn't had enough memory to run the code so couldn't test it until yesterday. I think the code is almost done, when my readers are correct (with the println() before the --X-ARDUINO_MULTIPART), it cannot read the fingerprint correctly, every time I get a error of wrong read length: -1, sometimes it says packet to long: 130, but it's rare. I don't know why this is happening, my server responds with unexpected end of file, so I know that at least one chunk of the file is being send. My code is:

uint16_t count = 0;
bool read_finished;
/* indicate the max size to read, and also returns how much was actually read */
uint16_t readlen = TRANSFER_SZ;

client.println("POST /post HTTP/1.1");
client.println("Host: 192.168.1.107");
client.println("Content-Type: multipart/form-data; boundary=X-ARDUINO_MULTIPART");
client.println("Connection: close");
client.println("Content-Length: 36864");
client.println();
client.println("--X-ARDUINO_MULTIPART");

while (true) {
  bool ret = finger.readRaw(FPM_OUTPUT_TO_BUFFER, buffer, &read_finished, &readlen);
  if (ret) {
    count++;
    client.println("Content-Disposition: form-data; name=\"blah.bmp\"");
    client.println("Content-Type: application/octet-stream");
    client.print("Content-Length: ");
    client.println(readlen);
    client.println();
    client.write(buffer, readlen);

    /* indicate the length to be read next time like before */
    readlen = TRANSFER_SZ;
    if (read_finished){
      client.println();
      client.println("--X-ARDUINO_MULTIPART--");
      client.println();
      client.flush();
      break;
    }
    client.println();
    client.println("--X-ARDUINO_MULTIPART");
    client.flush();
  }
  else {
    Serial.print("\r\nError receiving packet ");
    Serial.println(count);
    return;
  }
  yield();
}

I think that could help. My serial monitor messages:

Image taken
Starting image stream...

[+]Wrong chksum: 0x9444
[+]Response timeout

[+]Wrong read length: -1

Error receiving packet 29

Also, thanks a lot for the help, I didn't had any idea of how could I post the image, if I progress sometime, I will notify here.

@brianrho
Copy link
Owner

brianrho commented Aug 4, 2023

It's fine, i re-opened the old issue #48, you can continue this there, I already left a comment.

@brianrho brianrho closed this as completed Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants