跳到主要内容

版本信息

提供原生库版本与 SDK 版本查询。可用于运行时兼容性校验和故障排查日志。

版本查询函数

get_dll_version()

def get_dll_version(dll) -> Optional[dict]

获取原生库版本信息。

返回值:

  • Optional[dict] — 版本信息字典 {'major', 'minor', 'build', 'version'},失败返回 None

get_api_version()

def get_api_version() -> str

获取 Python SDK API 版本字符串 (从包内 VERSION 文件读取)。当前版本为 2.7.x

get_build_number()

def get_build_number(dll) -> int

获取构建号,失败返回 -1

get_build_date()

def get_build_date(dll) -> str

获取构建日期,失败返回空字符串。

get_serial_number()

def get_serial_number(dll) -> str

获取设备序列号,失败返回空字符串。

主站属性

dll_version

@property
def dll_version(self) -> Optional[dict]

通过主站实例直接获取版本信息。

返回值:

  • Optional[dict]{'major', 'minor', 'patch', 'build', 'build_date'}

示例:

info = master.dll_version
if info:
print(f"版本: {info['major']}.{info['minor']}.{info['patch']}.{info['build']}")

完整示例

from darra_ethercat import EtherCATMaster, get_api_version

with EtherCATMaster() as master:
info = master.dll_version
print(f"SDK 版本: {get_api_version()}")
if info:
print(f"原生库版本: {info['major']}.{info['minor']}.{info['patch']}.{info['build']}")

授权状态 (License Status)

除了版本号,原生库还提供授权状态查询。授权状态是一个枚举 LicenseStatus(IntEnum)(状态返回枚举,不返回裸 int),共 7 个取值:

枚举值数值含义
NOT_ACTIVATED0未激活
VERIFYING1校验中
VERIFIED2已验证(有效
FAILED3失败
EXPIRED4已过期
MACHINE_MISMATCH5机器不匹配
TIME_ROLLBACK6时间异常
"有效"判据

有效授权的唯一判据 = 状态等于 VERIFIED (== 2)。其余取值都表示授权当前不可用,应按对应原因处理(重新激活 / 等待校验 / 续期 / 在原机运行)。

授权的激活与状态查询封装在 Authorization 类(Authorization.activate() / Authorization.license_status,返回 LicenseStatus 枚举)。版本信息(本页)与授权状态是两类独立信息:版本用于兼容性诊断,授权状态用于运行许可判断。