diff --git a/DSP_API/ThumbDV/thumbDV.c b/DSP_API/ThumbDV/thumbDV.c index 4159f45..591ea08 100644 --- a/DSP_API/ThumbDV/thumbDV.c +++ b/DSP_API/ThumbDV/thumbDV.c @@ -282,8 +282,19 @@ static int thumbDV_writeSerial( FT_HANDLE handle , unsigned char * buffer, uint3 FT_STATUS status = FT_OK; DWORD written = 0; + static uint32 min, max; + static float avg; + static uint32 count = 0; + min = 0xFFFFFFFF; + max = 0; + avg = 0; + + struct timespec time; + + if ( handle != NULL ) { + clock_gettime(CLOCK_MONOTONIC, &time); status = FT_Write(handle, buffer, bytes, &written); if ( status != FT_OK || written != bytes ) { @@ -292,12 +303,23 @@ static int thumbDV_writeSerial( FT_HANDLE handle , unsigned char * buffer, uint3 } status = thumbDV_processSerial(handle); + uint32 ms_elapsed = msSince(time); + + if ( ms_elapsed > max ) + max = ms_elapsed; + + if ( ms_elapsed < min ) + min = ms_elapsed; + + avg = avg * .9 + ms_elapsed * .1; } else { output( ANSI_RED "Could not write to serial port. Timeout\n" ANSI_WHITE ); } + if ( count++ % 100 == 0) + output("Min: %d Max: %d Avg: %.1f", min, max, avg); return status; }