Guest User

Untitled

a guest
Jul 18th, 2013
138
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. unsigned short int calculateTriggerPoint(unsigned short int value)
  2. {
  3. unsigned short int result = value;
  4. // Each set bit inverts all bits with a lower value
  5. for(unsigned short int bitValue = 1; bitValue; bitValue <<= 1)
  6. if(result & bitValue)
  7. result ^= bitValue - 1;
  8. return result;
  9. }
  10.  
  11. /// \brief Gets the current state.
  12. /// \return The current CaptureState of the oscilloscope.
  13. CaptureState fd_runtime_getcapturestate(FDRuntime* self) {
  14. int errorCode;
  15. FDCommandGetCaptureState* gcs = (FDCommandGetCaptureState*)g_object_ref(self->commands[COMMAND_GETCAPTURESTATE]);
  16. errorCode = fd_device_sendcommand(FD_DEVICE(self->device), gcs);
  17. if(errorCode < 0)
  18. return errorCode;
  19. g_object_unref(G_OBJECT(gcs));
  20. FDCommandReceiveCaptureState* response = fd_commandreceivecapturestate_new();
  21. errorCode = fd_device_readcommand(FD_DEVICE(self->device), FD_COMMAND(response));
  22. if(errorCode < 0)
  23. return errorCode;
  24.  
  25. ****
  26. //self->triggerPoint = calculateTriggerPoint(fd_commandreceivecapturestate_getTriggerPoint(response));
  27. ****
  28. self->triggerPoint = fd_commandreceivecapturestate_getTriggerPoint(response);
  29. CaptureState state = fd_commandreceivecapturestate_getCaptureState(response);
  30. g_object_unref(G_OBJECT(response));
  31. return state;
  32. }
RAW Paste Data