类 KernelGuard

java.lang.Object
com.darra.ethercat.master.KernelGuard

public final class KernelGuard extends Object
内核驱动可用性门控 (DarraRT_Eth.sys 探测 + 缺失引导).

对齐 C# DarraEtherCAT_Master.KernelGuard, 包装 Darra.Core.dll 的 3 个 native 探测 API. roundSDKSAN2.

推荐用法:

 try {
     KernelGuard.assertAvailable();
     master.initialize(); master.setNetwork(...);
 } catch (DarraKernelNotAvailableException e) {
     System.err.println(e.getMessage());
     KernelGuard.openInstallerWebsite();  // 可选, 一键打开浏览器
     System.exit(1);
 }
 

不抛异常的轻量探测: probe().

  • 方法详细资料

    • probe

      public static DarraKernelStatus probe()
      探测当前内核驱动状态. 不抛异常.

      DLL 加载失败 / 符号缺失统一返回 DarraKernelStatus.UnknownError.

    • getStatusMessage

      public static String getStatusMessage(DarraKernelStatus status)
      把状态码转成可读消息 (从 DLL 拿). DLL 不可用时回退到 "EtherCAT 内核驱动状态未知".
    • getInstallerUrl

      public static String getInstallerUrl()
      获取安装包下载链接.

      默认 https://www.darrart.com/downloads/drivers, 部署可通过环境变量 DARRA_INSTALLER_URL 覆盖 (由 native 端读取).

    • assertAvailable

      public static void assertAvailable() throws DarraKernelNotAvailableException
      探测内核状态; 若不可用直接抛 DarraKernelNotAvailableException.

      应用层应在 Initialize/SetNetwork 之前调用; SDK 内部门控也会再调一次防御.

      抛出:
      DarraKernelNotAvailableException - 状态不为 DarraKernelStatus.Ok
    • openInstallerWebsite

      public static boolean openInstallerWebsite()
      用默认浏览器打开安装链接.

      应用层在 catch DarraKernelNotAvailableException 后可调用此方法引导用户下载. 失败不抛异常 (浏览器缺失 / 无 GUI 环境 / Headless 等问题不应再次中断流程).

      返回:
      true 浏览器调起成功; false 失败 (无 Desktop 支持 / URL 非法 / 异常)