C# WPF SDK连接Gocator加速器出现-999未定义错误求助
问题描述
开发的C# WPF SDK应用直连Gocator相机(IP:XXX.XXX.0.5)正常,但通过Gocator加速器(IP:XXX.XXX.0.145)连接时,抛出Lmi3d.Zen.KException: A Zen API error occurred (Error Not Found, -999)错误,错误触发在GoSystem.FindSensorByIpAddress方法处。已尝试使用相机/加速器IP连接、切换所有通信协议,均未解决,SDK版本为6.1.42.10,核心代码如下:
public static void Accelerated () { try { KApiLib.Construct(); GoSdkLib.Construct(); Variables.System = new GoSystem(); Variables.Accelerator = new GoAccelerator(); Variables.IpAddress = KIpAddress.Parse(Constants.SENSOR_IP); Variables.DataSet = new GoDataSet(); Variables.Accelerator.WebPort = Constants.WEB_PORT; Variables.Accelerator.Start(); Variables.Sensor = Variables.System.FindSensorByIpAddress(Variables.IpAddress); Variables.Accelerator.Attach(Variables.Sensor); Variables.Sensor.Connect(); Console.WriteLine("Camera connected with ACCELERATOR."); Variables.System.EnableData(true); Variables.System.Start(); // Refer to <<SetupMeasurement.cs>> for setting up of the measurement tools. Variables.DataSet = Variables.System.ReceiveData(30_000_000); } catch (Exception e) { Exception(e); } }
错误栈信息:
ERROR:
A problem has ocurred while attempting to establish a connection with the Gocator camera.
Error code: Lmi3d.Zen.KException: A Zen API error occurred (Error Not Found, -999).
en Lmi3d.Zen.Utils.Internal.KInternalUtils.Check(Int32 status)
en Lmi3d.GoSdk.GoSystem.FindSensorByIpAddress(KIpAddress address)
en Continental.Gocator.Accelerated() en D:\Projectes\4795_Continental\Programes\Continental\Continental\Gocator.cs:línea 73
Error message: A Zen API error occurred (Error Not Found, -999).
排查与解决思路
1. 修正加速器连接的代码逻辑顺序
当前代码先启动加速器再查找相机的流程不符合加速器工作机制,正确逻辑应先连接加速器,再通过加速器实例发现相机:
- 先初始化加速器并连接到加速器IP,而非直接查找相机IP
- 通过
Accelerator.FindSensorByIpAddress方法获取相机,而非GoSystem.FindSensorByIpAddress
修改后的核心逻辑示例:
// 替换原查找相机的代码段 Variables.Accelerator.IpAddress = KIpAddress.Parse(Constants.ACCELERATOR_IP); // 传入加速器IP Variables.Accelerator.WebPort = Constants.WEB_PORT; Variables.Accelerator.Connect(); // 先完成与加速器的连接 Variables.Accelerator.Start(); // 通过加速器实例查找并绑定相机 Variables.Sensor = Variables.Accelerator.FindSensorByIpAddress(Variables.IpAddress); // 相机IP Variables.Accelerator.Attach(Variables.Sensor); Variables.Sensor.Connect();
2. 验证加速器与相机的配对状态
- 登录加速器Web管理界面(XXX.XXX.0.145),检查已配对相机列表,确认目标相机(XXX.XXX.0.5)已被加速器识别并添加
- 若未配对,在Web界面手动完成相机与加速器的绑定,确保两者处于同一局域网,无防火墙或ACL规则限制通信
3. 检查SDK与固件版本兼容性
- 确认Gocator相机和加速器的固件版本与SDK版本(6.1.42.10)完全匹配,跨版本API调用易触发未定义错误
- 若固件版本过低,升级至SDK对应的推荐固件版本
4. 网络连通性与端口验证
- 使用
ping命令验证应用主机到加速器、加速器到相机的网络连通性 - 检查加速器的Web端口(默认80/443)、数据传输端口(默认8000等)是否在主机防火墙中开放
- 确认加速器的数据转发模式已开启,确保相机数据能通过加速器传输至应用主机
5. 调试API调用细节
- 在调用
FindSensorByIpAddress前添加加速器状态检查:if (!Variables.Accelerator.IsConnected) throw new Exception("加速器未建立连接") - 尝试使用
GoSystem.FindAllSensors()枚举所有设备,确认是否能通过加速器发现相机,排查IP解析异常问题
内容的提问来源于stack exchange,提问作者F A Fernández

