-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgvret_comm.h
68 lines (63 loc) · 1.35 KB
/
gvret_comm.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
#pragma once
#include <Arduino.h>
#include "config.h"
#ifdef USE_CAN
#include "esp32_can_local.h"
#endif
#include "commbuffer.h"
enum STATE {
IDLE,
GET_COMMAND,
BUILD_CAN_FRAME,
TIME_SYNC,
GET_DIG_INPUTS,
GET_ANALOG_INPUTS,
SET_DIG_OUTPUTS,
SETUP_CANBUS,
GET_CANBUS_PARAMS,
GET_DEVICE_INFO,
SET_SINGLEWIRE_MODE,
SET_SYSTYPE,
ECHO_CAN_FRAME,
SETUP_EXT_BUSES
};
enum GVRET_PROTOCOL
{
PROTO_BUILD_CAN_FRAME = 0,
PROTO_TIME_SYNC = 1,
PROTO_DIG_INPUTS = 2,
PROTO_ANA_INPUTS = 3,
PROTO_SET_DIG_OUT = 4,
PROTO_SETUP_CANBUS = 5,
PROTO_GET_CANBUS_PARAMS = 6,
PROTO_GET_DEV_INFO = 7,
PROTO_SET_SW_MODE = 8,
PROTO_KEEPALIVE = 9,
PROTO_SET_SYSTYPE = 10,
PROTO_ECHO_CAN_FRAME = 11,
PROTO_GET_NUMBUSES = 12,
PROTO_GET_EXT_BUSES = 13,
PROTO_SET_EXT_BUSES = 14,
PROTO_BUILD_FD_FRAME = 20,
PROTO_SETUP_FD = 21,
PROTO_GET_FD = 22,
};
class GVRET_Comm_Handler: public CommBuffer
{
public:
GVRET_Comm_Handler();
void processIncomingByte(uint8_t in_byte);
private:
#ifdef USE_CAN
CAN_FRAME build_out_frame;
#ifdef USE_CANFD
CAN_FRAME_FD build_out_fd_frame;
#endif
#endif
int out_bus;
uint8_t buff[20];
int step;
STATE state;
uint32_t build_int;
uint8_t checksumCalc(uint8_t *buffer, int length);
};