Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct sendMsg1 {
- byte errorCheck;//1
- unsigned long dT1;//4
- unsigned long dT2;//4
- unsigned long t;//4
- unsigned long plus[10];//40
- };//53
- sendMsg1 msg1;
- byte copyMsg1[53];
- unsigned long time1;
- unsigned long time2;
- unsigned long time3;
- unsigned long time4;
- void setup() {
- Serial.begin(1000000);
- }
- void loop() {
- sensorRead();
- sendMsg1_f();
- //time3 = micros();
- delayMicroseconds(900);
- //time4 = micros();
- }
- void sensorRead() {
- time3 = micros();
- msg1.t = micros();
- for (unsigned long i = 0; i < 1; i++) {
- memcpy((void*)&(copyMsg1[i*sizeof(sendMsg1)]), (void*)&msg1, sizeof(sendMsg1));
- }
- time4 = micros();
- msg1.dT2 = time4 - time3;
- }
- void sendMsg1_f() {
- time1 = micros();
- msg1.errorCheck = 0;
- for (int i = 0; i < sizeof(sendMsg1) - 1; i++) {
- msg1.errorCheck += ((byte*)&msg1)[i];
- }
- Serial.write((byte*)&msg1,sizeof(sendMsg1));
- time2 = micros();
- msg1.dT1 = time2 - time1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement