summaryrefslogtreecommitdiff
path: root/lpo/MyOBD.h
blob: 0f3004ddc6bc0457f83ccfb6ae9fe620c52cfc62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef __MYOBD_H
#define __MYOBD_H
#include <OBD.h>

#include <MyLCD.h>
extern MyLCD lcd;

class MyOBD : public COBDI2C {
  public:
  int debug;
  MyOBD() {
    debug=0;
  }
  void write(const char* s) {
    if (this->debug) lcd.print("<<<"); lcd.println(s);
    COBDI2C::write(s);
  }
  byte receive(char* buffer, byte bufsize, int timeout) {
    byte res = COBDI2C::receive(buffer,bufsize, timeout);
    if (this->debug) lcd.print(">>>"); lcd.println(buffer);
    return res;
  }
  /* Fake OBD for testing
  int i;
  MyOBD() {
    i=0;
  }
  byte begin() {
    delay(500);
    return 1;
  }
  bool init() {
    delay(500);
    return ++i>4;
  }
  bool readPID(byte pid, int& result) {
    result=millis();
    if ( result%1000 == 0 ) { this->errors++; }
    return true;
  }
  byte readDTC(uint16_t codes[], byte maxCodes = 1) {
    codes[0]=6002;
    codes[1]=6032;
    codes[2]=12;
    return 4;
  }
  */
};
#endif