#include "version.h"
#include "PublicDataRequest.h"
#include "FileStream.h"
+#include "checksumm.h"
+#include "PublicData.h"
+#include "Gcode.h"
+
+#include "SimpleShell.h"
#include "modules/tools/temperaturecontrol/TemperatureControlPublicAccess.h"
#include "modules/robot/RobotPublicAccess.h"
#include "NetworkPublicAccess.h"
#include "platform_memory.h"
+#include "system_LPC17xx.h"
+#include "LPC17xx.h"
+
extern unsigned int g_maximumHeapAddress;
#include <malloc.h>
void SimpleShell::on_module_loaded()
{
- this->current_path = "/";
this->register_for_event(ON_CONSOLE_LINE_RECEIVED);
this->register_for_event(ON_GCODE_RECEIVED);
this->register_for_event(ON_SECOND_TICK);
parse_command(check_sum, get_arguments(possible_command), new_message.stream);
}
-// Convert a path indication ( absolute or relative ) into a path ( absolute )
-string SimpleShell::absolute_from_relative( string path )
-{
- if ( path[0] == '/' ) {
- return path;
- }
- if ( path[0] == '.' ) {
- return this->current_path;
- }
- return this->current_path + path;
-}
-
// Act upon an ls command
// Convert the first parameter into an absolute path, then list the files in that path
void SimpleShell::ls_command( string parameters, StreamOutput *stream )
{
- string folder = this->absolute_from_relative( parameters );
+ string folder = absolute_from_relative( parameters );
DIR *d;
struct dirent *p;
d = opendir(folder.c_str());
// Delete a file
void SimpleShell::rm_command( string parameters, StreamOutput *stream )
{
- const char *fn= this->absolute_from_relative(shift_parameter( parameters )).c_str();
+ const char *fn= absolute_from_relative(shift_parameter( parameters )).c_str();
int s = remove(fn);
if (s != 0) stream->printf("Could not delete %s \r\n", fn);
}
// Change current absolute path to provided path
void SimpleShell::cd_command( string parameters, StreamOutput *stream )
{
- string folder = this->absolute_from_relative( parameters );
- if ( folder[folder.length() - 1] != '/' ) {
- folder += "/";
- }
+ string folder = absolute_from_relative( parameters );
+
DIR *d;
d = opendir(folder.c_str());
if (d == NULL) {
stream->printf("Could not open directory %s \r\n", folder.c_str() );
} else {
- this->current_path = folder;
+ THEKERNEL->current_path = folder;
closedir(d);
}
}
// Responds with the present working directory
void SimpleShell::pwd_command( string parameters, StreamOutput *stream )
{
- stream->printf("%s\r\n", this->current_path.c_str());
+ stream->printf("%s\r\n", THEKERNEL->current_path.c_str());
}
// Output the contents of a file, first parameter is the filename, second is the limit ( in number of lines to output )
void SimpleShell::cat_command( string parameters, StreamOutput *stream )
{
// Get parameters ( filename and line limit )
- string filename = this->absolute_from_relative(shift_parameter( parameters ));
+ string filename = absolute_from_relative(shift_parameter( parameters ));
string limit_paramater = shift_parameter( parameters );
int limit = -1;
if ( limit_paramater != "" ) {
void SimpleShell::load_command( string parameters, StreamOutput *stream )
{
// Get parameters ( filename )
- string filename = this->absolute_from_relative(parameters);
+ string filename = absolute_from_relative(parameters);
if(filename == "/") {
filename = THEKERNEL->config_override_filename();
}
void SimpleShell::save_command( string parameters, StreamOutput *stream )
{
// Get parameters ( filename )
- string filename = this->absolute_from_relative(parameters);
+ string filename = absolute_from_relative(parameters);
if(filename == "/") {
filename = THEKERNEL->config_override_filename();
}