39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
import binascii
|
||
import logging
|
||
import sys
|
||
|
||
sys.path.insert(0, '/home/zjz/CCSDS_study/netzob-030/test/src')
|
||
logging.basicConfig(level=logging.INFO, format='%(message)s')
|
||
|
||
from netzob.all import *
|
||
|
||
samples = ["00ff1f000000", "00fe1f000000", "00fe1f000000", "00fe1f000000",
|
||
"00ff1f000000", "00ff1f000000", "00ff0f000000", "00fe2f000000"]
|
||
|
||
messages = [RawMessage(data=binascii.unhexlify(s)) for s in samples]
|
||
symbol = Symbol(messages=messages)
|
||
symbol.encodingFunctions.add(TypeEncodingFunction(HexaString))
|
||
|
||
print("=== 原始消息 ===")
|
||
print(symbol)
|
||
|
||
# 按 SIZE_8 切分为 6 个字段,静态/动态均不合并
|
||
Format.splitStatic(symbol, unitSize=UnitSize.SIZE_8,
|
||
mergeAdjacentStaticFields=False,
|
||
mergeAdjacentDynamicFields=False)
|
||
print("\n=== SIZE_8 切分后(6个字段)===")
|
||
print(symbol)
|
||
|
||
# 手动合并 Field[1] 和 Field[2]
|
||
Format.mergeFields(symbol.children[1], symbol.children[2])
|
||
print("\n=== 合并 Field[1]+Field[2] 后 ===")
|
||
print(symbol)
|
||
|
||
# 手动合并 Field[2] 和 Field[3]
|
||
Format.mergeFields(symbol.children[2], symbol.children[3])
|
||
print("\n=== 合并 Field[2]+Field[3] 后 ===")
|
||
print(symbol)
|
||
|
||
print("\n=== 字段结构调试信息 ===")
|
||
print(symbol._str_debug())
|