feat: nodes should die entirely if no MCU found

This should allow anchor to restart automatically if it's being run as a service
This commit is contained in:
Tristan McGinnis
2025-04-15 20:35:49 -05:00
committed by David
parent f12daff861
commit 8c4f75f75e
4 changed files with 17 additions and 10 deletions

View File

@@ -7,6 +7,7 @@ import time
import atexit
import serial
import os
import sys
import threading
import glob
@@ -61,8 +62,9 @@ class SerialRelay(Node):
if self.port is None:
self.get_logger().info("Unable to find MCU...")
time.sleep(1)
sys.exit(1)
#kill the node/process entirely
os.kill(os.getpid(), signal.SIGKILL)
sys.exit(0)
self.ser = serial.Serial(self.port, 115200)
atexit.register(self.cleanup)

View File

@@ -95,9 +95,10 @@ class SerialRelay(Node):
break
if self.port is None:
self.get_logger().info("Unable to find MCU... please make sure it is connected.")
time.sleep(1)
sys.exit(1)
self.get_logger().info("Unable to find MCU...")
#kill the node/process entirely
os.kill(os.getpid(), signal.SIGKILL)
sys.exit(0)
self.ser = serial.Serial(self.port, 115200)
atexit.register(self.cleanup)

View File

@@ -3,6 +3,7 @@ from rclpy.node import Node
import serial
import sys
import threading
import os
import glob
import time
import atexit
@@ -65,9 +66,10 @@ class SerialRelay(Node):
pass
if self.port is None:
self.get_logger().info("Unable to find MCU... please make sure it is connected.")
time.sleep(1)
sys.exit(1)
self.get_logger().info("Unable to find MCU...")
#kill the node/process entirely
os.kill(os.getpid(), signal.SIGKILL)
sys.exit(0)
self.ser = serial.Serial(self.port, 115200)
atexit.register(self.cleanup)

View File

@@ -7,6 +7,7 @@ import time
import atexit
import serial
import os
import sys
import threading
import glob
@@ -74,8 +75,9 @@ class SerialRelay(Node):
if self.port is None:
self.get_logger().info("Unable to find MCU...")
time.sleep(1)
sys.exit(1)
#kill the node/process entirely
os.kill(os.getpid(), signal.SIGKILL)
sys.exit(0)
self.ser = serial.Serial(self.port, 115200)
atexit.register(self.cleanup)