Racelogic / Mbed 2 deprecated VIPS_LTC_RAW_IMU

Dependencies:   BufferedSerial FatFileSystemCpp mbed

Revision:
52:adbbaadca0a9
Parent:
51:d4a5151af5af
Child:
53:b790ed7b838f
Child:
55:ee36cab19a58
--- a/main.cpp	Tue Aug 17 16:38:39 2021 +0000
+++ b/main.cpp	Wed Aug 18 10:56:10 2021 +0000
@@ -1,4 +1,4 @@
-#define APP_VERSION 0.14
+#define APP_VERSION 0.15
 
 /*
 Settings file options
@@ -631,6 +631,7 @@
     UserSettings.InvertRoll = false;
     UserSettings.InvertPitch = false;
     UserSettings.InvertYaw = false;
+    UserSettings.bypassBaud = 0;
 
 
     LocalFileSystem localFS("local");
@@ -639,8 +640,13 @@
     int valueIn;
     float floatIn;
     if (LSFile) {
-        while (!feof(LSFile)) {
+        while (!feof(LSFile) && !UserSettings.bypassBaud) {
             if (fgets(lineBuffer, 64, LSFile)) {
+                if (sscanf(lineBuffer,"RadioConfigPassthrough=%d",&valueIn) == 1) {
+                    pc.printf("Switching to RADIO/USB bypass mode at %d baud\r\n",valueIn);
+                    UserSettings.bypassBaud = valueIn;
+                }
+
                 if (sscanf(lineBuffer,"Output_Format=%d",&valueIn) == 1) {
                     pc.printf("Got Output_Format value from file of %d\r\n",valueIn);
                     UserSettings.SerialOutMode = valueIn;
@@ -837,6 +843,59 @@
 }
 
 
+void XBEEBypassmode(int baud)
+{
+    pc.baud(baud);
+
+/*
+    COM1.baud(9600);
+    COM1.puts("+++");
+    wait(1.2);
+    switch (baud) {
+        case 1200:
+            COM1.puts("ATBD0\n");
+            break;
+        case 2400:
+            COM1.puts("ATBD1\n");
+            break;
+        case 4800:
+            COM1.puts("ATBD2\n");
+            break;
+        case 9600:
+            COM1.puts("ATBD3\n");
+            break;
+        case 19200:
+            COM1.puts("ATBD4\n");
+            break;
+        case 38400:
+            COM1.puts("ATBD5\n");
+            break;
+        case 57600:
+            COM1.puts("ATBD6\n");
+            break;
+        case 115200:
+            COM1.puts("ATBD7\n");
+            break;
+        default:
+            COM1.printf("ATBD%d\n",baud);
+            break;
+    }
+
+    wait(0.1);
+    COM1.puts("ATCN\n");
+    wait(0.5);
+*/
+
+    COM1.baud(baud);
+    while (true) {
+        if (pc.readable()) {
+            char commandIn = pc.getc();
+            COM1.putc(commandIn);
+        }
+        if (COM1.readable())
+            pc.putc(COM1.getc());
+    }
+}
 
 int main()
 {
@@ -846,6 +905,10 @@
 
     readSettingsFile();
 
+    if (UserSettings.bypassBaud) {
+        XBEEBypassmode(UserSettings.bypassBaud);
+    }
+
     switch(UserSettings.FIZmode) {
         case formatPreston :
             FIZPort = new FIZDisney(p9, p10);
@@ -868,7 +931,7 @@
             pc.printf("Set Default - Preston");
     }
 //    FIZPort = new FIZDigiPowerActive(p9, p10);
-    COM1.baud(115200); // VIPS port
+    COM1.baud(115200); // radio port
 
     Thread serialTask(ethernetTask, &UserSettings, osPriorityNormal, 256 * 4);