Code to load a LPC1114 over tx/rx. I have only tested with a 1114 chip but it should work with other LPC uControllers
Dependencies: DirectoryList MODSERIAL mbed
Fork of ika_shouyu_poppoyaki by
Diff: verification.cpp
- Revision:
- 29:96e28bc1bd99
- Parent:
- 28:689c3880e0e4
- Child:
- 30:e0d7524661ca
--- a/verification.cpp Fri Sep 20 00:40:08 2013 +0000 +++ b/verification.cpp Fri Sep 20 01:48:26 2013 +0000 @@ -8,21 +8,21 @@ #include "error_code.h" -int verify_binary_data( FILE *fp ); -int verify_uucoded_data( FILE *fp ); +int verify_binary_data( FILE *fp, int *transferred_size_p ); +int verify_uucoded_data( FILE *fp, int *transferred_size_p ); void get_binary_from_uucode_str( char *b, int size ); -int verify_flash( FILE *fp, target_param *tpp ) +int verify_flash( FILE *fp, target_param *tpp, int *transferred_size_p ) { if ( tpp->write_type == BINARY ) - return ( verify_binary_data( fp ) ); + return ( verify_binary_data( fp, transferred_size_p ) ); else - return ( verify_uucoded_data( fp ) ); + return ( verify_uucoded_data( fp, transferred_size_p ) ); } -int verify_binary_data( FILE *fp ) +int verify_binary_data( FILE *fp, int *read_size_p ) { char command_str[ STR_BUFF_SIZE ]; int read_size = 0; @@ -34,6 +34,7 @@ unsigned long checksum = 0; unsigned long checksum_count = 0; + fseek( fp, 0, SEEK_SET ); // seek back to beginning of file flash_reading_size = 128; @@ -83,23 +84,20 @@ break; read_size += size; - -// printf( " total %d bytes read\r\n", read_size ); } error_state |= error_flag; - printf( " total %d bytes read\r", read_size ); - printf( " verification result : \"%s\"\r\n", error_flag ? "Fail" : "Pass" ); - free( bf ); free( br ); + *read_size_p = read_size; + return ( error_flag ? ERROR_DATA_DOES_NOT_MATCH : NO_ERROR ); } -int verify_uucoded_data( FILE *fp ) +int verify_uucoded_data( FILE *fp, int *read_size_p ) { char command_str[ STR_BUFF_SIZE ]; int read_size = 0; @@ -147,17 +145,14 @@ break; read_size += size; -// printf( " total %d bytes read\r", read_size ); } error_state |= error_flag; - - printf( " total %d bytes read\r", read_size ); - printf( " verification result : \"%s\"\r\n", error_flag ? "Fail" : "Pass" ); - free( bf ); free( br ); + *read_size_p = read_size; + return ( error_flag ? ERROR_DATA_DOES_NOT_MATCH : NO_ERROR ); }