Skip to content

Releases: CreativeRobotics/Commander

Version 3.0.0

01 Mar 16:58
Compare
Choose a tag to compare

Made some major changes under the hood to the way payloads and items are processed including adding proper support for chaining multiple commands together in a single line:

-Changed help and query formatting so the comment char appears at the start of every line for help, query and errors.
-Changed delimiter char to a String. The defaults are | = , : \ / plus SPACE and TAB.
-Removed setDelimChar() method.
-Created setDelimiters(String), getDelimiters() and addDelimiter(char) methods.
-Added a method where delims are ignored for items in quotes when using getString.
-Added a settings bit to allow quotes to be ignored.
-Added containsFalse() and containsOff() to compliment ON and TRUE.
-Added public method of reading the dataReadIndex variable. This marks the start of the payload, or any section of the payload that has not been extracted with the getInt, getFloat or getString methods.
-Added chain() method, breakChain(), autoChain settings bit and autoChain() methods to allow commands to be chained on a single line. Unless set to autoChain mode, if chain() is called at the end of a handler, Commander will find the start of the next item in the payload (anything left over after calls to getInt etc), and reload everything from that point into the buffer as a pending command for processing on the next call to update. If autochaining is enables, then placing breakChain at the end of a handler will prevent any other commands in that chain from being handled.
-Chaining will work on any user command provided that any payload for that command has been extracted using the getInt, getFloat or getString methods. These methods will place the dataReadIndex at the end of the commands payload, and before the start of any chained command.
-Setting autoChain(true) will automatically allow all commands to be chained.
-A chaining state bit can be used to surpress the unrecognised command handler so if chained command does not turn out to be a valid command it gets ignored instead of generating an error.
-Comment characters break chains, so comments can be left at the end of a command line, for example in command files.
-Added autoChainSurpressErrors bit and methods to control if error messages are displayed when chaining commands.
-Added quickSet and get methods for Strings.
-Chains will break when a quickset or quickget command is found - this prevents chaining errors.
-Added a help tag [C] that indicates if the command is chainable.
-Fixed a lock bug printing the unlock message when it didn't unlock.
-Fixed internal commands recognising bad commands due to sloppy optimisation.
-Improved contaonsOn,off,true and false so they only with for recognisable items, not when the characters appear in a phrase. They now check the next item in the payload, but do not move dataReadIndex.

Version 2.2.0

21 Feb 12:37
Compare
Choose a tag to compare

Changes for 1.2:
Optimised the command search. The command search used to use the String method startsWith(). This has been replaced with a new algorithm:

  • When checking each command against the buffer it first checks if the buffer is too short (shorter than the command being checked) and returns false if it is.
  • If the command is a single character it performs a specific test and returns true if it matches the buffer, and has a valid end of command char (' ', end of line or delim)
  • Otherwise it checks the last command character against the buffer, then the first, and works its way in until it reaches the middle.
  • It returns true if it reaches the middle with all characters matching.
  • It returns false the moment a character fails to match.
  • If it returns true for a match of that command against the buffer, it logs the index and the command length and keeps searching.
  • If it finds another match against a longer command it updates the index.
  • For internal commands, a switch statement was implimented and optimised to check each item as efficiently as possible. This also increased speed.
    -- This reduced the time to search significantly, for example command match of 227 microsecs was reduced to 58 microsecs in a 16 item command list.
    -- Theory: The probablility of the last and first characters of a command and the buffer matching should be much lower than for the first and second or third (etc). For example commands 'set int 1234' and 'set float 1.2' match the first four characters but not the last character, so by checking the last character first they are rejected on the first iteration rather than the fourth.
    Swapped query and help in internal commands so they can be searched faster
    Removed enable command from internal commands because ... its stupid, and you should use locks instead.
    Moved printing of reload and comment characters so they are visible even if internal commands are not.
    Added a method of hiding commands from the command menu. Putting the '-' character at the start of the help text will prevent the command from printing.

Version 2.1.0

09 Feb 11:23
Compare
Choose a tag to compare

-Fixed a bug where CR was not ignored on a blank line.
-Fixed a bug where getString was not recognising the custom delimiter.
-Changes streamType_t enum so undefined streamtype is zero.
-Expanded the settings register to 32 bits and moved autoFormat and locked bits from state register to settings register.
-Removed PRINT_LINE_DELAY and replaced with setPrintDelay(uint8_t dTime) uint8_t getPrintDelay() and printDelay(bool enable) to allow a delay from 0-255 millis after a line is printed. Default is off with zero time.
-Changed commandListEntries to a uint8_t - Command lists must have no more than 256 items!
-Fixed a bug where countItems() will return 1 if there are no items.
-Added a benchmarking system using macros.
-Added a streamMode option so raw data streaming can be supported.
-Changed start stop and set stream method names to Streaming (instead of stream) to remove ambiguity over methods relating to the Stream objects
-Added setStreamingMode() and getStreamingMode() methods.
-Removed the isCommandStart() and isCommandChar() methods and rearranged the command buffer state machine to use one bit. Commands can now start with any ASCII character.
-Removed redundant settings register values.
-Renamed streamMode and streamOn bits as dataStreamMode and dataStreamOn.

Version 2.0

26 Jan 22:39
Compare
Choose a tag to compare

Some fairly big additions and some reworking of the API:

Re-worked several methods and method names and probably broke several things, for example setLockType(bool) replaces enableHardLock(), commandPrompt(bool) replaces enablePrompt() and disablePrompt(). Setting parameters like these are now all done by passing an argument, and macros for ON and OFF are defined.
errorMessagesEnabled now controls all internal messages so disabling them will prevent replies from internal commands like 'echo' or 'U'
bugfix: internal commands did not check length so, for example, sending helpaxfgqerg was recognised as a help command
Added PRINT_LINE_DELAY macro - if defined at the start of a sketch it will insert the defined marco before a line of text is printed - used to slow down transmission when sending many lines of data so a slow reciever can handle it.
Added a defaultHandler function pointer that will be called whenever an unknown command is found. The user can now attach their own command handler for dealing with unrecognised commands. If not specified, the internal handler will be used.
Added a method that returns the number of items in the command list.
Added a method to return a String with the command help text for a specified item in the command list.
Added a method that returns the number of items in the internal command list.
Added a method to return a String with the command and help text for a specified item in the internal command list.
Added a hide Internal Commands bit to prevent internal commands being displayed in help.
Added an enable internal commands bit to stop internal commands from working.
Added getString() method to extract sequential strings seperated by a space or special delimiter
Added a countItems method to return the number of items in the payload. An idem is defined as a string with a space or delimChar at each end (or an end of line char)
Renamed the eocChar into a delimChar, it is used as a delimiter between any items in the payload alongside the space character
Added methods to set the delimChar and endOfLine char.
Added two bit StreamType code to indicate if the attached stream is a serial port, file or web - this is to allow handlers to interrogate the Commander object calling the handler to adjust its response for that stream, for example by adding formatting to a response.
Methods containsOn and containsTrue now work for both lower case and capitals.
Updated the basic example sketch to demonstrate countItems() and getString() methods. These count and display all items in the payload.
Added an HTML web server example using Commander to deliver formatted web pages.
Removed updatePending() because this function is performed within update()

Utilities:
Added a function to convert an HTTP GET line to a command string - It finds the start and end of the GET message and converts and / or + chars to spaces. A line with "GET /help HTTP/1.1" will return a string containing "help" or "GET /setLED/on HTTP/1.1" will return "setLED on" The function can return a default string if nothing is found: String GET_CommandString(String serverGetLine, String defaultString)

Version 1.3

30 Dec 17:03
Compare
Choose a tag to compare

Added keywords for syntax highlighting and restructured the directories so that library source files are in src, and prefabs are in sub directories that can be created according to the category. Also changed some formatting for the help system.

Fixed help system

05 Dec 18:55
Compare
Choose a tag to compare

Version 1.2 includes a locking system for password protecting the command system, and 'prefabs' - pre-build command lists and functions for specific tasks. The first prefab is an SD card navigation system with an example of it in use as a sub command set.

This release fixes a minor issue with te help file system and the internal version number.

Version 1.2 now with prefabs

05 Dec 17:18
Compare
Choose a tag to compare

Added prefab command lists, and a few other features and tweaks.

Passwords

30 Nov 11:49
Compare
Choose a tag to compare

Added a locking and password system