Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- LIST: This command LIST directories and FILES.
- Parameters include:
- LIST D... LF
- D... = Directory to start at. "/" is root (UP TO 126 BYTES + SPACE)
- LF = LINE FEED (1 BYTE 0x0A)
- EXAMPLE: LIST / 0x0A
- The above example will return: C [X LF]
- C = Count of directories Found
- X = Directory/File Name
- LF = LINE FEED (0x0A)
- Example: If your root has 3 folders [FOLD1]-[FOLD2]-[FOLD3] and 1 file [HELLO.TXT]
- LIST / 0x0A
- Will return:
- 0x04 FOLD1 0x0A FOLD2 0x0A FOLD3 0x0A HELLO.TXT 0x0A
- */
- if(strncmp(CMD[LIST],RX_CMD,4) == 0) //Send out directory listing
- {
- res = scan_files(RX_ARG,ALL_T);
- return;
- }
- /*
- LIFI: This command list FILES ONLY.
- Parameters include:
- LIFI D... LF
- D... = Directory to start at. "/" is root (UP TO 126 BYTES + SPACE)
- LF = LINE FEED (1 BYTE 0x0A)
- EXAMPLE: LIFI / 0x0A
- The above example will return: C [X LF]
- C = Count of directories Found
- X = File Name
- LF = LINE FEED (0x0A)
- Example: If your root has 3 folders [FOLD1]-[FOLD2]-[FOLD3] and 1 file [HELLO.TXT]
- LIFI / 0x0A
- Will return:
- 0x01 HELLO.TXT 0x0A
- */
- if(strncmp(CMD[LIST_FILES],RX_CMD,4) == 0) //Send out directory listing
- {
- res = scan_files(RX_ARG,FILE_T);
- return;
- }
- /*
- LIDI: This command LIST directories only.
- Parameters include:
- LIDI D... LF
- D... = Directory to start at. "/" is root (UP TO 126 BYTES + SPACE)
- LF = LINE FEED (1 BYTE 0x0A)
- EXAMPLE: LIDI / 0x0A
- The above example will return: C [X LF]
- C = Count of directories Found
- X = Directory Name
- LF = LINE FEED (0x0A)
- Example: If your root has 3 folders [FOLD1]-[FOLD2]-[FOLD3] and 1 file [HELLO.TXT]
- LIDI / 0x0A
- Will return:
- 0x03 FOLD1 0x0A FOLD2 0x0A FOLD3 0x0A
- */
- if(strncmp(CMD[LIST_DIRS],RX_CMD,4) == 0) //Send out directory listing
- {
- res = scan_files(RX_ARG,DIR_T);
- return;
- }
- /*
- READ: This command reads a file.
- Parameters include:
- READ SSSS C F... LF
- SSSS = Seek Location, where to start when getting data (4 BYTES + SPACE)
- C = Count of bytes to return, MAX 128 (1 BYTE + SPACE)
- F... = FILE NAME (UP TO 120 BYTES + SPACE)
- LF = LINE FEED (1 BYTE 0x0A)
- EXAMPLE: READ 0000 10 HELLO.TXT 0x0A
- The above example will return the first 10 bytes in the file HELLO.TXT
- */
- if(strncmp(CMD[READ],RX_CMD,4) == 0) //Read data from a file
- {
- SeekPosition = RX_ARG[3] + (RX_ARG[2] << 8)+ (RX_ARG[1] << 16)+ (RX_ARG[0] << 24);
- Bytes2Read = RX_ARG[5];
- res = f_open(&fsrc,(RX_ARG+7),FA_READ);
- memset(Buffer,0,128);
- res = f_lseek(&fsrc,SeekPosition);
- res = f_read(&fsrc,Buffer, Bytes2Read, &br); /* Read a chunk of src file */
- RWC[0] = br; //Get how many actual bytes were read.
- UART_TX(RWC[0]); //inform the user how many bytes to expect after this
- UART_BUFF(Buffer,br); //Send the buffer.
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement