Skip to content

Commit

Permalink
example: added reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge committed Nov 29, 2023
1 parent 9615d12 commit 572aa7b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions examples/ESCNode/esc_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,16 @@ static void handle_param_ExecuteOpcode(CanardInstance* ins, CanardRxTransfer* tr
total_size);
}

/*
handle RestartNode request
*/
static void handle_RestartNode(CanardInstance* ins, CanardRxTransfer* transfer)
{
// the ESC should reboot now!
printf("Rebooting!!!\n");
exit(0);
}

/*
handle a GetNodeInfo request
*/
Expand Down Expand Up @@ -482,6 +492,10 @@ static void onTransferReceived(CanardInstance *ins, CanardRxTransfer *transfer)
handle_param_ExecuteOpcode(ins, transfer);
break;
}
case UAVCAN_PROTOCOL_RESTARTNODE_ID: {
handle_RestartNode(ins, transfer);
break;
}
}
}
if (transfer->transfer_type == CanardTransferTypeBroadcast) {
Expand Down Expand Up @@ -530,6 +544,10 @@ static bool shouldAcceptTransfer(const CanardInstance *ins,
*out_data_type_signature = UAVCAN_PROTOCOL_PARAM_EXECUTEOPCODE_SIGNATURE;
return true;
}
case UAVCAN_PROTOCOL_RESTARTNODE_ID: {
*out_data_type_signature = UAVCAN_PROTOCOL_RESTARTNODE_SIGNATURE;
return true;
}
}
}
if (transfer_type == CanardTransferTypeBroadcast) {
Expand Down

0 comments on commit 572aa7b

Please sign in to comment.