mirror of
https://github.com/mikecarper/MeshCore.git
synced 2026-09-24 12:04:22 +00:00
Merge meshcore-dev dev with companion and board integrations
This commit is contained in:
@@ -165,6 +165,13 @@ void loop() {
|
||||
#endif
|
||||
Stream& console = mesh::usbConsolePort();
|
||||
int len = strlen(command);
|
||||
// `command` must stay NUL-terminated within its bounds. If it ever isn't,
|
||||
// strlen() above can return >= sizeof(command) and the loop below would then
|
||||
// index past the buffer, so clamp defensively.
|
||||
if (len >= (int)sizeof(command)) {
|
||||
command[0] = 0;
|
||||
len = 0;
|
||||
}
|
||||
while (usb_ready && console.available() && len < sizeof(command)-1) {
|
||||
char c = console.read();
|
||||
if (c != '\n') {
|
||||
@@ -173,8 +180,9 @@ void loop() {
|
||||
}
|
||||
console.print(c);
|
||||
}
|
||||
if (len == sizeof(command)-1) { // command buffer full
|
||||
command[sizeof(command)-1] = '\r';
|
||||
if (len == sizeof(command)-1) { // buffer full: treat as a completed line
|
||||
command[sizeof(command)-2] = '\r'; // place end-of-line marker inside the buffer
|
||||
command[sizeof(command)-1] = 0; // keep the buffer NUL-terminated
|
||||
}
|
||||
|
||||
if (len > 0 && command[len - 1] == '\r') { // received complete line
|
||||
|
||||
Reference in New Issue
Block a user