File: serial.h

package info (click to toggle)
scantool 1.21+dfsg-5
  • links: PTS
  • area: main
  • in suites: sid
  • size: 2,956 kB
  • ctags: 2,392
  • sloc: ansic: 12,279; sh: 829; makefile: 344; asm: 86; perl: 29
file content (83 lines) | stat: -rw-r--r-- 2,218 bytes parent folder | download | duplicates (5)
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
80
81
82
83
#ifndef SERIAL_H
#define SERIAL_H

#ifdef ALLEGRO_WINDOWS
   #define BAUD_RATE_9600    9600
   #define BAUD_RATE_38400   38400
   #define BAUD_RATE_115200  115200
   #define BAUD_RATE_230400  230400
#else
   #define DZCOMM_SECONDARY_INCLUDE
   #include <dzcomm.h>
   #define BAUD_RATE_9600    _9600
   #define BAUD_RATE_38400   _38400
   #define BAUD_RATE_115200  _115200
#endif

//read_comport returned data type
#define EMPTY    0
#define DATA     1
#define PROMPT   2

#define SPECIAL_DELIMITER   '\t'

//comport status
#define READY          0
#define NOT_OPEN       1
#define USER_IGNORED   2

//process_response return values
#define HEX_DATA           0
#define BUS_BUSY           1
#define BUS_ERROR          2
#define BUS_INIT_ERROR     3
#define UNABLE_TO_CONNECT  4
#define CAN_ERROR          5
#define DATA_ERROR         6
#define DATA_ERROR2        7
#define ERR_NO_DATA        8
#define BUFFER_FULL        9
#define SERIAL_ERROR       10
#define UNKNOWN_CMD        11
#define RUBBISH            12

#define INTERFACE_ID       13
#define INTERFACE_ELM320   13
#define INTERFACE_ELM322   14
#define INTERFACE_ELM323   15
#define INTERFACE_ELM327   16
#define INTERFACE_OBDLINK  17
#define STN_MFR_STRING     18
#define ELM_MFR_STRING     19

// timeouts
#define OBD_REQUEST_TIMEOUT   12000
#define ATZ_TIMEOUT           2000
#define AT_TIMEOUT            1000
#define ECU_TIMEOUT           5000

// function prototypes
void serial_module_init();
void serial_module_shutdown();
int open_comport();
void close_comport();
void send_command(const char *command);
int read_comport(char *response);
void start_serial_timer(int delay);
void stop_serial_timer();
int process_response(const char *cmd_sent, char *msg_received);
int find_valid_response(char *buf, char *response, const char *filter, char **stop);
const char *get_protocol_string(int interface_type, int protocol_id);
int display_error_message(int error, int retry);

// variables
volatile int serial_time_out;
volatile int serial_timer_running;

struct COMPORT {
   int number;
   int baud_rate;
   int status;    // READY, NOT_OPEN, USER_IGNORED
} comport;

#endif