Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MTS-Cellular by
Terminal.cpp
00001 #include "mbed.h" 00002 #include "Terminal.h" 00003 #include "MTSLog.h" 00004 00005 using namespace mts; 00006 00007 Terminal::Terminal(MTSBufferedIO* io) : io(io), index(0) 00008 { 00009 terminal = new MTSSerial(USBTX, USBRX); 00010 } 00011 00012 Terminal::~Terminal() 00013 { 00014 delete terminal; 00015 } 00016 00017 void Terminal::start() 00018 { 00019 //Setup terminal session 00020 logInfo("Starting Terminal Mode.\n\r"); 00021 char buffer[256]; 00022 bool running = true; 00023 00024 //Run terminal session 00025 while (running) { 00026 //Write terminal data to interface 00027 int terminalRead = terminal->readable(); 00028 terminal->read(buffer, terminalRead); 00029 io->write(buffer, terminalRead); 00030 00031 //Check for exit condition 00032 for (int i = 0; i < terminalRead; i++) { 00033 if (index < (exitMsg.size() - 1)) { 00034 if(buffer[i] == exitMsg[index]) { 00035 index++; 00036 } else { 00037 index = 0; 00038 } 00039 } else { 00040 running = false; 00041 wait(.1); 00042 } 00043 } 00044 00045 //Write interface data to the terminal 00046 int ioRead = io->readable(); 00047 io->read(buffer, ioRead); 00048 terminal->write(buffer, ioRead); 00049 } 00050 00051 //Cleanup and return 00052 io->txClear(); 00053 io->rxClear(); 00054 logInfo("\n\rExited Terminal Mode.\n\r"); 00055 }
Generated on Wed Jul 13 2022 08:05:41 by
1.7.2
