Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float buffXAccToSend[20];
- [...]
- collect()
- {
- if (storeAccData)
- {
- // Filling Buff
- buffXAccToSend[contBuffAcc-1] = accX;
- contBuffAcc++;
- }
- // After 60 values call sendBuffAcc()
- if (contBuffAcc%(sizeBuffAcc+1) == 0)
- {
- sendBuffAcc();
- accDataReady=true;
- }
- }
- [...]
- void sendBuffAcc()
- {
- int stepCont = 1;
- // Data are store in a structure and then sent
- MyShortCommand * pMyCmdShort = (MyShortCommand *)(&bufferAcc[sizeof(MyControlHdr)]);
- for (int i=0;i<sizeBuffAcc;i++)
- {
- numFilterValuesToSend++;
- pMyCmdShort->cmd = accValuesID;
- pMyCmdShort->param1 = buffXAccToSend[i];
- // You can find the output of this loop at the end of the question
- if (printAckCommands)
- {
- Serial.print(" CMD number: ");
- Serial.println(stepCont);
- Serial.println(pMyCmdShort->param1);
- Serial.println();
- }
- pMyCmdShort++;
- // checks whether all values have been added to the message or the
- // content has reached the maximum dimension 'maxLengthMess'
- if (stepCont%(maxLengthMess) == 0 || stepCont == sizeBuffAcc)
- {
- sendCommandToMatlabFilter();
- }
- }
- stepCont++;
- }
- storeAccData = false;
- contBuffAcc=1;
- }
- val: 20 -0.00
- val: 21 0.02
- val: 22 0.02
- val: 23 0.01
- val: 24 -0.02
- val: 25 -0.02
- val: 26 0.00
- val: 27 0.03
- val: 28 -0.01
- val: 29 -0.00
- val: 30 0.01
- val: 31 -0.00
- val: 32 -0.01
- val: 33 0.00
- val: 34 0.01
- val: 35 0.02
- val: 36 0.02
- val: 37 -0.00
- val: 38 -0.00
- val: 39 0.00
- val: 40 0.00
- Sending # commands:20
- CMD number: 21
- -0.00
- CMD number: 22
- 0.02
- CMD number: 23
- 0.02
- CMD number: 24
- 0.01
- CMD number: 25
- -0.02
- CMD number: 26
- -0.02
- CMD number: 27 // From now on values are all zero! Why?
- 0.00
- CMD number: 28
- 0.00
- CMD number: 29
- 0.00
- [...]
- CMD number: 59
- 0.00
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement