Skip to content

Commit d5d238a

Browse files
committed
changed error loop to not hang
1 parent 3f99949 commit d5d238a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pio_workspace/src/power_main.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,11 +453,15 @@ rcl_timer_t timer;
453453
if (uxr_millis() - init > MS) { X; init = uxr_millis();} \
454454
} while (0)\
455455

456-
// Error handle loop
457456
void error_loop() {
458-
while(1) {
459-
delay(100);
460-
}
457+
int error = 0;
458+
while (error < 10) {
459+
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
460+
delay(100);
461+
462+
error++;
463+
}
464+
digitalWrite(LED_BUILTIN, HIGH);
461465
}
462466

463467
enum states {
@@ -562,6 +566,7 @@ void reConnectUSB() {
562566

563567
void destroy_entities()
564568
{
569+
digitalWrite(9, HIGH);
565570
reConnectUSB();
566571
rmw_context_t * rmw_context = rcl_context_get_rmw_context(&support.context);
567572
(void) rmw_uros_set_context_entity_destroy_session_timeout(rmw_context, 0);
@@ -573,6 +578,7 @@ void destroy_entities()
573578
rclc_executor_fini(&executor);
574579
rcl_node_fini(&node);
575580
rclc_support_fini(&support);
581+
digitalWrite(9, LOW);
576582
}
577583

578584
void power_setup() {

0 commit comments

Comments
 (0)