Skip to content

Commit da849e5

Browse files
authored
Feature node status (iNavFlight#13)
* Adding live data to NodeStatus message. * Updated the vcs code with github hash. Put the arming flags in the vendor specific code in Node Status.
1 parent ffba4b8 commit da849e5

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

src/main/drivers/dronecan/dronecan.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
#include "common/time.h"
44
#include "drivers/time.h"
55
#include <stdint.h>
6+
#include <stdlib.h>
67
#include "fc/settings.h"
78
#include "build/version.h"
9+
#include "sensors/diagnostics.h"
10+
#include "fc/runtime_config.h"
811
#if defined(USE_DRONECAN)
912

1013
#include "io/gps.h"
@@ -177,7 +180,7 @@ void handle_GetNodeInfo(CanardInstance *ins, CanardRxTransfer *transfer) {
177180
pkt.software_version.major = FC_VERSION_MAJOR;
178181
pkt.software_version.minor = FC_VERSION_MINOR;
179182
pkt.software_version.optional_field_flags = FC_VERSION_PATCH_LEVEL;
180-
pkt.software_version.vcs_commit = 0; // shortGitRevision; // need to convert string to integer put git hash in here
183+
pkt.software_version.vcs_commit = strtoul(shortGitRevision, NULL, 16); // need to convert string to integer put git hash in here
181184

182185
// should fill in hardware version
183186
pkt.hardware_version.major = 1;
@@ -213,12 +216,18 @@ void send_NodeStatus(void) {
213216

214217
// LOG_DEBUG(CAN, "Sending Node Status");
215218
node_status.uptime_sec = millis() / 1000UL;
216-
node_status.health = UAVCAN_PROTOCOL_NODESTATUS_HEALTH_OK;
217-
node_status.mode = UAVCAN_PROTOCOL_NODESTATUS_MODE_OPERATIONAL;
218-
node_status.sub_mode = 0;
219+
if(isHardwareHealthy()){
220+
node_status.health = UAVCAN_PROTOCOL_NODESTATUS_HEALTH_OK;
221+
}
222+
else {
223+
node_status.health = UAVCAN_PROTOCOL_NODESTATUS_HEALTH_CRITICAL;
224+
}
225+
226+
node_status.mode = UAVCAN_PROTOCOL_NODESTATUS_MODE_OPERATIONAL; // Indicates that node is able to communicate over CAN, not that it is in flight.
227+
node_status.sub_mode = 0; // Not currently used in dronecan
219228

220229
// put whatever you like in here for display in GUI
221-
node_status.vendor_specific_status_code = 1234;
230+
node_status.vendor_specific_status_code = armingFlags;
222231

223232
uint32_t len = uavcan_protocol_NodeStatus_encode(&node_status, buffer);
224233

0 commit comments

Comments
 (0)