Skip to content

HITL doesn't work with Ppprzlink 2.0 #80

@podhrmic

Description

@podhrmic

The issue is apparently memory alignment,

From nps_main_hitl.c when parsing DL_COMMANDS:

Pprzlink 1.0

  • everything works fine
#define DL_COMMANDS_values_length(_payload) _PPRZ_VAL_len_aligned(_payload, 2)
#define DL_COMMANDS_values(_payload) _PPRZ_VAL_int16_t_array(_payload, 3)

Pprzlink 2.0

  • length is at index 4, and payload is at index 5
/** Getter for length of array values in message COMMANDS
 *
 * @return values : 
 */
 static inline uint8_t pprzlink_get_COMMANDS_values_length(__attribute__ ((unused)) void* _payload) {
    return _PPRZ_VAL_len_aligned(_payload, 4);
}

/** Getter for field values in message COMMANDS
  *
  * @param _payload : a pointer to the COMMANDS message
  * @return 
  */
static inline int16_t * pprzlink_get_DL_COMMANDS_values(uint8_t * _payload __attribute__((unused)))
{
    return _PPRZ_VAL_int16_t_array(_payload, 5);
}


/* 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)
  • length is returned properly, but instead of a pointer to the payload I am getting NULL (DL_COMMANDS_values(buf) = NULL) and as a result memcopy crashes (access to memory at NULL).
printf("DL_COMMANDS_values_length(buf) = %u\n",DL_COMMANDS_values_length(buf));
printf("DL_COMMANDS_values(buf) = %p\n",DL_COMMANDS_values(buf));

prints

DL_COMMANDS_values_length(buf) = 5
DL_COMMANDS_values(buf) = (nil)

while the buffer values are:

9,0,1,102,5,0,0,0,0,0,0,0,0,0,0

(sender id =9, dest_id=0, class=telemetry, msg_id=102)

When turning the alignment off, the same result is produced.

@gautierhattenberger what do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions