mirror of
https://github.com/CopterExpress/clover.git
synced 2026-05-26 11:43:25 +00:00
selfcheck.py: add network check
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
|
||||
import os
|
||||
import math
|
||||
import subprocess
|
||||
import re
|
||||
@@ -692,9 +693,32 @@ def check_preflight_status():
|
||||
failure(' '.join([match.groups()[1], 'check:', check_status]))
|
||||
|
||||
|
||||
@check('Network')
|
||||
def check_network():
|
||||
ros_hostname = os.environ.get('ROS_HOSTNAME').strip()
|
||||
|
||||
if not ros_hostname:
|
||||
failure('No ROS_HOSTNAME is set')
|
||||
|
||||
elif ros_hostname.endswith('.local'):
|
||||
# using mdns hostname
|
||||
hosts = open('/etc/hosts', 'r')
|
||||
for line in hosts:
|
||||
parts = line.split()
|
||||
if len(parts) < 2:
|
||||
continue
|
||||
ip = parts.pop(0).split('.')
|
||||
if ip[0] == '127': # loopback ip
|
||||
if ros_hostname in parts:
|
||||
break
|
||||
else:
|
||||
failure('Not found %s in /etc/hosts, ROS will malfunction if network interfaces are down, https://clever.coex.tech/hostname', ros_hostname)
|
||||
|
||||
|
||||
def selfcheck():
|
||||
check_image()
|
||||
check_clever_service()
|
||||
check_network()
|
||||
check_fcu()
|
||||
check_imu()
|
||||
check_local_position()
|
||||
|
||||
Reference in New Issue
Block a user