{"id":16148890,"url":"https://github.com/erriez/erriezserialterminal","last_synced_at":"2025-03-18T18:33:07.423Z","repository":{"id":43272708,"uuid":"141902413","full_name":"Erriez/ErriezSerialTerminal","owner":"Erriez","description":"Serial Terminal library for Arduino","archived":false,"fork":false,"pushed_at":"2022-03-10T20:12:49.000Z","size":956,"stargazers_count":27,"open_issues_count":3,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-11T00:35:14.855Z","etag":null,"topics":["arduino","commandline","documentation","esp32","esp8266","getting","library","serial","started","terminal","universal","uno"],"latest_commit_sha":null,"homepage":"https://github.com/Erriez/ErriezArduinoLibrariesAndSketches","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Erriez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-22T14:23:18.000Z","updated_at":"2024-04-28T20:23:12.000Z","dependencies_parsed_at":"2022-08-12T10:21:34.590Z","dependency_job_id":null,"html_url":"https://github.com/Erriez/ErriezSerialTerminal","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erriez%2FErriezSerialTerminal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erriez%2FErriezSerialTerminal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erriez%2FErriezSerialTerminal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erriez%2FErriezSerialTerminal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Erriez","download_url":"https://codeload.github.com/Erriez/ErriezSerialTerminal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221715906,"owners_count":16868641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","commandline","documentation","esp32","esp8266","getting","library","serial","started","terminal","universal","uno"],"created_at":"2024-10-10T00:35:11.734Z","updated_at":"2024-10-27T18:15:03.126Z","avatar_url":"https://github.com/Erriez.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Serial Terminal library for Arduino\n\nThis is a universal Serial Terminal library for Arduino to parse ASCII commands and arguments.\n\n![Serial Terminal](https://raw.githubusercontent.com/Erriez/ErriezSerialTerminal/master/extras/ScreenshotSerialTerminal.png)\n\n\n## Hardware\n\nAny Arduino hardware with a serial port, such as:\n\nArduino:\n* UNO\n* Nano\n* Micro\n* Pro or Pro Mini\n* Mega or Mega2560\n* Leonardo\n\nOther targets:\n* DUE\n* ESP8266\n* ESP32\n* SAMD21\n* STM32F1\n\n\n## Examples\n\nArduino IDE | Examples | Erriez Serial Terminal |\n\n* [ErriezSerialTerminal](https://github.com/Erriez/ErriezSerialTerminal/blob/master/examples/ErriezSerialTerminal/ErriezSerialTerminal.ino)\n\n\n## Documentation\n\n- [Online HTML](https://erriez.github.io/ErriezSerialTerminal)\n- [Download PDF](https://github.com/Erriez/ErriezSerialTerminal/raw/master/ErriezSerialTerminal.pdf)\n\n\n## Usage\n\n**Initialization**\n\nCreate a Serial Terminal object. This can be initialized with optional newline and delimiter characters.\n\nDefault newline character: ```'\\n'```\nDefault delimiter character: ```Space```\n\n```c++\n#include \u003cErriezSerialTerminal.h\u003e\n\n// Newline character '\\r' or '\\n'\nchar newlineChar = '\\n'; \n// Separator character between commands and arguments\nchar delimiterChar = ' ';\n\n// Create serial terminal object\nSerialTerminal term(newlineChar, delimiterChar);\n\n\nvoid setup()\n{\n    // Initialize serial port\n    Serial.begin(115200);\n    \n    // Initialize the built-in LED\n    pinMode(LED_BUILTIN, OUTPUT);\n    digitalWrite(LED_BUILTIN, LOW);\n}\n```\n**Register new commands**\n\nCommands must be registered at startup with a corresponding ```callback handler``` .  This registers the command only, excluding arguments.\n\nThe callback handler will be called when the command has been received including the newline character.\n\nAn example of registering multiple commands:\n\n```c++\nvoid setup()\n{\n    ...\n\n    // Add command callback handlers\n    term.addCommand(\"?\", cmdHelp);\n    term.addCommand(\"help\", cmdHelp);\n    term.addCommand(\"on\", cmdLedOn);\n    term.addCommand(\"off\", cmdLedOff);\n}\n\nvoid cmdHelp()\n{\n    // Print usage\n    Serial.println(F(\"Serial terminal usage:\"));\n    Serial.println(F(\"  help or ?          Print this usage\"));\n    Serial.println(F(\"  on                 Turn LED on\"));\n    Serial.println(F(\"  off                Turn LED off\"));\n}\n\nvoid cmdLedOn()\n{\n    // Turn LED on\n    Serial.println(F(\"LED on\"));\n    digitalWrite(LED_BUILTIN, HIGH);\n}\n\nvoid cmdLedOff()\n{\n    // Turn LED off\n    Serial.println(F(\"LED off\"));\n    digitalWrite(LED_BUILTIN, LOW);\n}\n```\n\n**Set default handler**\n\nOptional: The default handler will be called when the command is not recognized.\n\n```c++\nvoid setup()\n{   \n    ...\n\n    // Set default handler for unknown commands\n    term.setDefaultHandler(unknownCommand);\n}\n\nvoid unknownCommand(const char *command)\n{\n    // Print unknown command\n    Serial.print(F(\"Unknown command: \"));\n    Serial.println(command);\n}\n```\n\n**Read from serial port**\n\nRead from the serial port in the main loop:\n\n```c++\nvoid loop()\n{\n    // Read from serial port and handle command callbacks\n    term.readSerial();\n}\n```\n\n**Get next argument**\n\nGet pointer to next argument in serial receive buffer:\n\n```c++\nchar *arg;\n\n// Get next argument\narg = term.getNext();\nif (arg != NULL) {\n    Serial.print(F(\"Argument: \"));\n    Serial.println(arg);\n} else {\n    Serial.println(F(\"No argument\"));\n}\n```\n\n**Get remaining characters**\n\nGet pointer to remaining characters in serial receive buffer:\n\n```c++\nchar *arg;\n\n// Get remaining characters\narg = term.getRemaining();\nif (arg != NULL) {\n    Serial.print(F(\"Remaining: \"));\n    Serial.println(arg);\n}\n```\n\n**Clear buffer**\n\nOptional: The serial receive buffer can be cleared with the following call:\n\n```c++\nterm.clearBuffer();\n```\n\n\n**Enable/Disable Character Echoing**\n\nOptional: Allow for any entered charecters to be printed back to the Serial interface.\nThis is useful for terminal programs like PuTTY.\nSupports both backspace characters, ^H and ^127.\n\n```c++\nterm.setSerialEcho(true); //Enable Character Echoing\n```\n\n\n**Set Post Command Handler**\n\nOptional: Add a function to be called AFTER a command has been handled.\n\n```c++\nvoid setup()\n{   \n    ...\n\n    // Set handler to be run AFTER a command has been handled.\n    term.setPostCommandHandler(postCommandHandler);\n}\n\nvoid setPostCommandHandler()\n{\n    // Print '\u003e ' for a primitive user UI\n    Serial.print(F(\"\u003e \"));\n}\n```\n\n## Library configuration\n\n```SerialTerminal.h``` contains the following configuration macro's:\n\n* ```ST_RX_BUFFER_SIZE``` : The default serial receive buffer size is 32 Bytes. This includes the command and arguments, excluding the ```'\\0'``` character.\n* ```ST_NUM_COMMAND_CHARS```: The default number of command characters is 8 Bytes, excluding the ```'\\0'``` character.\n\n\n## Library dependencies\n\n* None.\n\n\n## Library installation\n\nPlease refer to the [Wiki](https://github.com/Erriez/ErriezArduinoLibrariesAndSketches/wiki) page.\n\n\n## Other Arduino Libraries and Sketches from Erriez\n\n* [Erriez Libraries and Sketches](https://github.com/Erriez/ErriezArduinoLibrariesAndSketches)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferriez%2Ferriezserialterminal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferriez%2Ferriezserialterminal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferriez%2Ferriezserialterminal/lists"}