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