Add timing debug to write/read from serial

This commit is contained in:
Ed Gonzalez 2019-06-20 13:56:38 -05:00
parent a10cb40a9f
commit 95d5a53c63

View file

@ -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;
}