diff --git a/CommObd2Ble4.cpp b/CommObd2Ble4.cpp index 8cdcb41..b85c73f 100644 --- a/CommObd2Ble4.cpp +++ b/CommObd2Ble4.cpp @@ -404,7 +404,7 @@ bool CommObd2Ble4::parseRow() { // 1 frame data Serial.println(liveData->responseRow); - // Merge 0:xxxx 1:yyyy 2:zzzz to single xxxxyyyyzzzz string + // Merge frames 0:xxxx 1:yyyy 2:zzzz to single response xxxxyyyyzzzz string if (liveData->responseRow.length() >= 2 && liveData->responseRow.charAt(1) == ':') { liveData->responseRowMerged += liveData->responseRow.substring(2); } diff --git a/CommObd2Can.cpp b/CommObd2Can.cpp index 759e1ab..72d3fe0 100644 --- a/CommObd2Can.cpp +++ b/CommObd2Can.cpp @@ -1,6 +1,7 @@ #include "CommObd2Can.h" #include "BoardInterface.h" #include "LiveData.h" +#include /** Connect CAN adapter @@ -8,6 +9,21 @@ void CommObd2Can::connectDevice() { Serial.println("CAN connectDevice"); + + // Initialize MCP2515 running at 16MHz with a baudrate of 500kb/s and the masks and filters disabled. +/* if (CAN.begin(MCP_STDEXT, CAN_500KBPS, MCP_8MHZ) == CAN_OK) { + Serial.println("MCP2515 Initialized Successfully!"); + board->displayMessage(" > CAN init OK", ""); + } else { + Serial.println("Error Initializing MCP2515..."); + board->displayMessage(" > CAN init failed", ""); + return; + } + + CAN.setMode(MCP_NORMAL); // Set operation mode to normal so the MCP2515 sends acks to received data. + pinMode(pinCanInt, INPUT); // Configuring pin for /INT input +*/ + Serial.println("init_can() done"); } /** @@ -22,13 +38,13 @@ void CommObd2Can::disconnectDevice() { Scan device list, from menu */ void CommObd2Can::scanDevices() { - + Serial.println("COMM scanDevices"); } /** - * Main loop - */ + Main loop +*/ void CommObd2Can::mainLoop() { - + } diff --git a/CommObd2Can.h b/CommObd2Can.h index 231851f..aea03cb 100644 --- a/CommObd2Can.h +++ b/CommObd2Can.h @@ -2,20 +2,26 @@ #include "LiveData.h" #include "CommInterface.h" +#include class CommObd2Can : public CommInterface { protected: + byte pinCanInt = 15; + //MCP_CAN CAN(12); // Set CS to pin 10 + long unsigned int rxId; + unsigned char len = 0; + unsigned char rxBuf[512]; + char msgString[128]; // Array to store serial string public: void connectDevice() override; void disconnectDevice() override; void scanDevices() override; void mainLoop() override; // - /* void startBleScan(); - bool connectToServer(BLEAddress pAddress); - bool doNextAtCommand(); - bool parseRow(); - bool parseRowMerged(); */ + /* void startBleScan(); + bool connectToServer(BLEAddress pAddress); + bool doNextAtCommand(); + bool parseRow(); + bool parseRowMerged(); */ }; -