mirror of
https://github.com/n5ac/smartsdr-dsp.git
synced 2026-03-03 19:23:48 +01:00
Add timing debug to write/read from serial
This commit is contained in:
parent
a10cb40a9f
commit
95d5a53c63
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue