Skip to content

Commit

Permalink
[messages] add AUTOPILOT_VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
flixr committed Dec 19, 2014
1 parent f296ca7 commit 1f7d11f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
7 changes: 6 additions & 1 deletion conf/messages.xml
Expand Up @@ -183,7 +183,12 @@
<field name="segment_north_2" type="float" unit="m"/>
</message>

<!-- ID 23 is free -->
<message name="AUTOPILOT_VERSION" id="23">
<field name="version" type="uint32"/>
<field name="git_sha1" type="uint8[8]" format="%x"/>
<field name="desc" type="char[]"/>
</message>

<!-- ID 24 is free -->

<message name="SVINFO" id="25">
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/firmwares/fixedwing/main_ap.c
Expand Up @@ -158,7 +158,7 @@ static inline void on_gps_solution(void);
#endif

/** Paparazzi version */
static const uint16_t version = PPRZ_VERSION_INT;
static const uint16_t version = PPRZ_VERSION_INT16;

#if defined RADIO_CONTROL || defined RADIO_CONTROL_AUTO1
static uint8_t mcu1_ppm_cpt;
Expand Down
10 changes: 9 additions & 1 deletion sw/airborne/firmwares/rotorcraft/main.c
Expand Up @@ -115,7 +115,9 @@ INFO_VALUE("it is recommended to configure in your airframe PERIODIC_FREQUENCY t
#endif

/** Paparazzi version */
static const uint16_t version = PPRZ_VERSION_INT;
static const uint16_t version = PPRZ_VERSION_INT16;
static uint32_t ap_version = PPRZ_VERSION_INT32;
static uint8_t git_version[8];

static inline void on_gyro_event(void);
static inline void on_accel_event(void);
Expand Down Expand Up @@ -148,6 +150,7 @@ int main(void)

STATIC_INLINE void main_init(void)
{
get_pprz_git_version(git_version);

mcu_init();

Expand Down Expand Up @@ -253,8 +256,13 @@ STATIC_INLINE void telemetry_periodic(void)

/* initialisation phase during boot */
if (boot) {
#if DOWNLINK
uint16_t non_const_version = version;
DOWNLINK_SEND_BOOT(DefaultChannel, DefaultDevice, &non_const_version);
char *ver_desc = PPRZ_VERSION_DESC;
DOWNLINK_SEND_AUTOPILOT_VERSION(DefaultChannel, DefaultDevice,
&ap_version, git_version, strlen(ver_desc), ver_desc);
#endif
boot = FALSE;
}
/* then report periodicly */
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/modules/datalink/mavlink.c
Expand Up @@ -302,7 +302,7 @@ static inline void mavlink_send_params(void)
static inline void mavlink_send_autopilot_version(void)
{
/// TODO: fill in versions correctly, how should they be encoded?
static uint32_t ver = PPRZ_VERSION_INT;
static uint32_t ver = PPRZ_VERSION_INT32;
mavlink_msg_autopilot_version_send(MAVLINK_COMM_0,
0, // capabilities,
ver, // version
Expand Down
7 changes: 5 additions & 2 deletions sw/include/pprz_version.h
Expand Up @@ -48,8 +48,11 @@
#define PPRZ_VERSION_DESC STRINGIFY(GIT_DESC)
#define PPRZ_VERSION STRINGIFY(PPRZ_VER)

/** paparazzi version encoded as one integer */
#define PPRZ_VERSION_INT (PPRZ_VER_MAJOR * 100 + PPRZ_VER_MINOR * 10 + PPRZ_VER_PATCH)
/** paparazzi version encoded as one 16bit integer */
#define PPRZ_VERSION_INT16 (PPRZ_VER_MAJOR * 100 + PPRZ_VER_MINOR * 10 + PPRZ_VER_PATCH)

/** paparazzi version encoded as one 32bit integer */
#define PPRZ_VERSION_INT32 (PPRZ_VER_MAJOR * 10000 + PPRZ_VER_MINOR * 100 + PPRZ_VER_PATCH)

static inline uint8_t nibble_from_char(char c)
{
Expand Down

0 comments on commit 1f7d11f

Please sign in to comment.