├── README.txt ├── SerialCommand.cpp ├── SerialCommand.h ├── examples ├── SerialCommandExample │ └── SerialCommandExample.pde ├── SerialCommandExampleSoftwareSerial │ └── SerialCommandExampleSoftwareSerial.ino ├── SerialCommandHardwareOnlyExample │ └── SerialCommandHardwareOnlyExample.ino └── SoftwareSerialCheck │ └── SoftwareSerialCheck.ino └── keywords.txt /README.txt: -------------------------------------------------------------------------------- 1 | An Arduino library to tokenize and parse commands received over a serial port. 2 | 3 | Initially documented here: http://awtfy.com/2011/05/23/a-minimal-arduino-library-for-processing-serial-commands/ 4 | 5 | An alternate version of this library is available as https://github.com/kroimon/Arduino-SerialCommand 6 | 7 | This version is the one on Github. 8 | 9 | /******************************************************************************* 10 | SerialCommand - An Arduino library to tokenize and parse commands received over 11 | a serial port. 12 | Copyright (C) 2011-2013 Steven Cogswell 13 | http://awtfy.com 14 | 15 | Version 20131021A. 16 | 17 | Version History: 18 | May 11 2011 - Initial version 19 | May 13 2011 - Prevent overwriting bounds of SerialCommandCallback[] array in addCommand() 20 | defaultHandler() for non-matching commands 21 | Mar 2012 - Some const char * changes to make compiler happier about deprecated warnings. 22 | Arduino 1.0 compatibility (Arduino.h header) 23 | Oct 2013 - SerialCommand object can be created using a SoftwareSerial object, for SoftwareSerial 24 | support. Requires #include in your sketch even if you don't use 25 | a SoftwareSerial port in the project. sigh. See Example Sketch for usage. 26 | Oct 2013 - Conditional compilation for the SoftwareSerial support, in case you really, really 27 | hate it and want it removed. 28 | 29 | This library is free software; you can redistribute it and/or 30 | modify it under the terms of the GNU Lesser General Public 31 | License as published by the Free Software Foundation; either 32 | version 2.1 of the License, or (at your option) any later version. 33 | 34 | This library is distributed in the hope that it will be useful, 35 | but WITHOUT ANY WARRANTY; without even the implied warranty of 36 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 37 | Lesser General Public License for more details. 38 | 39 | You should have received a copy of the GNU Lesser General Public 40 | License along with this library; if not, write to the Free Software 41 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 42 | ***********************************************************************************/ -------------------------------------------------------------------------------- /SerialCommand.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | SerialCommand - An Arduino library to tokenize and parse commands received over 3 | a serial port. 4 | Copyright (C) 2011-2013 Steven Cogswell 5 | http://awtfy.com 6 | 7 | See SerialCommand.h for version history. 8 | 9 | This library is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU Lesser General Public 11 | License as published by the Free Software Foundation; either 12 | version 2.1 of the License, or (at your option) any later version. 13 | 14 | This library is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this library; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | ***********************************************************************************/ 23 | 24 | #if defined(ARDUINO) && ARDUINO >= 100 25 | #include "Arduino.h" 26 | #else 27 | #include "WProgram.h" 28 | #endif 29 | 30 | #include "SerialCommand.h" 31 | 32 | 33 | #include 34 | #ifndef SERIALCOMMAND_HARDWAREONLY 35 | #include 36 | #endif 37 | 38 | // Constructor makes sure some things are set. 39 | SerialCommand::SerialCommand() 40 | { 41 | usingSoftwareSerial=0; 42 | strncpy(delim," ",MAXDELIMETER); // strtok_r needs a null-terminated string 43 | term='\r'; // return character, default terminator for commands 44 | numCommand=0; // Number of callback handlers installed 45 | clearBuffer(); 46 | } 47 | 48 | #ifndef SERIALCOMMAND_HARDWAREONLY 49 | // Constructor to use a SoftwareSerial object 50 | SerialCommand::SerialCommand(SoftwareSerial &_SoftSer) 51 | { 52 | usingSoftwareSerial=1; 53 | SoftSerial = &_SoftSer; 54 | strncpy(delim," ",MAXDELIMETER); // strtok_r needs a null-terminated string 55 | term='\r'; // return character, default terminator for commands 56 | numCommand=0; // Number of callback handlers installed 57 | clearBuffer(); 58 | } 59 | #endif 60 | 61 | 62 | // 63 | // Initialize the command buffer being processed to all null characters 64 | // 65 | void SerialCommand::clearBuffer() 66 | { 67 | for (int i=0; i 0) 91 | #else 92 | while ((usingSoftwareSerial==0 && Serial.available() > 0) || (usingSoftwareSerial==1 && SoftSerial->available() > 0) ) 93 | #endif 94 | { 95 | int i; 96 | boolean matched; 97 | if (usingSoftwareSerial==0) { 98 | // Hardware serial port 99 | inChar=Serial.read(); // Read single available character, there may be more waiting 100 | } else { 101 | #ifndef SERIALCOMMAND_HARDWAREONLY 102 | // SoftwareSerial port 103 | inChar = SoftSerial->read(); // Read single available character, there may be more waiting 104 | #endif 105 | } 106 | #ifdef SERIALCOMMANDDEBUG 107 | Serial.print(inChar); // Echo back to serial stream 108 | #endif 109 | if (inChar==term) { // Check for the terminator (default '\r') meaning end of command 110 | #ifdef SERIALCOMMANDDEBUG 111 | Serial.print("Received: "); 112 | Serial.println(buffer); 113 | #endif 114 | bufPos=0; // Reset to start of buffer 115 | token = strtok_r(buffer,delim,&last); // Search for command at start of buffer 116 | if (token == NULL) return; 117 | matched=false; 118 | for (i=0; i SERIALCOMMANDBUFFER-1) bufPos=0; // wrap buffer around if full 151 | } 152 | } 153 | } 154 | 155 | // Adds a "command" and a handler function to the list of available commands. 156 | // This is used for matching a found token in the buffer, and gives the pointer 157 | // to the handler function to deal with it. 158 | void SerialCommand::addCommand(const char *command, void (*function)()) 159 | { 160 | if (numCommand < MAXSERIALCOMMANDS) { 161 | #ifdef SERIALCOMMANDDEBUG 162 | Serial.print(numCommand); 163 | Serial.print("-"); 164 | Serial.print("Adding command for "); 165 | Serial.println(command); 166 | #endif 167 | 168 | strncpy(CommandList[numCommand].command,command,SERIALCOMMANDBUFFER); 169 | CommandList[numCommand].function = function; 170 | numCommand++; 171 | } else { 172 | // In this case, you tried to push more commands into the buffer than it is compiled to hold. 173 | // Not much we can do since there is no real visible error assertion, we just ignore adding 174 | // the command 175 | #ifdef SERIALCOMMANDDEBUG 176 | Serial.println("Too many handlers - recompile changing MAXSERIALCOMMANDS"); 177 | #endif 178 | } 179 | } 180 | 181 | // This sets up a handler to be called in the event that the receveived command string 182 | // isn't in the list of things with handlers. 183 | void SerialCommand::addDefaultHandler(void (*function)()) 184 | { 185 | defaultHandler = function; 186 | } -------------------------------------------------------------------------------- /SerialCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | SerialCommand - An Arduino library to tokenize and parse commands received over 3 | a serial port. 4 | Copyright (C) 2011-2013 Steven Cogswell 5 | http://awtfy.com 6 | 7 | Version 20131021A. 8 | 9 | Version History: 10 | May 11 2011 - Initial version 11 | May 13 2011 - Prevent overwriting bounds of SerialCommandCallback[] array in addCommand() 12 | defaultHandler() for non-matching commands 13 | Mar 2012 - Some const char * changes to make compiler happier about deprecated warnings. 14 | Arduino 1.0 compatibility (Arduino.h header) 15 | Oct 2013 - SerialCommand object can be created using a SoftwareSerial object, for SoftwareSerial 16 | support. Requires #include in your sketch even if you don't use 17 | a SoftwareSerial port in the project. sigh. See Example Sketch for usage. 18 | Oct 2013 - Conditional compilation for the SoftwareSerial support, in case you really, really 19 | hate it and want it removed. 20 | 21 | This library is free software; you can redistribute it and/or 22 | modify it under the terms of the GNU Lesser General Public 23 | License as published by the Free Software Foundation; either 24 | version 2.1 of the License, or (at your option) any later version. 25 | 26 | This library is distributed in the hope that it will be useful, 27 | but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | Lesser General Public License for more details. 30 | 31 | You should have received a copy of the GNU Lesser General Public 32 | License along with this library; if not, write to the Free Software 33 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 34 | ***********************************************************************************/ 35 | #ifndef SerialCommand_h 36 | #define SerialCommand_h 37 | 38 | #if defined(ARDUINO) && ARDUINO >= 100 39 | #include "Arduino.h" 40 | #else 41 | #include "WProgram.h" 42 | #endif 43 | 44 | // If you want to use SerialCommand with the hardware serial port only, and want to disable 45 | // SoftwareSerial support, and thus don't have to use "#include " in your 46 | // sketches, then uncomment this define for SERIALCOMMAND_HARDWAREONLY, and comment out the 47 | // corresponding #undef line. 48 | // 49 | // You don't have to use SoftwareSerial features if this is not defined, you can still only use 50 | // the Hardware serial port, just that this way lets you get out of having to include 51 | // the SoftwareSerial.h header. 52 | //#define SERIALCOMMAND_HARDWAREONLY 1 53 | #undef SERIALCOMMAND_HARDWAREONLY 54 | 55 | #ifdef SERIALCOMMAND_HARDWAREONLY 56 | #warning "Warning: Building SerialCommand without SoftwareSerial Support" 57 | #endif 58 | 59 | #ifndef SERIALCOMMAND_HARDWAREONLY 60 | #include 61 | #endif 62 | 63 | #include 64 | 65 | 66 | #define SERIALCOMMANDBUFFER 16 67 | #define MAXSERIALCOMMANDS 10 68 | #define MAXDELIMETER 2 69 | 70 | #define SERIALCOMMANDDEBUG 1 71 | #undef SERIALCOMMANDDEBUG // Comment this out to run the library in debug mode (verbose messages) 72 | 73 | class SerialCommand 74 | { 75 | public: 76 | SerialCommand(); // Constructor 77 | #ifndef SERIALCOMMAND_HARDWAREONLY 78 | SerialCommand(SoftwareSerial &SoftSer); // Constructor for using SoftwareSerial objects 79 | #endif 80 | 81 | void clearBuffer(); // Sets the command buffer to all '\0' (nulls) 82 | char *next(); // returns pointer to next token found in command buffer (for getting arguments to commands) 83 | void readSerial(); // Main entry point. 84 | void addCommand(const char *, void(*)()); // Add commands to processing dictionary 85 | void addDefaultHandler(void (*function)()); // A handler to call when no valid command received. 86 | 87 | private: 88 | char inChar; // A character read from the serial stream 89 | char buffer[SERIALCOMMANDBUFFER]; // Buffer of stored characters while waiting for terminator character 90 | int bufPos; // Current position in the buffer 91 | char delim[MAXDELIMETER]; // null-terminated list of character to be used as delimeters for tokenizing (default " ") 92 | char term; // Character that signals end of command (default '\r') 93 | char *token; // Returned token from the command buffer as returned by strtok_r 94 | char *last; // State variable used by strtok_r during processing 95 | typedef struct _callback { 96 | char command[SERIALCOMMANDBUFFER]; 97 | void (*function)(); 98 | } SerialCommandCallback; // Data structure to hold Command/Handler function key-value pairs 99 | int numCommand; 100 | SerialCommandCallback CommandList[MAXSERIALCOMMANDS]; // Actual definition for command/handler array 101 | void (*defaultHandler)(); // Pointer to the default handler function 102 | int usingSoftwareSerial; // Used as boolean to see if we're using SoftwareSerial object or not 103 | #ifndef SERIALCOMMAND_HARDWAREONLY 104 | SoftwareSerial *SoftSerial; // Pointer to a user-created SoftwareSerial object 105 | #endif 106 | }; 107 | 108 | #endif //SerialCommand_h -------------------------------------------------------------------------------- /examples/SerialCommandExample/SerialCommandExample.pde: -------------------------------------------------------------------------------- 1 | // Demo Code for SerialCommand Library 2 | // Steven Cogswell 3 | // May 2011 4 | 5 | #include // We need this even if we're not using a SoftwareSerial object 6 | // Due to the way the Arduino IDE compiles 7 | #include 8 | 9 | #define arduinoLED 13 // Arduino LED on board 10 | 11 | SerialCommand SCmd; // The demo SerialCommand object 12 | 13 | void setup() 14 | { 15 | pinMode(arduinoLED,OUTPUT); // Configure the onboard LED for output 16 | digitalWrite(arduinoLED,LOW); // default to LED off 17 | 18 | Serial.begin(9600); 19 | 20 | // Setup callbacks for SerialCommand commands 21 | SCmd.addCommand("ON",LED_on); // Turns LED on 22 | SCmd.addCommand("OFF",LED_off); // Turns LED off 23 | SCmd.addCommand("HELLO",SayHello); // Echos the string argument back 24 | SCmd.addCommand("P",process_command); // Converts two arguments to integers and echos them back 25 | SCmd.addDefaultHandler(unrecognized); // Handler for command that isn't matched (says "What?") 26 | Serial.println("Ready"); 27 | 28 | } 29 | 30 | void loop() 31 | { 32 | SCmd.readSerial(); // We don't do much, just process serial commands 33 | } 34 | 35 | 36 | void LED_on() 37 | { 38 | Serial.println("LED on"); 39 | digitalWrite(arduinoLED,HIGH); 40 | } 41 | 42 | void LED_off() 43 | { 44 | Serial.println("LED off"); 45 | digitalWrite(arduinoLED,LOW); 46 | } 47 | 48 | void SayHello() 49 | { 50 | char *arg; 51 | arg = SCmd.next(); // Get the next argument from the SerialCommand object buffer 52 | if (arg != NULL) // As long as it existed, take it 53 | { 54 | Serial.print("Hello "); 55 | Serial.println(arg); 56 | } 57 | else { 58 | Serial.println("Hello, whoever you are"); 59 | } 60 | } 61 | 62 | 63 | void process_command() 64 | { 65 | int aNumber; 66 | char *arg; 67 | 68 | Serial.println("We're in process_command"); 69 | arg = SCmd.next(); 70 | if (arg != NULL) 71 | { 72 | aNumber=atoi(arg); // Converts a char string to an integer 73 | Serial.print("First argument was: "); 74 | Serial.println(aNumber); 75 | } 76 | else { 77 | Serial.println("No arguments"); 78 | } 79 | 80 | arg = SCmd.next(); 81 | if (arg != NULL) 82 | { 83 | aNumber=atol(arg); 84 | Serial.print("Second argument was: "); 85 | Serial.println(aNumber); 86 | } 87 | else { 88 | Serial.println("No second argument"); 89 | } 90 | 91 | } 92 | 93 | // This gets set as the default handler, and gets called when no other command matches. 94 | void unrecognized() 95 | { 96 | Serial.println("What?"); 97 | } 98 | 99 | -------------------------------------------------------------------------------- /examples/SerialCommandExampleSoftwareSerial/SerialCommandExampleSoftwareSerial.ino: -------------------------------------------------------------------------------- 1 | // Demo Code for SerialCommand Library. 2 | // This example uses a SoftwareSerial object instead of the Hardware Serial port. 3 | // 4 | // Make sure your SoftwareSerial port is actually functioning correctly before 5 | // you use this. See sketch for SoftwareSerialCheck included with this library. 6 | // 7 | // For this demo, all the command output is also echoed to the Hardware Serial port 8 | // which you might find useful for debugging that you have it working correctly. 9 | // 10 | // Steven Cogswell 11 | // October 2013 12 | 13 | #include 14 | #include 15 | 16 | #define arduinoLED 13 // Arduino LED on board 17 | 18 | // Parameters for SoftwareSerial port. For this example a Sparkfun CP2103 Breakout Module 19 | // was used. Change defines as appopriate for your use. 20 | // CP2103 -- Arduino 21 | // 3.3V 3.3V 22 | // TX-O pin 7 23 | // RX-I pin 6 24 | // GND GND 25 | #define TX 6 26 | #define RX 7 27 | SoftwareSerial testSoftSerial = SoftwareSerial(RX,TX); // The SoftwareSerial Object 28 | 29 | SerialCommand SCmd(testSoftSerial); // The demo SerialCommand object, using the SoftwareSerial Constructor 30 | 31 | void setup() 32 | { 33 | pinMode(arduinoLED,OUTPUT); // Configure the onboard LED for output 34 | digitalWrite(arduinoLED,LOW); // default to LED off 35 | 36 | Serial.begin(9600); 37 | testSoftSerial.begin(9600); 38 | 39 | // Setup callbacks for SerialCommand commands 40 | SCmd.addCommand("ON",LED_on); // Turns LED on 41 | SCmd.addCommand("OFF",LED_off); // Turns LED off 42 | SCmd.addCommand("HELLO",SayHello); // Echos the string argument back 43 | SCmd.addCommand("P",process_command); // Converts two arguments to integers and echos them back 44 | SCmd.addDefaultHandler(unrecognized); // Handler for command that isn't matched (says "What?") 45 | Serial.println("Ready"); 46 | testSoftSerial.println("SoftSerial Port Ready"); 47 | testSoftSerial.println("Command Output will also echo to Hardware Serial Port"); 48 | } 49 | 50 | void loop() 51 | { 52 | SCmd.readSerial(); // We don't do much, just process serial commands 53 | } 54 | 55 | 56 | void LED_on() 57 | { 58 | Serial.println("LED on"); 59 | testSoftSerial.println("(softserial) LED on"); 60 | digitalWrite(arduinoLED,HIGH); 61 | } 62 | 63 | void LED_off() 64 | { 65 | Serial.println("LED off"); 66 | testSoftSerial.println("(softserial) LED off"); 67 | 68 | digitalWrite(arduinoLED,LOW); 69 | } 70 | 71 | void SayHello() 72 | { 73 | char *arg; 74 | arg = SCmd.next(); // Get the next argument from the SerialCommand object buffer 75 | if (arg != NULL) // As long as it existed, take it 76 | { 77 | Serial.print("Hello "); 78 | Serial.println(arg); 79 | 80 | testSoftSerial.print("(softserial) Hello "); 81 | testSoftSerial.println(arg); 82 | } 83 | else { 84 | Serial.println("Hello, whoever you are"); 85 | testSoftSerial.println("(softserial) Hello, whoever you are"); 86 | } 87 | } 88 | 89 | 90 | void process_command() 91 | { 92 | int aNumber; 93 | char *arg; 94 | 95 | Serial.println("We're in process_command"); 96 | testSoftSerial.println("(softserial) We're in process_command"); 97 | arg = SCmd.next(); 98 | if (arg != NULL) 99 | { 100 | aNumber=atoi(arg); // Converts a char string to an integer 101 | Serial.print("First argument was: "); 102 | Serial.println(aNumber); 103 | 104 | testSoftSerial.print("(softserial) First argument was: "); 105 | testSoftSerial.println(aNumber); 106 | } 107 | else { 108 | Serial.println("No arguments"); 109 | testSoftSerial.println("(softserial) No Arguments"); 110 | } 111 | 112 | arg = SCmd.next(); 113 | if (arg != NULL) 114 | { 115 | aNumber=atol(arg); 116 | Serial.print("Second argument was: "); 117 | Serial.println(aNumber); 118 | 119 | testSoftSerial.print("(softserial) Second argument was: "); 120 | testSoftSerial.println(aNumber); 121 | } 122 | else { 123 | Serial.println("No second argument"); 124 | testSoftSerial.println("No second argument"); 125 | 126 | } 127 | 128 | } 129 | 130 | // This gets set as the default handler, and gets called when no other command matches. 131 | void unrecognized() 132 | { 133 | Serial.println("What?"); 134 | testSoftSerial.println("(softserial) What?"); 135 | } 136 | 137 | -------------------------------------------------------------------------------- /examples/SerialCommandHardwareOnlyExample/SerialCommandHardwareOnlyExample.ino: -------------------------------------------------------------------------------- 1 | // Demo Code for SerialCommand Library 2 | // Steven Cogswell 3 | // May 2011 4 | 5 | // If you want to use HardwareSerial only, and not have to include SoftwareSerial support, you 6 | // can define SERIALCOMMAND_HARDWAREONLY in SerialCommand.h, which will cause it to build without 7 | // SoftwareSerial support. This makes the library act as it used to before SoftwareSerial 8 | // support was added, and you don't need this next include: 9 | //#include 10 | 11 | #include 12 | 13 | #define arduinoLED 13 // Arduino LED on board 14 | 15 | SerialCommand SCmd; // The demo SerialCommand object 16 | 17 | void setup() 18 | { 19 | pinMode(arduinoLED,OUTPUT); // Configure the onboard LED for output 20 | digitalWrite(arduinoLED,LOW); // default to LED off 21 | 22 | Serial.begin(9600); 23 | 24 | // Setup callbacks for SerialCommand commands 25 | SCmd.addCommand("ON",LED_on); // Turns LED on 26 | SCmd.addCommand("OFF",LED_off); // Turns LED off 27 | SCmd.addCommand("HELLO",SayHello); // Echos the string argument back 28 | SCmd.addCommand("P",process_command); // Converts two arguments to integers and echos them back 29 | SCmd.addDefaultHandler(unrecognized); // Handler for command that isn't matched (says "What?") 30 | Serial.println("Ready"); 31 | 32 | } 33 | 34 | void loop() 35 | { 36 | SCmd.readSerial(); // We don't do much, just process serial commands 37 | } 38 | 39 | 40 | void LED_on() 41 | { 42 | Serial.println("LED on"); 43 | digitalWrite(arduinoLED,HIGH); 44 | } 45 | 46 | void LED_off() 47 | { 48 | Serial.println("LED off"); 49 | digitalWrite(arduinoLED,LOW); 50 | } 51 | 52 | void SayHello() 53 | { 54 | char *arg; 55 | arg = SCmd.next(); // Get the next argument from the SerialCommand object buffer 56 | if (arg != NULL) // As long as it existed, take it 57 | { 58 | Serial.print("Hello "); 59 | Serial.println(arg); 60 | } 61 | else { 62 | Serial.println("Hello, whoever you are"); 63 | } 64 | } 65 | 66 | 67 | void process_command() 68 | { 69 | int aNumber; 70 | char *arg; 71 | 72 | Serial.println("We're in process_command"); 73 | arg = SCmd.next(); 74 | if (arg != NULL) 75 | { 76 | aNumber=atoi(arg); // Converts a char string to an integer 77 | Serial.print("First argument was: "); 78 | Serial.println(aNumber); 79 | } 80 | else { 81 | Serial.println("No arguments"); 82 | } 83 | 84 | arg = SCmd.next(); 85 | if (arg != NULL) 86 | { 87 | aNumber=atol(arg); 88 | Serial.print("Second argument was: "); 89 | Serial.println(aNumber); 90 | } 91 | else { 92 | Serial.println("No second argument"); 93 | } 94 | 95 | } 96 | 97 | // This gets set as the default handler, and gets called when no other command matches. 98 | void unrecognized() 99 | { 100 | Serial.println("What?"); 101 | } 102 | 103 | -------------------------------------------------------------------------------- /examples/SoftwareSerialCheck/SoftwareSerialCheck.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // Do you actually have your SoftwareSerial hooked up correctly? Find out with this. 4 | // Tested with Sparkfun CPD2103 module. 5 | 6 | #define TX 6 7 | #define RX 7 8 | SoftwareSerial SoS = SoftwareSerial(RX,TX); 9 | 10 | 11 | void setup() { 12 | Serial.begin(9600); 13 | SoS.begin(9600); 14 | Serial.println("Starting up"); 15 | SoS.println("(Software) Starting up"); 16 | } 17 | 18 | void loop() { 19 | Serial.print("(Hardware) I'm sending something... "); 20 | SoS.println("(Software) Hello out the Software Serial Port"); 21 | SoS.println("(Software) This one is the Software Serial Port"); 22 | Serial.println("I sent two lines"); 23 | delay(1000); 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | SerialCommand KEYWORD1 2 | clearBuffer KEYWORD2 3 | next KEYWORD2 4 | readSerial KEYWORD2 5 | addCommand KEYWORd2 --------------------------------------------------------------------------------