feat(master : tool)添加FRU解析工具
This commit is contained in:
parent
b8f2c88020
commit
84efd3eb0b
@ -977,8 +977,8 @@ write_read_chip(){
|
||||
cmd_wr=$option_data
|
||||
res_wr=`$cmd_wr`
|
||||
|
||||
format_print $INFO ">>> Chip Command: $cmd_wr"
|
||||
format_print $INFO ">>> The Result : $res_wr"
|
||||
format_print $INFO "Chip Command: $cmd_wr"
|
||||
format_print $INFO "The Result : $res_wr"
|
||||
}
|
||||
|
||||
process_chip(){
|
||||
|
||||
194
tool/fru_parse.py
Normal file
194
tool/fru_parse.py
Normal file
@ -0,0 +1,194 @@
|
||||
import os
|
||||
|
||||
fru_file="frudata.txt"
|
||||
internal = []
|
||||
chassis = []
|
||||
board = []
|
||||
product = []
|
||||
|
||||
def array_to_string(arr):
|
||||
result = ""
|
||||
for element in arr:
|
||||
result += chr(element)
|
||||
return result
|
||||
|
||||
def parse_internal():
|
||||
pass
|
||||
|
||||
def parse_chassis():
|
||||
pass
|
||||
|
||||
def parse_board():
|
||||
print("")
|
||||
print("Board Field")
|
||||
board_mfg_time = board[3:5]
|
||||
|
||||
cnt=5
|
||||
board_manufactor_length=board[cnt+1]-192
|
||||
cnt+=2
|
||||
board_manufactor=board[cnt:cnt+board_manufactor_length]
|
||||
cnt=cnt+board_manufactor_length
|
||||
|
||||
board_product_name_length=board[cnt]-192
|
||||
cnt+=1
|
||||
board_product_name=board[cnt:cnt+board_product_name_length]
|
||||
cnt=cnt+board_product_name_length
|
||||
|
||||
board_sn_length=board[cnt]-192
|
||||
cnt+=1
|
||||
board_sn=board[cnt:cnt+board_sn_length]
|
||||
cnt=cnt+board_sn_length
|
||||
|
||||
board_pn_length=board[cnt]-192
|
||||
cnt+=1
|
||||
board_pn=board[cnt:cnt+board_pn_length]
|
||||
cnt=cnt+board_pn_length
|
||||
|
||||
board_id_length=board[cnt]-192
|
||||
cnt+=1
|
||||
board_id=board[cnt:cnt+board_id_length]
|
||||
cnt=cnt+board_id_length
|
||||
|
||||
print("Board Manufacturer : " + array_to_string(board_manufactor))
|
||||
print("Board Product Name : " + array_to_string(board_product_name))
|
||||
print("Board Serial Number: " + array_to_string(board_sn))
|
||||
print("Board Part Number : " + array_to_string(board_pn))
|
||||
print("Board Fru File ID : " + array_to_string(board_id))
|
||||
|
||||
while board[cnt] != 193:
|
||||
board_OEM_length=board[cnt]-192
|
||||
cnt+=1
|
||||
board_oem=board[cnt:cnt+board_OEM_length]
|
||||
cnt=cnt+board_OEM_length
|
||||
print("Board Extra : " + array_to_string(board_oem))
|
||||
|
||||
def parse_product():
|
||||
print("")
|
||||
print("Product Field")
|
||||
|
||||
cnt=3
|
||||
|
||||
product_manu_name_len = product[cnt] - 192
|
||||
cnt+=1
|
||||
product_manu_name=product[cnt:cnt+product_manu_name_len]
|
||||
cnt=cnt+product_manu_name_len
|
||||
|
||||
product_product_name_len = product[cnt] - 192
|
||||
cnt+=1
|
||||
product_product_name=product[cnt:cnt+product_product_name_len]
|
||||
cnt=cnt+product_product_name_len
|
||||
|
||||
product_pn_len = product[cnt] - 192
|
||||
cnt+=1
|
||||
product_pn=product[cnt:cnt+product_pn_len]
|
||||
cnt=cnt+product_pn_len
|
||||
|
||||
product_version_len = product[cnt] - 192
|
||||
cnt+=1
|
||||
product_version=product[cnt:cnt+product_version_len]
|
||||
cnt=cnt+product_version_len
|
||||
|
||||
product_sn_len = product[cnt] - 192
|
||||
cnt+=1
|
||||
product_sn=product[cnt:cnt+product_sn_len]
|
||||
cnt=cnt+product_sn_len
|
||||
|
||||
product_asset_len = product[cnt] - 192
|
||||
cnt+=1
|
||||
product_asset=product[cnt:cnt+product_asset_len]
|
||||
cnt=cnt+product_asset_len
|
||||
|
||||
product_id_len = product[cnt] - 192
|
||||
cnt+=1
|
||||
product_id=product[cnt:cnt+product_id_len]
|
||||
cnt=cnt+product_id_len
|
||||
|
||||
print("Product Manufacturer : " + array_to_string(product_manu_name))
|
||||
print("Product Name : " + array_to_string(product_product_name))
|
||||
print("Product Part Number : " + array_to_string(product_pn))
|
||||
print("Product Version : " + array_to_string(product_version))
|
||||
print("Product Serial Numebr: " + array_to_string(product_sn))
|
||||
print("Product Asset Tag : " + array_to_string(product_asset))
|
||||
print("Product Fru File ID : " + array_to_string(product_id))
|
||||
|
||||
while product[cnt] != 193:
|
||||
product_OEM_length=product[cnt]-192
|
||||
cnt+=1
|
||||
product_oem=product[cnt:cnt+product_OEM_length]
|
||||
cnt=cnt+product_OEM_length
|
||||
print("Product Extra : " + array_to_string(product_oem))
|
||||
|
||||
|
||||
def parse_fru_data():
|
||||
print("===> Start Parse Fru data")
|
||||
if len(internal) > 0:
|
||||
parse_internal()
|
||||
|
||||
if len(chassis) > 0:
|
||||
parse_chassis()
|
||||
|
||||
if len(board) > 0:
|
||||
parse_board()
|
||||
|
||||
if len(product) > 0:
|
||||
parse_product()
|
||||
|
||||
def split_fru_data(data):
|
||||
print("===> Start split fru data")
|
||||
header = data[0:8]
|
||||
internal_offset = header[1] * 8
|
||||
chassis_offset = header[2] * 8
|
||||
board_offset = header[3] * 8
|
||||
product_offset = header[4] * 8
|
||||
|
||||
if internal_offset > 0:
|
||||
internal_data_length = data[internal_offset+1]*8
|
||||
global internal
|
||||
internal = data[internal_offset : internal_offset+internal_data_length]
|
||||
|
||||
if chassis_offset > 0:
|
||||
chassis_data_length = data[chassis_offset+1]*8
|
||||
global chassis
|
||||
chassis = data[chassis_offset : chassis_offset+chassis_data_length ]
|
||||
|
||||
if board_offset > 0:
|
||||
board_data_length = data[board_offset+1]*8
|
||||
global board
|
||||
board = data[board_offset : board_offset+board_data_length]
|
||||
print("board data")
|
||||
print(board)
|
||||
|
||||
if product_offset > 0:
|
||||
product_data_length = data[product_offset+1]*8
|
||||
global product
|
||||
product = data[product_offset : product_offset+product_data_length]
|
||||
print("product data")
|
||||
print(product)
|
||||
|
||||
print("<=== Complete split fru data")
|
||||
|
||||
|
||||
def load_fru_txt_file():
|
||||
if os.path.exists(fru_file):
|
||||
print(f"{fru_file} exists.")
|
||||
else:
|
||||
print(f"{fru_file} does not exist.")
|
||||
exit(1)
|
||||
|
||||
print("===> Start load fru file")
|
||||
result = []
|
||||
with open(fru_file, 'r') as file:
|
||||
lines = file.readlines()
|
||||
for line in lines:
|
||||
hex_numbers = line.strip().split()
|
||||
for hex_num in hex_numbers:
|
||||
decimal_num = int(hex_num, 16)
|
||||
result.append(decimal_num)
|
||||
print(result)
|
||||
print("<=== Complete load fru data")
|
||||
return result
|
||||
|
||||
if __name__ == "__main__":
|
||||
fru_data = load_fru_txt_file()
|
||||
split_fru_data(fru_data)
|
||||
parse_fru_data()
|
||||
16
tool/frudata.txt
Normal file
16
tool/frudata.txt
Normal file
@ -0,0 +1,16 @@
|
||||
01 00 00 01 0c 00 00 f2 01 0b 00 78 20 df c7 69
|
||||
6e 61 67 69 6c 65 c2 4e 43 cf 30 30 30 30 30 30
|
||||
30 30 30 30 30 30 30 30 30 ce 59 5a 4e 43 2d 58
|
||||
58 58 58 58 2d 59 59 59 c0 cf 4e 55 4c 4c 20 20
|
||||
20 20 20 20 20 20 20 20 20 ce 4e 55 4c 4c 20 20
|
||||
20 20 20 20 20 20 20 20 c1 00 00 00 00 00 00 88
|
||||
01 0b 00 cc 49 45 49 54 20 53 59 53 54 45 4d 53
|
||||
e0 45 4e 58 58 58 58 58 58 2d 58 58 58 20 20 20
|
||||
20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
|
||||
20 ce 59 5a 4e 43 2d 58 58 58 58 58 2d 59 59 59
|
||||
c2 30 31 cf 30 30 30 30 30 30 30 30 30 30 30 30
|
||||
30 30 30 c0 c0 c1 00 3b ff ff ff ff ff ff ff ff
|
||||
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
Loading…
Reference in New Issue
Block a user