From 2a63483aced280d88dfc3323c8bf911a706135ee Mon Sep 17 00:00:00 2001 From: Thomas Sarlandie Date: Wed, 22 Nov 2017 18:48:03 -0800 Subject: [PATCH] Changes submitted by Ron aka rescotti47 --- lib/KBox/src/KBox.cpp | 10 ++- lib/KBox/src/KMessage.h | 7 +- lib/KBox/src/KMessageNMEAVisitor.cpp | 87 +++++++++++++---------- lib/KBox/src/TaskManager.cpp | 3 +- lib/KBox/src/pages/BatteryMonitorPage.cpp | 51 +++++++++---- lib/KBox/src/pages/BatteryMonitorPage.h | 11 ++- lib/KBox/src/tasks/BarometerTask.cpp | 4 +- lib/KBox/src/tasks/SDCardTask.cpp | 9 ++- lib/KBox/src/tasks/SDCardTask.h | 3 + lib/KBox/src/tasks/WiFiTask.cpp | 9 ++- lib/KBoxDebug/src/KBoxDebug.cpp | 13 ++-- lib/KBoxDebug/src/KBoxDebug.h | 4 ++ src/esp/main.cpp | 31 ++++++-- src/host/main.cpp | 43 +++++++---- 14 files changed, 196 insertions(+), 89 deletions(-) mode change 100644 => 100755 lib/KBox/src/KBox.cpp mode change 100644 => 100755 lib/KBox/src/KMessage.h mode change 100644 => 100755 lib/KBox/src/KMessageNMEAVisitor.cpp mode change 100644 => 100755 lib/KBox/src/TaskManager.cpp mode change 100644 => 100755 lib/KBox/src/pages/BatteryMonitorPage.cpp mode change 100644 => 100755 lib/KBox/src/pages/BatteryMonitorPage.h mode change 100644 => 100755 lib/KBox/src/tasks/BarometerTask.cpp mode change 100644 => 100755 lib/KBox/src/tasks/SDCardTask.cpp mode change 100644 => 100755 lib/KBox/src/tasks/SDCardTask.h mode change 100644 => 100755 lib/KBox/src/tasks/WiFiTask.cpp mode change 100644 => 100755 lib/KBoxDebug/src/KBoxDebug.cpp mode change 100644 => 100755 lib/KBoxDebug/src/KBoxDebug.h mode change 100644 => 100755 src/esp/main.cpp mode change 100644 => 100755 src/host/main.cpp diff --git a/lib/KBox/src/KBox.cpp b/lib/KBox/src/KBox.cpp old mode 100644 new mode 100755 index 6070e1d7..8e084e9e --- a/lib/KBox/src/KBox.cpp +++ b/lib/KBox/src/KBox.cpp @@ -45,11 +45,13 @@ void KBox::setup() { neopixels.show(); // Initialize serialports - digitalWrite(nmea1_out_enable, 0); + //RES_MOD_11_6_17 enable nmea1 output - set one to 'high' 1`?! + digitalWrite(nmea1_out_enable, 1); digitalWrite(nmea2_out_enable, 0); pinMode(nmea1_out_enable, OUTPUT); pinMode(nmea2_out_enable, OUTPUT); - NMEA1_SERIAL.begin(38400); + //RES_MOD_7_25_17 set baud rate for NMEA0183 + NMEA1_SERIAL.begin(4800); NMEA2_SERIAL.begin(38400); // Initialize ADC @@ -71,11 +73,13 @@ void KBox::setup() { //adc.setConversionSpeed(ADC_LOW_SPEED, ADC_1); //adc.setSamplingSpeed(ADC_HIGH_SPEED, ADC_1); - taskManager.addTask(&mfd); taskManager.setup(); } void KBox::loop() { taskManager.loop(); + //RES_MOD_11_6_17 add next line to test writting to NMEA1 out + NMEA1_SERIAL.write("in loop"); + DEBUG("debug in loop"); } diff --git a/lib/KBox/src/KMessage.h b/lib/KBox/src/KMessage.h old mode 100644 new mode 100755 index 59651b85..3fbe0856 --- a/lib/KBox/src/KMessage.h +++ b/lib/KBox/src/KMessage.h @@ -47,9 +47,9 @@ class KMessage { class KVisitor { public: virtual void visit(const NMEASentence &) {}; - virtual void visit(const BarometerMeasurement &) {}; virtual void visit(const VoltageMeasurement &) {}; virtual void visit(const NMEA2000Message &) {}; + virtual void visit(const BarometerMeasurement &) {}; virtual void visit(const IMUMessage &) {}; }; @@ -180,14 +180,15 @@ class IMUMessage: public KMessage { * Pitch in radians. Positive when bow rises. */ double getPitch() const { - return pitch; + return pitch; }; /* * Roll in radians. Positive when tilted right. */ + double getRoll() const { - return roll; + return roll; }; }; diff --git a/lib/KBox/src/KMessageNMEAVisitor.cpp b/lib/KBox/src/KMessageNMEAVisitor.cpp old mode 100644 new mode 100755 index a9701845..57d63c45 --- a/lib/KBox/src/KMessageNMEAVisitor.cpp +++ b/lib/KBox/src/KMessageNMEAVisitor.cpp @@ -23,6 +23,7 @@ */ #include "KMessageNMEAVisitor.h" +#include "KBoxDebug.h" #include "util/NMEASentenceBuilder.h" #include "util/nmea2000.h" @@ -30,21 +31,6 @@ void KMessageNMEAVisitor::visit(const NMEASentence& s) { nmeaContent += s.getSentence() + "\r\n"; } -void KMessageNMEAVisitor::visit(const BarometerMeasurement &bm) { - // XDR is not a very well defined sentence. Can be used for lots of things - // apparently but that is better than nothing. - NMEASentenceBuilder sb("II", "XDR", 8); - sb.setField(1, "P"); - sb.setField(2, bm.getPressure(), 5); - sb.setField(3, "B"); - sb.setField(4, "Barometer"); - sb.setField(5, "T"); - sb.setField(6, bm.getTemperature()); - sb.setField(7, "C"); - sb.setField(8, "TempAir"); - nmeaContent += sb.toNMEA() + "\r\n"; -} - void KMessageNMEAVisitor::visit(const VoltageMeasurement &vm) { NMEASentenceBuilder sb("II", "XDR", 4); sb.setField(1, "V"); @@ -63,37 +49,66 @@ void KMessageNMEAVisitor::visit(const NMEA2000Message &n2km) { free(s); } +void KMessageNMEAVisitor::visit(const BarometerMeasurement &bm) { + // XDR is not a very well defined sentence. Can be used for lots of things + // apparently but that is better than nothing. + double respressure = bm.getPressure(); + //RES_MOD_7_29_17 convert pressure to Bar not hBar - 5 decimal places + respressure = respressure/100000; + NMEASentenceBuilder sb("II", "XDR", 8); + sb.setField(1, "P"); + sb.setField(2, respressure, 5); + sb.setField(3, "B"); + sb.setField(4, "Barometer"); + sb.setField(5, "C"); + sb.setField(6, bm.getTemperature()); + sb.setField(7, "C"); + sb.setField(8, "TempAir"); + nmeaContent += sb.toNMEA() + "\r\n"; + } -inline static double RadToDeg(double v) { return v*180.0/3.1415926535897932384626433832795; } - + //RES_MOD_7_29_17 for OpenCPN drop yaw data now only 12 instead of 16 data + // part of message, switch pitch and roll to match my mount void KMessageNMEAVisitor::visit(const IMUMessage &imu) { - NMEASentenceBuilder sb("II", "XDR", 16); + NMEASentenceBuilder sb("II", "XDR", 12); + //sb.setField(1, "A"); + //sb.setField(2, imu.getYaw(), 1); + //sb.setField(3, "D"); + //sb.setField(4, "Yaw"); + + //RES_MOD_7_29_17 DEFINE NEW VARIABLEs TO ADD OFFSET to pitch and roll + // and switch pitch and roll for my mounting, adjust SetField + double resrolloffset = imu.getPitch(); + double resptchoffset = imu.getRoll(); + resrolloffset = - resrolloffset; + resptchoffset = - resptchoffset; sb.setField(1, "A"); - sb.setField(2, RadToDeg(imu.getYaw()), 1); + //RES_MOD_7_29_17 use new variable + //sb.setField(6, imu.getPitch(), 1); + sb.setField(2, resrolloffset, 1); sb.setField(3, "D"); - sb.setField(4, "Yaw"); + //make pitch to be roll + sb.setField(4, "ROLL"); sb.setField(5, "A"); - sb.setField(6, RadToDeg(imu.getPitch()), 1); + //sb.setField(10, imu.getRoll(), 1); + sb.setField(6, resptchoffset, 1); sb.setField(7, "D"); - sb.setField(8, "Pitch"); + // make roll to be pitch; PTCH in OpenCPN + sb.setField(8, "PTCH"); - sb.setField(9, "A"); - sb.setField(10, RadToDeg(imu.getRoll()), 1); - sb.setField(11, "D"); - sb.setField(12, "Roll"); - - sb.setField(13, ""); - sb.setField(14, imu.getCalibration()); - sb.setField(15, ""); - sb.setField(16, "Calibration"); + sb.setField(9, ""); + sb.setField(10, imu.getCalibration()); + sb.setField(11, ""); + sb.setField(12, "Calibration"); nmeaContent += sb.toNMEA() + "\r\n"; - NMEASentenceBuilder sb2("II", "HDM", 2); - sb2.setField(1, RadToDeg(imu.getCourse())); - sb2.setField(2, "M"); + //RES_MOD_10_28_17 remove HDM output, as repeated from GPS + //NMEASentenceBuilder sb2("II", "HDM", 2); + //sb2.setField(1, imu.getCourse()); + //sb2.setField(2, "M"); - nmeaContent += sb2.toNMEA() + "\r\n"; -} + //nmeaContent += sb2.toNMEA() + "\r\n"; +} diff --git a/lib/KBox/src/TaskManager.cpp b/lib/KBox/src/TaskManager.cpp old mode 100644 new mode 100755 index b413fbcb..d77a7c26 --- a/lib/KBox/src/TaskManager.cpp +++ b/lib/KBox/src/TaskManager.cpp @@ -63,7 +63,8 @@ void TaskManager::loop() { loopStats.recordRun(loopTimer); if (statDisplayTimer > statDisplayInterval) { - displayStats(); + //RES_MOD_10_28_17 remove stat display + // displayStats(); statDisplayTimer = 0; } } diff --git a/lib/KBox/src/pages/BatteryMonitorPage.cpp b/lib/KBox/src/pages/BatteryMonitorPage.cpp old mode 100644 new mode 100755 index aeebd1a8..89b73175 --- a/lib/KBox/src/pages/BatteryMonitorPage.cpp +++ b/lib/KBox/src/pages/BatteryMonitorPage.cpp @@ -35,17 +35,19 @@ BatteryMonitorPage::BatteryMonitorPage() { addLayer(new TextLayer(Point(col1, row1), Size(20, 20), "House Battery", ColorWhite, ColorBlack, FontDefault)); addLayer(new TextLayer(Point(col2, row1), Size(20, 20), "House Current", ColorWhite, ColorBlack, FontDefault)); - addLayer(new TextLayer(Point(col1, row3), Size(20, 20), "Engine Battery", ColorWhite, ColorBlack, FontDefault)); + addLayer(new TextLayer(Point(col1, row3), Size(20, 20), "Baro Pressure", ColorWhite, ColorBlack, FontDefault)); addLayer(new TextLayer(Point(col2, row3), Size(20, 20), "Supply Voltage", ColorWhite, ColorBlack, FontDefault)); houseVoltage = new TextLayer(Point(col1, row2), Size(20, 20), "--", ColorWhite, ColorBlack, FontLarge); houseCurrent = new TextLayer(Point(col2, row2), Size(20, 20), "--", ColorWhite, ColorBlack, FontLarge); - starterVoltage = new TextLayer(Point(col1, row4), Size(20, 20), "--", ColorWhite, ColorBlack, FontLarge); + baroPressure = new TextLayer(Point(col1, row4), Size(20, 20), "101.535", ColorWhite, ColorBlack, FontLarge); supplyVoltage = new TextLayer(Point(col2, row4), Size(20, 20), "--", ColorWhite, ColorBlack, FontLarge); addLayer(houseVoltage); addLayer(houseCurrent); - addLayer(starterVoltage); + //RES_MOD_10_28_17 substatue baroPressure for starterVoltage see above also + addLayer(baroPressure); + //addLayer(starterVoltage); addLayer(supplyVoltage); } @@ -57,35 +59,56 @@ Color BatteryMonitorPage::colorForVoltage(float v) { return ColorRed; } if (v < 13.5) { - return ColorGreen; } return ColorBlue; } - +//RES_MOD_10_28_17 add color for pressure +Color BatteryMonitorPage::colorForPressure(float b) { + return ColorRed; +} String BatteryMonitorPage::formatMeasurement(float measure, const char *unit) { // extra spaces at the end needed to clear previous value completely // (we use a non-fixed width font) char s[10]; + //RES_MOD_10_28_17 change format to 6.2? + //snprintf(s, sizeof(s), "%6.2f %s ", measure, unit); + if (unit = "V"){ snprintf(s, sizeof(s), "%.1f %s ", measure, unit); - return String(s); +} + else { + snprintf(s, sizeof(s), "%8.4f %s ", measure, unit); + } +return String(s); } void BatteryMonitorPage::processMessage(const KMessage &message) { message.accept(*this); } +//RES_MOD_10_28_17 My playing around with the display +void BatteryMonitorPage::visit(const BarometerMeasurement &bm) { +//double respressure = bm.getPressure(); +//RES_MOD_7_29_17 convert pressure to Bar not hBar - 5 decimal places +//respressure = respressure/1000; +//respressure = 101.3; +DEBUG(" pressure from BatteryMonitorPage", bm.getTemperature()); +baroPressure->setText(formatMeasurement(bm.getTemperature(), "C")); +baroPressure->setColor(colorForPressure(bm.getTemperature())); +} + void BatteryMonitorPage::visit(const VoltageMeasurement &vm) { if (vm.getLabel() == "house") { - houseVoltage->setText(formatMeasurement(vm.getVoltage(), "V")); - houseVoltage->setColor(colorForVoltage(vm.getVoltage())); - } + houseVoltage->setText(formatMeasurement(vm.getVoltage(), "V")); + houseVoltage->setColor(colorForVoltage(vm.getVoltage())); + DEBUG("print from Display", vm.getVoltage()); + } if (vm.getLabel() == "supply") { supplyVoltage->setText(formatMeasurement(vm.getVoltage(), "V")); supplyVoltage->setColor(colorForVoltage(vm.getVoltage())); } - if (vm.getLabel() == "starter") { - starterVoltage->setText(formatMeasurement(vm.getVoltage(), "V")); - starterVoltage->setColor(colorForVoltage(vm.getVoltage())); - } + //if (vm.getLabel() == "starter") { + //Original below + //starterVoltage->setText(formatMeasurement(vm.getVoltage(), "V")); + //starterVoltage->setColor(colorForVoltage(vm.getVoltage())); + //} } - diff --git a/lib/KBox/src/pages/BatteryMonitorPage.h b/lib/KBox/src/pages/BatteryMonitorPage.h old mode 100644 new mode 100755 index 6a75b86c..383af913 --- a/lib/KBox/src/pages/BatteryMonitorPage.h +++ b/lib/KBox/src/pages/BatteryMonitorPage.h @@ -25,17 +25,26 @@ #include "MFD.h" #include "KMessage.h" #include "ui/TextLayer.h" +//RES_MOD_10_28_17 indclude DEBUG +#include "KBoxDebug.h" class BatteryMonitorPage : public Page, public KReceiver, public KVisitor { private: - TextLayer *houseVoltage, *houseCurrent, *starterVoltage, *supplyVoltage; + //RES_MOD_10_28_17 substatue baroPressure for starterVoltage + TextLayer *houseVoltage, *houseCurrent, *baroPressure, *supplyVoltage; Color colorForVoltage(float v); String formatMeasurement(float measure, const char *unit); + //RES_MOD_10_28_17 setup color for Pressure + Color colorForPressure(float b); + + public: BatteryMonitorPage(); void processMessage(const KMessage& message); void visit(const VoltageMeasurement&); + //RES_MOD_10_28_17 add this to public + void visit(const BarometerMeasurement&); }; diff --git a/lib/KBox/src/tasks/BarometerTask.cpp b/lib/KBox/src/tasks/BarometerTask.cpp old mode 100644 new mode 100755 index 2d93a91d..d9fe1234 --- a/lib/KBox/src/tasks/BarometerTask.cpp +++ b/lib/KBox/src/tasks/BarometerTask.cpp @@ -41,8 +41,8 @@ void BarometerTask::setup() { void BarometerTask::fetchValues() { temperature = bmp280.readTemperature(); pressure = bmp280.readPressure(); - - DEBUG("Read temperature=%.2f C and pressure=%.1f hPa", temperature, pressure/100); + //RES_MOD_10_28_17 clean up debug output to nmea cmmds only + //DEBUG("Read temperature=%.2f C and pressure=%.1f hPa", temperature, pressure/100); BarometerMeasurement m(temperature, pressure); sendMessage(m); } diff --git a/lib/KBox/src/tasks/SDCardTask.cpp b/lib/KBox/src/tasks/SDCardTask.cpp old mode 100644 new mode 100755 index af2aa593..e5433e94 --- a/lib/KBox/src/tasks/SDCardTask.cpp +++ b/lib/KBox/src/tasks/SDCardTask.cpp @@ -59,11 +59,16 @@ void SDCardTask::loop() { if (!isLogging()) { return; } - for (LinkedList::iterator it = receivedMessages.begin(); it != receivedMessages.end(); it++) { + for (LinkedList::iterator it = receivedMessages.begin(); it != receivedMessages.end(); it++) { logFile->print(it->timestamp); logFile->print(","); logFile->print(it->_message); logFile->println(); + //RES_MOD_10_28_17 send character message to DEBUG + const char *messagecpy = (it->_message.c_str()); + //DEBUG("Nmea data to follow","\n"); + DEBUG(messagecpy); + //end of my MOD } // Force data to SD and update the directory entry to avoid data loss. if (!logFile->sync() || logFile->getWriteError()) { @@ -154,7 +159,7 @@ uint64_t SDCardTask::getFreeSpace() const { // the running led stops flashing (although we do still call digitalWrite on it) // the serial ports start messing up big time (missing a lot of data) // eventually other things crash... - // Could be a memory problem or something like that. Have not found + // Could be a memory problem or something like that. Have not found // it yet but the culprit is this line so for now it is disabled. uint64_t space = 0; //logFile->volume()->freeClusterCount(); space *= logFile->volume()->blocksPerCluster(); diff --git a/lib/KBox/src/tasks/SDCardTask.h b/lib/KBox/src/tasks/SDCardTask.h old mode 100644 new mode 100755 index af1a6338..c52545dd --- a/lib/KBox/src/tasks/SDCardTask.h +++ b/lib/KBox/src/tasks/SDCardTask.h @@ -49,6 +49,9 @@ class SDCardTask : public Task, public KReceiver { LinkedList receivedMessages; public: + //RES_MOD_10_28_17 add messagecpy to public string + String messagecpy() const; + //end of my add SDCardTask(); virtual ~SDCardTask(); diff --git a/lib/KBox/src/tasks/WiFiTask.cpp b/lib/KBox/src/tasks/WiFiTask.cpp old mode 100644 new mode 100755 index b1143ff7..10522527 --- a/lib/KBox/src/tasks/WiFiTask.cpp +++ b/lib/KBox/src/tasks/WiFiTask.cpp @@ -41,11 +41,14 @@ void WiFiTask::loop() { if (rxBuf[rxIndex - 1] == '\n') { rxBuf[rxIndex - 1] = 0; DEBUG("WiFi: %s", rxBuf); + //RES_MOD_10_28_17 add a blank line in output + DEBUG(""); rxIndex = 0; } if (rxIndex >= sizeof(rxBuf) - 1) { rxBuf[rxIndex] = 0; DEBUG("WiFi full: %s", rxBuf); + DEBUG(""); rxIndex = 0; } } @@ -62,13 +65,15 @@ void WiFiTask::loop() { } if (WiFiSerial.availableForWrite() <= 0) { - //DEBUG("Not sending because send buffer is full (need %i but %i available).", toSend.length(), WiFiSerial.availableForWrite()); + //RES_MOD_9_6_17 comment debug + //DEBUG("Not sending because send buffer is full (need %i but %i available).", toSend.length(), WiFiSerial.availableForWrite()); break; } size_t available = WiFiSerial.availableForWrite(); String s = toSend; s.remove(available); size_t written = WiFiSerial.print(s); + //RES_MOD_9_6_17 comment debug //DEBUG("Sent %i/%i (%i avail) of %s", written, toSend.length(), available, toSend.c_str()); if (written == toSend.length()) { @@ -96,5 +101,3 @@ void WiFiTask::processMessage(const KMessage &m) { m.accept(v); sendQueue.add(v.toNMEA()); } - - diff --git a/lib/KBoxDebug/src/KBoxDebug.cpp b/lib/KBoxDebug/src/KBoxDebug.cpp old mode 100644 new mode 100755 index c9b5f4c5..095ef1cf --- a/lib/KBoxDebug/src/KBoxDebug.cpp +++ b/lib/KBoxDebug/src/KBoxDebug.cpp @@ -24,6 +24,9 @@ #include #include +//RES_MOD_11_6_17 add drivers for NMEA1_SERIAL +/* Drivers */ +#include #ifndef DebugSerial #ifdef ESP8266 @@ -58,14 +61,16 @@ void debug(const char *fname, int lineno, const char *fmt, ... ) { if (lastSlash > 0) { fname = fname + lastSlash + 1; } - DebugSerial.print(fname); - DebugSerial.print(":"); - DebugSerial.print(lineno); - DebugSerial.print(" "); + //RES_MOD_10_28_17 if NMEA1083 data skip fname and lineno + //DebugSerial.print(fname); + //DebugSerial.print(":"); + //DebugSerial.print(lineno); + //DebugSerial.print(" "); char tmp[128]; // resulting string limited to 128 chars va_list args; va_start (args, fmt ); vsnprintf(tmp, 128, fmt, args); va_end (args); DebugSerial.println(tmp); + NMEA1_SERIAL.write(tmp); } diff --git a/lib/KBoxDebug/src/KBoxDebug.h b/lib/KBoxDebug/src/KBoxDebug.h old mode 100644 new mode 100755 index 678ea32a..11d5bfb8 --- a/lib/KBoxDebug/src/KBoxDebug.h +++ b/lib/KBoxDebug/src/KBoxDebug.h @@ -29,3 +29,7 @@ void debug_init(); void debug(const char *fname, int lineno, const char *fmt, ... ); + +//RES_MOD_11_6_17 add drivers for NMEA1_SERIAL +/* Drivers */ +//#include "drivers/board.h" diff --git a/src/esp/main.cpp b/src/esp/main.cpp old mode 100644 new mode 100755 index 1cd6028b..4d4d7781 --- a/src/esp/main.cpp +++ b/src/esp/main.cpp @@ -32,19 +32,22 @@ NetServer server(10110); static const uint32_t connectedColor = rgb.Color(0x00, 0xff, 0x00); static const uint32_t readyColor = rgb.Color(0x00, 0x00, 0xff); +//RES_MOD_8_2_17 add HeronRpi static parameters +const char* ssid = "HeronRpi"; +const char* password = "sharon47"; #include #include - +//RREMOD_8_4_17 mod wifi to connect to HeronRpi network void setup() { DEBUG_INIT(); rgb.begin(); rgb.setPixelColor(0, 0, 0, 0xff); rgb.show(); - - WiFi.mode(WIFI_AP); - WiFi.softAP("KBox"); + //RES_MOD_8_2_17 comment out softAP setup - 2 lines use station class + //WiFi.mode(WIFI_AP); + //WiFi.softAP("KBox"); Serial.begin(115200); Serial.setTimeout(0); @@ -54,7 +57,24 @@ void setup() { // upload are done and restart normal operation. delay(1000); - DEBUG("Starting KBox WiFi module"); + //DEBUG("Starting KBox WiFi module"); + + //RES_MOD_8_2_17 use wifi.begin instead -up to } is mine + DEBUG("Starting Kbox WiFi to connect to HeronRpi"); + WiFi.begin(ssid, password); + DEBUG("Connecting to", ssid); + int i = 0; + //RES_MOD_8_2_17 wait for the wifi to connect + while (WiFi.status() != WL_CONNECTED) { + delay(1000); + DEBUG("waiting to connect", ++i); + + } + //RES_MOD_9_6_17 serial print when connected + DEBUG("Connection established"); + DEBUG("Connected to %s", WiFi.localIP().toString().c_str()); + + //RES_MOD_8_2_17 end of my add } uint8_t buffer[1024]; @@ -90,4 +110,3 @@ void loop() { } rgb.show(); } - diff --git a/src/host/main.cpp b/src/host/main.cpp old mode 100644 new mode 100755 index b54d395f..d058a8b8 --- a/src/host/main.cpp +++ b/src/host/main.cpp @@ -40,7 +40,8 @@ void setup() { // https://forum.pjrc.com/threads/27827-Float-in-sscanf-on-Teensy-3-1 asm(".global _printf_float"); - delay(3000); + //RES_MOD_7_25_17 increase delay to 5 seconds to allow putty to start + delay(5000); DEBUG_INIT(); DEBUG("Starting"); @@ -52,8 +53,9 @@ void setup() { WiFiTask *wifi = new WiFiTask(); // Create all the generating tasks and connect them - NMEA2000Task *n2kTask = new NMEA2000Task(); - n2kTask->connectTo(*wifi); + //RES_MOD_9_12 comment out all NMEA2000tasks except voltage + //NMEA2000Task *n2kTask = new NMEA2000Task(); + //n2kTask->connectTo(*wifi); ADCTask *adcTask = new ADCTask(kbox.getADC()); @@ -61,7 +63,7 @@ void setup() { VoltageN2kConverter *voltageConverter = new VoltageN2kConverter(); adcTask->connectTo(*voltageConverter); voltageConverter->connectTo(*wifi); - voltageConverter->connectTo(*n2kTask); + //voltageConverter->connectTo(*n2kTask); NMEAReaderTask *reader1 = new NMEAReaderTask(NMEA1_SERIAL); NMEAReaderTask *reader2 = new NMEAReaderTask(NMEA2_SERIAL); @@ -70,30 +72,33 @@ void setup() { IMUTask *imuTask = new IMUTask(); imuTask->connectTo(*wifi); - imuTask->connectTo(*n2kTask); + //imuTask->connectTo(*n2kTask); BarometerTask *baroTask = new BarometerTask(); + //RES_Mod_7_29_17 add baromoeter task to wifi before n2kTask + baroTask->connectTo(*wifi); - BarometerN2kConverter *bn2k = new BarometerN2kConverter(); - bn2k->connectTo(*wifi); - bn2k->connectTo(*n2kTask); + //BarometerN2kConverter *bn2k = new BarometerN2kConverter(); + //bn2k->connectTo(*wifi); + //bn2k->connectTo(*n2kTask); - baroTask->connectTo(*bn2k); + //baroTask->connectTo(*bn2k); SDCardTask *sdcardTask = new SDCardTask(); reader1->connectTo(*sdcardTask); reader2->connectTo(*sdcardTask); adcTask->connectTo(*sdcardTask); - n2kTask->connectTo(*sdcardTask); + //n2kTask->connectTo(*sdcardTask); baroTask->connectTo(*sdcardTask); imuTask->connectTo(*sdcardTask); // Add all the tasks kbox.addTask(new IntervalTask(new RunningLightTask(), 250)); kbox.addTask(new IntervalTask(adcTask, 1000)); - kbox.addTask(new IntervalTask(imuTask, 50)); + //RES_Mod_7_29_17 - change imyu internval to 250 + kbox.addTask(new IntervalTask(imuTask, 1000)); kbox.addTask(new IntervalTask(baroTask, 1000)); - kbox.addTask(n2kTask); + //kbox.addTask(n2kTask); kbox.addTask(reader1); kbox.addTask(reader2); kbox.addTask(wifi); @@ -106,7 +111,7 @@ void setup() { StatsPage *statsPage = new StatsPage(); statsPage->setNmea1Task(reader1); statsPage->setNmea2Task(reader2); - statsPage->setNMEA2000Task(n2kTask); + //statsPage->setNMEA2000Task(n2kTask); statsPage->setTaskManager(&(kbox.getTaskManager())); statsPage->setSDCardTask(sdcardTask); @@ -137,6 +142,16 @@ void loop() { CPU_RESTART; } else { - kbox.loop(); + kbox.loop(); + //RES_MOD_10_28_17 add serial read to empty buffer from Rpi + //and repeat to Nmeaouput1 what the Rpi repeats + //int c = Serial.read(); + //while (Serial.read()>0){ + //int c_rd = 0; + while (Serial.read() > 0) { + // DEBUG("USB input"); + NMEA1_SERIAL.write(Serial.read()); + } + } }