Skip to content

Not an issue: I adapted your code for LittleFS #1

Description

@lesept777

Hi
Thanks for this great code. It's really a marvellous idea!
I wanted to make it work with LitlleFS instead of SPIFFS. I just changed all occurences of 'SPIFFS' by 'LittleFS' and it worked immediately.
I also added a command 'dump file' to print the content of a file in hexadecimal. Youo can take it and add it in your code.

My contribution is here: https://github.com/lesept777/LittleFS-Shell

Activity

  1. lesept777 commented on Aug 15, 2024

    @lesept777
    Author

    I also corrected a small mistake in the parsing of the commands.

    If you use the command
    echo Hello World file.txt
    you end up with a file called World file.txt containing 'Hello'.

    So I changed the parsing function to:

      void static parseCommand(const String& command, String& cmd, String& arg1, String& arg2) {
        Serial.println(command);
        int spaceIndex1 = command.indexOf(' '); // Find the index of the first space character
        int spaceIndex2 = command.lastIndexOf(' '); // Find the index of the last space character
    //    int spaceIndex2 = command.indexOf(' ', spaceIndex1 + 1); // Find the index of the second space character
    
        if (spaceIndex1 == -1) {
          cmd = command;
        } else {
          cmd = command.substring(0, spaceIndex1); // Extract the command from the command string
          if (spaceIndex2 == -1 or spaceIndex1 == spaceIndex2) {
            arg1 = command.substring(spaceIndex1 + 1); // Extract the first argument from the command string
          } else {
            arg1 = command.substring(spaceIndex1 + 1, spaceIndex2); // Extract the first argument from the command string
            arg2 = command.substring(spaceIndex2 + 1); // Extract the second argument from the command string
          }
        }
        // Check for CR character
        if (command.indexOf('\r') != -1) {
          Serial.println("Warning: Carriage return (CR) character detected in input");
        }
      }
    

    which seems to be working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions