tx01_msg.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef _TELEMETRY_HPP_
  2. #define _TELEMETRY_HPP_ 1
  3. #if __cplusplus < 201103L
  4. #include <boost/static_assert.hpp>
  5. #define static_assert BOOST_STATIC_ASSERT
  6. #endif
  7. #include "tx01_endian.hpp"
  8. #define TX01_MSG_HEADER_MAGIC 1234567890
  9. #define TX01_MSG_POSTAMBLE -1234567890
  10. struct tx01_msg_header
  11. {
  12. // should be MSG_HEADER_MAGIC
  13. big_int32_t magic;
  14. // size of the message (including header and postamble)
  15. big_int32_t size;
  16. // user configurable for flow identification
  17. big_int32_t flow;
  18. };
  19. static_assert(sizeof(struct tx01_msg_header) == 12);
  20. struct tx01_data_msg
  21. {
  22. struct tx01_msg_header header;
  23. big_int32_t time_tag_1;
  24. big_int32_t time_tag_2;
  25. big_uint32_t seq_counter;
  26. big_int32_t frame_check_result;
  27. big_int32_t frame_sync_stat;
  28. big_int32_t bit_slip_stat;
  29. big_int32_t tm_delay;
  30. big_int32_t frame_len;
  31. big_int32_t sync_word_len;
  32. big_int32_t frame_check_rs_stat;
  33. big_int32_t data_fmt;
  34. big_int32_t _unused0;
  35. big_int32_t _unused1;
  36. char data[];
  37. };
  38. static_assert(sizeof(struct tx01_data_msg) == 64);
  39. /* Try to match a tx01_msg_header at ptr. If success, return a pointer
  40. * to this tx01_msg_header. Otherwise return NULL. */
  41. extern const struct tx01_msg_header *
  42. tx01_try_match_msg_header(const char *ptr);
  43. extern const struct tx01_data_msg *
  44. tx01_try_match_data_msg(const struct tx01_msg_header *ptr);
  45. #undef _STATIC_ASSERT
  46. #undef _CAT2
  47. #undef _CAT
  48. #endif