title: getting started with Thorlabs APT
body: <p>I'm hoping someone else out there has experience programming an APT - DC Servo controller.
  My client wants a custom solution, so using the ActiveX control isn't viable.</p>
  
  <p>I think once I can figure out how to send a basic message, I will be able to follow the API well enough, but I'm having difficulties getting started... and the documentation doesn't seem to clearly state how to actually send messages to the controller. </p>
  
  <p>IE, am I supposed to be using the FTDI interface, with the FT_Write/FT_Read commands to operate the device?</p>
  
  <p>I've run the following code which runs through the initial setup, which fails on the very last line where I try to flash the LED.</p>
  
  <pre><code>//the following is per the user manual for thor device.    
  ftHandle = FT_W32_CreateFile(SerialNumber.c_str(),
      GENERIC_READ|GENERIC_WRITE,
      0,
      0,
      OPEN_EXISTING,
      FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED |  FT_OPEN_BY_SERIAL_NUMBER,
      0); // Open device by serial number
  assert (ftHandle != INVALID_HANDLE_VALUE);
  // Set baud rate to 115200.
  const int uBaudRate=115200;
  auto ftStatus =  FT_SetBaudRate(ftHandle, (ULONG)uBaudRate);
  assert(ftStatus==FT_OK);
  
  // 8 data bits, 1 stop bit, no parity
  ftStatus = FT_SetDataCharacteristics(ftHandle, FT_BITS_8, FT_STOP_BITS_1, FT_PARITY_NONE);
  assert(ftStatus==FT_OK);
  // Pre purge dwell 50ms.
  Sleep(50);
  // Purge the device.
  ftStatus = FT_Purge(ftHandle, FT_PURGE_RX | FT_PURGE_TX);
  assert(ftStatus==FT_OK);
  // Post purge dwell 50ms.
  Sleep(50); 
  ftStatus = FT_ResetDevice(ftHandle);
  assert(ftStatus==FT_OK);
  // Set flow control to RTS/CTS.
  ftStatus = FT_SetFlowControl(ftHandle, FT_FLOW_RTS_CTS, 0, 0);
  // Set RTS.
  ftStatus = FT_SetRts(ftHandle);
  assert(ftStatus==FT_OK);
  
  //lets flash the led, MGMSG_MOD_IDENTIFY
  BYTE buf[6] ={0x23,0x2,0,0,0x21,0x1};
  DWORD written=0;
  /*******************/
  ftStatus = FT_Write(ftHandle, buf, (DWORD)6, &amp;written);//4= FT_IO_ERROR
  assert(ftStatus==FT_OK);  //this is where I'm failing
  /*******************/
  </code></pre>
  
  <p>For reference, I'm programming a 32 bit application - working on a 64 bit laptop.</p>