From 3a671a71f2c9c1993d487e8453793cff41258cc2 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Sat, 6 Mar 2021 09:04:42 +0100 Subject: [PATCH] Do not send if USB is not active --- main.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/main.c b/main.c index 9f8f42b..ccf3628 100644 --- a/main.c +++ b/main.c @@ -895,21 +895,27 @@ VNA_SHELL_FUNCTION(cmd_capture) void send_region(const char *t, int x, int y, int w, int h) { - shell_printf(t); - struct { - char new_str[2]; - uint16_t x; - uint16_t y; - uint16_t w; - uint16_t h; - } region={"\r\n", x,y,w,h}; - streamWrite(shell_stream, (void*)®ion, sizeof(region)); + if (SDU1.config->usbp->state == USB_ACTIVE) { + shell_printf(t); + struct { + char new_str[2]; + uint16_t x; + uint16_t y; + uint16_t w; + uint16_t h; + } region={"\r\n", x,y,w,h}; + streamWrite(shell_stream, (void*)®ion, sizeof(region)); + } + else + auto_capture = false; } void send_buffer(uint8_t * buf, int s) { - streamWrite(shell_stream, (void*) buf, s); - streamWrite(shell_stream, (void*)"ch> \r\n", 6); + if (SDU1.config->usbp->state == USB_ACTIVE) { + streamWrite(shell_stream, (void*) buf, s); + streamWrite(shell_stream, (void*)"ch> \r\n", 6); + } } #if 0