Browse Source

added git version

Andrew Tridgell 3 years ago
parent
commit
dc39582d7e

+ 1 - 0
.gitignore

@@ -1 +1,2 @@
 *generated/
+git-version.h

+ 2 - 3
RemoteIDModule/DroneCAN.cpp

@@ -2,6 +2,7 @@
   DroneCAN class for handling OpenDroneID messages
  */
 #include <Arduino.h>
+#include "version.h"
 #include <time.h>
 #include "DroneCAN.h"
 #include <canard.h>
@@ -16,8 +17,6 @@
 #include <dronecan.remoteid.OperatorID.h>
 #include <dronecan.remoteid.ArmStatus.h>
 
-#define FW_VERSION_MAJOR 1
-#define FW_VERSION_MINOR 0
 #define BOARD_ID 10001
 #define CAN_APP_NODE_NAME "ArduPilot RemoteIDModule"
 #define CAN_DEFAULT_NODE_ID 0 // use DNA
@@ -357,7 +356,7 @@ void DroneCAN::handle_get_node_info(CanardInstance* ins, CanardRxTransfer* trans
     pkt.software_version.major = FW_VERSION_MAJOR;
     pkt.software_version.minor = FW_VERSION_MINOR;
     pkt.software_version.optional_field_flags = UAVCAN_PROTOCOL_SOFTWAREVERSION_OPTIONAL_FIELD_FLAG_VCS_COMMIT | UAVCAN_PROTOCOL_SOFTWAREVERSION_OPTIONAL_FIELD_FLAG_IMAGE_CRC;
-    pkt.software_version.vcs_commit = 0;
+    pkt.software_version.vcs_commit = GIT_VERSION;
 
     readUniqueID(pkt.hardware_version.unique_id);
 

+ 4 - 0
RemoteIDModule/RemoteIDModule.ino

@@ -8,6 +8,7 @@
  */
 
 #include <Arduino.h>
+#include "version.h"
 #include <math.h>
 #include <time.h>
 #include <sys/time.h>
@@ -41,6 +42,9 @@ void setup()
     // Serial for debug printf
     Serial.begin(DEBUG_BAUDRATE);
 
+    Serial.printf("ArduRemoteID version %u.%u %08x\n",
+                  FW_VERSION_MAJOR, FW_VERSION_MINOR, GIT_VERSION);
+
     // Serial1 for MAVLink
     Serial1.begin(MAVLINK_BAUDRATE, SERIAL_8N1, RX_PIN, TX_PIN);
 

+ 4 - 0
RemoteIDModule/version.h

@@ -0,0 +1,4 @@
+#define FW_VERSION_MAJOR 1
+#define FW_VERSION_MINOR 0
+
+#include "git-version.h"

+ 7 - 0
scripts/git-version.sh

@@ -0,0 +1,7 @@
+#!/bin/bash
+cat <<EOF > RemoteIDModule/git-version.h
+#define GIT_VERSION 0x$(git describe --always)
+EOF
+
+
+

+ 2 - 0
scripts/regen_headers.sh

@@ -18,3 +18,5 @@ for p in $PACKETS; do
         ln -s src/*"$p"*.c .
     )
 done
+
+scripts/git-version.sh