Advertisement
Guest User

ANT USB Mac OSX El Capitan AntLib Fix (thisisant.com/forum)

a guest
Dec 4th, 2015
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.45 KB | None | 0 0
  1. --- a/software/USB/device_handles/usb_device_handle_mac.cpp
  2. +++ b/software/USB/device_handles/usb_device_handle_mac.cpp
  3. @@ -20,6 +20,7 @@ limitations under the License.
  4.  #include "usb_device_handle.hpp"
  5.  
  6.  #include "macros.h"
  7. +#include "antmessage.h"
  8.  
  9.  #include "usb_device_handle_vcp.hpp"
  10.  #include "usb_device_handle_si_iokit.hpp"
  11. @@ -236,6 +237,19 @@ BOOL USBDeviceHandle::Open(const USBDevice& clDevice_, USBDeviceHandle*& pclDevi
  12.        }
  13.     }
  14.  
  15. +   if(bSuccess && clDevice_.GetDeviceType() != DeviceType::SI_LABS_IOKIT && clDevice_.GetDeviceType() != DeviceType::SI_LABS)
  16. +   {
  17. +      // Workaround for USB2/m data toggle syncronization and busy bit issue
  18. +      UCHAR aucReqCapabilitiesMsg[MESG_FRAME_SIZE + 2] = {0xA4, 0x02, 0x4D, 0x00, 0x54, 0xBF};
  19. +      UCHAR aucCapabilitiesMsg[MESG_MAX_SIZE];
  20. +      ULONG ulBytesWritten, ulBytesRead = 0;
  21. +
  22. +      pclDeviceHandle_->Write(aucReqCapabilitiesMsg, sizeof(aucReqCapabilitiesMsg), ulBytesWritten);
  23. +      pclDeviceHandle_->Write(aucReqCapabilitiesMsg, sizeof(aucReqCapabilitiesMsg), ulBytesWritten);
  24. +      pclDeviceHandle_->Read(aucCapabilitiesMsg, sizeof(aucCapabilitiesMsg), ulBytesRead, 10);
  25. +      pclDeviceHandle_->Read(aucCapabilitiesMsg, sizeof(aucCapabilitiesMsg), ulBytesRead, 10);
  26. +   }
  27. +
  28.     return bSuccess;
  29.  }
  30.  
  31.  
  32. --- a/software/USB/device_handles/usb_device_handle_win.cpp
  33. +++ b/software/USB/device_handles/usb_device_handle_win.cpp
  34. @@ -16,6 +16,7 @@ limitations under the License.
  35.  #include "types.h"
  36.  #if defined(DSI_TYPES_WINDOWS)
  37.  
  38. +#include "antmessage.h"
  39.  
  40.  #include "usb_device_handle.hpp"
  41.  
  42. @@ -156,6 +157,19 @@ BOOL USBDeviceHandle::Open(const USBDevice& clDevice_, USBDeviceHandle*& pclDevi
  43.        }
  44.     }
  45.  
  46. +   if(bSuccess && clDevice_.GetDeviceType() != DeviceType::SI_LABS_IOKIT && clDevice_.GetDeviceType() != DeviceType::SI_LABS)
  47. +   {
  48. +      // Workaround for USB2/m data toggle syncronization and busy bit issue
  49. +      UCHAR aucReqCapabilitiesMsg[MESG_FRAME_SIZE + 2] = {0xA4, 0x02, 0x4D, 0x00, 0x54, 0xBF};
  50. +      UCHAR aucCapabilitiesMsg[MESG_MAX_SIZE];
  51. +      ULONG ulBytesWritten, ulBytesRead = 0;
  52. +
  53. +      pclDeviceHandle_->Write(aucReqCapabilitiesMsg, sizeof(aucReqCapabilitiesMsg), ulBytesWritten);
  54. +      pclDeviceHandle_->Write(aucReqCapabilitiesMsg, sizeof(aucReqCapabilitiesMsg), ulBytesWritten);
  55. +      pclDeviceHandle_->Read(aucCapabilitiesMsg, sizeof(aucCapabilitiesMsg), ulBytesRead, 10);
  56. +      pclDeviceHandle_->Read(aucCapabilitiesMsg, sizeof(aucCapabilitiesMsg), ulBytesRead, 10);
  57. +   }
  58. +
  59.     return bSuccess;
  60.  }
  61.  
  62. --- a/software/serial/device_management/dsi_ant_device.cpp
  63. +++ b/software/serial/device_management/dsi_ant_device.cpp
  64. @@ -298,17 +298,11 @@ BOOL DSIANTDevice::ConnectToDevice(void)
  65.        ulUSBSerialNumber = pclSerialObject->GetDeviceSerialNumber();
  66.  
  67.        //Reset so we know we have a clean state
  68. -      int i = 0;
  69. -      while(i++ < 10)
  70. -      {
  71. -          pclANT->ResetSystem(1000);
  72. -
  73. -          failedConnect = !pclANT->GetCapabilities(NULL, 200); //This function always returns. If this fails something is wrong at the serial layer, often caused using the wrong baud rate
  74. -
  75. -          if(!failedConnect)
  76. -              break;
  77. -      }
  78. +      pclANT->ResetSystem(200);
  79. +      //If this fails it is probably connected at the wrong baud rate
  80.  
  81. +      if(pclANT->GetCapabilities(NULL, 200) == FALSE)
  82. +         failedConnect = TRUE;
  83.        //TODO could get number of channels and use dynamic sized channel array
  84.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement