Fork of Smoothie to port to mbed non-LPC targets.
Fork of Smoothie by
modules/communication/SerialConsole.h@3:f151d08d335c, 2014-03-02 (annotated)
- Committer:
- Bigcheese
- Date:
- Sun Mar 02 06:33:08 2014 +0000
- Revision:
- 3:f151d08d335c
- Parent:
- 2:1df0b61d3b5a
Bunch of stuff. Need to locally merge in updated USB changes.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Michael J. Spencer |
2:1df0b61d3b5a | 1 | /* |
scachat | 0:31e91bb0ef3c | 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). |
scachat | 0:31e91bb0ef3c | 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. |
scachat | 0:31e91bb0ef3c | 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. |
Michael J. Spencer |
2:1df0b61d3b5a | 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. |
scachat | 0:31e91bb0ef3c | 6 | */ |
scachat | 0:31e91bb0ef3c | 7 | |
scachat | 0:31e91bb0ef3c | 8 | #ifndef SERIALCONSOLE_H |
scachat | 0:31e91bb0ef3c | 9 | #define SERIALCONSOLE_H |
scachat | 0:31e91bb0ef3c | 10 | |
scachat | 0:31e91bb0ef3c | 11 | #include "libs/Module.h" |
Michael J. Spencer |
2:1df0b61d3b5a | 12 | #include "Serial.h" // mbed.h lib |
scachat | 0:31e91bb0ef3c | 13 | #include "libs/Kernel.h" |
scachat | 0:31e91bb0ef3c | 14 | #include <vector> |
scachat | 0:31e91bb0ef3c | 15 | #include <string> |
scachat | 0:31e91bb0ef3c | 16 | using std::string; |
scachat | 0:31e91bb0ef3c | 17 | #include "libs/RingBuffer.h" |
scachat | 0:31e91bb0ef3c | 18 | #include "libs/StreamOutput.h" |
scachat | 0:31e91bb0ef3c | 19 | |
scachat | 0:31e91bb0ef3c | 20 | |
Michael J. Spencer |
2:1df0b61d3b5a | 21 | #define baud_rate_setting_checksum CHECKSUM("baud_rate") |
scachat | 0:31e91bb0ef3c | 22 | |
scachat | 0:31e91bb0ef3c | 23 | class SerialConsole : public Module, public StreamOutput { |
scachat | 0:31e91bb0ef3c | 24 | public: |
scachat | 0:31e91bb0ef3c | 25 | SerialConsole( PinName rx_pin, PinName tx_pin, int baud_rate ); |
Michael J. Spencer |
2:1df0b61d3b5a | 26 | |
Michael J. Spencer |
2:1df0b61d3b5a | 27 | void on_module_loaded(); |
scachat | 0:31e91bb0ef3c | 28 | void on_serial_char_received(); |
Michael J. Spencer |
2:1df0b61d3b5a | 29 | void on_main_loop(void * argument); |
scachat | 0:31e91bb0ef3c | 30 | bool has_char(char letter); |
Michael J. Spencer |
2:1df0b61d3b5a | 31 | |
Michael J. Spencer |
2:1df0b61d3b5a | 32 | int _putc(int c); |
Michael J. Spencer |
2:1df0b61d3b5a | 33 | int _getc(void); |
Michael J. Spencer |
2:1df0b61d3b5a | 34 | int puts(const char*); |
Michael J. Spencer |
2:1df0b61d3b5a | 35 | |
scachat | 0:31e91bb0ef3c | 36 | //string receive_buffer; // Received chars are stored here until a newline character is received |
scachat | 0:31e91bb0ef3c | 37 | //vector<std::string> received_lines; // Received lines are stored here until they are requested |
scachat | 0:31e91bb0ef3c | 38 | RingBuffer<char,256> buffer; // Receive buffer |
scachat | 0:31e91bb0ef3c | 39 | mbed::Serial* serial; |
scachat | 0:31e91bb0ef3c | 40 | }; |
scachat | 0:31e91bb0ef3c | 41 | |
scachat | 0:31e91bb0ef3c | 42 | #endif |