# HG changeset patch # User sl # Date 1400736605 -7200 # Node ID 69f1fcfdf6a51dcbea487e19da943640f1e73701 # Parent 7268128148b8b2967cac7aeca2ae3b392c9010c2 Fixing crash on stratup if no Futaba VFD connected. diff -r 7268128148b8 -r 69f1fcfdf6a5 inc/FutabaVfd.h --- a/inc/FutabaVfd.h Thu May 22 07:16:55 2014 +0200 +++ b/inc/FutabaVfd.h Thu May 22 07:30:05 2014 +0200 @@ -52,6 +52,7 @@ int Open(const char* aPath); int Open(unsigned short aVendorId, unsigned short aProductId, const wchar_t* aSerialNumber); void Close(); + bool IsOpen(); // int SetNonBlocking(int aNonBlocking); // @@ -60,7 +61,7 @@ // const wchar_t* Error(); - + private: ///Our USB HID device @@ -81,9 +82,9 @@ */ class FutabaVfdReport: public HidReport { - + private: - + }; diff -r 7268128148b8 -r 69f1fcfdf6a5 src/FutabaVfd.cpp --- a/src/FutabaVfd.cpp Thu May 22 07:16:55 2014 +0200 +++ b/src/FutabaVfd.cpp Thu May 22 07:30:05 2014 +0200 @@ -110,6 +110,13 @@ iHidDevice=NULL; } +/** +*/ +bool HidDevice::IsOpen() + { + return iHidDevice!=NULL; + } + /** */ @@ -122,7 +129,7 @@ */ int HidDevice::SetNonBlocking(int aNonBlocking) { - //Success we are now connected to our HID device + //Success we are now connected to our HID device //Set read operation as non blocking return hid_set_nonblocking(iHidDevice, aNonBlocking); } diff -r 7268128148b8 -r 69f1fcfdf6a5 src/test.cpp --- a/src/test.cpp Thu May 22 07:16:55 2014 +0200 +++ b/src/test.cpp Thu May 22 07:30:05 2014 +0200 @@ -197,10 +197,11 @@ onRescan(NULL, 0, NULL); //Just testing our new VFD class - iVfd01.Open(); - iVfd01.SetAllPixels(true); - iVfd01.Close(); - + if (iVfd01.Open()) + { + iVfd01.SetAllPixels(true); + iVfd01.Close(); + } #ifdef __APPLE__ init_apple_message_system();