@@ -244,6 +244,10 @@ std::string vtkPlusNDITracker::Command(const char* format, ...)
244244 {
245245 LOG_DEBUG (" NDI Command:send serial break" );
246246 }
247+
248+ // Linux and MacOSX require resetting of va parameters
249+ va_end (ap);
250+ va_start (ap, format);
247251
248252 if (this ->Device )
249253 {
@@ -340,11 +344,22 @@ PlusStatus vtkPlusNDITracker::InternalConnectSerial()
340344 }
341345 }
342346
347+ #if defined(WIN32)
343348 // TODO: use the lines in this comment to replace next 5 lines when VS2010 support is dropped:
344349 // auto baudRates = { NDI_1228739, NDI_921600, NDI_230400, NDI_115200, NDI_57600, NDI_38400, NDI_19200, NDI_14400, NDI_9600 };
345350 // for (auto baud : baudRates)
346351 const unsigned int numberOfBaudRates = 9 ;
347352 int baudRates[numberOfBaudRates] = { NDI_1228739, NDI_921600, NDI_230400, NDI_115200, NDI_57600, NDI_38400, NDI_19200, NDI_14400, NDI_9600 };
353+ #elif defined(__APPLE__)
354+ const unsigned int numberOfBaudRates = 6 ;
355+ int baudRates[numberOfBaudRates] = { NDI_115200, NDI_57600, NDI_38400, NDI_19200, NDI_14400, NDI_9600 };
356+ #elif defined(__linux__)
357+ const unsigned int numberOfBaudRates = 6 ;
358+ int baudRates[numberOfBaudRates] = { NDI_115200, NDI_57600, NDI_38400, NDI_19200, NDI_14400, NDI_9600 };
359+ #else
360+ const unsigned int numberOfBaudRates = 6 ;
361+ int baudRates[numberOfBaudRates] = { NDI_115200, NDI_57600, NDI_38400, NDI_19200, NDI_14400, NDI_9600 };
362+ #endif
348363 for (unsigned int baudIndex = 0 ; baudIndex < numberOfBaudRates; baudIndex++)
349364 {
350365 int baud = baudRates[baudIndex];
@@ -605,6 +620,13 @@ PlusStatus vtkPlusNDITracker::EnableToolPorts()
605620
606621 // free ports that are waiting to be freed
607622 this ->Command (" PHSR:01" );
623+ int errnum = ndiGetError (this ->Device );
624+ if (errnum != NDI_OKAY)
625+ {
626+ LOG_ERROR (" Unable to get the number of handles. Error: " << ndiErrorString (errnum));
627+ return PLUS_FAIL;
628+ }
629+
608630 int ntools = ndiGetPHSRNumberOfHandles (this ->Device );
609631 for (int ndiToolIndex = 0 ; ndiToolIndex < ntools; ndiToolIndex++)
610632 {
@@ -639,7 +661,7 @@ PlusStatus vtkPlusNDITracker::EnableToolPorts()
639661 }
640662
641663 // initialize ports waiting to be initialized
642- int errnum = 0 ;
664+ errnum = 0 ;
643665 ntools = 0 ;
644666 do // repeat as necessary (in case multi-channel tools are used)
645667 {
0 commit comments