Commit | Line | Data |
---|---|---|
df27a6a3 | 1 | /* |
4cff3ded AW |
2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). |
3 | Smoothie 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. | |
4 | Smoothie 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. | |
df27a6a3 | 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. |
4cff3ded AW |
6 | */ |
7 | ||
8 | #ifndef SERIALCONSOLE_H | |
9 | #define SERIALCONSOLE_H | |
10 | ||
4cff3ded | 11 | #include "libs/Module.h" |
da3a10b9 | 12 | #include "Serial.h" // mbed.h lib |
4cff3ded AW |
13 | #include "libs/Kernel.h" |
14 | #include <vector> | |
15 | #include <string> | |
16 | using std::string; | |
13e4a3f9 | 17 | #include "libs/RingBuffer.h" |
838b33b4 | 18 | #include "libs/StreamOutput.h" |
4cff3ded | 19 | |
da3a10b9 | 20 | |
d4f93cf4 | 21 | #define baud_rate_setting_checksum CHECKSUM("baud_rate") |
4cff3ded | 22 | |
838b33b4 | 23 | class SerialConsole : public Module, public StreamOutput { |
4cff3ded AW |
24 | public: |
25 | SerialConsole( PinName rx_pin, PinName tx_pin, int baud_rate ); | |
99b9ed8a | 26 | |
836222e7 | 27 | void on_module_loaded(); |
4cff3ded | 28 | void on_serial_char_received(); |
836222e7 | 29 | void on_main_loop(void * argument); |
dcc91612 | 30 | void on_idle(void * argument); |
13e4a3f9 | 31 | bool has_char(char letter); |
99b9ed8a | 32 | |
836222e7 MM |
33 | int _putc(int c); |
34 | int _getc(void); | |
35 | int puts(const char*); | |
99b9ed8a | 36 | |
13e4a3f9 AW |
37 | //string receive_buffer; // Received chars are stored here until a newline character is received |
38 | //vector<std::string> received_lines; // Received lines are stored here until they are requested | |
39 | RingBuffer<char,256> buffer; // Receive buffer | |
da3a10b9 | 40 | mbed::Serial* serial; |
dcc91612 JM |
41 | struct { |
42 | bool query_flag:1; | |
43 | bool halt_flag:1; | |
44 | }; | |
4cff3ded AW |
45 | }; |
46 | ||
47 | #endif |