Rev 10 | Rev 13 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
10 | mjames | 1 | #pragma once |
2 | #include "libSerial/serial.h" |
||
3 | |||
4 | /// @brief storage for a string reader |
||
5 | typedef struct |
||
6 | { |
||
7 | char *buffer; // pointer to workspace |
||
8 | int limit; // string limit |
||
9 | int counter; // byte counter |
||
10 | char complete; // flag complete |
||
11 | char readLines; // true if reading lines with CR at end |
||
12 | } editBuffer; |
||
13 | |||
14 | /// |
||
15 | typedef enum |
||
16 | { |
||
17 | EDIT_NULL = 0, ///< No result |
||
18 | EDIT_DONE, ///< All characters read |
||
19 | EDIT_CR ///< Characters up to CR read |
||
20 | } editBufferReturn; |
||
21 | |||
11 | mjames | 22 | /// @brief Send a string to the user |
23 | /// @param ctl |
||
24 | /// @param string |
||
25 | /// @param length |
||
26 | extern void sendString(usart_ctl *ctl, char const *string, int length); |
||
27 | |||
28 | /// @brief Prepare the line buffer reader |
||
29 | /// @param context editBuffer object to initialise |
||
30 | /// @param buffer Pointer to data: externally allocated memory buffer. |
||
31 | /// @param limit Maximum number of bytes in externally allocated memory buffer. |
||
32 | /// @param readLines if 1 then we are reading text with <CR> as line terminator, control codes ignored. |
||
10 | mjames | 33 | extern void initReadLine(editBuffer *context, char *buffer, int limit, char readLines); |
34 | |||
11 | mjames | 35 | /// @brief Poll the line buffer reader |
36 | /// @param ctl pointer to a USART control structure |
||
37 | /// @param context pointer to the editBuffer context |
||
38 | /// @return what kind of state the buffer is now in |
||
10 | mjames | 39 | extern editBufferReturn readLine(usart_ctl *ctl, editBuffer *context); |