summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/main.cpp b/main.cpp
index fec1ba0..29263cd 100644
--- a/main.cpp
+++ b/main.cpp
@@ -37,7 +37,7 @@ std::vector<std::string> split(const std::string& str, const char sep)
size_t next = 0;
while ((next = str.find(sep, last)) != std::string::npos) {
- v.push_back(str.substr(next, next +1));
+ v.push_back(str.substr(last, next-last));
last = next + 1;
}
@@ -87,19 +87,16 @@ int main(int argc, char** argv)
// write prompt
uart::write<1>("> ");
-
- while (uart::rx_buffer<1>().empty());
+
do {
- input += uart::read_wait<1>();
- } while (uart::rx_buffer<1>().front() != '\r');
- // remove '\r' from the RX buffer
- uart::rx_buffer<1>().pop();
+ input += uart::read_wait<1>();
+ } while (input.back() != '\r');
#ifdef DEBUG
uart::write<1>("\n\rinput: ");
uart::print<1>(input);
#endif
-
+
// remove weird symbols
strip(input);
@@ -107,8 +104,9 @@ int main(int argc, char** argv)
const std::vector<std::string> command = split(input, ' ');
#ifdef DEBUG
- for (const std::string &s : command) {
- uart::print<1>(s);
+ uart::print<1>("parsed commmands:");
+ for (int i = 0; i < command.size(); i++) {
+ uart::print<1>(command[i]);
}
#endif