#include "config.h"
#include "modules/file_system/fs_com.h"
Go to the source code of this file.
Shell Commands | |
#define | CMD_NONE 0x00 |
#define | CMD_NB_DRIVE 0x01 |
#define | CMD_DF 0x02 |
#define | CMD_FORMAT 0x03 |
#define | CMD_MOUNT 0x04 |
#define | CMD_SPACE 0x05 |
#define | CMD_LS 0x06 |
#define | CMD_LS_MORE 0x07 |
#define | CMD_CD 0x08 |
#define | CMD_UP 0x09 |
#define | CMD_CAT 0x0A |
#define | CMD_CAT_MORE 0x0B |
#define | CMD_HELP 0x0C |
#define | CMD_MKDIR 0x0D |
#define | CMD_TOUCH 0x0E |
#define | CMD_RM 0x0F |
#define | CMD_APPEND 0x10 |
#define | CMD_SET_ID 0x11 |
#define | CMD_GOTO_ID 0x12 |
#define | CMD_CP 0x13 |
#define | CMD_MV 0x14 |
#define | CMD_SYNC 0x15 |
#define | CMD_PERFORM 0x16 |
#define | CMD_REBOOT 0x17 |
#define | CMD_LS_USB 0x18 |
#define | CMD_USB_SUSPEND 0x19 |
#define | CMD_USB_RESUME 0x1A |
#define | CMD_USB_FORCE_ENUM 0x1B |
#define | CMD_DFU_ERASE 0x1C |
#define | CMD_DFU_LOAD 0x1D |
#define | CMD_DFU_START 0x1E |
#define | CMD_HID_ENTER_DFU 0x1F |
#define | CMD_HID_GET_INFO 0x20 |
#define | STR_DISK "disk" |
#define | STR_DF "df" |
#define | STR_FORMAT "format" |
#define | STR_MOUNT "mount" |
#define | STR_SPACE "space" |
#define | STR_LS "ls" |
#define | STR_LS_MORE "ls|more" |
#define | STR_CD "cd" |
#define | STR_UP "cd.." |
#define | STR_CAT "cat" |
#define | STR_CAT_MORE "cat|more" |
#define | STR_HELP "help" |
#define | STR_MKDIR "mkdir" |
#define | STR_TOUCH "touch" |
#define | STR_RM "rm" |
#define | STR_APPEND "append" |
#define | STR_MARK "mark" |
#define | STR_GOTO "goto" |
#define | STR_CP "cp" |
#define | STR_MV "mv" |
#define | STR_SYNC "sync" |
#define | STR_PERFORM "perf" |
#define | STR_REBOOT "reboot" |
#define | STR_LS_USB "lsusb" |
#define | STR_USB_SUSPEND "suspend" |
#define | STR_USB_RESUME "resume" |
#define | STR_USB_FORCE_ENUM "enumerate" |
#define | STR_DFU_ERASE "dfu_erase" |
#define | STR_DFU_LOAD "dfu_prog" |
#define | STR_DFU_START "dfu_start" |
#define | STR_HID_GET_INFO "hid_get" |
#define | STR_HID_ENTER_DFU "hid_dfu" |
#define | MSG_PROMPT "$>" |
#define | MSG_WELCOME |
#define | MSG_EXIT |
#define | MSG_ER_CMD_NOT_FOUND "Command not found\r\n" |
#define | MSG_ER_MOUNT "Unable to mount drive\r\n" |
#define | MSG_ER_DRIVE "Drive does not exist\r\n" |
#define | MSG_ER_RM "Can not erase, if the name is a directory, check it is empty\r\n" |
#define | MSG_ER_UNKNOWN_FILE "Unknown file\r\n" |
#define | MSG_ER_FORMAT "Format fails\r\n" |
#define | MSG_APPEND_WELCOME "\r\nSimple text editor, enter char to append, ^q to exit and save\r\n" |
#define | MSG_HELP |
#define | MSG_NO_DEVICE "Not currently applicable to supported connected device(s) if any\r\n" |
#define | MSG_REMOTE_WAKEUP_OK "Device supports remote wake-up\r\n" |
#define | MSG_REMOTE_WAKEUP_KO "Device does not support remote wake-up\r\n" |
#define | MSG_SELF_POWERED "Device is self-powered\r\n" |
#define | MSG_BUS_POWERED "Device is bus-powered\r\n" |
#define | MSG_USB_SUSPENDED "USB is suspended!\r\n" |
#define | MSG_OK "ok\r\n" |
#define | MSG_KO "FAIL\r\n" |
#define | MSG_DEVICE_FULL_SPEED "Device is full-speed\r\n" |
#define | MSG_DEVICE_LOW_SPEED "Device is low-speed\r\n" |
#define | MSG_ER_PASTE "Paste Fail\r\n" |
void | ushell_task_init (void) |
void | ushell_task (void) |
Defines | |
Specific ASCII Values | |
#define | ASCII_CR '\r' |
#define | ASCII_LF '\n' |
#define | ASCII_BKSPACE '\b' |
#define | ASCII_ESCAPE 0x1B |
#define | ASCII_CTRL_Q 0x11 |
#define | ASCII_CTRL_C 0x03 |
Definition in file ushell_task.h.
#define ASCII_CR '\r' |
Definition at line 58 of file ushell_task.h.
Referenced by ushell_cmd_append_file(), ushell_cmd_cat(), ushell_cmd_nb_drive(), ushell_cmd_scan(), and ushell_cmdusb_ls().
#define ASCII_LF '\n' |
Definition at line 59 of file ushell_task.h.
Referenced by ushell_cmd_append_file(), ushell_cmd_cat(), ushell_cmd_nb_drive(), ushell_cmd_scan(), and ushell_cmdusb_ls().
#define ASCII_BKSPACE '\b' |
Definition at line 60 of file ushell_task.h.
Referenced by ushell_clean_cmd_line(), and ushell_cmd_scan().
#define ASCII_ESCAPE 0x1B |
#define ASCII_CTRL_Q 0x11 |
#define ASCII_CTRL_C 0x03 |
Definition at line 63 of file ushell_task.h.
#define CMD_NONE 0x00 |
#define CMD_NB_DRIVE 0x01 |
#define CMD_DF 0x02 |
#define CMD_FORMAT 0x03 |
#define CMD_MOUNT 0x04 |
#define CMD_SPACE 0x05 |
#define CMD_LS 0x06 |
#define CMD_LS_MORE 0x07 |
#define CMD_CD 0x08 |
#define CMD_UP 0x09 |
#define CMD_CAT 0x0A |
#define CMD_CAT_MORE 0x0B |
#define CMD_HELP 0x0C |
#define CMD_MKDIR 0x0D |
#define CMD_TOUCH 0x0E |
#define CMD_RM 0x0F |
#define CMD_APPEND 0x10 |
#define CMD_SET_ID 0x11 |
#define CMD_GOTO_ID 0x12 |
#define CMD_CP 0x13 |
#define CMD_MV 0x14 |
#define CMD_SYNC 0x15 |
#define CMD_PERFORM 0x16 |
#define CMD_REBOOT 0x17 |
#define CMD_LS_USB 0x18 |
#define CMD_USB_SUSPEND 0x19 |
#define CMD_USB_RESUME 0x1A |
#define CMD_USB_FORCE_ENUM 0x1B |
#define CMD_DFU_ERASE 0x1C |
#define CMD_DFU_LOAD 0x1D |
#define CMD_DFU_START 0x1E |
#define CMD_HID_ENTER_DFU 0x1F |
#define CMD_HID_GET_INFO 0x20 |
#define STR_DISK "disk" |
Definition at line 109 of file ushell_task.h.
#define STR_DF "df" |
Definition at line 110 of file ushell_task.h.
#define STR_FORMAT "format" |
Definition at line 111 of file ushell_task.h.
#define STR_MOUNT "mount" |
Definition at line 112 of file ushell_task.h.
#define STR_SPACE "space" |
Definition at line 113 of file ushell_task.h.
#define STR_LS "ls" |
Definition at line 114 of file ushell_task.h.
#define STR_LS_MORE "ls|more" |
Definition at line 115 of file ushell_task.h.
#define STR_CD "cd" |
Definition at line 116 of file ushell_task.h.
#define STR_UP "cd.." |
Definition at line 117 of file ushell_task.h.
#define STR_CAT "cat" |
Definition at line 118 of file ushell_task.h.
#define STR_CAT_MORE "cat|more" |
Definition at line 119 of file ushell_task.h.
#define STR_HELP "help" |
Definition at line 120 of file ushell_task.h.
#define STR_MKDIR "mkdir" |
Definition at line 121 of file ushell_task.h.
#define STR_TOUCH "touch" |
Definition at line 122 of file ushell_task.h.
#define STR_RM "rm" |
Definition at line 123 of file ushell_task.h.
#define STR_APPEND "append" |
Definition at line 124 of file ushell_task.h.
#define STR_MARK "mark" |
Definition at line 125 of file ushell_task.h.
#define STR_GOTO "goto" |
Definition at line 126 of file ushell_task.h.
#define STR_CP "cp" |
Definition at line 127 of file ushell_task.h.
#define STR_MV "mv" |
Definition at line 128 of file ushell_task.h.
#define STR_SYNC "sync" |
Definition at line 129 of file ushell_task.h.
#define STR_PERFORM "perf" |
Definition at line 130 of file ushell_task.h.
#define STR_REBOOT "reboot" |
Definition at line 131 of file ushell_task.h.
#define STR_LS_USB "lsusb" |
Definition at line 133 of file ushell_task.h.
#define STR_USB_SUSPEND "suspend" |
Definition at line 134 of file ushell_task.h.
#define STR_USB_RESUME "resume" |
Definition at line 135 of file ushell_task.h.
#define STR_USB_FORCE_ENUM "enumerate" |
Definition at line 136 of file ushell_task.h.
#define STR_DFU_ERASE "dfu_erase" |
Definition at line 138 of file ushell_task.h.
#define STR_DFU_LOAD "dfu_prog" |
Definition at line 139 of file ushell_task.h.
#define STR_DFU_START "dfu_start" |
Definition at line 140 of file ushell_task.h.
#define STR_HID_GET_INFO "hid_get" |
Definition at line 142 of file ushell_task.h.
#define STR_HID_ENTER_DFU "hid_dfu" |
Definition at line 143 of file ushell_task.h.
#define MSG_PROMPT "$>" |
Definition at line 146 of file ushell_task.h.
#define MSG_WELCOME |
Value:
"\x0C" \ "--------------------------\r\n" \ " ATMEL AVR uShell\r\n" \ "--------------------------\r\n"
Definition at line 147 of file ushell_task.h.
#define MSG_EXIT |
Value:
"\x0C" \ "------------------------\r\n" \ "uShell not available\r\n" \ "------------------------\r\n"
Definition at line 151 of file ushell_task.h.
#define MSG_ER_CMD_NOT_FOUND "Command not found\r\n" |
Definition at line 155 of file ushell_task.h.
#define MSG_ER_MOUNT "Unable to mount drive\r\n" |
Definition at line 156 of file ushell_task.h.
#define MSG_ER_DRIVE "Drive does not exist\r\n" |
Definition at line 157 of file ushell_task.h.
#define MSG_ER_RM "Can not erase, if the name is a directory, check it is empty\r\n" |
Definition at line 158 of file ushell_task.h.
#define MSG_ER_UNKNOWN_FILE "Unknown file\r\n" |
Definition at line 159 of file ushell_task.h.
#define MSG_ER_FORMAT "Format fails\r\n" |
Definition at line 160 of file ushell_task.h.
#define MSG_APPEND_WELCOME "\r\nSimple text editor, enter char to append, ^q to exit and save\r\n" |
Definition at line 161 of file ushell_task.h.
#define MSG_HELP |
Definition at line 162 of file ushell_task.h.
#define MSG_NO_DEVICE "Not currently applicable to supported connected device(s) if any\r\n" |
Definition at line 200 of file ushell_task.h.
#define MSG_REMOTE_WAKEUP_OK "Device supports remote wake-up\r\n" |
Definition at line 201 of file ushell_task.h.
#define MSG_REMOTE_WAKEUP_KO "Device does not support remote wake-up\r\n" |
Definition at line 202 of file ushell_task.h.
#define MSG_SELF_POWERED "Device is self-powered\r\n" |
Definition at line 203 of file ushell_task.h.
#define MSG_BUS_POWERED "Device is bus-powered\r\n" |
Definition at line 204 of file ushell_task.h.
#define MSG_USB_SUSPENDED "USB is suspended!\r\n" |
Definition at line 205 of file ushell_task.h.
#define MSG_OK "ok\r\n" |
Definition at line 206 of file ushell_task.h.
#define MSG_KO "FAIL\r\n" |
Definition at line 207 of file ushell_task.h.
#define MSG_DEVICE_FULL_SPEED "Device is full-speed\r\n" |
Definition at line 208 of file ushell_task.h.
#define MSG_DEVICE_LOW_SPEED "Device is low-speed\r\n" |
Definition at line 209 of file ushell_task.h.
#define MSG_ER_PASTE "Paste Fail\r\n" |
Definition at line 210 of file ushell_task.h.
void ushell_task_init | ( | void | ) |
This function initializes the hardware/software ressources required for ushell task.
Definition at line 272 of file ushell_task.c.
References FALSE, g_b_ushell_task_run, g_s_cmd_his, rf_task_init(), uart_init(), ushell_get_char, USHELL_HISTORY, and ushell_putchar.
00273 { 00274 U8 u8_i; 00275 #if (USHELL_RF==ENABLE) 00276 rf_task_init(); 00277 #else 00278 uart_init(); 00279 #endif 00280 00281 #ifdef __GNUC__ 00282 fdevopen((int (*)(char, FILE*))(ushell_putchar),(int (*)(FILE*))ushell_get_char); //for printf redirection 00283 #endif 00284 g_b_ushell_task_run = FALSE; 00285 for( u8_i=0; u8_i<USHELL_HISTORY; u8_i++ ) { 00286 g_s_cmd_his[u8_i][0] = 0; // Set end of line for all cmd line history 00287 } 00288 00289 }
void ushell_task | ( | void | ) |
Entry point of the explorer task management This function performs ushell task decoding to access file system functions.
Definition at line 296 of file ushell_task.c.
References CMD_APPEND, CMD_CAT, CMD_CAT_MORE, CMD_CD, CMD_CP, CMD_DF, CMD_DFU_ERASE, CMD_DFU_LOAD, CMD_DFU_START, CMD_FORMAT, CMD_GOTO_ID, CMD_HELP, CMD_HID_ENTER_DFU, CMD_HID_GET_INFO, CMD_LS, CMD_LS_MORE, CMD_LS_USB, CMD_MKDIR, CMD_MOUNT, CMD_MV, CMD_NB_DRIVE, CMD_PERFORM, CMD_REBOOT, CMD_RM, CMD_SET_ID, CMD_SPACE, CMD_SYNC, CMD_TOUCH, CMD_UP, CMD_USB_FORCE_ENUM, CMD_USB_RESUME, CMD_USB_SUSPEND, FALSE, FS_NAV_ID_USHELL_CMD, g_b_ushell_task_run, Is_usb_id_device, msg_er_cmd_not_found, msg_exit, msg_prompt, msg_welcome, nav_exit(), nav_getindex(), nav_gotoindex(), nav_reset(), nav_select(), print_msg(), TRUE, ushell_cmd_append_file(), ushell_cmd_cat(), ushell_cmd_cd(), ushell_cmd_copy(), ushell_cmd_decode(), ushell_cmd_format(), ushell_cmd_free_space(), ushell_cmd_gotoparent(), ushell_cmd_help(), ushell_cmd_ls(), ushell_cmd_mkdir(), ushell_cmd_mount(), ushell_cmd_nb_drive(), ushell_cmd_perform(), ushell_cmd_reboot(), ushell_cmd_rename(), ushell_cmd_rm(), ushell_cmd_scan(), ushell_cmd_space(), ushell_cmd_sync(), ushell_cmd_touch(), ushell_cmddfu_erase(), ushell_cmddfu_load(), ushell_cmddfu_start(), ushell_cmdhid_enter_dfu(), ushell_cmdhid_getinfo(), ushell_cmdusb_force_enum(), ushell_cmdusb_ls(), ushell_cmdusb_resume(), and ushell_cmdusb_suspend().
00297 { 00298 //** Check the USB mode and autorize/unautorize ushell 00299 if(!g_b_ushell_task_run) 00300 { 00301 if( Is_usb_id_device() ) 00302 return; 00303 g_b_ushell_task_run = TRUE; 00304 print_msg((U8 code *)msg_welcome); 00305 ushell_cmd_nb_drive(); 00306 print_msg((U8 code *)msg_prompt); 00307 // Reset the embedded FS on ushell navigator and on first drive 00308 nav_reset(); 00309 nav_select( FS_NAV_ID_USHELL_CMD ); 00310 }else{ 00311 if( Is_usb_id_device() ) 00312 { 00313 g_b_ushell_task_run = FALSE; 00314 print_msg((U8 code *)msg_exit); 00315 nav_exit(); 00316 return; 00317 } 00318 } 00319 00320 if( !ushell_cmd_scan() ) 00321 return; 00322 00323 //** Command ready then decode and execute this one 00324 switch( ushell_cmd_decode() ) 00325 { 00326 // Displays number of drives 00327 case CMD_NB_DRIVE: 00328 ushell_cmd_nb_drive(); 00329 break; 00330 00331 // Displays free space information for all connected drives 00332 case CMD_DF: 00333 ushell_cmd_free_space(); 00334 break; 00335 00336 // Formats disk 00337 case CMD_FORMAT: 00338 ushell_cmd_format(); 00339 break; 00340 00341 // Mounts a drive (e.g. "b:") 00342 case CMD_MOUNT: 00343 ushell_cmd_mount(); 00344 break; 00345 00346 // Displays the space information for current drive 00347 case CMD_SPACE: 00348 ushell_cmd_space(); 00349 break; 00350 00351 // Lists the files present in current directory (e.g. "ls") 00352 case CMD_LS: 00353 ushell_cmd_ls(FALSE); 00354 break; 00355 case CMD_LS_MORE: 00356 ushell_cmd_ls(TRUE); 00357 break; 00358 00359 // Enters in a directory (e.g. "cd folder_toto") 00360 case CMD_CD: 00361 ushell_cmd_cd(); 00362 break; 00363 00364 // Enters in parent directory ("cd..") 00365 case CMD_UP: 00366 ushell_cmd_gotoparent(); 00367 break; 00368 00369 // Displays a text file 00370 case CMD_CAT: 00371 ushell_cmd_cat(FALSE); 00372 break; 00373 case CMD_CAT_MORE: 00374 ushell_cmd_cat(TRUE); 00375 break; 00376 00377 // Displays the help 00378 case CMD_HELP: 00379 ushell_cmd_help(); 00380 break; 00381 00382 // Creates directory 00383 case CMD_MKDIR: 00384 ushell_cmd_mkdir(); 00385 break; 00386 00387 // Creates file 00388 case CMD_TOUCH: 00389 ushell_cmd_touch(); 00390 break; 00391 00392 // Deletes files or directories 00393 case CMD_RM: 00394 ushell_cmd_rm(); 00395 break; 00396 00397 // Appends char to selected file 00398 case CMD_APPEND: 00399 ushell_cmd_append_file(); 00400 break; 00401 00402 // Index routines (= specific shortcut from ATMEL FileSystem) 00403 case CMD_SET_ID: 00404 g_mark_index = nav_getindex(); 00405 break; 00406 case CMD_GOTO_ID: 00407 nav_gotoindex( &g_mark_index ); 00408 break; 00409 00410 // Copys file to other location 00411 case CMD_CP: 00412 ushell_cmd_copy(); 00413 break; 00414 00415 // Renames file 00416 case CMD_MV: 00417 ushell_cmd_rename(); 00418 break; 00419 00420 // Synchronize folders 00421 case CMD_SYNC: 00422 ushell_cmd_sync(); 00423 break; 00424 00425 // Perform transfer 00426 case CMD_PERFORM: 00427 ushell_cmd_perform(); 00428 break; 00429 00430 // Reboot target 00431 case CMD_REBOOT: 00432 ushell_cmd_reboot(); 00433 break; 00434 00435 // USB commands 00436 #if (USHELL_USB==ENABLE) 00437 case CMD_LS_USB: 00438 ushell_cmdusb_ls(); 00439 break; 00440 case CMD_USB_SUSPEND: 00441 ushell_cmdusb_suspend(); 00442 break; 00443 case CMD_USB_RESUME: 00444 ushell_cmdusb_resume(); 00445 break; 00446 case CMD_USB_FORCE_ENUM: 00447 ushell_cmdusb_force_enum(); 00448 break; 00449 #endif 00450 00451 // DFU commands 00452 #if (USHELL_DFU==ENABLE) 00453 case CMD_DFU_ERASE: 00454 ushell_cmddfu_erase(); 00455 break; 00456 case CMD_DFU_LOAD: 00457 ushell_cmddfu_load(); 00458 break; 00459 case CMD_DFU_START: 00460 ushell_cmddfu_start(); 00461 break; 00462 #endif 00463 00464 // HID commands 00465 #if (USHELL_HID==ENABLE) 00466 case CMD_HID_ENTER_DFU: 00467 ushell_cmdhid_enter_dfu(); 00468 break; 00469 case CMD_HID_GET_INFO: 00470 ushell_cmdhid_getinfo(); 00471 break; 00472 #endif 00473 00474 // Unknown command 00475 default: 00476 print_msg((U8 code *)msg_er_cmd_not_found); 00477 break; 00478 } 00479 00480 print_msg((U8 code *)msg_prompt); 00481 }