Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // to_receive es el total
- while ((this_read < to_receive) && (Serial.available() > 0)) {
- if (to_receive - this_read < FIO_TX_SIZE) {
- to_read = to_receive - this_read;
- } else {
- to_read = FIO_TX_SIZE;
- }
- read = Serial.readBytes(_buffer, to_read);
- // read es menor que to_read
- _tmp_file.write(_buffer, read);
- this_read += read;
- total_read += read;
- // ahora comienza de vuelta el loop,
- // si no le pido que chequee que no hay mas para leer (Serial.available() > 0)
- // va a intentar leer to_receive - this_read bytes mas, pero como no hay mas para leer ocurre un Timeout
- // Si hago el chequeo, termina el loop y cuando va a chequear si se creo bien el archivo se encuentra con que el tamanio
- // escrito posta es menor de lo que esperaba (to_receive)
- // Entonces me pregunto si tiene sentido completar el tamanio del archivo hasta llegar a to_receive
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement