Fixing crash on stratup if no Futaba VFD connected.
authorsl
Thu, 22 May 2014 07:30:05 +0200
changeset 1369f1fcfdf6a5
parent 12 7268128148b8
child 14 4a5538e0ccbf
Fixing crash on stratup if no Futaba VFD connected.
inc/FutabaVfd.h
src/FutabaVfd.cpp
src/test.cpp
     1.1 --- a/inc/FutabaVfd.h	Thu May 22 07:16:55 2014 +0200
     1.2 +++ b/inc/FutabaVfd.h	Thu May 22 07:30:05 2014 +0200
     1.3 @@ -52,6 +52,7 @@
     1.4  	int Open(const char* aPath);
     1.5  	int Open(unsigned short aVendorId, unsigned short aProductId, const wchar_t* aSerialNumber);
     1.6  	void Close();
     1.7 +    bool IsOpen();
     1.8  	//
     1.9  	int SetNonBlocking(int aNonBlocking);
    1.10  	//
    1.11 @@ -60,7 +61,7 @@
    1.12  	//
    1.13  	const wchar_t* Error();
    1.14  
    1.15 -	
    1.16 +
    1.17  
    1.18  private:
    1.19  	///Our USB HID device
    1.20 @@ -81,9 +82,9 @@
    1.21  */
    1.22  class FutabaVfdReport: public HidReport<KFutabaMaxHidReportSize>
    1.23  	{
    1.24 -	
    1.25 +
    1.26  private:
    1.27 -	
    1.28 +
    1.29  	};
    1.30  
    1.31  
     2.1 --- a/src/FutabaVfd.cpp	Thu May 22 07:16:55 2014 +0200
     2.2 +++ b/src/FutabaVfd.cpp	Thu May 22 07:30:05 2014 +0200
     2.3 @@ -110,6 +110,13 @@
     2.4  	iHidDevice=NULL;
     2.5  	}
     2.6  
     2.7 +/**
     2.8 +*/
     2.9 +bool HidDevice::IsOpen()
    2.10 +    {
    2.11 +    return iHidDevice!=NULL;
    2.12 +    }
    2.13 +
    2.14  
    2.15  /**
    2.16  */
    2.17 @@ -122,7 +129,7 @@
    2.18  */
    2.19  int HidDevice::SetNonBlocking(int aNonBlocking)
    2.20  	{
    2.21 -	//Success we are now connected to our HID device 
    2.22 +	//Success we are now connected to our HID device
    2.23  	//Set read operation as non blocking
    2.24  	return hid_set_nonblocking(iHidDevice, aNonBlocking);
    2.25  	}
     3.1 --- a/src/test.cpp	Thu May 22 07:16:55 2014 +0200
     3.2 +++ b/src/test.cpp	Thu May 22 07:30:05 2014 +0200
     3.3 @@ -197,10 +197,11 @@
     3.4  	onRescan(NULL, 0, NULL);
     3.5  
     3.6  	//Just testing our new VFD class
     3.7 -	iVfd01.Open();
     3.8 -	iVfd01.SetAllPixels(true);
     3.9 -	iVfd01.Close();
    3.10 -
    3.11 +	if (iVfd01.Open())
    3.12 +        {
    3.13 +	    iVfd01.SetAllPixels(true);
    3.14 +	    iVfd01.Close();
    3.15 +        }
    3.16  
    3.17  #ifdef __APPLE__
    3.18  	init_apple_message_system();