send_data.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #include "send_data.h"
  2. void send_package_data(uint16_t package_num, int16_t right_pos_data[3], int16_t left_pos_data[3], int16_t right_att_data[3], int16_t left_att_data[3],
  3. int16_t s_zupt, int16_t h_zupt,int16_t is_down, int16_t is_jump, int8_t s_rssi, uint8_t time_stamp)
  4. {
  5. uint8_t buf[256];
  6. uint8_t L=0;
  7. buf[L++] = (uint8_t)(right_pos_data[0]>>8);
  8. buf[L++] = (uint8_t)(right_pos_data[0]>>0);
  9. buf[L++] = (uint8_t)(right_pos_data[1]>>8);
  10. buf[L++] = (uint8_t)(right_pos_data[1]>>0);
  11. buf[L++] = (uint8_t)(right_pos_data[2]>>8);
  12. buf[L++] = (uint8_t)(right_pos_data[2]>>0);
  13. buf[L++] = (uint8_t)(left_pos_data[0]>>8);
  14. buf[L++] = (uint8_t)(left_pos_data[0]>>0);
  15. buf[L++] = (uint8_t)(left_pos_data[1]>>8);
  16. buf[L++] = (uint8_t)(left_pos_data[1]>>0);
  17. buf[L++] = (uint8_t)(left_pos_data[2]>>8);
  18. buf[L++] = (uint8_t)(left_pos_data[2]>>0);
  19. buf[L++] = (uint8_t)(right_att_data[0]>>8);
  20. buf[L++] = (uint8_t)(right_att_data[0]>>0);
  21. buf[L++] = (uint8_t)(right_att_data[1]>>8);
  22. buf[L++] = (uint8_t)(right_att_data[1]>>0);
  23. buf[L++] = (uint8_t)(right_att_data[2]>>8);
  24. buf[L++] = (uint8_t)(right_att_data[2]>>0);
  25. buf[L++] = (uint8_t)(left_att_data[0]>>8);
  26. buf[L++] = (uint8_t)(left_att_data[0]>>0);
  27. buf[L++] = (uint8_t)(left_att_data[1]>>8);
  28. buf[L++] = (uint8_t)(left_att_data[1]>>0);
  29. buf[L++] = (uint8_t)(left_att_data[2]>>8);
  30. buf[L++] = (uint8_t)(left_att_data[2]>>0);
  31. buf[L++] = (uint8_t)(s_zupt * 8 + h_zupt * 4 + is_down * 2 + is_jump * 1);
  32. buf[L++] = (uint8_t)(s_rssi >> 0);
  33. buf[L++] = (uint8_t)(time_stamp);
  34. send_protocol(DEX_NUM,package_num,buf,L);
  35. }
  36. void send_data_to_com(int16_t s_pos[3], int16_t h_pos[3], int16_t s_att[3], int16_t h_att[3] , int16_t s_zupt, int16_t h_zupt, int16_t is_down, int16_t is_jump, int8_t s_rssi)
  37. {
  38. static uint8_t time_stamp = 0;
  39. send_package_data( 0x04, s_pos, h_pos, s_att, h_att ,s_zupt, h_zupt, is_down, is_jump, s_rssi, time_stamp);
  40. time_stamp ++;
  41. }
  42. void send_data_to_host(uint16_t press, int16_t pos_n_offset[3], int16_t att[3], int16_t zupt)
  43. {
  44. static uint16_t ts = 0;
  45. uint8_t buf[256];
  46. uint8_t L=0;
  47. buf[L++] = (uint8_t)(press>>8);
  48. buf[L++] = (uint8_t)(press>>0);
  49. buf[L++] = (uint8_t)(pos_n_offset[0]>>8);
  50. buf[L++] = (uint8_t)(pos_n_offset[0]>>0);
  51. buf[L++] = (uint8_t)(pos_n_offset[1]>>8);
  52. buf[L++] = (uint8_t)(pos_n_offset[1]>>0);
  53. buf[L++] = (uint8_t)(pos_n_offset[2]>>8);
  54. buf[L++] = (uint8_t)(pos_n_offset[2]>>0);
  55. buf[L++] = (uint8_t)(att[0]>>8);
  56. buf[L++] = (uint8_t)(att[0]>>0);
  57. buf[L++] = (uint8_t)(att[1]>>8);
  58. buf[L++] = (uint8_t)(att[1]>>0);
  59. buf[L++] = (uint8_t)(att[2]>>8);
  60. buf[L++] = (uint8_t)(att[2]>>0);
  61. buf[L++] = (uint8_t)(zupt>>0);
  62. ts++;
  63. send_protocol(DEX_NUM,CMD_HEART,buf,L);
  64. }
  65. void send_acc_mag_to_host(uint16_t press, int16_t accl[3], int16_t magn[3], int16_t zupt)
  66. {
  67. static uint16_t ts = 0;
  68. uint8_t buf[256];
  69. uint8_t L=0;
  70. buf[L++] = (uint8_t)(press>>8);
  71. buf[L++] = (uint8_t)(press>>0);
  72. buf[L++] = (uint8_t)(accl[0]>>8);
  73. buf[L++] = (uint8_t)(accl[0]>>0);
  74. buf[L++] = (uint8_t)(accl[1]>>8);
  75. buf[L++] = (uint8_t)(accl[1]>>0);
  76. buf[L++] = (uint8_t)(accl[2]>>8);
  77. buf[L++] = (uint8_t)(accl[2]>>0);
  78. buf[L++] = (uint8_t)(magn[0]>>8);
  79. buf[L++] = (uint8_t)(magn[0]>>0);
  80. buf[L++] = (uint8_t)(magn[1]>>8);
  81. buf[L++] = (uint8_t)(magn[1]>>0);
  82. buf[L++] = (uint8_t)(magn[2]>>8);
  83. buf[L++] = (uint8_t)(magn[2]>>0);
  84. buf[L++] = (uint8_t)(zupt>>0);
  85. ts++;
  86. send_protocol(DEX_NUM,CMD_HEART,buf,L);
  87. }