scpi_errq.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef SCPI_ERRQ_H
  2. #define SCPI_ERRQ_H
  3. #include "app/queue/queue.h"
  4. #include "app/queue/queue_ex.h"
  5. typedef queue_t errq_t;
  6. ///
  7. /// \brief Initialize SCPI error queue
  8. /// \param self Pointer to the queue.
  9. /// \param buffer Pointer to the user buffer to be used as storage
  10. /// \param capacity Capacity of the user buffer storage
  11. /// \return true if no error or false otherwise
  12. ///
  13. static inline bool errq_init(queue_t * self, void * buffer, size_t capacity )
  14. {
  15. return( QUEUE_RC_NOERROR == queue_init(self, buffer, capacity ) );
  16. }
  17. // errq_push
  18. // @self - Pointer to the record queue.
  19. // @errorCode - SCPI error code
  20. // @message - error textual description, null-terminated string
  21. // Return: true if no error occurred, false otherwise
  22. bool errq_push( errq_t * self, int16_t errorCode, const char * message );
  23. // errq_peek
  24. // Retrieves an information about SCPI error stored in the top of SCPI Error FIFO.
  25. // DO NOT remove element from the log.
  26. // @self - Pointer to the record queue.
  27. // @errorCode - pointer to the variable to store SCPI error code
  28. // @message - pointer to buffer to store error textual description
  29. // @msgBufSize - pointer to the variable where the size of the buffer @message is stored. After successful operation
  30. // the value will be modified to the length of message stored to @message
  31. // Return: true if no error occurred, false otherwise
  32. bool errq_peek( errq_t * self, int16_t * perrorCode, char * message, size_t * msgBufSize );
  33. // errq_pop
  34. // Retrieves an information about SCPI error stored in the top of SCPI Error FIFO.
  35. // DO remove element from the log.
  36. // @self - Pointer to the record queue.
  37. // @errorCode - pointer to the variable to store SCPI error code
  38. // @message - pointer to buffer to store error textual description
  39. // @msgBufSize - pointer to the variable where the size of the buffer @message is stored. After successful operation
  40. // the value will be modified to the length of message stored to @message
  41. // Return: true if no error occurred, false otherwise
  42. bool errq_pop( errq_t * self, int16_t * perrorCode, char * message, size_t * msgBufSize );
  43. // errq_removetop
  44. // Remove element from the SCPI Error log.
  45. // @self - Pointer to the record queue.
  46. // Return: true if no error occurred, false otherwise
  47. bool errq_removetop( errq_t * self );
  48. // errq_isempty
  49. // Check is the error queue is empty
  50. // @self - Pointer to the record queue.
  51. // Return: true if no error records is stored in queue, false otherwise
  52. bool errq_isempty( errq_t * self );
  53. // errq_clear
  54. // Clears error queue
  55. // @self - Pointer to the record queue.
  56. // Return: none
  57. void errq_clear( errq_t * self );
  58. #endif