feat(cube : create_nicsensor) 添加生成set_configuration的逻辑
This commit is contained in:
parent
d651c1459e
commit
8d2f8a06e2
@ -73,7 +73,7 @@ res_tmp468=""
|
|||||||
file.write(header_content)
|
file.write(header_content)
|
||||||
file.write(param_context)
|
file.write(param_context)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"写入文件时出现错误: {e}")
|
dbg_print("Error", f"写入文件时出现错误: {e}")
|
||||||
|
|
||||||
def process_hw_topo():
|
def process_hw_topo():
|
||||||
dbg_print("info", "====== Process Server Hw Topo ======")
|
dbg_print("info", "====== Process Server Hw Topo ======")
|
||||||
@ -92,9 +92,18 @@ def process_hw_topo():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
dbg_print("Error", f"发生未知错误:{e}")
|
dbg_print("Error", f"发生未知错误:{e}")
|
||||||
|
|
||||||
|
set_configuration_content = """
|
||||||
|
set_configuration_oem(){
|
||||||
|
"""
|
||||||
|
|
||||||
maxPcieSlotNum = hw_topo_data['maxPcieSlotNum']
|
maxPcieSlotNum = hw_topo_data['maxPcieSlotNum']
|
||||||
dbg_print("info", f"maxPcieSlotNum={maxPcieSlotNum}")
|
dbg_print("info", f"maxPcieSlotNum={maxPcieSlotNum}")
|
||||||
|
|
||||||
|
if maxPcieSlotNum > 0 :
|
||||||
|
set_configuration_content += """
|
||||||
|
if [ $nic_type == "pcie" ];then
|
||||||
|
"""
|
||||||
|
|
||||||
PcieSlotProperties = hw_topo_data['PcieSlotProperties']
|
PcieSlotProperties = hw_topo_data['PcieSlotProperties']
|
||||||
# dbg_print("info", f"PcieSlotProperties={PcieSlotProperties}")
|
# dbg_print("info", f"PcieSlotProperties={PcieSlotProperties}")
|
||||||
|
|
||||||
@ -114,11 +123,14 @@ def process_hw_topo():
|
|||||||
is_have_pca9641 = i2c_cs['is_have_pca9641']
|
is_have_pca9641 = i2c_cs['is_have_pca9641']
|
||||||
|
|
||||||
if is_have_pca9641 == "enable":
|
if is_have_pca9641 == "enable":
|
||||||
|
pca9641_flag = 1
|
||||||
pca9641_slave = i2c_cs['pca9641_slave']
|
pca9641_slave = i2c_cs['pca9641_slave']
|
||||||
dbg_print("info", f">>> there has pca9641 !!!")
|
dbg_print("info", f">>> there has pca9641 !!!")
|
||||||
dbg_print("info", f">>> pca9641_slave={pca9641_slave}")
|
dbg_print("info", f">>> pca9641_slave={pca9641_slave}")
|
||||||
else:
|
else:
|
||||||
dbg_print("info", f">>> there has no pca9641 !!!")
|
dbg_print("info", f">>> there has no pca9641 !!!")
|
||||||
|
pca9641_flag = 0
|
||||||
|
pca9641_slave = "0xff"
|
||||||
|
|
||||||
pca9548num = i2c_cs['pca9548num']
|
pca9548num = i2c_cs['pca9548num']
|
||||||
dbg_print("info", f">>> pca9548num={pca9548num}")
|
dbg_print("info", f">>> pca9548num={pca9548num}")
|
||||||
@ -135,12 +147,40 @@ def process_hw_topo():
|
|||||||
for i in range(8):
|
for i in range(8):
|
||||||
channel = f"channel{i}"
|
channel = f"channel{i}"
|
||||||
pca9548_channel = pca9548_cs[channel]
|
pca9548_channel = pca9548_cs[channel]
|
||||||
|
pca9548_i2c_offset = 0x01 << i
|
||||||
|
|
||||||
if pca9548_channel != None :
|
if pca9548_channel != None :
|
||||||
dbg_print("info", f"{channel}={pca9548_channel}")
|
dbg_print("info", f"{channel}={pca9548_channel}")
|
||||||
|
set_configuration_content += f"""
|
||||||
|
if [ $slot_name == "{pca9548_channel}" ];
|
||||||
|
i2c_bus = "{i2c_bus}"
|
||||||
|
is_have_pca9641 = "{pca9641_flag}"
|
||||||
|
pca9641_slave = "{pca9641_slave}"
|
||||||
|
pca9548_slave = "{pca9548_slave}"
|
||||||
|
pca9548_channel = "0x{pca9548_i2c_offset:02x}"
|
||||||
|
fi
|
||||||
|
"""
|
||||||
else:
|
else:
|
||||||
dbg_print("info", f"{channel} is null")
|
dbg_print("info", f"{channel} is null")
|
||||||
|
|
||||||
|
# PCIe 类型添加 fi
|
||||||
|
set_configuration_content += """
|
||||||
|
fi
|
||||||
|
"""
|
||||||
|
|
||||||
|
# 添加 }
|
||||||
|
set_configuration_content += """}
|
||||||
|
"""
|
||||||
|
|
||||||
|
# 写入 script
|
||||||
|
try:
|
||||||
|
with open (output_path, 'a+', encoding='utf-8') as file:
|
||||||
|
file.write(set_configuration_content)
|
||||||
|
dbg_print("info", "Success to load hw topo!")
|
||||||
|
except Exception as e:
|
||||||
|
dbg_print("Error", f"An error ouccuer when load hw topo")
|
||||||
|
|
||||||
|
|
||||||
def load_adc128_feature(data):
|
def load_adc128_feature(data):
|
||||||
dbg_print("info", ">>> Start load adc128 feature ...")
|
dbg_print("info", ">>> Start load adc128 feature ...")
|
||||||
ch0_name = data['ch0_name']
|
ch0_name = data['ch0_name']
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user