diff options
-rw-r--r-- | megalogger/config.h | 1 | ||||
-rw-r--r-- | megalogger/datalogger.h | 36 | ||||
-rw-r--r-- | megalogger/megalogger.ino | 2 | ||||
-rw-r--r-- | megalogger/megalogger.layout | 16 |
4 files changed, 11 insertions, 44 deletions
diff --git a/megalogger/config.h b/megalogger/config.h index ac06fd6..7b4c1f7 100644 --- a/megalogger/config.h +++ b/megalogger/config.h @@ -10,6 +10,7 @@ * Choose model of OBD-II Adapter **************************************/ #define OBD_MODEL OBD_MODEL_UART +#define OBD_PROTOCOL 0 /* 0 for auto */ /************************************** * Choose SD pin here diff --git a/megalogger/datalogger.h b/megalogger/datalogger.h index 1f3b301..4fdf805 100644 --- a/megalogger/datalogger.h +++ b/megalogger/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); @@ -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/megalogger/megalogger.ino b/megalogger/megalogger.ino index 401e06e..da65d6d 100644 --- a/megalogger/megalogger.ino +++ b/megalogger/megalogger.ino @@ -103,7 +103,7 @@ public: do { showStates(); - } while (!init()); + } while (!init(OBD_PROTOCOL)); state |= STATE_OBD_READY; diff --git a/megalogger/megalogger.layout b/megalogger/megalogger.layout index e3b98df..0aceb52 100644 --- a/megalogger/megalogger.layout +++ b/megalogger/megalogger.layout @@ -1,24 +1,24 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <CodeBlocks_layout_file> <ActiveTarget name="Arduino Mega 2560/ADK" /> - <File name="megalogger.ino" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> + <File name="megalogger.ino" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> <Cursor> - <Cursor1 position="16362" topLine="526" /> + <Cursor1 position="639" topLine="18" /> </Cursor> </File> - <File name="config.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> + <File name="images.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> <Cursor> - <Cursor1 position="643" topLine="0" /> + <Cursor1 position="36893" topLine="41" /> </Cursor> </File> - <File name="datalogger.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> + <File name="config.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> <Cursor> - <Cursor1 position="480" topLine="0" /> + <Cursor1 position="123" topLine="0" /> </Cursor> </File> - <File name="images.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> + <File name="datalogger.h" open="1" top="1" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> <Cursor> - <Cursor1 position="36893" topLine="41" /> + <Cursor1 position="82" topLine="0" /> </Cursor> </File> </CodeBlocks_layout_file> |