From d3b0f907fe7337e8eed0c82abe677a2f413bc12c Mon Sep 17 00:00:00 2001 From: Lubos Petrovic Date: Mon, 21 Dec 2020 18:32:18 +0100 Subject: [PATCH] can --- CommObd2Can.cpp | 10 +++++----- evDash.ino | 4 +--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/CommObd2Can.cpp b/CommObd2Can.cpp index 2f92249..af0dfa9 100644 --- a/CommObd2Can.cpp +++ b/CommObd2Can.cpp @@ -70,15 +70,14 @@ void CommObd2Can::mainLoop() { if ((firstByte & 0xf0) == 0x10) { // First frame, request another sendFlowControlFrame(); delay(10); - for (uint8_t i = 0; i < 50; i++) { + for (uint16_t i = 0; i < 1000; i++) { receivePID(); if (rxRemaining <= 2) break; - delay(10); + delay(1); } - delay(30); } - if (lastDataSent != 0 && (unsigned long)(millis() - lastDataSent) > 500) { + if (lastDataSent != 0 && (unsigned long)(millis() - lastDataSent) > 100) { Serial.print("CAN execution timeout. Continue with next command."); liveData->canSendNextAtCommand = true; return; @@ -132,6 +131,7 @@ void CommObd2Can::sendPID(const uint16_t pid, const String& cmd) { // uint8_t sndStat = CAN->sendMsgBuf(0x7e4, 1, 8, tmp); // 29 bit extended frame if (sndStat == CAN_OK) { Serial.print("SENT "); + lastDataSent = millis(); } else { Serial.print("Error sending PID "); } @@ -141,7 +141,6 @@ void CommObd2Can::sendPID(const uint16_t pid, const String& cmd) { Serial.print(msgString); } Serial.println(""); - lastDataSent = millis(); } /** @@ -171,6 +170,7 @@ uint8_t CommObd2Can::receivePID() { if (!digitalRead(pinCanInt)) // If CAN0_INT pin is low, read receive buffer { + lastDataSent = millis(); Serial.print(" CAN READ "); CAN->readMsgBuf(&rxId, &rxLen, rxBuf); // Read data: len = data length, buf = data byte(s) diff --git a/evDash.ino b/evDash.ino index f0908fa..b68f12d 100644 --- a/evDash.ino +++ b/evDash.ino @@ -1,7 +1,5 @@ /* - Project renamed from eNiroDashboard to evDash - - !! Supported BLE4 adapter is Vgate ICar Pro BLE4 version + Project renamed from eNiroDashboard to evDash Serial console commands