unsigned short check_sum = get_checksum( possible_command.substr(0,possible_command.find_first_of(" \r\n")) ); // todo: put this method somewhere more convenient
// Act depending on command
- switch( check_sum ){
- case ls_command_checksum : this->ls_command( get_arguments(possible_command), new_message.stream ); break;
- case cd_command_checksum : this->cd_command( get_arguments(possible_command), new_message.stream ); break;
- case pwd_command_checksum : this->pwd_command( get_arguments(possible_command), new_message.stream ); break;
- case cat_command_checksum : this->cat_command( get_arguments(possible_command), new_message.stream ); break;
- case play_command_checksum : this->play_command(get_arguments(possible_command), new_message.stream ); break;
- case reset_command_checksum : this->reset_command(get_arguments(possible_command),new_message.stream ); break;
- case dfu_command_checksum : this->reset_command(get_arguments(possible_command),new_message.stream ); break;
- case break_command_checksum : this->break_command(get_arguments(possible_command),new_message.stream ); break;
- }
+ if (check_sum == ls_command_checksum)
+ this->ls_command( get_arguments(possible_command), new_message.stream );
+ else if (check_sum == cd_command_checksum)
+ this->cd_command( get_arguments(possible_command), new_message.stream );
+ else if (check_sum == pwd_command_checksum)
+ this->pwd_command( get_arguments(possible_command), new_message.stream );
+ else if (check_sum == cat_command_checksum)
+ this->cat_command( get_arguments(possible_command), new_message.stream );
+ else if (check_sum == play_command_checksum)
+ this->play_command(get_arguments(possible_command), new_message.stream );
++ else if (check_sum == break_command_checksum)
++ this->break_command(get_arguments(possible_command),new_message.stream );
+ else if (check_sum == reset_command_checksum)
+ this->reset_command(get_arguments(possible_command),new_message.stream );
+ else if (check_sum == dfu_command_checksum)
+ this->reset_command(get_arguments(possible_command),new_message.stream );
+ else if (check_sum == help_command_checksum)
+ this->help_command(get_arguments(possible_command),new_message.stream );
+ else if (check_sum == progress_command_checksum)
+ this->progress_command(get_arguments(possible_command),new_message.stream );
+ else if (check_sum == abort_command_checksum)
+ this->abort_command(get_arguments(possible_command),new_message.stream );
}
// Convert a path indication ( absolute or relative ) into a path ( absolute )
system_reset();
}
+// Break out into the MRI debugging system
+void SimpleShell::break_command( string parameters, StreamOutput* stream){
+ stream->printf("Entering MRI debug mode...\r\n");
+ __debugbreak();
+}
+
+ void SimpleShell::help_command( string parameters, StreamOutput* stream ){
+ stream->printf("Commands:\r\n");
+ stream->printf("ls [folder]\r\n");
+ stream->printf("cd folder\r\n");
+ stream->printf("pwd\r\n");
+ stream->printf("cat file [limit]\r\n");
+ stream->printf("play file [-q]\r\n");
+ stream->printf("progress\r\n");
+ stream->printf("abort\r\n");
+ stream->printf("reset\r\n");
+ stream->printf("config-get [<configuration_source>] <configuration_setting>\r\n");
+ stream->printf("config-set [<configuration_source>] <configuration_setting> <value>\r\n");
+ stream->printf("config-load [<file_name>]\r\n");
+ }
+
void SimpleShell::on_main_loop(void* argument){
if( this->playing_file ){
#include "libs/StreamOutput.h"
- #define ls_command_checksum 19679
- #define cd_command_checksum 11207
- #define pwd_command_checksum 42060
- #define cat_command_checksum 24889
- #define play_command_checksum 17335
- #define reset_command_checksum 27429
- #define dfu_command_checksum 28480
- #define break_command_checksum 5127
+ #define ls_command_checksum CHECKSUM("ls")
+ #define cd_command_checksum CHECKSUM("cd")
+ #define pwd_command_checksum CHECKSUM("pwd")
+ #define cat_command_checksum CHECKSUM("cat")
+ #define play_command_checksum CHECKSUM("play")
+ #define progress_command_checksum CHECKSUM("progress")
+ #define abort_command_checksum CHECKSUM("abort")
+ #define reset_command_checksum CHECKSUM("reset")
+ #define dfu_command_checksum CHECKSUM("dfu")
++#define break_command_checksum CHECKSUM("break")
+ #define help_command_checksum CHECKSUM("help")
class SimpleShell : public Module {
public:
void pwd_command( string parameters, StreamOutput* stream );
void cat_command( string parameters, StreamOutput* stream );
void play_command( string parameters, StreamOutput* stream );
- void reset_command(string parameters, StreamOutput* stream );
+ void progress_command( string parameters, StreamOutput* stream );
+ void abort_command( string parameters, StreamOutput* stream );
+ void break_command(string parameters, StreamOutput* stream );
-
+ void reset_command(string parameters, StreamOutput* stream );
+ void help_command(string parameters, StreamOutput* stream );
+
+ private:
string current_path;
- bool playing_file;
+ bool playing_file;
+
StreamOutput* current_stream;
- FILE* current_file_handler;
+ FILE* current_file_handler;
+ long file_size, played_cnt;
};