Open podhrmic opened 6 years ago
Where is compiled this code, which MCU/CPU ?
Did you try to compile with -DPPRZLINK_UNALIGNED_ACCESS
?
I did. I will run some more tests and post a better output info.
Update:
The code is from airframes/AGGIEAIR/aggieair_conf.xml
and then Minion_RP3
- compiled for Lisa MX (ap target) and for a generix linux machine (hitl/nps). I am running 64-bit Ubuntu 16.04.
With pprzlink 1.0 (and PPRZLINK_UNALIGNED_ACCESS
allowed):
DL_COMMANDS_values_length(buf) = 5
DL_COMMANDS_values(buf) = 0x7fea06ec1b53
With pprzlink 2.0 (and PPRZLINK_UNALIGNED_ACCESS
enabled):
DL_COMMANDS_values_length(buf) = 5
DL_COMMANDS_values(buf) = (nil)
With PPRZLINK_UNALIGNED_ACCESS=0
I get:
DL_COMMANDS_values_length(buf) = 0
DL_COMMANDS_values(buf) = (nil)
So clearly with pprzlink 2.0 and unaligned access enabled I get the correct values_length
, but the array pointer is still NULL.
Also, when I just read and display DL_COMMANDS_values(buf)
(and don't try to do memcopy) I get different (but most likely illegal) address every time (instead of NULL).
I am kind of out of ideas - it could be related to the compiler (gcc 5.4) and many other things, but it is also just very weird:-/
Just to be sure, could you try with a more recent (GCC7) compiler ?
Actually, I was probably doing something wrong in the end. Can you try the fix_array_access
branch ?
The issue is apparently memory alignment,
From nps_main_hitl.c when parsing
DL_COMMANDS
:Pprzlink 1.0
Pprzlink 2.0
length
is at index 4, andpayload
is at index 5/* Getter for field values in message COMMANDS
/ Compatibility macros /
define DL_COMMANDS_values_length(_payload) pprzlink_get_COMMANDS_values_length(_payload)
define DL_COMMANDS_values(_payload) pprzlink_get_DL_COMMANDS_values(_payload)
printf("DL_COMMANDS_values_length(buf) = %u\n",DL_COMMANDS_values_length(buf)); printf("DL_COMMANDS_values(buf) = %p\n",DL_COMMANDS_values(buf));
DL_COMMANDS_values_length(buf) = 5 DL_COMMANDS_values(buf) = (nil)
9,0,1,102,5,0,0,0,0,0,0,0,0,0,0