This structure then gets copied into a section of memory in order to be transmitted as a UDP packet.
In addition to the structure there is a preceding message code and a CRC byte added.
I think the optimiser is stopping the entire structure from being copied.
Here is some notified code that demonstrates the problem.
Code: Select all
case i_sync.ready():
sync_data sync_pulse = i_sync.get_data();
memcpy(&sync_msg[1], &sync_pulse, 5);
printf("A: ");
for(int i=0; i<sizeof(sync_msg); i++)
printf("%02X ", sync_msg[i]);
printf("\n");
memset(sync_msg, 0x03, sizeof(sync_msg));
//printf("-- %d\n", (int)sync_pulse.count);
break;
Code: Select all
typedef struct {
unsigned int period;
unsigned short count;
} sync_data;
The notifying task is printing SYNC: <count value>, which can be seen in position [5] of the array.
Code: Select all
SYNC: 5
A: 03 2A 42 0F 00 05 03
-- 5
SYNC: 6
A: 03 2A 42 0F 00 06 03
-- 6
SYNC: 7
A: 03 2A 42 0F 00 07 03
-- 7
SYNC: 8
A: 03 2A 42 0F 00 08 03
-- 8
SYNC: 9
A: 03 2A 42 0F 00 09 03
-- 9
SYNC: 10
A: 03 2A 42 0F 00 0A 03
-- 10
SYNC: 11
A: 03 2A 42 0F 00 0B 03
-- 11
SYNC: 12
A: 03 2A 42 0F 00 0C 03
-- 12
Code: Select all
SYNC: 5
A: 03 2A 42 0F 00 03 03
SYNC: 6
A: 03 2A 42 0F 00 03 03
SYNC: 7
A: 03 2A 42 0F 00 03 03
SYNC: 8
A: 03 2A 42 0F 00 03 03
SYNC: 9
A: 03 2A 42 0F 00 03 03
SYNC: 10
A: 03 2A 42 0F 00 03 03
SYNC: 11
A: 03 2A 42 0F 00 03 03
SYNC: 12
A: 03 2A 42 0F 00 03 03