mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 17:19:09 -04:00
feat(openthread): change wlan to ethernet
This commit is contained in:
parent
13e8541007
commit
276087c4d3
@ -2,6 +2,7 @@
|
|||||||
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
# !/usr/bin/env python3
|
# !/usr/bin/env python3
|
||||||
# this file defines some functions for testing cli and br under pytest framework
|
# this file defines some functions for testing cli and br under pytest framework
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
import struct
|
import struct
|
||||||
@ -11,6 +12,7 @@ from typing import Tuple
|
|||||||
|
|
||||||
import netifaces
|
import netifaces
|
||||||
import pexpect
|
import pexpect
|
||||||
|
import yaml
|
||||||
from pytest_embedded_idf.dut import IdfDut
|
from pytest_embedded_idf.dut import IdfDut
|
||||||
|
|
||||||
|
|
||||||
@ -256,9 +258,30 @@ def init_interface_ipv6_address() -> None:
|
|||||||
|
|
||||||
|
|
||||||
def get_host_interface_name() -> str:
|
def get_host_interface_name() -> str:
|
||||||
interfaces = netifaces.interfaces()
|
home_dir = os.path.expanduser('~')
|
||||||
interface_name = [s for s in interfaces if 'wl' in s][0]
|
config_path = os.path.join(home_dir, 'config', 'env_config.yml')
|
||||||
return str(interface_name)
|
try:
|
||||||
|
if os.path.exists(config_path):
|
||||||
|
with open(config_path, 'r') as file:
|
||||||
|
config = yaml.safe_load(file)
|
||||||
|
interface_name = config.get('interface_name')
|
||||||
|
if interface_name:
|
||||||
|
if interface_name == 'eth0':
|
||||||
|
print(
|
||||||
|
f"Warning: 'eth0' is not recommended as a valid network interface. "
|
||||||
|
f"Please check and update the 'interface_name' in the configuration file: "
|
||||||
|
f'{config_path}'
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return str(interface_name)
|
||||||
|
else:
|
||||||
|
print("Warning: Configuration file found but 'interface_name' is not defined.")
|
||||||
|
except Exception as e:
|
||||||
|
print(f'Error: Failed to read or parse {config_path}. Details: {e}')
|
||||||
|
if 'eth1' in netifaces.interfaces():
|
||||||
|
return 'eth1'
|
||||||
|
|
||||||
|
raise Exception('Warning: No valid network interface detected. Please check your configuration.')
|
||||||
|
|
||||||
|
|
||||||
def clean_buffer(dut:IdfDut) -> None:
|
def clean_buffer(dut:IdfDut) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user