Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. float buffXAccToSend[20];
  2. [...]
  3. collect()
  4. {
  5. if (storeAccData)
  6. {
  7. // Filling Buff
  8. buffXAccToSend[contBuffAcc-1] = accX;
  9. contBuffAcc++;
  10. }
  11.  
  12. // After 60 values call sendBuffAcc()
  13. if (contBuffAcc%(sizeBuffAcc+1) == 0)
  14. {
  15. sendBuffAcc();
  16. accDataReady=true;
  17. }
  18. }
  19. [...]
  20.  
  21. void sendBuffAcc()
  22. {
  23. int stepCont = 1;
  24.  
  25. // Data are store in a structure and then sent
  26. MyShortCommand * pMyCmdShort = (MyShortCommand *)(&bufferAcc[sizeof(MyControlHdr)]);
  27.  
  28. for (int i=0;i<sizeBuffAcc;i++)
  29. {
  30. numFilterValuesToSend++;
  31.  
  32. pMyCmdShort->cmd = accValuesID;
  33. pMyCmdShort->param1 = buffXAccToSend[i];
  34.  
  35. // You can find the output of this loop at the end of the question
  36. if (printAckCommands)
  37. {
  38. Serial.print(" CMD number: ");
  39. Serial.println(stepCont);
  40. Serial.println(pMyCmdShort->param1);
  41. Serial.println();
  42. }
  43. pMyCmdShort++;
  44.  
  45. // checks whether all values have been added to the message or the
  46. // content has reached the maximum dimension 'maxLengthMess'
  47. if (stepCont%(maxLengthMess) == 0 || stepCont == sizeBuffAcc)
  48. {
  49. sendCommandToMatlabFilter();
  50. }
  51. }
  52. stepCont++;
  53. }
  54. storeAccData = false;
  55. contBuffAcc=1;
  56. }
  57.  
  58. val: 20 -0.00
  59. val: 21 0.02
  60. val: 22 0.02
  61. val: 23 0.01
  62. val: 24 -0.02
  63. val: 25 -0.02
  64. val: 26 0.00
  65. val: 27 0.03
  66. val: 28 -0.01
  67. val: 29 -0.00
  68. val: 30 0.01
  69. val: 31 -0.00
  70. val: 32 -0.01
  71. val: 33 0.00
  72. val: 34 0.01
  73. val: 35 0.02
  74. val: 36 0.02
  75. val: 37 -0.00
  76. val: 38 -0.00
  77. val: 39 0.00
  78. val: 40 0.00
  79.  
  80. Sending # commands:20
  81. CMD number: 21
  82. -0.00
  83.  
  84. CMD number: 22
  85. 0.02
  86.  
  87. CMD number: 23
  88. 0.02
  89.  
  90. CMD number: 24
  91. 0.01
  92.  
  93. CMD number: 25
  94. -0.02
  95.  
  96. CMD number: 26
  97. -0.02
  98.  
  99. CMD number: 27 // From now on values are all zero! Why?
  100. 0.00
  101.  
  102. CMD number: 28
  103. 0.00
  104.  
  105. CMD number: 29
  106. 0.00
  107.  
  108. [...]
  109.  
  110. CMD number: 59
  111. 0.00
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement