Browse Source

Fix MAVLink reporting of Firmware version, implement dev / release version reporting

sbg
Lorenz Meier 9 years ago
parent
commit
972a6f7be8
  1. 4
      src/modules/mavlink/mavlink_main.cpp
  2. 3
      src/modules/systemlib/battery_params.c
  3. 62
      src/systemcmds/ver/ver.c

4
src/modules/mavlink/mavlink_main.cpp

@ -1222,8 +1222,8 @@ void Mavlink::send_autopilot_capabilites() @@ -1222,8 +1222,8 @@ void Mavlink::send_autopilot_capabilites()
msg.capabilities |= MAV_PROTOCOL_CAPABILITY_SET_ATTITUDE_TARGET;
msg.capabilities |= MAV_PROTOCOL_CAPABILITY_SET_POSITION_TARGET_LOCAL_NED;
msg.capabilities |= MAV_PROTOCOL_CAPABILITY_SET_ACTUATOR_TARGET;
msg.flight_sw_version = version_tag_to_number(px4_git_version);
msg.middleware_sw_version = version_tag_to_number(px4_git_version);
msg.flight_sw_version = version_tag_to_number(px4_git_tag);
msg.middleware_sw_version = version_tag_to_number(px4_git_tag);
msg.os_sw_version = version_tag_to_number(os_git_tag);
msg.board_version = px4_board_version;
memcpy(&msg.flight_custom_version, &px4_git_version_binary, sizeof(msg.flight_custom_version));

3
src/modules/systemlib/battery_params.c

@ -125,6 +125,7 @@ PARAM_DEFINE_FLOAT(BAT_V_LOAD_DROP, 0.3f); @@ -125,6 +125,7 @@ PARAM_DEFINE_FLOAT(BAT_V_LOAD_DROP, 0.3f);
*
* @group Battery Calibration
* @unit S
* @value 0 Unconfigured
* @value 2 2S Battery
* @value 3 3S Battery
* @value 4 4S Battery
@ -141,7 +142,7 @@ PARAM_DEFINE_FLOAT(BAT_V_LOAD_DROP, 0.3f); @@ -141,7 +142,7 @@ PARAM_DEFINE_FLOAT(BAT_V_LOAD_DROP, 0.3f);
* @value 15 15S Battery
* @value 16 16S Battery
*/
PARAM_DEFINE_INT32(BAT_N_CELLS, 3);
PARAM_DEFINE_INT32(BAT_N_CELLS, 0);
/**
* Battery capacity.

62
src/systemcmds/ver/ver.c

@ -70,6 +70,19 @@ __EXPORT const char *os_git_tag = ""; @@ -70,6 +70,19 @@ __EXPORT const char *os_git_tag = "";
__EXPORT const uint32_t px4_board_version = 1;
#endif
// dev >= 0
// alpha >= 64
// beta >= 128
// release candidate >= 192
// release == 255
enum FIRMWARE_TYPE {
FIRMWARE_TYPE_DEV = 0,
FIRMWARE_TYPE_ALPHA = 64,
FIRMWARE_TYPE_BETA = 128,
FIRMWARE_TYPE_RC = 192,
FIRMWARE_TYPE_RELEASE = 255
};
/**
* Convert a version tag string to a number
*/
@ -78,9 +91,16 @@ uint32_t version_tag_to_number(const char *tag) @@ -78,9 +91,16 @@ uint32_t version_tag_to_number(const char *tag)
uint32_t ver = 0;
unsigned len = strlen(tag);
unsigned mag = 0;
int32_t type = -1;
bool dotparsed = false;
unsigned dashcount = 0;
for (int i = len - 1; i >= 0; i--) {
if (tag[i] == '-') {
dashcount++;
}
if (tag[i] >= '0' && tag[i] <= '9') {
unsigned number = tag[i] - '0';
@ -94,6 +114,29 @@ uint32_t version_tag_to_number(const char *tag) @@ -94,6 +114,29 @@ uint32_t version_tag_to_number(const char *tag)
/* this is a full version and we have enough digits */
return ver;
} else if (tag[i] == '-' && i > 3 && type == -1) {
/* scan until the first number */
const char *curr = &tag[i - 1];
// dev: v1.4.0rc3-7-g7e282f57
while (curr >= &tag[0] && (*curr <= '0' || *curr >= '9')) {
if (*curr == 'd') {
type = FIRMWARE_TYPE_DEV;
break;
} else if (*curr == 'a') {
type = FIRMWARE_TYPE_ALPHA;
break;
} else if (*curr == 'b') {
type = FIRMWARE_TYPE_BETA;
break;
} else if (*curr == 'r') {
type = FIRMWARE_TYPE_BETA;
break;
}
curr--;
}
} else if (tag[i] != 'v') {
/* reset, because we don't have a full tag but
* are seeing non-numeric characters again
@ -103,15 +146,16 @@ uint32_t version_tag_to_number(const char *tag) @@ -103,15 +146,16 @@ uint32_t version_tag_to_number(const char *tag)
}
}
// XXX not reporting patch version yet
// dev > 0
// alpha > 64
// beta > 128
// release candidate > 192
// release > 255
/* if the type is still uninitialized, check if there is a single dash in git describe */
if (type == -1 && dashcount == 1) {
type = FIRMWARE_TYPE_RELEASE;
} else if (type == -1) {
type = FIRMWARE_TYPE_DEV;
}
ver = (ver << 8);
return ver;
return ver | type;
}
static void usage(const char *reason)
@ -167,8 +211,8 @@ int ver_main(int argc, char *argv[]) @@ -167,8 +211,8 @@ int ver_main(int argc, char *argv[])
unsigned minor = (fwver >> (8 * 2)) & 0xFF;
unsigned patch = (fwver >> (8 * 1)) & 0xFF;
unsigned type = (fwver >> (8 * 0)) & 0xFF;
printf("FW version: %s (%u.%u.%u %s)\n", px4_git_tag, major, minor, patch,
(type == 0) ? "dev" : "stable");
printf("FW version: %s (%u.%u.%u %u), %u\n", px4_git_tag, major, minor, patch,
type, fwver);
/* middleware is currently the same thing as firmware, so not printing yet */
printf("OS version: %s (%u)\n", os_git_tag, version_tag_to_number(os_git_tag));
ret = 0;

Loading…
Cancel
Save