Skip to content

AP_DroneCAN : add Node Status Logging #23583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ghost
Copy link

@ghost ghost commented Apr 24, 2023

This will create a log if Option 6 Enable in CAN_OPTION.

The Log created will have the information of every Node Health ,Uptime ,and delta between 2 status packet information.

It is a very good way for diagnosis if the AP_Periph has been failing to send data and also if it has rebooted.

This will create a log if Option 6 Enable in CAN_OPTION.

The Log created will have the information of every Node Health ,Uptime ,and delta between 2 status packet information.
@ghost
Copy link
Author

ghost commented Apr 27, 2023

@tridge can you review this code.


// Log NodeInfo
void log_NodeStatus(uint8_t node_id, uint32_t uptime_sec, uint8_t healthy, uint8_t mode, uint32_t delta);
uint32_t last_can_init_delta_ms[126];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is using a lot of memory for users with the option enabled. I think we should dynamically allocated it, so declare as a pointer here
variable name is also a bit confusing, last_node_status_ms[] would be better

@@ -416,6 +416,16 @@ void AP_DroneCAN_DNA_Server::handleNodeStatus(const CanardRxTransfer& transfer,
server_state = HEALTHY;
}
}

//to calculate the delta b/w handlenode status pkt
uint32_t now = AP_HAL::native_millis();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be just millis() (its a normal timestamp, not a bus time)

uint32_t now = AP_HAL::native_millis();

if (_ap_dronecan.option_is_set(AP_DroneCAN::Options::LOG_NODE_STATUS)) {
log_NodeStatus(transfer.source_node_id, msg.uptime_sec, msg.health, msg.mode , now - last_can_init_delta_ms[transfer.source_node_id]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add dynamic allocation if needed

log_NodeStatus(transfer.source_node_id, msg.uptime_sec, msg.health, msg.mode , now - last_can_init_delta_ms[transfer.source_node_id]);
}

last_can_init_delta_ms[transfer.source_node_id] = now;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that node IDs can be up to 127, so allocated array needs to be 128 long. Check this when you put the timestamp in the array, and move this line into if() for option

*/
void AP_DroneCAN_DNA_Server::log_NodeStatus(uint8_t node_id, uint32_t uptime_sec, uint8_t healthy, uint8_t mode, uint32_t delta)
{
if (node_id > MAX_NODE_ID) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should log up to and including 127, to get the GUI tool when used

@tridge tridge added the CAN label May 4, 2023
@peterbarker
Copy link
Contributor

@robertlong13 I can't tag the original author on this - is this something you're interested in?

@loki077
Copy link
Contributor

loki077 commented Sep 25, 2024

@peterbarker this is a PR from my Old carbonix account.

This will be a very handy feature to have in ardupilot.

@loki077
Copy link
Contributor

loki077 commented Sep 25, 2024

@peterbarker Need your opinion on this PR also comment on the below suggestion.

A better idea is the delta should not just be based on NodeStatus but all the packets from the node. Basically, when it is last heard from the node would give us alot of info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants