-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSerial.hpp
66 lines (55 loc) · 1.5 KB
/
Serial.hpp
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
#ifndef SERIAL_H
#define SERIAL_H
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <iostream>
#include <thread>
#include <atomic>
#include <chrono>
#include "lines.hpp"
#include "bluetooth_client.hpp"
#define SERIAL_SPEED B115200
#define PARITY 0
#define MOVE_COMMAND 255
#define KICK_COMMAND 254
#define START_COMMAND 251
#define LINE_CALIBRATION_COMMAND 250
#define INIT_COMMAND 249
#define RESET_COMMAND 248
#define DRIBBLER_START_COMMAND 247
#define LINE_DETECTED_COMMAND 246
#define STOP_COMMAND 245
#define START_ULTRASONIC_COMMAND 244
#define STOP_ULTRASONIC_COMMAND 243
#define LEFT_TRUE 242
#define LEFT_FALSE 241
#define RIGHT_TRUE 240
#define RIGHT_FALSE 239
#define LEFT_CLOSE 238
#define RIGHT_CLOSE 237
#define DRIBBLER_STOP_SPEED 100
using namespace std;
extern int fd;
extern atomic<int> ext_degree;
extern atomic<int> ext_speed;
extern atomic<int> ext_dribbler_speed;
extern atomic<int> ext_azimuth;
extern atomic<bool> ext_calibration;
extern atomic<bool> ext_start;
extern atomic<bool> ext_dribbler_start;
extern atomic<bool> ext_kick;
extern atomic<bool> ext_send_calibration_data;
extern atomic<bool> ext_turn_off_dribbler;
extern atomic<bool> ext_line_detected;
extern atomic<int> ext_left_ultrasonic;
extern atomic<int> ext_right_ultrasonic;
int set_interface_attribs (int fd, int speed, int parity);
void set_blocking (int fd, int should_block);
int init_serial();
void write_protocol();
void read_protocol();
void sdPut(uint8_t byte);
#endif