-
Notifications
You must be signed in to change notification settings - Fork 19
/
iface.h
79 lines (63 loc) · 1.56 KB
/
iface.h
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* iface.h
*
* (C) Copyright 2014 Ulrich Hecht
*
* This file is part of CASCADE. CASCADE is almost free software; you can
* redistribute it and/or modify it under the terms of the Cascade Public
* License 1.0. Read the file "LICENSE" for details.
*/
#ifndef _IFACE_H_
#define _IFACE_H_
#include <stdint.h>
#include "cpu.h"
#include "interface.h"
typedef enum {
ASTATE_IDLE,
ASTATE_OBD_COMPOSING,
ASTATE_OBD_ANSWERING,
ASTATE_SLOW_INIT_KW_SENT,
ASTATE_SLOW_INIT_WAIT_FOR_CHECK_BYTE,
ASTATE_SLOW_INIT_CHECK_BYTE_RECEIVED,
ASTATE_SLOW_INIT_PAUSE_AFTER_55,
} adapter_state_t;
class Serial;
class Cpu;
class IfaceELM : public Interface {
public:
IfaceELM(Cpu *p, UI *ui, const char *tty);
virtual ~IfaceELM();
virtual void setBaudDivisor(int divisor);
virtual void checkInput();
virtual void sendByte(uint8_t byte);
virtual void sendSlowInit(uint8_t target);
virtual void slowInitImminent();
protected:
int *getObdReply();
void sendObdMessage();
void sendObdMessageThread();
private:
bool isInInputBuffer(uint8_t byte);
char *getInputBuffer();
void fillInputBuffer();
int *obd_request;
int sh;
adapter_state_t astate;
int obd_ptr;
int obd_message[128];
const int *obd_reply;
uint64_t delay;
uint8_t slow_init_target;
uint8_t slow_init_check_byte;
int baud_divisor;
static const int in_buf_size = 256;
char in_buf[in_buf_size];
int in_buf_start;
int in_buf_end;
Cpu *cpu;
static int msgThreadRunner(void * data);
void *msg_thread;
bool msg_thread_idle;
bool msg_thread_quit;
};
#endif