diff options
Diffstat (limited to 'obdlogger/OBD.h')
-rw-r--r-- | obdlogger/OBD.h | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/obdlogger/OBD.h b/obdlogger/OBD.h index e608fee..e97ab67 100644 --- a/obdlogger/OBD.h +++ b/obdlogger/OBD.h @@ -9,10 +9,10 @@ #define OBD_TIMEOUT_LONG 7000 /* ms */ #define OBD_TIMEOUT_INIT 3000 /* ms */ #define OBD_SERIAL_BAUDRATE 38400 -#define OBD_RECV_BUF_SIZE 48 +#define OBD_RECV_BUF_SIZE 64 #ifndef OBDUART -#ifdef __AVR_ATmega32U4__ /* for Leonardo */ +#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) #define OBDUART Serial1 #else #define OBDUART Serial @@ -30,7 +30,7 @@ #define PID_ABS_ENGINE_LOAD 0x43 #define PID_AMBIENT_TEMP 0x46 #define PID_FUEL_PRESSURE 0x0A -#define PID_INTAKE_PRESSURE 0x0B +#define PID_INTAKE_MAP 0x0B #define PID_BAROMETRIC 0x33 #define PID_TIMING_ADVANCE 0x0E #define PID_FUEL_LEVEL 0x2F @@ -43,25 +43,20 @@ unsigned char hex2uint8(const char *p); class COBD { public: - COBD() - { - dataMode = 1; - errors = 0; - } + COBD():dataMode(1),errors(0) {} bool Init(bool passive = false); bool ReadSensor(byte pid, int& result, bool passive = false); + bool IsValidPID(byte pid); void Sleep(int seconds); // Query and GetResponse for advanced usage only void Query(byte pid); - virtual char* GetResponse(byte pid, char* buffer); - virtual bool GetResponse(byte pid, int& result); - virtual bool GetResponsePassive(byte& pid, int& result); - virtual bool DataAvailable(); + char* GetResponse(byte& pid, char* buffer); + bool GetResponseParsed(byte& pid, int& result); byte dataMode; byte errors; //char recvBuf[OBD_RECV_BUF_SIZE]; protected: - static bool GetParsedData(byte pid, char* data, int& result); + static int GetConvertedValue(byte pid, char* data); static int GetPercentageValue(char* data) { return (int)hex2uint8(data) * 100 / 255; @@ -78,8 +73,11 @@ protected: { return (int)hex2uint8(data) - 40; } - virtual char ReadData(); - virtual void WriteData(const char* s); - virtual void WriteData(const char c); - virtual void DataTimeout() {} + virtual bool available(); + virtual char read(); + virtual void write(const char* s); + virtual void write(const char c); + virtual void InitIdleLoop() {} + virtual void DataIdleLoop() {} + byte pidmap[4 * 4]; }; |