Simple embedded shell with runtime pluggable commands.

Dependents:   DataBus2018

Implements a simple unix-like shell for embedded systems with a pluggable command architecture.

Revision:
23:b1e49cfcaef6
Parent:
21:5d7ac1f0b842
Child:
24:004e33abce37
--- a/SimpleShell.cpp	Mon Dec 24 17:44:29 2018 +0000
+++ b/SimpleShell.cpp	Mon Dec 24 18:35:29 2018 +0000
@@ -28,6 +28,12 @@
 }
 
 
+char *SimpleShell::basename(char *path) {
+    return path;
+}
+
+
+
 SimpleShell::SimpleShell()
 {
     lookupEnd = 0;
@@ -40,6 +46,7 @@
     attach(callback(this, &SimpleShell::rm), "rm");
     attach(callback(this, &SimpleShell::touch), "touch");
     attach(callback(this, &SimpleShell::ls), "ls");
+    attach(callback(this, &SimpleShell::send), "send");
 }
 
 
@@ -168,6 +175,27 @@
 }
 
 
+void SimpleShell::send(int argc, char **argv)
+{
+    const char SOF=0x01;
+    const char ETX=0x03;
+    const char EOT=0x04;
+    const char ACK=0x07;
+    const char NACK=0x18;
+    FILE *fp;
+
+    int i = 1;
+    if (argc >= 2) {
+        if ((fp = fopen(canon(argv[i]), "r")) == 0) {
+            printf("%s: can't open file\n", basename(argv[i]));
+        } else {
+        }
+    } else {
+        puts("usage: send file1 [file2 ...]");
+    }
+}
+
+
 void SimpleShell::run()
 {
     bool done=false;