From 1d5577a777cbd24ee5755a8ceb911a046d8ad50f Mon Sep 17 00:00:00 2001 From: andreas Date: Mon, 4 Nov 2024 10:32:52 +0100 Subject: [PATCH] #81: directly enable the ISR on HWCDC restart if connected --- lib/serial/GwSerial.h | 11 ++++++++--- tools/log.pl | 28 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100755 tools/log.pl diff --git a/lib/serial/GwSerial.h b/lib/serial/GwSerial.h index 83d98a6..f3712ab 100644 --- a/lib/serial/GwSerial.h +++ b/lib/serial/GwSerial.h @@ -4,6 +4,9 @@ #include "GwLog.h" #include "GwBuffer.h" #include "GwChannelInterface.h" +#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3 + #include "hal/usb_serial_jtag_ll.h" +#endif #define USBCDC_RESTART_TIME 100 class GwSerialStream; @@ -77,7 +80,7 @@ template * workaround for the HWCDC beeing stuck at some point in time * with availableForWrite == 0 but the ISR being disabled * we simply give a small delay of 100ms for availableForWrite being 0 - * and afterwards call isConnected that seems to retrigger the ISR + * and afterwards retrigger the ISR */ int availableForWrite(HWCDC* c){ int rt=c->availableForWrite(); @@ -88,8 +91,10 @@ template unsigned long now=millis(); if (now > (lastWritable+USBCDC_RESTART_TIME)){ lastWritable=now; - LOG_ERROR("***Restart USBCDC***"); - c->isConnected(); //this seems to retrigger the ISR + if (c->isConnected()){ + //this retriggers the ISR + usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY); + } } return rt; } diff --git a/tools/log.pl b/tools/log.pl new file mode 100755 index 0000000..fcc5f5e --- /dev/null +++ b/tools/log.pl @@ -0,0 +1,28 @@ +#! /usr/bin/env perl +use strict; +use POSIX qw(strftime); +my ($dev,$speed)=@ARGV; +if (not defined $dev){ + die "usage: $0 dev" +} +if (! -e $dev) { + die "$dev not found" +} +open(my $fh,"<",$dev) or die "unable to open $dev"; +if (defined $speed){ + print("setting speed $speed"); + system("stty speed $speed < $dev") == 0 or die "unable to set speed"; +} +my $last=0; +while (<$fh>){ + my $x=time(); + if ($last != 0){ + if ($x > ($last+5)){ + print("****gap***\n"); + } + } + printf strftime("%Y/%m/%d-%H%M%S",localtime($x)); + printf("[%04.2f]: ",$x-$last); + $last=$x; + print $_; +} \ No newline at end of file