For one of my projects, we needed a little more data handling w/large data files (some more than 10mb). In main.c, just under the “read” module, we added the following code for a simple handshake after each full text line:
else if(strncmp_P(command_arg, PSTR(“rdlin”), 5) == 0) // ijt 7-22-2010
{
//Argument 2: File name
command_arg = get_cmd_arg(1);
if(command_arg == 0)
continue;
/* search file in current directory and open it */
struct fat_file_struct* fd = open_file_in_dir(fs, dd, command_arg);
if(!fd)
{
uart_puts_p(PSTR("error opening "));
uart_puts(command_arg);
uart_putc(‘\n’);
continue;
}
uint32_t chunk_to_read = (uint32_t)-1;
/* print file contents, 1 line at a time. */
uint8_t buffer;
while((fat_read_file(fd, &buffer, 1) > 0) && (chunk_to_read > 0))
{
if( buffer >= ’ ’ && buffer < 127 )
uart_putc(buffer);
else if (buffer == ‘\n’)
{
uart_putc(buffer);
if (uart_getc() == 0x1b)
break; // ESCAPE = cancel read
}
chunk_to_read–;
}
uart_putc(0x1A); // ctrl Z
uart_putc(‘\n’);
fat_close_file(fd);
}
As you can see, it would be easy to add ‘repeat’ previous line, add chksum, etc.
Nice work on the main app Nathan!
Jack