can fixes

This commit is contained in:
Lubos Petrovic
2020-12-21 15:21:23 +01:00
parent d0c5eb72b1
commit 682fa25ab8
2 changed files with 9 additions and 9 deletions

View File

@@ -17,7 +17,7 @@
#include "CarKiaEniro.h"
#define commandQueueCountKiaENiro 30
#define commandQueueLoopFromKiaENiro 10
#define commandQueueLoopFromKiaENiro 8
/**
* activateCommandQueue

View File

@@ -72,13 +72,12 @@ void CommObd2Can::mainLoop() {
delay(10);
for (uint8_t i = 0; i < 50; i++) {
receivePID();
if (rxRemaining <= 0)
if (rxRemaining <= 2)
break;
delay(10);
}
delay(30);
}
Serial.println(liveData->params.currentTime );
if (lastDataSent != 0 && (unsigned long)(millis() - lastDataSent) > 500) {
Serial.print("CAN execution timeout. Continue with next command.");
liveData->canSendNextAtCommand = true;
@@ -95,6 +94,7 @@ void CommObd2Can::executeCommand(String cmd) {
Serial.println(cmd);
if (cmd.equals("") || cmd.startsWith("AT")) { // skip AT commands as not used by direct CAN connection
lastDataSent = 0;
liveData->canSendNextAtCommand = true;
return;
}
@@ -215,13 +215,13 @@ bool CommObd2Can::processFrame() {
switch (frameType) {
// Single frame
case 0:
rxRemaining = (rxBuf[1] & 0x0f) + 1;
rxRemaining = (rxBuf[1] & 0x0f);
break;
// First frame
case 1:
rxRemaining = ((rxBuf[0] & 0x0f) << 8) + rxBuf[1] + 1;
rxRemaining = ((rxBuf[0] & 0x0f) << 8) + rxBuf[1];
liveData->responseRowMerged = "";
for (uint16_t i = 0; i < 62; i++)
for (uint16_t i = 0; i < rxRemaining - 1; i++)
liveData->responseRowMerged += "00";
liveData->responseRow = "0:";
start = 2;
@@ -264,8 +264,8 @@ bool CommObd2Can::processFrame() {
Serial.println(liveData->responseRowMerged);
}
// Send command to board module (obd2 simulation)
if (rxRemaining <= 0) {
// Send response to board module
if (rxRemaining <= 2) {
Serial.print("merged:");
Serial.println(liveData->responseRowMerged);
board->parseRowMerged();