Skip to content

Commit

Permalink
Add new streaming method, leaving bufferString intact between update(…
Browse files Browse the repository at this point in the history
…) calls

- can read()/write() from Commander class with this method
  • Loading branch information
Louis Beaudoin committed Jul 13, 2021
1 parent 7f41e29 commit 092d216
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ bool Commander::streamData(){
echoPorts(inByte);
//call the handler if you fill the buffer, then return so everything is reset
if(bytesWritten == bufferSize-1 || !ports.inPort->available()) {

// dataStreamMethod==1 doesn't call handleCustomCommand(), and keeps bufferString intact between update() calls
if(ports.settings.bit.dataStreamMethod)
return (bool)ports.inPort->available(); //return true if any bytes left to read

//println("Buffer ready, calling handler");
commandState.bit.commandHandled = !handleCustomCommand();

Expand Down
5 changes: 4 additions & 1 deletion src/Commander.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ typedef union {
uint32_t printInternalCommands:1; //8 enable printing of internal commands with help
uint32_t multiCommanderMode:1; //9 set to true when using multiple commander objects for multilayerd commands. Prevents multiple command prompts from appearing
uint32_t printComments:1; //10 set to true and lines prefixed with the comment char will print to the out and alt ports
uint32_t dataStreamMode:1; //11 indicates the stream mode. mode 0 looks for an end of line, 1 is pure stream mode and cannot be terminated using a command char.
uint32_t dataStreamMode:1; //11 indicates the stream mode. mode 0 looks for an EOF, 1 is pure stream mode and cannot be terminated using a command char.
uint32_t useHardLock:1; //12 use hard or soft lock (0 or 1)
uint32_t locked:1; //13 Indicates if Commander is in a locked or unlocked state
uint32_t stripCR:1; //14 Strip carriage returns from the buffer
Expand All @@ -98,6 +98,7 @@ typedef union {
uint32_t autoChain:1; //19 Automatically chain commands, and to hell with the consequences
uint32_t autoChainSurpressErrors:1; //20 Prevent error messages when chaining commands
uint32_t ignoreQuotes:1; //21 don't treat items in quotes as special
uint32_t dataStreamMethod:1; //22 0: use bufferString, 1: use loopbackStream
} bit; // used for bit access
uint32_t reg; //used for register access
} cmdSettings_t;
Expand Down Expand Up @@ -204,6 +205,8 @@ class Commander : public Stream {
bool isStreaming() {return commandState.bit.dataStreamOn;}
Commander& setStreamingMode(bool dataStreamMode) {ports.settings.bit.dataStreamMode = dataStreamMode; return *this;}
bool getStreamingMode() {return ports.settings.bit.dataStreamMode;}
Commander& setStreamingMethod(bool dataStreamMethod) {ports.settings.bit.dataStreamMethod = dataStreamMethod; return *this;}
bool getStreamingMethod() {return ports.settings.bit.dataStreamMethod;}
Commander& transfer(Commander& Cmdr);
bool transferTo(const commandList_t *commands, uint32_t size, String newName);
Commander& transferBack(const commandList_t *commands, uint32_t size, String newName);
Expand Down

0 comments on commit 092d216

Please sign in to comment.