From 91bb900ff1516567de77163a343b3785310d7c28 Mon Sep 17 00:00:00 2001 From: "marcinlei@outlook.com" <1750818448@qq.com> Date: Sun, 30 Mar 2025 22:58:49 +0800 Subject: [PATCH] =?UTF-8?q?feat(cube=20:=20create=5Fnicsensor.sh)=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0tmp112=E7=94=9F=E6=88=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cube/src/create_nicsensor.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/cube/src/create_nicsensor.py b/cube/src/create_nicsensor.py index b4f89c4..c114dd8 100644 --- a/cube/src/create_nicsensor.py +++ b/cube/src/create_nicsensor.py @@ -359,6 +359,18 @@ REG_tmp468="0x80" def load_tmp112_feature(data): dbg_print("info", ">>> Start load tmp112 feature ...") + tmp112_name = data['tmp112_name'] + + tmp112_channel_name_context = f""" +TMP112_Sensor_name="{tmp112_name}" +""" + try: + with open (output_path, 'a+', encoding='utf-8') as file: + file.write(tmp112_channel_name_context) + dbg_print("info", "Success to load tmp112 feature!") + except Exception as e: + dbg_print("Error", f"An error ouccuer when load tmp112 feature") + def load_fru_feature(data): dbg_print("info", ">>> Start load fru feature ...") @@ -1202,7 +1214,21 @@ fi except Exception as e: dbg_print("Error", f"An error ouccuer when load default function") +def replace_crlf_with_lf(input_file_path, output_file_path): + try: + with open(input_file_path, 'r', encoding='utf-8') as input_file: + content = input_file.read() + # 将 CRLF 替换为 LF + content = content.replace('\r\n', '\n') + with open(output_file_path, 'w', encoding='utf-8') as output_file: + output_file.write(content) + + dbg_print("info", f"成功将 {input_file_path} 中的 CRLF 替换为 LF, 并保存到 {output_file_path}") + except FileNotFoundError: + dbg_print("Error", f"错误: 文件 {input_file_path} 未找到。") + except Exception as e: + dbg_print("Error", f"发生未知错误: {e}") # ===================================================== # Start execute script @@ -1211,4 +1237,5 @@ init_output_file() process_nic_feature() load_public_function() process_hw_topo() -load_default_function() \ No newline at end of file +load_default_function() +replace_crlf_with_lf(output_path, output_path) \ No newline at end of file