From 9faa3431d1d82fa73e198803d888d2933d930d39 Mon Sep 17 00:00:00 2001 From: "trent.wyatt" Date: Fri, 12 Jan 2024 04:41:54 -0600 Subject: [PATCH] removed copy of Bang source --- examples/fileIO/bang.cpp | 90 ---------------------------------------- examples/fileIO/bang.h | 42 ------------------- 2 files changed, 132 deletions(-) delete mode 100644 examples/fileIO/bang.cpp delete mode 100644 examples/fileIO/bang.h diff --git a/examples/fileIO/bang.cpp b/examples/fileIO/bang.cpp deleted file mode 100644 index 8d952c7..0000000 --- a/examples/fileIO/bang.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * bang.cpp - * - * class implementation file for the ArduinoCLI project - * https://github.com/ripred/ArduinoCLI - * - */ -#include "Bang.h" - -Bang::Bang() { - dbgstrm = nullptr; - cmdstrm = nullptr; -} - -Bang::Bang(Stream &cmd_strm) : - dbgstrm{nullptr}, - cmdstrm{&cmd_strm} -{ -} - -Bang::Bang(Stream &cmd_strm, Stream &dbg_strm) { - dbgstrm = &dbg_strm; - cmdstrm = &cmd_strm; -} - -String Bang::send_and_recv(char const cmd_id, char const *pcmd) { - if (!cmdstrm) { return ""; } - - String output = ""; - String cmd(String(cmd_id) + pcmd); - Stream &stream = *cmdstrm; - stream.println(cmd); - delay(100); - while (stream.available()) { - output += stream.readString(); - } - - return output; -} - -String Bang::exec(char const *pcmd) { - return send_and_recv('!', pcmd); -} - -String Bang::macro(char const *pcmd) { - return send_and_recv('@', pcmd); -} - -String Bang::serial(char const *ptext) { - return send_and_recv('#', ptext); -} - -String Bang::compile_and_upload(char const *pcmd) { - return send_and_recv('&', pcmd); -} - -long Bang::write_file(char const *filename, char const * const lines[], int const num) { - if (num <= 0) { return 0; } - long len = 0; - - String cmd = String("echo \"") + lines[0] + "\" > " + filename; - len += cmd.length(); - exec(cmd.c_str()); - - for (int i=1; i < num; i++) { - cmd = String("echo \"") + lines[i] + "\" >> " + filename; - len += cmd.length(); - exec(cmd.c_str()); - } - - return len; -} - -void Bang::push_me_pull_you(Stream &str1, Stream &str2) { - if (str1.available() >= 2) { - uint32_t const period = 5; - uint32_t start = millis(); - while (millis() - start < period) { - while (str1.available()) { - str2.println(str1.readString()); - } - } - } -} - -void Bang::sync() { - if (!cmdstrm || !dbgstrm) { return; } - push_me_pull_you(*cmdstrm, *dbgstrm); - push_me_pull_you(*dbgstrm, *cmdstrm); -} diff --git a/examples/fileIO/bang.h b/examples/fileIO/bang.h deleted file mode 100644 index 513a13b..0000000 --- a/examples/fileIO/bang.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * bang.h - * - * class declaration file for the ArduinoCLI project - * https://github.com/ripred/ArduinoCLI - * - */ -#ifndef BANG_H_INCL -#define BANG_H_INCL - -#include -#include -#include - -class Bang { -private: - // pointers to the cmd I/O stream and the optional serial output stream - Stream *dbgstrm {nullptr}; - Stream *cmdstrm {nullptr}; - -public: - // constructors - Bang(); - Bang(Stream &cmd_strm); - Bang(Stream &cmd_strm, Stream &dbg_strm); - - String send_and_recv(char const cmd_id, char const *pcmd); - - String exec(char const *pcmd); - String macro(char const *pcmd); - String serial(char const *pcmd); - String compile_and_upload(char const *pcmd); - - long write_file(char const *filename, char const * const lines[], int const num); - - void push_me_pull_you(Stream &str1, Stream &str2); - - void sync(); - -}; // class Bang - -#endif // BANG_H_INCL