SHARE
TWEET

Untitled

a guest Jul 16th, 2019 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct sendMsg1 {
  2.   byte errorCheck;//1
  3.  
  4.   unsigned long dT1;//4
  5.   unsigned long dT2;//4
  6.   unsigned long t;//4
  7.   unsigned long plus[10];//40
  8. };//53
  9.  
  10. sendMsg1 msg1;
  11. byte copyMsg1[53];
  12.  
  13. unsigned long time1;
  14. unsigned long time2;
  15. unsigned long time3;
  16. unsigned long time4;
  17.  
  18. void setup() {
  19.   Serial.begin(1000000);
  20. }
  21.  
  22. void loop() {
  23.   sensorRead();
  24.   sendMsg1_f();
  25.  
  26.   //time3 = micros();
  27.   delayMicroseconds(900);
  28.   //time4 = micros();
  29. }
  30.  
  31. void sensorRead() {
  32.   time3 = micros();
  33.  
  34.   msg1.t = micros();
  35.   for (unsigned long i = 0; i < 1; i++) {
  36.     memcpy((void*)&(copyMsg1[i*sizeof(sendMsg1)]), (void*)&msg1, sizeof(sendMsg1));
  37.   }
  38.  
  39.   time4 = micros();
  40.   msg1.dT2 = time4 - time3;
  41. }
  42.  
  43. void sendMsg1_f() {
  44.   time1 = micros();
  45.  
  46.   msg1.errorCheck = 0;
  47.   for (int i = 0; i < sizeof(sendMsg1) - 1; i++) {
  48.     msg1.errorCheck += ((byte*)&msg1)[i];
  49.   }
  50.   Serial.write((byte*)&msg1,sizeof(sendMsg1));
  51.  
  52.   time2 = micros();
  53.   msg1.dT1 = time2 - time1;
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top