Commit ec0722e6 authored by Christian Eichler's avatar Christian Eichler
Browse files

Implemen handling of commands not known to the device (esp. IDS systems)

parent cfffac82
......@@ -237,9 +237,11 @@ int main(void) {
char byte = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);
switch(byte) {
case '\n':
case '\n': {
bool handled = false;
buffer[pos] = '\0';
#define COMMAND(NAME, FUNC) { if(!strncmp(NAME " ", buffer, strlen(NAME) + 1)) { FUNC(&buffer[strlen(NAME)]); } }
#define COMMAND(NAME, FUNC) { if(!strncmp(NAME " ", buffer, strlen(NAME) + 1)) { FUNC(&buffer[strlen(NAME)]); handled = true; } }
COMMAND("inf", command_inf)
......@@ -252,9 +254,15 @@ int main(void) {
#undef COMMAND
if(!handled) {
CDC_Device_SendString(&VirtualSerial_CDC_Interface, "e:uc\n");
CDC_Device_Flush(&VirtualSerial_CDC_Interface);
}
pos = 0;
break;
}
default:
if(pos < BUFFER_SIZE) {
buffer[pos] = byte;
......
#define _POSIX_C_SOURCE 199309L
#define _XOPEN_SOURCE 500
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
......@@ -210,7 +213,14 @@ static void response_loop(FILE *fh, void (*cb)(bool, char*)) {
return;
}
cb(success, '\0' != &buf[1] ? &buf[2] : NULL);
char *rem = NULL;
if(rem = strsw(buf, "e:uc")) {
printf("Command not known to device; are you trying to benchmark on an IDS?\n");
exit(EXIT_FAILURE);
} else {
cb(success, '\0' != &buf[1] ? &buf[2] : NULL);
}
printf(SHELL_ESC"[m\n");
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment