can fixes
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
#include "CarKiaEniro.h"
|
#include "CarKiaEniro.h"
|
||||||
|
|
||||||
#define commandQueueCountKiaENiro 30
|
#define commandQueueCountKiaENiro 30
|
||||||
#define commandQueueLoopFromKiaENiro 10
|
#define commandQueueLoopFromKiaENiro 8
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* activateCommandQueue
|
* activateCommandQueue
|
||||||
|
|||||||
@@ -72,13 +72,12 @@ void CommObd2Can::mainLoop() {
|
|||||||
delay(10);
|
delay(10);
|
||||||
for (uint8_t i = 0; i < 50; i++) {
|
for (uint8_t i = 0; i < 50; i++) {
|
||||||
receivePID();
|
receivePID();
|
||||||
if (rxRemaining <= 0)
|
if (rxRemaining <= 2)
|
||||||
break;
|
break;
|
||||||
delay(10);
|
delay(10);
|
||||||
}
|
}
|
||||||
delay(30);
|
delay(30);
|
||||||
}
|
}
|
||||||
Serial.println(liveData->params.currentTime );
|
|
||||||
if (lastDataSent != 0 && (unsigned long)(millis() - lastDataSent) > 500) {
|
if (lastDataSent != 0 && (unsigned long)(millis() - lastDataSent) > 500) {
|
||||||
Serial.print("CAN execution timeout. Continue with next command.");
|
Serial.print("CAN execution timeout. Continue with next command.");
|
||||||
liveData->canSendNextAtCommand = true;
|
liveData->canSendNextAtCommand = true;
|
||||||
@@ -95,6 +94,7 @@ void CommObd2Can::executeCommand(String cmd) {
|
|||||||
Serial.println(cmd);
|
Serial.println(cmd);
|
||||||
|
|
||||||
if (cmd.equals("") || cmd.startsWith("AT")) { // skip AT commands as not used by direct CAN connection
|
if (cmd.equals("") || cmd.startsWith("AT")) { // skip AT commands as not used by direct CAN connection
|
||||||
|
lastDataSent = 0;
|
||||||
liveData->canSendNextAtCommand = true;
|
liveData->canSendNextAtCommand = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ void CommObd2Can::executeCommand(String cmd) {
|
|||||||
String atsh = "0" + liveData->currentAtshRequest.substring(4); // remove ATSH
|
String atsh = "0" + liveData->currentAtshRequest.substring(4); // remove ATSH
|
||||||
cmd.replace(" ", ""); // remove possible spaces
|
cmd.replace(" ", ""); // remove possible spaces
|
||||||
sendPID(liveData->hexToDec(atsh, 2, false), cmd);
|
sendPID(liveData->hexToDec(atsh, 2, false), cmd);
|
||||||
delay(40);
|
delay(40);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -215,13 +215,13 @@ bool CommObd2Can::processFrame() {
|
|||||||
switch (frameType) {
|
switch (frameType) {
|
||||||
// Single frame
|
// Single frame
|
||||||
case 0:
|
case 0:
|
||||||
rxRemaining = (rxBuf[1] & 0x0f) + 1;
|
rxRemaining = (rxBuf[1] & 0x0f);
|
||||||
break;
|
break;
|
||||||
// First frame
|
// First frame
|
||||||
case 1:
|
case 1:
|
||||||
rxRemaining = ((rxBuf[0] & 0x0f) << 8) + rxBuf[1] + 1;
|
rxRemaining = ((rxBuf[0] & 0x0f) << 8) + rxBuf[1];
|
||||||
liveData->responseRowMerged = "";
|
liveData->responseRowMerged = "";
|
||||||
for (uint16_t i = 0; i < 62; i++)
|
for (uint16_t i = 0; i < rxRemaining - 1; i++)
|
||||||
liveData->responseRowMerged += "00";
|
liveData->responseRowMerged += "00";
|
||||||
liveData->responseRow = "0:";
|
liveData->responseRow = "0:";
|
||||||
start = 2;
|
start = 2;
|
||||||
@@ -264,8 +264,8 @@ bool CommObd2Can::processFrame() {
|
|||||||
Serial.println(liveData->responseRowMerged);
|
Serial.println(liveData->responseRowMerged);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send command to board module (obd2 simulation)
|
// Send response to board module
|
||||||
if (rxRemaining <= 0) {
|
if (rxRemaining <= 2) {
|
||||||
Serial.print("merged:");
|
Serial.print("merged:");
|
||||||
Serial.println(liveData->responseRowMerged);
|
Serial.println(liveData->responseRowMerged);
|
||||||
board->parseRowMerged();
|
board->parseRowMerged();
|
||||||
|
|||||||
Reference in New Issue
Block a user