MCPcopy Create free account
hub / github.com/kiibohd/controller / CLI_process

Function CLI_process

Debug/cli/cli.c:161–357  ·  view source on GitHub ↗

Query the serial input buffer for any new characters

Source from the content-addressed store, hash-verified

159
160// Query the serial input buffer for any new characters
161int CLI_process()
162{
163 // Current buffer position
164 uint8_t prev_buf_pos = CLILineBufferCurrent;
165
166 if (CLILineBufferPrev != 255) {
167 prev_buf_pos = CLILineBufferPrev;
168 CLILineBufferPrev = 255;
169 } else {
170 // Process each character while available
171 while ( 1 )
172 {
173 // No more characters to process
174 if ( Output_availablechar() == 0 )
175 break;
176
177 // Retrieve from output module
178 char cur_char = (char)Output_getchar();
179
180 // Make sure buffer isn't full
181 if ( CLILineBufferCurrent >= CLILineBufferMaxSize )
182 {
183 print( NL );
184 erro_printNL("Serial line buffer is full, dropping character and resetting...");
185
186 // Clear buffer
187 CLILineBufferCurrent = 0;
188
189 // Reset the prompt
190 prompt();
191
192 return 0;
193 }
194
195 // Place into line buffer
196 CLILineBuffer[CLILineBufferCurrent++] = cur_char;
197 }
198 }
199
200 // Display Hex Key Input if enabled
201 if ( CLIHexDebugMode && CLILineBufferCurrent > prev_buf_pos )
202 {
203 print("\033[s\r\n"); // Save cursor position, and move to the next line
204 print("\033[2K"); // Erases the current line
205
206 uint8_t pos = prev_buf_pos;
207 while ( CLILineBufferCurrent > pos )
208 {
209 printHex( CLILineBuffer[pos++] );
210 print(" ");
211 }
212
213 print("\033[u"); // Restore cursor position
214 }
215
216 // If buffer has changed, output to screen while there are still characters in the buffer not displayed
217 uint8_t dirty = CLILineBufferCurrent > prev_buf_pos;
218 while ( CLILineBufferCurrent > prev_buf_pos )

Callers 3

mainFunction · 0.85
Host_cli_processFunction · 0.85
Host_pollFunction · 0.85

Calls 9

promptFunction · 0.85
CLI_saveHistoryFunction · 0.85
CLI_commandLookupFunction · 0.85
CLI_tabCompletionFunction · 0.85
CLI_retreiveHistoryFunction · 0.85
printCharFunction · 0.85
HIDIO_print_flushFunction · 0.85
Output_availablecharFunction · 0.50
Output_getcharFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…