1515const uint8_t CMDBUFFER_CHAR_PRINTABLE = 0x1F ;
1616const uint8_t CMDBUFFER_CHAR_LF = 0x0A ;
1717const uint8_t CMDBUFFER_CHAR_CR = 0x0D ;
18+ const uint8_t CMDBUFFER_CHAR_BS = 0x08 ;
19+ const uint8_t CMDBUFFER_CHAR_DEL = 0x7F ;
1820
1921/* *
2022 *
@@ -26,7 +28,13 @@ class CmdBufferObject
2628 /* *
2729 * Clear buffer and set defaults.
2830 */
29- CmdBufferObject () : m_endChar(CMDBUFFER_CHAR_LF), m_dataOffset(0 ) {}
31+ CmdBufferObject ()
32+ : m_endChar(CMDBUFFER_CHAR_LF),
33+ m_bsChar (CMDBUFFER_CHAR_BS),
34+ m_dataOffset(0 ),
35+ m_echo(false )
36+ {
37+ }
3038
3139 /* *
3240 * Read data from serial communication to buffer. It read only printable
@@ -39,9 +47,21 @@ class CmdBufferObject
3947 */
4048 bool readFromSerial (Stream *serial, uint32_t timeOut = 0 );
4149
50+ /* *
51+ * Read one char from serial communication to buffer if available.
52+ * It read only printable ASCII character from serial.
53+ * All other will ignore for buffer. This function only ready currently
54+ * available data and doesn't wait for a full command (= end character)
55+ *
56+ * @param serial Arduino Serial object from read commands
57+ * @return TRUE if data readed until end character or
58+ * FALSE if not.
59+ */
60+ bool readSerialChar (Stream *serial);
61+
4262 /* *
4363 * Set a ASCII character for serial cmd end.
44- " Default value is LF.
64+ * Default value is LF.
4565 *
4666 * Macros for helping are:
4767 * - CMDBUFFER_CHAR_LF
@@ -51,6 +71,25 @@ class CmdBufferObject
5171 */
5272 void setEndChar (uint8_t end) { m_endChar = end; }
5373
74+ /* *
75+ * Set a ASCII character for serial cmd backspace.
76+ * Default value is BS.
77+ *
78+ * Macros for helping are:
79+ * - CMDBUFFER_CHAR_BS
80+ * - CMDBUFFER_CHAR_DEL
81+ *
82+ * @param backspace ASCII character
83+ */
84+ void setBackChar (uint8_t backspace) { m_bsChar = backspace; }
85+
86+ /* *
87+ * Set echo serial on (true) or off (false)
88+ *
89+ * @param echo bool
90+ */
91+ void setEcho (bool echo) { m_echo = echo; }
92+
5493 /* *
5594 * Cast Buffer to c string.
5695 *
@@ -83,7 +122,9 @@ class CmdBufferObject
83122 private:
84123 /* * Character for handling the end of serial data communication */
85124 uint8_t m_endChar;
125+ uint8_t m_bsChar;
86126 size_t m_dataOffset;
127+ bool m_echo;
87128};
88129
89130/* *
0 commit comments