Advertisement
Picardian14

Lector de Buffer

Jun 1st, 2022
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. // to_receive es el total
  2. while ((this_read < to_receive) && (Serial.available() > 0)) {
  3.     if (to_receive - this_read < FIO_TX_SIZE) {
  4.         to_read = to_receive - this_read;                    
  5.     } else {
  6.         to_read = FIO_TX_SIZE;
  7.     }                
  8.     read = Serial.readBytes(_buffer, to_read);
  9.     // read es menor que to_read
  10.     _tmp_file.write(_buffer, read);
  11.     this_read += read;
  12.     total_read += read;
  13.     // ahora comienza de vuelta el loop,
  14.     // si no le pido que chequee que no hay mas para leer (Serial.available() > 0)
  15.     // va a intentar leer to_receive - this_read bytes mas, pero como no hay mas para leer ocurre un Timeout
  16.     // Si hago el chequeo, termina el loop y cuando va a chequear si se creo bien el archivo se encuentra con que el tamanio
  17.     // escrito posta es menor de lo que esperaba (to_receive)
  18.     // 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