GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bitengine-hub-zigbee-ncp/nvm3_stats.py at main · bitEngineTech/bitengine-hub-zigbee-ncp

Expand file tree

/

nvm3_stats.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
33 lines (27 loc) · 1.9 KB
/

nvm3_stats.py

Copy path

File metadata and controls

33 lines (27 loc) · 1.9 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""XNCP 0x7002(只读 NVM3 统计)应答载荷的解码与判读 —— mg24/ncp_probe.py 用它打印 NVM3 那一行,
mg24/ncp/VERIFY.sh 拿 test_host/vectors.txt 的黄金字节核它(解码顺序错了会红)。
布局正本:mg24/ncp/bitengine_xncp.h 的 BE_NVM3_STATS_LEN 注释(15 字节,全小端)。
为什么要看:mg24/README.md「直连子设备 64:根因实测」。不依赖 bellows,主机上直接 import。
"""
import struct
FMT = "<HHHHBHHH"
FIELDS = ("live", "deleted", "cache_size", "cache_used", "overflow", "dom_user", "dom_zigbee", "dom_other")
UNKNOWN = 0xFFFF # 缓存溢出过时 NCP 不数(mg24/ncp/app.c),五个计数都回这个
HEADROOM_MIN = 64 # 余量低于一次布局变化(直连子设备 32 → 64 那种,64 个对象)就提醒
def decode(payload: bytes):
"""15 字节载荷 → dict;短了回 None。"""
if len(payload) < struct.calcsize(FMT):
return None
return dict(zip(FIELDS, struct.unpack_from(FMT, payload)))
def describe(d: dict) -> str:
"""一行人话。判据看余量,不只看溢出位:缓存满时新对象会悄悄挤掉已删除条目、不置溢出位,
下次开机重扫照样溢出、令牌初始化断言(SDK nvm3_cache.c / sl_token_manager.c)。"""
room = d["cache_size"] - d["cache_used"]
cache = f"cache={d['cache_used']}/{d['cache_size']}(余 {room})"
if d["overflow"]:
return f"NVM3: {cache} ⚠️ 溢出过 —— 计数没数(关中断扫 Flash 太贵);默认令牌管理器下次开机会断言"
line = (f"NVM3: live={d['live']}(令牌 {d['dom_zigbee']} · 用户域 {d['dom_user']} · 其余 {d['dom_other']})"
f" deleted={d['deleted']} {cache}")
if room < HEADROOM_MIN:
line += f" ⚠️ 余量 < {HEADROOM_MIN}:再动一次会进 NVM3 的表、或回滚到缓存更小的镜像,就可能开机即崩"
return line
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.