Definition in file ushell_task.h.
#include "fs_com.h"
Go to the source code of this file.
Defines | |
Specific ASCII Values | |
#define | ASCII_BKSPACE '\b' |
#define | ASCII_CR '\r' |
#define | ASCII_CTRL_C 0x03 |
#define | ASCII_CTRL_Q 0x11 |
#define | ASCII_ESCAPE 0x1B |
#define | ASCII_LF '\n' |
Shell Commands | |
#define | CMD_APPEND 0x10 |
#define | CMD_CAT 0x0A |
#define | CMD_CAT_MORE 0x0B |
#define | CMD_CD 0x08 |
#define | CMD_CP 0x13 |
#define | CMD_DF 0x02 |
#define | CMD_FORMAT 0x03 |
#define | CMD_GOTO_ID 0x12 |
#define | CMD_HELP 0x0C |
#define | CMD_LS 0x06 |
#define | CMD_LS_MORE 0x07 |
#define | CMD_LS_USB 0x18 |
#define | CMD_MKDIR 0x0D |
#define | CMD_MOUNT 0x04 |
#define | CMD_MV 0x14 |
#define | CMD_NB_DRIVE 0x01 |
#define | CMD_NONE 0x00 |
#define | CMD_PERFORM 0x16 |
#define | CMD_RM 0x0F |
#define | CMD_SET_ID 0x11 |
#define | CMD_SPACE 0x05 |
#define | CMD_SYNC 0x15 |
#define | CMD_TOUCH 0x0E |
#define | CMD_UP 0x09 |
#define | CMD_USB_RESUME 0x1A |
#define | CMD_USB_SUSPEND 0x19 |
String Messages | |
#define | MSG_APPEND_WELCOME "\r\nSimple text editor, enter char to append, ^q to exit and save\r\n" |
#define | MSG_BUS_POWERED "Device is bus-powered\r\n" |
#define | MSG_DEVICE_FULL_SPEED "Device is full-speed\r\n" |
#define | MSG_DEVICE_HIGH_SPEED "Device is high-speed\r\n" |
#define | MSG_DEVICE_LOW_SPEED "Device is low-speed\r\n" |
#define | MSG_ER_CMD_NOT_FOUND "Command not found\r\n" |
#define | MSG_ER_DRIVE "Drive does not exist\r\n" |
#define | MSG_ER_FORMAT "Format fails\r\n" |
#define | MSG_ER_MOUNT "Unable to mount drive\r\n" |
#define | MSG_ER_PASTE "Paste Fail\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_EXIT |
#define | MSG_HELP |
#define | MSG_KO "FAIL\r\n" |
#define | MSG_NO_DEVICE "Not currently applicable to supported connected device(s) if any\r\n" |
#define | MSG_OK "ok\r\n" |
#define | MSG_PROMPT "$>" |
#define | MSG_REMOTE_WAKEUP_KO "Device does not support remote wake-up\r\n" |
#define | MSG_REMOTE_WAKEUP_OK "Device supports remote wake-up\r\n" |
#define | MSG_SELF_POWERED "Device is self-powered\r\n" |
#define | MSG_USB_SUSPENDED "USB is suspended!\r\n" |
#define | MSG_WELCOME |
String Values for Commands | |
#define | STR_APPEND "append" |
#define | STR_CAT "cat" |
#define | STR_CAT_MORE "cat|more" |
#define | STR_CD "cd" |
#define | STR_CP "cp" |
#define | STR_DF "df" |
#define | STR_DISK "disk" |
#define | STR_FORMAT "format" |
#define | STR_GOTO "goto" |
#define | STR_HELP "help" |
#define | STR_LS "ls" |
#define | STR_LS_MORE "ls|more" |
#define | STR_LS_USB "lsusb" |
#define | STR_MARK "mark" |
#define | STR_MKDIR "mkdir" |
#define | STR_MOUNT "mount" |
#define | STR_MV "mv" |
#define | STR_PERFORM "perf" |
#define | STR_RM "rm" |
#define | STR_SPACE "space" |
#define | STR_SYNC "sync" |
#define | STR_TOUCH "touch" |
#define | STR_UP "cd.." |
#define | STR_USB_RESUME "resume" |
#define | STR_USB_SUSPEND "suspend" |
Functions | |
void | ushell_task (void) |
Entry point of the explorer task management. | |
void | ushell_task_init (U32 pba_hz) |
This function initializes the hardware/software ressources required for ushell task. |
#define ASCII_BKSPACE '\b' |
Definition at line 62 of file ushell_task.h.
Referenced by ushell_clean_cmd_line(), and ushell_cmd_scan().
#define ASCII_CR '\r' |
Definition at line 60 of file ushell_task.h.
Referenced by ushell_cmd_append_file(), ushell_cmd_cat(), ushell_cmd_scan(), and ushell_cmdusb_ls().
#define ASCII_CTRL_C 0x03 |
Definition at line 65 of file ushell_task.h.
#define ASCII_CTRL_Q 0x11 |
#define ASCII_ESCAPE 0x1B |
#define ASCII_LF '\n' |
Definition at line 61 of file ushell_task.h.
Referenced by ushell_cmd_append_file(), ushell_cmd_cat(), ushell_cmd_scan(), and ushell_cmdusb_ls().
#define CMD_APPEND 0x10 |
#define CMD_CAT 0x0A |
#define CMD_CAT_MORE 0x0B |
#define CMD_CD 0x08 |
#define CMD_CP 0x13 |
#define CMD_DF 0x02 |
#define CMD_FORMAT 0x03 |
#define CMD_GOTO_ID 0x12 |
#define CMD_HELP 0x0C |
#define CMD_LS 0x06 |
#define CMD_LS_MORE 0x07 |
#define CMD_LS_USB 0x18 |
#define CMD_MKDIR 0x0D |
#define CMD_MOUNT 0x04 |
#define CMD_MV 0x14 |
#define CMD_NB_DRIVE 0x01 |
#define CMD_NONE 0x00 |
#define CMD_PERFORM 0x16 |
#define CMD_RM 0x0F |
#define CMD_SET_ID 0x11 |
#define CMD_SPACE 0x05 |
#define CMD_SYNC 0x15 |
#define CMD_TOUCH 0x0E |
#define CMD_UP 0x09 |
#define CMD_USB_RESUME 0x1A |
#define CMD_USB_SUSPEND 0x19 |
#define MSG_APPEND_WELCOME "\r\nSimple text editor, enter char to append, ^q to exit and save\r\n" |
#define MSG_BUS_POWERED "Device is bus-powered\r\n" |
#define MSG_DEVICE_FULL_SPEED "Device is full-speed\r\n" |
#define MSG_DEVICE_HIGH_SPEED "Device is high-speed\r\n" |
#define MSG_DEVICE_LOW_SPEED "Device is low-speed\r\n" |
#define MSG_ER_CMD_NOT_FOUND "Command not found\r\n" |
#define MSG_ER_DRIVE "Drive does not exist\r\n" |
#define MSG_ER_FORMAT "Format fails\r\n" |
#define MSG_ER_MOUNT "Unable to mount drive\r\n" |
#define MSG_ER_PASTE "Paste Fail\r\n" |
#define MSG_ER_RM "Can not erase, if the name is a directory, check it is empty\r\n" |
Definition at line 150 of file ushell_task.h.
#define MSG_ER_UNKNOWN_FILE "Unknown file\r\n" |
Definition at line 151 of file ushell_task.h.
Referenced by ushell_cmd_append_file(), ushell_cmd_cat(), ushell_cmd_cd(), ushell_cmd_copy(), and ushell_cmd_rename().
#define MSG_EXIT |
Value:
"\x0C" \ "------------------------\r\n" \ "uShell not available\r\n" \ "------------------------\r\n"
Definition at line 143 of file ushell_task.h.
Referenced by ushell_task(), and ushell_task_init().
#define MSG_HELP |
Value:
"\r\n---- Ushell Commands:\r\n" \ " HELP Provides Help information for Ushell commands.\r\n" \ " ! Previous command (history).\r\n" \ " $ Next command (history).\r\n" \ "\r\n---- File Systems Commands:\r\n" \ " DISK Displays the number of drives.\r\n" \ " DF Displays free space of all connected drives.\r\n" \ " FORMAT [/A:] Formats drive, /A drive letter (a, b, etc.).\r\n" \ " MOUNT [/A:] Mounts drive, /A drive letter (a, b, etc.).\r\n" \ " [/A:] Mounts drive, /A drive letter (a, b, etc.).\r\n" \ " SPACE Displays drive capacity.\r\n" \ " LS [|MORE] Displays a list of files and subdirectories in a directory.\r\n" \ " CD [..][path] Changes the current directory.\r\n" \ " CAT [file name] Displays file contents.\r\n" \ " MKDIR [dir name] Creates a directory.\r\n" \ " TOUCH [file name] Creates a file.\r\n" \ " RM [*][file name] Deletes one or more files or directories.\r\n" \ " APPEND [file name] Appends file from terminal input\r\n" \ " MARK Record the current directory in bookmark\r\n" \ " GOTO Go to bookmarked directory\r\n" \ " CP [file name][path\\] Copys file to bookmarked directory or to path argument.\r\n" \ " MV [path] [new name] Renames file from path with new name.\r\n" \ " SYNC [src_path] [dest_path] Synchronizes a folder content with other folder.\r\n" \ " PERF [/A:] [/A:] Evaluates the transfer rate between two devices.\r\n" \ "\r\n---- USB Host Commands:\r\n" \ " LSUSB Displays USB information.\r\n" \ " SUSPEND Suspends USB bus activity.\r\n" \ " RESUME Resumes USB bus activity.\r\n" \
Definition at line 154 of file ushell_task.h.
Referenced by ushell_cmd_help().
#define MSG_KO "FAIL\r\n" |
Definition at line 190 of file ushell_task.h.
Referenced by ushell_cmd_append_file(), ushell_cmd_copy(), ushell_cmd_mkdir(), ushell_cmd_rename(), and ushell_cmd_rm().
#define MSG_NO_DEVICE "Not currently applicable to supported connected device(s) if any\r\n" |
Definition at line 183 of file ushell_task.h.
Referenced by ushell_cmdusb_ls(), ushell_cmdusb_resume(), and ushell_cmdusb_suspend().
#define MSG_OK "ok\r\n" |
Definition at line 189 of file ushell_task.h.
#define MSG_PROMPT "$>" |
#define MSG_REMOTE_WAKEUP_KO "Device does not support remote wake-up\r\n" |
#define MSG_REMOTE_WAKEUP_OK "Device supports remote wake-up\r\n" |
Definition at line 184 of file ushell_task.h.
#define MSG_SELF_POWERED "Device is self-powered\r\n" |
#define MSG_USB_SUSPENDED "USB is suspended!\r\n" |
#define MSG_WELCOME |
Value:
"\x0C" \ "--------------------------\r\n" \ " ATMEL AVR32 uShell\r\n" \ "--------------------------\r\n"
Definition at line 139 of file ushell_task.h.
Referenced by ushell_task().
#define STR_APPEND "append" |
#define STR_CAT "cat" |
#define STR_CAT_MORE "cat|more" |
#define STR_CD "cd" |
#define STR_CP "cp" |
#define STR_DF "df" |
#define STR_DISK "disk" |
#define STR_FORMAT "format" |
#define STR_GOTO "goto" |
#define STR_HELP "help" |
#define STR_LS "ls" |
#define STR_LS_MORE "ls|more" |
#define STR_LS_USB "lsusb" |
#define STR_MARK "mark" |
#define STR_MKDIR "mkdir" |
#define STR_MOUNT "mount" |
#define STR_MV "mv" |
#define STR_PERFORM "perf" |
#define STR_RM "rm" |
#define STR_SPACE "space" |
#define STR_SYNC "sync" |
#define STR_TOUCH "touch" |
#define STR_UP "cd.." |
#define STR_USB_RESUME "resume" |
#define STR_USB_SUSPEND "suspend" |
void ushell_task | ( | void | ) |
Entry point of the explorer task management.
This function performs uShell decoding to access file-system functions.
Definition at line 264 of file ushell_task.c.
References CMD_APPEND, CMD_CAT, CMD_CAT_MORE, CMD_CD, CMD_CP, CMD_DF, CMD_FORMAT, CMD_GOTO_ID, CMD_HELP, CMD_LS, CMD_LS_MORE, CMD_LS_USB, CMD_MKDIR, CMD_MOUNT, CMD_MV, CMD_NB_DRIVE, CMD_PERFORM, CMD_RM, CMD_SET_ID, CMD_SPACE, CMD_SYNC, CMD_TOUCH, CMD_UP, CMD_USB_RESUME, CMD_USB_SUSPEND, configTSK_USHELL_PERIOD, FS_NAV_ID_USHELL_CMD, g_b_ushell_task_run, g_mark_index, MSG_ER_CMD_NOT_FOUND, MSG_EXIT, MSG_PROMPT, MSG_WELCOME, 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_rename(), ushell_cmd_rm(), ushell_cmd_scan(), ushell_cmd_space(), ushell_cmd_sync(), ushell_cmd_touch(), ushell_cmdusb_ls(), ushell_cmdusb_resume(), and ushell_cmdusb_suspend().
Referenced by main(), and ushell_task_init().
00266 { 00267 00268 #ifdef FREERTOS_USED 00269 //** Inifinit loop for RTOS because it is a RTOS task 00270 portTickType xLastWakeTime; 00271 00272 xLastWakeTime = xTaskGetTickCount(); 00273 while (TRUE) 00274 { 00275 vTaskDelayUntil(&xLastWakeTime, configTSK_USHELL_PERIOD); 00276 #else 00277 //** No loop with the basic scheduler 00278 { 00279 #endif // FREERTOS_USED 00280 00281 00282 //** Check the USB mode and autorize/unautorize ushell 00283 if(!g_b_ushell_task_run) 00284 { 00285 if( Is_usb_id_device() ) 00286 #ifdef FREERTOS_USED 00287 continue; // Continue in the RTOS task 00288 #else 00289 return; // Exit of the task scheduled 00290 #endif 00291 g_b_ushell_task_run = TRUE; 00292 // Display shell startup 00293 fputs(MSG_WELCOME, stdout); 00294 ushell_cmd_nb_drive(); 00295 fputs(MSG_PROMPT, stdout); 00296 00297 // Reset the embedded FS on ushell navigator and on first drive 00298 nav_reset(); 00299 nav_select( FS_NAV_ID_USHELL_CMD ); 00300 nav_drive_set( 0 ); 00301 }else{ 00302 if( Is_usb_id_device() ) 00303 { 00304 g_b_ushell_task_run = FALSE; 00305 fputs(MSG_EXIT, stdout ); 00306 nav_exit(); 00307 #ifdef FREERTOS_USED 00308 continue; // Continue in the RTOS task 00309 #else 00310 return; // Exit of the task scheduled 00311 #endif 00312 } 00313 } 00314 00315 //** Scan shell command 00316 if( !ushell_cmd_scan() ) 00317 #ifdef FREERTOS_USED 00318 continue; // Continue in the RTOS task 00319 #else 00320 return; // Exit of the task scheduled 00321 #endif 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 case CMD_PERFORM: 00426 ushell_cmd_perform(); 00427 break; 00428 00429 // USB commands 00430 #if USB_HOST_FEATURE == ENABLED 00431 case CMD_LS_USB: 00432 ushell_cmdusb_ls(); 00433 break; 00434 case CMD_USB_SUSPEND: 00435 ushell_cmdusb_suspend(); 00436 break; 00437 case CMD_USB_RESUME: 00438 ushell_cmdusb_resume(); 00439 break; 00440 #endif 00441 00442 // Unknown command 00443 default: 00444 fputs(MSG_ER_CMD_NOT_FOUND, stdout); 00445 break; 00446 } 00447 00448 fputs(MSG_PROMPT, stdout); 00449 00450 } 00451 }
void ushell_task_init | ( | U32 | pba_hz | ) |
This function initializes the hardware/software ressources required for ushell task.
Definition at line 191 of file ushell_task.c.
References configTSK_USHELL_NAME, configTSK_USHELL_PRIORITY, configTSK_USHELL_STACK_SIZE, g_b_ushell_task_run, g_s_cmd_his, g_u32_ushell_pba_hz, MSG_EXIT, SHL_USART, SHL_USART_BAUDRATE, SHL_USART_RX_FUNCTION, SHL_USART_RX_PIN, SHL_USART_TX_FUNCTION, SHL_USART_TX_PIN, USHELL_HISTORY, and ushell_task().
Referenced by main().
00192 { 00193 U8 u8_i; 00194 00195 //** Initialize the USART used by uShell with the configured parameters 00196 static const gpio_map_t SHL_USART_GPIO_MAP = 00197 { 00198 {SHL_USART_RX_PIN, SHL_USART_RX_FUNCTION}, 00199 {SHL_USART_TX_PIN, SHL_USART_TX_FUNCTION} 00200 }; 00201 #if (defined __GNUC__) 00202 set_usart_base((void *)SHL_USART); 00203 gpio_enable_module(SHL_USART_GPIO_MAP, 00204 sizeof(SHL_USART_GPIO_MAP) / sizeof(SHL_USART_GPIO_MAP[0])); 00205 usart_init(SHL_USART_BAUDRATE); 00206 #elif (defined __ICCAVR32__) 00207 static const usart_options_t SHL_USART_OPTIONS = 00208 { 00209 .baudrate = SHL_USART_BAUDRATE, 00210 .charlength = 8, 00211 .paritytype = USART_NO_PARITY, 00212 .stopbits = USART_1_STOPBIT, 00213 .channelmode = USART_NORMAL_CHMODE 00214 }; 00215 00216 extern volatile avr32_usart_t *volatile stdio_usart_base; 00217 stdio_usart_base = SHL_USART; 00218 gpio_enable_module(SHL_USART_GPIO_MAP, 00219 sizeof(SHL_USART_GPIO_MAP) / sizeof(SHL_USART_GPIO_MAP[0])); 00220 usart_init_rs232(SHL_USART, &SHL_USART_OPTIONS, pba_hz); 00221 #endif 00222 00223 00224 //** Configure standard I/O streams as unbuffered. 00225 #if (defined __GNUC__) 00226 setbuf(stdin, NULL); 00227 #endif 00228 setbuf(stdout, NULL); 00229 00230 // Set default state of ushell 00231 g_b_ushell_task_run = FALSE; 00232 for( u8_i=0; u8_i<USHELL_HISTORY; u8_i++ ) { 00233 g_s_cmd_his[u8_i][0] = 0; // Set end of line for all cmd line history 00234 } 00235 00236 fputs(MSG_EXIT, stdout ); 00237 00238 g_u32_ushell_pba_hz = pba_hz; // Save value to manage a time counter during perform command 00239 00240 #ifdef FREERTOS_USED 00241 xTaskCreate(ushell_task, 00242 configTSK_USHELL_NAME, 00243 configTSK_USHELL_STACK_SIZE, 00244 NULL, 00245 configTSK_USHELL_PRIORITY, 00246 NULL); 00247 #endif // FREERTOS_USED 00248 }