-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathprotocol.h
More file actions
131 lines (100 loc) · 3.11 KB
/
protocol.h
File metadata and controls
131 lines (100 loc) · 3.11 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
protocol.c - Driveboard protocol parser.
Part of DriveboardFirmware
Copyright (c) 2014 Stefan Hechenberger
DriveboardFirmware is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. <http://www.gnu.org/licenses/>
DriveboardFirmware is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#ifndef protocol_h
#define protocol_h
// commands, handled in serial.c
#define CMD_STOP 1
#define CMD_RESUME 2
#define CMD_STATUS 3
#define CMD_SUPERSTATUS 4
#define CMD_CHUNK_PROCESSED 5
#define CMD_RASTER_DATA_START 16
#define CMD_RASTER_DATA_END 17
#define STATUS_END 6
// commands, handled in protocol.c
#define CMD_NONE 'A'
#define CMD_LINE 'B'
#define CMD_DWELL 'C'
#define CMD_RASTER 'D'
#define CMD_REF_RELATIVE 'E'
#define CMD_REF_ABSOLUTE 'F'
#define CMD_REF_STORE 'G'
#define CMD_REF_RESTORE 'H'
#define CMD_HOMING 'I'
#define CMD_OFFSET_STORE 'J'
#define CMD_OFFSET_RESTORE 'K'
#define CMD_AIR_ENABLE 'L'
#define CMD_AIR_DISABLE 'M'
#define CMD_AUX_ENABLE 'N'
#define CMD_AUX_DISABLE 'O'
#define PARAM_TARGET_X 'x'
#define PARAM_TARGET_Y 'y'
#define PARAM_TARGET_Z 'z'
#define PARAM_FEEDRATE 'f'
#define PARAM_INTENSITY 's'
#define PARAM_DURATION 'd'
#define PARAM_PIXEL_WIDTH 'p'
#define PARAM_OFFSET_X 'h'
#define PARAM_OFFSET_Y 'i'
#define PARAM_OFFSET_Z 'j'
// status: error markers
#define STOPERROR_OK ' '
#define STOPERROR_SERIAL_STOP_REQUEST '!'
#define STOPERROR_RX_BUFFER_OVERFLOW '"'
#define STOPERROR_LIMIT_HIT_X1 '$'
#define STOPERROR_LIMIT_HIT_X2 '%'
#define STOPERROR_LIMIT_HIT_Y1 '&'
#define STOPERROR_LIMIT_HIT_Y2 '*'
#define STOPERROR_LIMIT_HIT_Z1 '+'
#define STOPERROR_LIMIT_HIT_Z2 '-'
#define STOPERROR_INVALID_MARKER '#'
#define STOPERROR_INVALID_DATA ':'
#define STOPERROR_INVALID_COMMAND '<'
#define STOPERROR_INVALID_PARAMETER '>'
#define STOPERROR_TRANSMISSION_ERROR '='
// status: info markers
#define INFO_IDLE_YES 'A'
#define INFO_DOOR_OPEN 'B'
#define INFO_CHILLER_OFF 'C'
// status: info params
#define INFO_POS_X 'x'
#define INFO_POS_Y 'y'
#define INFO_POS_Z 'z'
#define INFO_VERSION 'v'
#define INFO_BUFFER_UNDERRUN 'w'
#define INFO_STACK_CLEARANCE 'u'
#define INFO_HELLO '~'
// super status:
#define INFO_OFFSET_X 'a'
#define INFO_OFFSET_Y 'b'
#define INFO_OFFSET_Z 'c'
#define INFO_FEEDRATE 'g'
#define INFO_INTENSITY 'h'
#define INFO_DURATION 'i'
#define INFO_PIXEL_WIDTH 'j'
#define INFO_DEBUG 'k'
// Initialize the parser.
void protocol_init();
// Main firmware loop.
// Processes serial rx buffer and queues commands for stepper interrupt.
void protocol_loop();
// Called to make protocol_idle report
// (super)status the next time it runs.
void protocol_request_status();
void protocol_request_superstatus();
// called when rx serial buffer empty
void protocol_mark_underrun();
// called whenever protocol loop is waiting
void protocol_idle();
#endif