关于SMC JXC91通过Ethernet/IP获取LER50-K执行器名称的技术问询
针对SMC JXC91 + LER50-K执行器的Ethernet/IP通信,获取执行器名称的几个可行方向:
枚举厂商自定义对象:Ethernet/IP中厂商自定义对象的Class ID通常从
0x0064(十进制100)开始。用你的C#库调用ListIdentity服务枚举设备内所有对象类,过滤出非标准的厂商类,再通过GetInstanceList和GetAttributeList服务读取这些对象的属性,重点查找名称类属性(通常Attribute ID为1)。分析Assembly Object数据:尝试读取Assembly Object(Class ID
0x04)的实例数据,部分设备会将附属执行器的信息打包在Assembly实例中。可以枚举Assembly的所有实例,读取每个实例的属性或整个实例的数据,解析是否包含LER50-K的名称。抓包复刻厂商程序通信:用Wireshark抓取ACTC Controller与JXC91的Ethernet/IP通信包,定位程序获取执行器名称时发送的服务请求(比如
GetAttributeSingle、GetAttributeList或厂商自定义服务),记录对应的Class ID、Instance ID、Attribute ID,然后在C#代码中复刻该请求。检查Parameter Object:尝试访问Parameter Object(Class ID
0x0F),部分运动控制设备会将附属设备参数存储在此处,通过GetAttributeList或GetParameter服务读取相关参数条目。
代码示例(枚举厂商自定义对象)
// 假设client是已建立连接的Ethernet/IP客户端 var listIdentityReq = new ListIdentityRequest(); var listIdentityResp = await client.SendRequestAsync(listIdentityReq); foreach (var identity in listIdentityResp.Identities) { // 筛选厂商自定义对象类 if (identity.ClassId >= 0x0064) { Console.WriteLine($"检测到厂商自定义类: 0x{identity.ClassId:X4}"); // 获取该类的所有实例 var getInstanceListReq = new GetInstanceListRequest(identity.ClassId); var getInstanceListResp = await client.SendRequestAsync(getInstanceListReq); foreach (var instanceId in getInstanceListResp.InstanceIds) { // 读取实例的核心属性(1=名称,2=描述等) var getAttrListReq = new GetAttributeListRequest(identity.ClassId, instanceId, new uint[] { 1, 2 }); var getAttrListResp = await client.SendRequestAsync(getAttrListReq); foreach (var attr in getAttrListResp.Attributes) { if (attr.AttributeId == 1) { string actuatorName = Encoding.ASCII.GetString(attr.Data).Trim('\0'); Console.WriteLine($"找到执行器名称: {actuatorName}"); } } } } }
内容的提问来源于stack exchange,提问作者RosJes

