processSerial() with every serial write.

We now do processSerial() inline with the writeSerial() to not be dependent on a separate read thread
This commit is contained in:
Ed Gonzalez 2019-06-20 13:48:40 -05:00
parent 0a4be8cb8b
commit a10cb40a9f

View file

@ -277,7 +277,7 @@ void thumbDV_dump( char * text, unsigned char * data, unsigned int length ) {
} }
} }
static void thumbDV_writeSerial( FT_HANDLE handle , unsigned char * buffer, uint32 bytes ) static int thumbDV_writeSerial( FT_HANDLE handle , unsigned char * buffer, uint32 bytes )
{ {
FT_STATUS status = FT_OK; FT_STATUS status = FT_OK;
DWORD written = 0; DWORD written = 0;
@ -288,23 +288,26 @@ static void thumbDV_writeSerial( FT_HANDLE handle , unsigned char * buffer, uint
if ( status != FT_OK || written != bytes ) { if ( status != FT_OK || written != bytes ) {
output( ANSI_RED "Could not write to serial port. status = %d\n", status ); output( ANSI_RED "Could not write to serial port. status = %d\n", status );
return; return status;
} }
status = thumbDV_processSerial(handle);
} }
else else
{ {
output( ANSI_RED "Could not write to serial port. Timeout\n" ANSI_WHITE ); output( ANSI_RED "Could not write to serial port. Timeout\n" ANSI_WHITE );
} }
return status;
} }
static int _check_serial( FT_HANDLE handle ) static int _check_serial( FT_HANDLE handle )
{ {
unsigned char reset[5] = { 0x61, 0x00, 0x01, 0x00, 0x33 }; unsigned char reset[5] = { 0x61, 0x00, 0x01, 0x00, 0x33 };
thumbDV_writeSerial( handle, reset, 5 );
int ret = thumbDV_processSerial(handle); int ret = thumbDV_writeSerial( handle, reset, 5 );
if ( ret != 0 ) if ( ret != 0 )
{ {
@ -313,9 +316,7 @@ static int _check_serial( FT_HANDLE handle )
} }
unsigned char get_prodID[5] = {0x61, 0x00, 0x01, 0x00, 0x30 }; unsigned char get_prodID[5] = {0x61, 0x00, 0x01, 0x00, 0x30 };
thumbDV_writeSerial( handle, get_prodID, 5 ); ret = thumbDV_writeSerial( handle, get_prodID, 5 );
ret = thumbDV_processSerial(handle);
if ( ret != 0 ) if ( ret != 0 )
{ {
@ -323,7 +324,6 @@ static int _check_serial( FT_HANDLE handle )
return -1; return -1;
} }
return 0 ; return 0 ;
} }
@ -698,7 +698,6 @@ static void _connectSerial( FT_HANDLE * ftHandle )
unsigned char disable_parity[6] = {0x61, 0x00, 0x02, 0x00, 0x3F, 0x00}; unsigned char disable_parity[6] = {0x61, 0x00, 0x02, 0x00, 0x3F, 0x00};
thumbDV_writeSerial( *ftHandle, disable_parity, 6 ); thumbDV_writeSerial( *ftHandle, disable_parity, 6 );
thumbDV_processSerial( *ftHandle );
unsigned char get_version[5] = {0x61, 0x00, 0x01, 0x00, 0x31}; unsigned char get_version[5] = {0x61, 0x00, 0x01, 0x00, 0x31};
unsigned char read_cfg[5] = {0x61, 0x00, 0x01, 0x00, 0x37}; unsigned char read_cfg[5] = {0x61, 0x00, 0x01, 0x00, 0x37};