summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--unologger/config.h9
-rw-r--r--unologger/datalogger.h38
-rw-r--r--unologger/unologger.ino4
3 files changed, 11 insertions, 40 deletions
diff --git a/unologger/config.h b/unologger/config.h
index 5ec6061..d0da7db 100644
--- a/unologger/config.h
+++ b/unologger/config.h
@@ -4,14 +4,15 @@
/**************************************
* OBD-II options
**************************************/
+#define OBD_MODEL OBD_MODEL_UART
#define OBD_PROTOCOL 0 /* 0 for auto */
/**************************************
* Data logging/streaming out
**************************************/
-#define ENABLE_DATA_OUT 0
+#define ENABLE_DATA_OUT 1
#define ENABLE_DATA_LOG 1
-#define USE_SOFTSERIAL 0
+#define USE_SOFTSERIAL 1
//this defines the format of log file
#define LOG_FORMAT FORMAT_CSV
@@ -39,9 +40,9 @@
/**************************************
* Choose LCD model here
**************************************/
-LCD_ILI9341 lcd;
+//LCD_ILI9341 lcd;
//LCD_SSD1306 lcd;
-//LCD_Null lcd;
+LCD_Null lcd;
/**************************************
* Other options
diff --git a/unologger/datalogger.h b/unologger/datalogger.h
index 2c4ebfe..4fdf805 100644
--- a/unologger/datalogger.h
+++ b/unologger/datalogger.h
@@ -93,7 +93,7 @@ typedef struct {
#define FILE_NAME_FORMAT "/DAT%05d.CSV"
#endif
-#if ENABLE_DATA_OUT && !USE_OBD_BT
+#if ENABLE_DATA_OUT
#if defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
SoftwareSerial mySerial(A8, A9); /* for BLE Shield on MEGA*/
#elif defined(__AVR_ATmega644P__)
@@ -111,12 +111,8 @@ public:
void initSender()
{
#if ENABLE_DATA_OUT
-#if USE_OBD_BT
- btInit(9600);
-#else
mySerial.begin(9600);
#endif
-#endif
#if ENABLE_DATA_LOG && LOG_FORMAT == FORMAT_CSV
m_lastDataTime = 0;
#endif
@@ -140,26 +136,17 @@ public:
info.logType = hdr.logType;
info.logFlags = hdr.flags;
info.checksum = getChecksum((char*)&info, sizeof(info));
-#if USE_OBD_BT
- btSend((uint8_t*)&info, sizeof(info));
-#else
mySerial.write((uint8_t*)&info, sizeof(info));
-#endif
}
void sendCommand(byte message, void* data = 0, byte bytes = 0)
{
LOG_DATA_COMMAND msg = {0, PID_MESSAGE, message};
if (data) memcpy(msg.data, data, bytes);
msg.checksum = getChecksum((char*)&msg, sizeof(msg));
-#if USE_OBD_BT
- btSend((uint8_t*)&msg, sizeof(msg));
-#else
mySerial.write((uint8_t*)&msg, sizeof(msg));
-#endif
}
bool receiveCommand(LOG_DATA_COMMAND& msg)
{
-#if !USE_OBD_BT
if (!mySerial.available())
return false;
@@ -171,7 +158,6 @@ public:
if (getChecksum((char*)&msg, sizeof(msg)) != msg.checksum) {
return false;
}
-#endif
return true;
}
#endif
@@ -180,12 +166,8 @@ public:
LOG_DATA_COMM ld = {dataTime, pid, 1, 0, value};
ld.checksum = getChecksum((char*)&ld, 12);
#if ENABLE_DATA_OUT
-#if USE_OBD_BT
- btSend((uint8_t*)&ld, 12);
-#else
mySerial.write((uint8_t*)&ld, 12);
#endif
-#endif
#if ENABLE_DATA_LOG
#if LOG_FORMAT == FORMAT_BIN
sdfile.write((uint8_t*)&ld, 12);
@@ -206,12 +188,8 @@ public:
LOG_DATA_COMM ld = {dataTime, pid, 1, 0, value};
ld.checksum = getChecksum((char*)&ld, 12);
#if ENABLE_DATA_OUT
-#if USE_OBD_BT
- btSend((uint8_t*)&ld, 12);
-#else
mySerial.write((uint8_t*)&ld, 12);
#endif
-#endif
#if ENABLE_DATA_LOG
#if LOG_FORMAT == FORMAT_BIN
sdfile.write((uint8_t*)&ld, 12);
@@ -232,12 +210,8 @@ public:
LOG_DATA_COMM ld = {dataTime, pid, 2, 0, {value1, value2}};
ld.checksum = getChecksum((char*)&ld, 16);
#if ENABLE_DATA_OUT
-#if USE_OBD_BT
- btSend((uint8_t*)&ld, 16);
-#else
mySerial.write((uint8_t*)&ld, 16);
#endif
-#endif
#if ENABLE_DATA_LOG
#if LOG_FORMAT == FORMAT_BIN
sdfile.write((uint8_t*)&ld, 16);
@@ -248,7 +222,7 @@ public:
dataSize += sdfile.print(pid, HEX);
dataSize += sdfile.write(',');
dataSize += sdfile.print(value1, 6);
- dataSize += sdfile.write(',');
+ dataSize += sdfile.write(' ');
dataSize += sdfile.print(value2, 6);
dataSize += sdfile.write('\n');
m_lastDataTime = dataTime;
@@ -260,12 +234,8 @@ public:
LOG_DATA_COMM ld = {dataTime, pid, 2, 0, {value1, value2}};
ld.checksum = getChecksum((char*)&ld, 16);
#if ENABLE_DATA_OUT
-#if USE_OBD_BT
- btSend((uint8_t*)&ld, 16);
-#else
mySerial.write((uint8_t*)&ld, 16);
#endif
-#endif
#if ENABLE_DATA_LOG
#if LOG_FORMAT == FORMAT_BIN
sdfile.write((uint8_t*)&ld, 16);
@@ -288,12 +258,8 @@ public:
LOG_DATA_COMM ld = {dataTime, pid, 3, 0, {value1, value2, value3}};
ld.checksum = getChecksum((char*)&ld, 20);
#if ENABLE_DATA_OUT
-#if USE_OBD_BT
- btSend((uint8_t*)&ld, 20);
-#else
mySerial.write((uint8_t*)&ld, 20);
#endif
-#endif
#if ENABLE_DATA_LOG
#if LOG_FORMAT == FORMAT_BIN
sdfile.write((uint8_t*)&ld, 20);
diff --git a/unologger/unologger.ino b/unologger/unologger.ino
index d636938..9c03ac6 100644
--- a/unologger/unologger.ino
+++ b/unologger/unologger.ino
@@ -45,7 +45,11 @@ static byte pidTier3[] = {PID_COOLANT_TEMP, PID_INTAKE_TEMP, PID_AMBIENT_TEMP, P
#define TIER_NUM2 sizeof(pidTier2)
#define TIER_NUM3 sizeof(pidTier3)
+#if OBD_MODEL == OBD_MODEL_UART
class COBDLogger : public COBD, public CDataLogger
+#else
+class COBDLogger : public COBDI2C, public CDataLogger
+#endif
{
public:
COBDLogger():state(0) {}