Added a 'format' command that formats a CFS Coffee flash file system

This commit is contained in:
adamdunkels 2008-07-02 14:14:37 +00:00
parent da4803e4d4
commit b8820a7d89

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: shell-sky.c,v 1.6 2008/07/02 09:05:40 adamdunkels Exp $
* $Id: shell-sky.c,v 1.7 2008/07/02 14:14:37 adamdunkels Exp $
*/
/**
@ -63,6 +63,11 @@ struct power_msg {
};
/*---------------------------------------------------------------------------*/
PROCESS(shell_format_process, "format");
SHELL_COMMAND(format_command,
"format",
"format: format the flash-based Coffee file system",
&shell_format_process);
PROCESS(shell_sense_process, "sense");
SHELL_COMMAND(sense_command,
"sense",
@ -104,6 +109,29 @@ SHELL_COMMAND(powergraph_command,
"powergraph: convert power profile to a 'graphical' repressentation",
&shell_powergraph_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_format_process, ev, data)
{
struct shell_input *input;
PROCESS_BEGIN();
shell_output_str(&format_command, "format: this command will erase all files. Do you want to format? [y/n]", "");
PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input);
input = data;
if(input->len1 > 0 &&
(input->data1[0] == 'y' || input->data1[0] == 'Y')) {
shell_output_str(&format_command, "format: formatting file system", "");
if(cfs_coffee_format() == 0) {
shell_output_str(&format_command, "format: formatting complete", "");
} else {
shell_output_str(&format_command, "format: formatting failed", "");
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
#define MAX(a, b) ((a) > (b)? (a): (b))
#define MIN(a, b) ((a) < (b)? (a): (b))
struct spectrum {
@ -425,5 +453,6 @@ shell_sky_init(void)
shell_register_command(&rfchannel_command);
shell_register_command(&sense_command);
shell_register_command(&senseconv_command);
shell_register_command(&format_command);
}
/*---------------------------------------------------------------------------*/