scpi_response_helper.h 1.8 KB

1234567891011121314151617181920212223242526
  1. #ifndef SCPI_RESPONSE_HELPER_H
  2. #define SCPI_RESPONSE_HELPER_H
  3. // @scpi_response_helper
  4. // Helper function. Helps to implement correct data output from the QUERY.
  5. // Copies the query data and updates the @sRead.nDataLength and @common_ctx->status
  6. // to the appropriate values, also returns actual query data offset.
  7. // @common_ctx - common context pointer passed to the handler;
  8. // @idx - current data offset in the handler;
  9. // @source - the data source pointer;
  10. // @source_max - maximum length of @source
  11. // @isdone - optional, if passed, specifies wheither to set DONE status or not;
  12. // Returns: actual data offset for the handler after the data pushed into the output buffer
  13. size_t scpi_response_helper( sProcessProgramDataCommonContext_t * common_ctx, size_t idx, void * source, size_t source_max, bool * isdone );
  14. // @scpi_response_done_helper
  15. // Helper function. Helps to implement setting of the status
  16. // @isdone - DONE status for handler
  17. void scpi_response_done_helper( sProcessProgramDataCommonContext_t * common_ctx, bool isdone );
  18. #define SCPI_RESPONSE_HELPER(_common_ctx_,idx_value) idx_value = scpi_response_helper( _common_ctx_, idx_value, common_ctx->tempBuffer, sizeof(common_ctx->tempBuffer), NULL )
  19. #define SCPI_RESPONSE_HELPER_EX(_common_ctx_,idx_value,src,srcmax) idx_value = scpi_response_helper( _common_ctx_, idx_value, src, srcmax, NULL )
  20. #define SCPI_RESPONSE_HELPER_EXTDONE_IDXINC(_common_ctx_,idx_value,BOOL_ISDONE) idx_value += scpi_response_helper( _common_ctx_, idx_value, common_ctx->tempBuffer, sizeof(common_ctx->tempBuffer), &(BOOL_ISDONE) )
  21. #define SCPI_RESPONSE_HELPER_EXTDONE_SET(_common_ctx_,BOOL_ISDONE) scpi_response_done_helper( _common_ctx_, BOOL_ISDONE )
  22. #endif