forked from H4jen/webasto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand.h
69 lines (58 loc) · 2.2 KB
/
command.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
#ifndef COMMAND_H
#define COMMAND_H
#include <Arduino.h>
#include "webasto.h"
struct command_message
{
char data_string[MESSAGE_BUFFER_SIZE];
};
//Define the wbus class
class Command {
//Holds communication object
//CustomSoftwareSerial* mySerial;
//can only be pins 8-13 because prtmapping is hardcoded to PORTB
//Wraparound message buffer;
int message_buffer[MESSAGE_BUFFER_SIZE];
//Tracks were read and write in buffer is. Strategy is to always write to buffer when data availible. Read of buffer is only done when data is avalible.
int *read_ptr,*write_ptr;
int write_array_counter = 0;
int read_array_counter = 0;
struct command_message cmd_msg;
uint8_t rxPin=19;
uint8_t txPin=18;
int BAUDRATE = 2400;
int PARITY = SERIAL_8E1;
int TXHEADER = 0xf4;
int RXHEADER = 0x4f;
//enum rx_reception_states {START, FINDHEADER, READLENGTH, READDATA, RESET_STATE, CHECKSUM_CHECK, PARSE_MESSAGE};
//enum rx_reception_states rx_state = START;
//indicates if the wbus is initialized and ready to go. (1 = ok, 0 = in progressm, -1 failed)
//The flag below is implemented so that a sent request should result in a RX response.
//bool waiting_for_rx_response = false;
//Number of external loops before timeout and rx_response cleared.
int time_out_loops=10;
//Keeps track of the number of times trying to read from RX without reponse. Reset, when a succespul read has been done.
int number_of_rx_loops=0;
//int wbus_ok=0;
String subStringDataMsg(int index);
//This function is called if a type 50 message is received (status)
//void parseStatusData(int pos);
//struct webasto_status wbus_status;
public:
//bool wbus_ok=false;
void parseCommand(int string_size);
Command();
void printMsgDebug(void);
//void sendSerialBreak(void);
//void sendTXmessage(const int msg[],bool need_ack);
//void getCommand()
void readSerialData(void);
void getSerialMessage(void);
//void initSequence(void);
//void statusSequence(void);
//struct webasto_status wbus_status;
};
//put your function headers here
//void parse_message();
//void sendTXmessage(const int msg[]);
#endif