找回密码
 注册

QQ登录

只需一步,快速开始

查看: 334|回复: 5

hw_ctree.xml configuration in .bin?

[复制链接]
发表于 2024-11-13 23:45:40 | 显示全部楼层 |阅读模式
can i put hw_ctree.xml in .bin file flasher to make epon at the same time load the configuration?
4 P- p6 h" Q% H. P- C
发表于 2024-11-14 03:11:26 | 显示全部楼层
本人不懂英文;顶贴。
发表于 2024-11-14 03:24:24 | 显示全部楼层
you need to convert file content in hw_ctree.xml to binary data as output.bin
3 s/ [4 o( Z' E1 ^/ R8 R2 f- d; f2 |
Python:! }/ ~: F- k. ?* j1 O
8 k' g3 J% w  l- f3 }  G
import struct$ T8 Q' `3 O8 W: Y" J7 I
) Q* Z! y! t' e! c$ u' G; ^
# to write in$ m* o3 T( f3 U9 |
data_to_write = "file content"  #file content of hw_ctree.xml
0 j4 C. D# M4 k6 o$ k* V) J
: w4 N# [. A9 p) _# open .bin to write
* _( H9 f( w0 T- `1 B) m+ rwith open("output.bin", "wb") as bin_file:
$ s- k* c: v2 M# to binary
) x$ L8 s' [! F1 o5 P   binary_data = data_to_write.encode('utf-8')3 C# V2 V2 Q4 a4 I  |% f9 F" g
. n3 m& o& h* g# w" f1 e# F
# to .bin7 B, c, P  f& C- P* P
    bin_file.write(binary_data)
  J* q, a- o5 l! U
% d( r, w, p! j' j8 E/ ^#So do game over
发表于 2024-11-14 03:35:33 | 显示全部楼层
import struct
& y; Q# j! l4 Qwith open('hw_ctree.xml', 'r') as file:; Y# L0 i5 Y$ E7 A/ ]& z
    content = file.read()
2 q7 ?; |( Q; c6 A* i7 X' x$ Q
8 l/ D: ?# j% k$ C; abinary_data = content.encode('utf-8')+ x4 q! S% r! o& U/ j
, f" \* `3 b( U3 D( X8 ]: z
with open('output.bin', 'wb') as bin_file:
) p0 h, H* I" Q) \0 T0 p4 D  L* u    bin_file.write(binary_data)
 楼主| 发表于 2024-11-14 04:02:26 | 显示全部楼层
zhang260gt 发表于 2024-11-14 03:352 r' I, |& N0 E' B
import struct3 t- \2 h# x: Q4 ^8 @
with open('hw_ctree.xml', 'r') as file:
8 @1 T* L7 q5 A8 N6 E1 F    content = file.read()

1 T- m2 M' D$ o' q" Hwhats this what app
发表于 2024-11-14 09:47:28 | 显示全部楼层
python 转二进制。厉害了
*滑块验证:
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|宽带技术网 |网站地图 粤公网安备44152102000001号

GMT+8, 2025-5-2 10:16 , Processed in 0.022538 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5 Licensed

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表