From eda34ee25547a73de40ef9e416d26600e0dde441 Mon Sep 17 00:00:00 2001 From: Ed Gonzalez Date: Fri, 12 Jun 2015 11:22:34 -0500 Subject: [PATCH] CID12153 - Make sure we get a correct serial descriptor on startup if not loop until we do --- DSP_API/ThumbDV/thumbDV.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/DSP_API/ThumbDV/thumbDV.c b/DSP_API/ThumbDV/thumbDV.c index dc4337c..95b40db 100644 --- a/DSP_API/ThumbDV/thumbDV.c +++ b/DSP_API/ThumbDV/thumbDV.c @@ -568,8 +568,13 @@ void thumbDV_init(const char * serial_device_name, int * serial_fd) pthread_rwlock_unlock(&_decoded_list_lock); - - *serial_fd = thumbDV_openSerial("/dev/ttyUSB0"); + do { + *serial_fd = thumbDV_openSerial("/dev/ttyUSB0"); + if ( *serial_fd < 0 ) { + output("Could not open serial. Waiting 1 second before trying again.\n"); + usleep(1000 * 1000); + } + } while ( *serial_fd < 0 ) ; unsigned char reset[5] = { 0x61, 0x00, 0x01, 0x00, 0x33 }; thumbDV_writeSerial(*serial_fd, reset, 5);