gtk2 sam7fc telemetrie application
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
2.7KB

  1. #ifndef TDCPROTO_H_
  2. #define TDCPROTO_H_
  3. #include <stdint.h>
  4. /*
  5. * 0: this is a request (host -> board)
  6. * 1: this is a reply (board -> host)
  7. */
  8. #define TDC_DIR 0x80
  9. #define TDC_REPLY TDC_DIR
  10. /*
  11. * TDC_DIR = 0: destination address
  12. * TDC_DIR = 1: source address
  13. */
  14. #define TDC_ADDRMASK 0x70
  15. #define TDC_ADDR0 0x00 // host (dynamic!, sends to interface of last hello)
  16. #define TDC_ADDR1 0x10 // flightcontrol
  17. #define TDC_ADDR2 0x20 // missioncontrol
  18. #define TDC_ADDR3 0x30 // videocontrol
  19. #define TDC_ADDR4 0x40
  20. #define TDC_ADDR5 0x50
  21. #define TDC_ADDR6 0x60
  22. #define TDC_ADDR7 0x70
  23. #define TDC_OPCODEMASK 0x0F
  24. #define TDC_HELLO 0x00 // sets the path/interface to the host, reply is a info string
  25. #define TDC_GETVARS 0x01 // request variable names, many replies
  26. #define TDC_GETVALUE 0x02 // get one value, one reply
  27. #define TDC_SETVALUE 0x03 // set one value, no reply
  28. #define TDC_REQVALUES 0x04 // registers a periodic update, timed replies
  29. #define TDC_TERMINAL 0x05 // stdout data
  30. #define TDC_USERDATA 0x0F // user-defined data e.g. between boards
  31. struct tdc_pkt_header {
  32. uint8_t cmd; // TDC_*
  33. uint8_t size; // size including this header
  34. } __attribute__ ((packed));
  35. struct tdc_hello_reply {
  36. uint8_t cmd;
  37. uint8_t size;
  38. char name[32]; // name of device, version string
  39. } __attribute__ ((packed));
  40. struct tdc_getvars_reply {
  41. uint8_t cmd;
  42. uint8_t size;
  43. uint8_t id; // variable ID (max 256 vars / board)
  44. uint32_t flags; // variable parameters (type, size, ro/rw)
  45. uint8_t name_len; // size of variable name
  46. char name[0]; // variable name, excluding '\0'
  47. } __attribute__ ((packed));
  48. struct tdc_getvalue_request {
  49. uint8_t cmd;
  50. uint8_t size;
  51. uint8_t id; // variable ID (max 256 vars / board)
  52. } __attribute__ ((packed));
  53. struct tdc_getvalue_reply {
  54. uint8_t cmd;
  55. uint8_t size;
  56. uint8_t id; // variable ID (max 256 vars / board)
  57. uint8_t data[0]; // variable data 1-8 bytes
  58. } __attribute__ ((packed));
  59. struct tdc_setvalue_request {
  60. uint8_t cmd;
  61. uint8_t size;
  62. uint8_t id; // variable ID (max 256 vars / board)
  63. uint8_t data[0]; // variable data 1-8 bytes
  64. } __attribute__ ((packed));
  65. struct tdc_reqvalues_request {
  66. uint8_t cmd;
  67. uint8_t size;
  68. uint16_t interval; // interval in ms
  69. uint32_t varmap[8]; // bitmap of variables (32 * 8 = 256)
  70. } __attribute__ ((packed));
  71. struct tdc_reqvalues_reply {
  72. uint8_t cmd;
  73. uint8_t size;
  74. uint32_t timestamp; // internal jiffie count
  75. uint8_t cnt; // number of variables
  76. } __attribute__ ((packed));
  77. #define TDC_SIZEMASK 0x000F
  78. #define TDC_TYPEMASK 0x00F0
  79. #define TDC_UNSIGNED 0x0000
  80. #define TDC_SIGNED 0x0010
  81. #define TDC_FP 0x0020
  82. #define TDC_FIXED 0x0040
  83. #define TDC_READONLY 0x0100
  84. #define TDC_GUI_GRAPH 0x8000
  85. #endif /* TDCPROTO_H_ */