Ika Shouyu Poppoyaki - LPC82x supported
Fork of ika_shouyu_poppoyaki by
command_interface.cpp
- Committer:
- okano
- Date:
- 2013-09-13
- Revision:
- 22:bd98a782fba6
- Child:
- 26:a63e73885b21
File content as of revision 22:bd98a782fba6:
#include "mbed.h" #include "command_interface.h" #include "serial_utilities.h" #include "ika.h" int try_and_check( char *command, char *expected_return_str, int mode ) { char rtn_str[ STR_BUFF_SIZE ]; int result = 1; print_command( command ); put_string( command ); get_string( rtn_str ); print_result( result = strcmp( expected_return_str, rtn_str ) ); if ( result && !mode ) error( "command failed\r\n" ); error_state |= result; return ( result ); } int try_and_check2( char *command, char *expected_return_str, int mode ) { char rtn_str[ STR_BUFF_SIZE ]; int result = 1; print_command( command ); put_string( command ); get_string( rtn_str ); // just readout echoback get_string( rtn_str ); print_result( result = strcmp( expected_return_str, rtn_str ) ); if ( result && !mode ) error( "command failed\r\n" ); error_state |= result; return ( result ); } void print_command( char *command ) { char s[ STR_BUFF_SIZE ]; char *pos; strcpy( s, command ); if ( pos = strchr( s, '\r' ) ) *pos = '\0'; if ( pos = strchr( s, '\n' ) ) *pos = '\0'; printf( " command-\"%s\" : ", s ); } void print_result( int r ) { printf( "%s\r\n", r ? "Fail" : "Pass" ); } void send_RAM_transfer_checksum( int checksum ) { char command[ 16 ]; sprintf( command, "%d\n", checksum ); try_and_check( command, "OK", 0 ); }