epan/dissectors/pidl/ C99 drsuapi
[wireshark-sm.git] / epan / dissectors / packet-sercosiii.c
blobdc37a4594017d2631099fc373fecf3ac3985830f
1 /* packet-sercosiii.c
2 * Routines for SERCOS III dissection
4 * Initial plugin code by,
5 * Bosch Rexroth
6 * Hilscher
8 * Hans-Peter Bock <hpbock@avaapgh.de>
10 * Convert to built-in dissector
11 * Michael Mann * Copyright 2011
13 * Wireshark - Network traffic analyzer
14 * By Gerald Combs <gerald@wireshark.org>
15 * Copyright 1998 Gerald Combs
17 * SPDX-License-Identifier: GPL-2.0-or-later
20 #include "config.h"
22 #include <epan/packet.h>
23 #include <epan/expert.h>
24 #include <epan/etypes.h>
25 #include <epan/tfs.h>
26 #include <wsutil/array.h>
28 #define MAX_SERCOS_DEVICES (512)
29 #define MAX_SERCOS_ADDRESS (511)
30 #define SERCOS_SLAVE_GROUP_SIZE (128)
32 #define COMMUNICATION_PHASE_0 (0x0)
33 #define COMMUNICATION_PHASE_1 (0x1)
34 #define COMMUNICATION_PHASE_2 (0x2)
35 #define COMMUNICATION_PHASE_3 (0x3)
36 #define COMMUNICATION_PHASE_4 (0x4)
38 void proto_register_sercosiii(void);
39 void proto_reg_handoff_sercosiii(void);
41 static dissector_handle_t siii_handle;
43 /* Initialize the protocol and registered fields */
44 static int proto_siii;
46 /* Initialize the subtree pointers */
47 static int ett_siii;
48 static int ett_siii_header;
49 static int ett_siii_mst;
50 static int ett_siii_mst_teltype;
51 static int ett_siii_mst_phase;
52 static int ett_siii_mdt;
53 static int ett_siii_mdt_svc;
54 static int ett_siii_mdt_devctrls;
55 static int ett_siii_mdt_version;
56 static int ett_siii_mdt_svc_channel;
57 static int ett_siii_mdt_dev_control;
58 static int ett_siii_mdt_devctrl;
59 static int ett_siii_mdt_svcctrl;
60 static int ett_siii_mdt_svcinfo;
61 static int ett_siii_at_svcstat;
62 static int ett_siii_at_svcinfo;
63 static int ett_siii_mdt_svch_data_error_info;
64 static int ett_siii_mdt_svch_data;
65 static int ett_siii_at_devstatus;
66 static int ett_siii_at_sercosaddress;
67 static int ett_siii_at;
68 static int ett_siii_at_svc;
69 static int ett_siii_at_sercos_address;
70 static int ett_siii_at_devstats;
71 static int ett_siii_at_svc_channel;
72 static int ett_siii_at_dev_status;
73 static int ett_siii_mdt_hp;
74 static int ett_siii_at_hp;
75 static int ett_siii_mdt_hp_ctrl;
76 static int ett_siii_mdt_hp_info;
77 static int ett_siii_at_hp_stat;
78 static int ett_siii_at_hp_info;
79 static int ett_siii_recognized_devices;
81 static int hf_siii_mdt_version;
82 static int hf_siii_mdt_version_initprocvers;
83 static int hf_siii_mdt_version_num_mdt_at_cp1_2;
84 static int hf_siii_mdt_version_switch_off_sercos_telegrams;
85 static int hf_siii_mdt_version_fast_cp_switch;
86 static int hf_siii_mdt_version_transmission_of_communication_parameters_mdt0_cp0;
87 static int hf_siii_mdt_dev_control_top_control;
88 static int hf_siii_at_dev_control_ident;
89 static int hf_siii_mdt_dev_control_change_topology;
90 static int hf_siii_mdt_dev_control;
91 static int hf_siii_mst_channel;
92 static int hf_siii_mst_type;
93 static int hf_siii_mst_cyclecntvalid;
94 static int hf_siii_mst_telno;
95 static int hf_siii_mst_phase;
96 static int hf_siii_mst_cyclecnt;
97 static int hf_siii_mst_crc32;
98 static int hf_siii_mdt_svch_dbe;
99 static int hf_siii_mdt_svch_eot;
100 static int hf_siii_mdt_svch_rw;
101 static int hf_siii_mdt_svch_mhs;
102 static int hf_siii_mdt_svch_info;
103 static int hf_siii_at_svch_valid;
104 static int hf_siii_at_svch_error;
105 static int hf_siii_at_svch_busy;
106 static int hf_siii_at_svch_ahs;
107 static int hf_siii_at_svch_info;
108 static int hf_siii_mdt_svch_idn;
109 static int hf_siii_mdt_svch_ctrl;
110 static int hf_siii_at_svch_stat;
111 /* static int hf_siii_svch_data_telofs_telno; */
112 /* static int hf_siii_svch_data_telofs_mdt_at; */
113 /* static int hf_siii_svch_data_telofs_offset; */
114 /* static int hf_siii_svch_data_proccmd_proccmdexec; */
115 /* static int hf_siii_svch_data_proccmd_proccmd; */
116 static int hf_siii_at_cp0_support_functions;
117 static int hf_siii_at_cp0_device_address;
118 static int hf_siii_at_dev_status;
119 static int hf_siii_at_dev_status_commwarning;
120 static int hf_siii_at_dev_status_change_topology;
121 static int hf_siii_at_dev_status_top_status;
122 static int hf_siii_at_dev_status_inactive_port_status;
123 static int hf_siii_at_dev_status_errorconnection;
124 static int hf_siii_at_dev_status_slave_valid;
125 static int hf_siii_at_dev_status_proc_command_change;
126 static int hf_siii_at_dev_status_parameterization_level_active;
127 static int hf_siii_mdt_hotplug_address;
128 static int hf_siii_mdt_hp_ctrl;
129 static int hf_siii_mdt_hp_info;
130 static int hf_siii_at_hotplug_address;
131 static int hf_siii_at_hp_stat;
132 static int hf_siii_at_hp_info;
133 static int hf_siii_mdt_hotplug_control_param;
134 static int hf_siii_mdt_hotplug_control_svc_switch;
135 static int hf_siii_at_hotplug_status_param;
136 static int hf_siii_at_hotplug_status_hp0_finished;
137 static int hf_siii_at_hotplug_status_error;
138 static int hf_siii_service_channels;
139 static int hf_siii_device_controls;
140 static int hf_siii_device_status;
141 static int hf_siii_idn_code;
142 static int hf_siii_at_cp0_num_devices;
143 static int hf_siii_at_cp0_sercos_address;
145 static expert_field ei_siii_cp_unknown;
148 /* Allow heuristic dissection */
149 static heur_dissector_list_t heur_subdissector_list;
151 static const value_string siii_mdt_version_num_mdtat_cp1_2_text[]=
153 {0x00, "2 MDTs/ATs in CP1/2"},
154 {0x01, "4 MDTs/ATs in CP1/2"},
155 {0, NULL}
158 static const true_false_string siii_mdt_version_fast_cp_switch_text = {
159 "Transmission of MST (MDT0) interrupted during CP switch for CPS delay time (120ms)",
160 "CPS delay time reduce to the re-configuration time of the master"
164 static const true_false_string siii_switch_off_sercos_telegram_text = {
165 "Industrial Ethernet devices not used by application",
166 "Industrial Ethernet devices used by application"
169 static const true_false_string siii_mdt_version_initprocvers_text = {
170 "No remote address allocation",
171 "Remote address allocation"
174 #if 0
175 static const value_string siii_svch_data_proccmd_proccmdexec_text[]=
177 {0, "Interrupt procedure command execution"},
178 {1, "Enable procedure command execution"},
179 {0, NULL}
182 static const value_string siii_svch_data_proccmd_proccmd_text[]=
184 {0, "Cancel procedure command"},
185 {1, "Set procedure command"},
186 {0, NULL}
189 static const value_string siii_svch_data_mdt_at_text[]=
191 {0, "AT-telegram"},
192 {1, "MDT-telegram"},
193 {0, NULL}
195 #endif
197 #define IDN(SI, SE, type, paramset, datablock) ((SI<<24)|(SE<<16)|(type<<15)|(paramset<<12)|(datablock))
199 static const value_string siii_mdt_idn_text[]=
201 {IDN(0,0,0,0, 0), "Dummy-Parameter"},
202 {IDN(0,0,0,0, 1), "Control unit cycle time (tNcyc)"},
203 {IDN(0,0,0,0, 2), "Communication cycle time (tScyc)"},
204 {IDN(0,0,0,0, 11), "Class 1 diagnostic"},
205 {IDN(0,0,0,0, 12), "Class 2 diagnostic"},
206 {IDN(0,0,0,0, 14), "Interface status"},
207 {IDN(0,0,0,0, 15), "Telegram Type"},
208 {IDN(0,0,0,0, 16), "Configuration list of AT"},
209 {IDN(0,0,0,0, 17), "IDN-list of all operation data"},
210 {IDN(0,0,0,0, 18), "IDN-list of operation data for CP2"},
211 {IDN(0,0,0,0, 19), "IDN-list of operation data for CP3"},
212 {IDN(0,0,0,0, 21), "IDN-list of invalid operation data for CP2"},
213 {IDN(0,0,0,0, 22), "IDN-list of invalid operation data for CP3"},
214 {IDN(0,0,0,0, 24), "Configuration list of MDT"},
215 {IDN(0,0,0,0, 25), "IDN-list of all procedure commands"},
216 {IDN(0,0,0,0, 26), "Configuration list for signal status word"},
217 {IDN(0,0,0,0, 27), "Configuration list for signal control word"},
218 {IDN(0,0,0,0, 28), "MST error counter"},
219 {IDN(0,0,0,0, 29), "MDT error counter"},
220 {IDN(0,0,0,0, 32), "Primary operation mode"},
221 {IDN(0,0,0,0, 36), "Velocity command value"},
222 {IDN(0,0,0,0, 37), "Additive velocity command value"},
223 {IDN(0,0,0,0, 38), "Positive velocity limit value"},
224 {IDN(0,0,0,0, 39), "Negative velocity limit value"},
225 {IDN(0,0,0,0, 40), "Velocity feedback value 1"},
226 {IDN(0,0,0,0, 41), "Homing velocity"},
227 {IDN(0,0,0,0, 42), "Homing acceleration"},
228 {IDN(0,0,0,0, 43), "Velocity polarity parameter"},
229 {IDN(0,0,0,0, 44), "Velocity data scaling type"},
230 {IDN(0,0,0,0, 45), "Velocity data scaling factor"},
231 {IDN(0,0,0,0, 46), "Velocity data scaling exponent"},
232 {IDN(0,0,0,0, 47), "Position command value"},
233 {IDN(0,0,0,0, 48), "Additive position command value"},
234 {IDN(0,0,0,0, 49), "Positive position limit value"},
235 {IDN(0,0,0,0, 50), "Negative position limit value"},
236 {IDN(0,0,0,0, 51), "Position feedback value 1 (motor feedback)"},
237 {IDN(0,0,0,0, 52), "Reference distance 1"},
238 {IDN(0,0,0,0, 53), "Position feedback value 2 (external feedback)"},
239 {IDN(0,0,0,0, 54), "Reference distance 2"},
240 {IDN(0,0,0,0, 55), "Position polarity parameter"},
241 {IDN(0,0,0,0, 57), "Position window"},
242 {IDN(0,0,0,0, 58), "Reversal clearance"},
243 {IDN(0,0,0,0, 59), "Position switch flag parameter"},
244 {IDN(0,0,0,0, 60), "Position switches (position switch points on 1-16)"},
245 {IDN(0,0,0,0, 76), "Position data scaling type"},
246 {IDN(0,0,0,0, 77), "Linear position data scaling factor"},
247 {IDN(0,0,0,0, 78), "Linear position data scaling exponent"},
248 {IDN(0,0,0,0, 79), "Rotational position resolution"},
249 {IDN(0,0,0,0, 80), "Torque command value"},
250 {IDN(0,0,0,0, 81), "Additive torque command value"},
251 {IDN(0,0,0,0, 82), "Positive torque limit value"},
252 {IDN(0,0,0,0, 83), "Negative torque limit value"},
253 {IDN(0,0,0,0, 84), "Torque feedback value"},
254 {IDN(0,0,0,0, 85), "Torque polarity parameter"},
255 {IDN(0,0,0,0, 86), "Torque/force data scaling type"},
256 {IDN(0,0,0,0, 91), "Bipolar velocity limit value"},
257 {IDN(0,0,0,0, 92), "Bipolar torque limit value"},
258 {IDN(0,0,0,0, 93), "Torque/force scaling data factor"},
259 {IDN(0,0,0,0, 94), "Torque/force scaling data exponent"},
260 {IDN(0,0,0,0, 95), "Diagnostic message"},
261 {IDN(0,0,0,0, 96), "Slave arrangement (SLKN)"},
262 {IDN(0,0,0,0, 97), "Mask class 2 diagnostic"},
263 {IDN(0,0,0,0, 98), "Mask class 3 diagnostic"},
264 {IDN(0,0,0,0, 99), "Reset class 1 diagnostic"},
265 {IDN(0,0,0,0, 100), "Velocity loop proportional gain"},
266 {IDN(0,0,0,0, 101), "Velocity loop integral action time"},
267 {IDN(0,0,0,0, 102), "Velocity loop differential time"},
268 {IDN(0,0,0,0, 103), "Modulo value"},
269 {IDN(0,0,0,0, 104), "Position loop KV-factor"},
270 {IDN(0,0,0,0, 105), "Position loop integral action time"},
271 {IDN(0,0,0,0, 106), "Current loop proportional gain 1"},
272 {IDN(0,0,0,0, 107), "Current loop integral action time 1"},
273 {IDN(0,0,0,0, 108), "Feedrate override"},
274 {IDN(0,0,0,0, 109), "Motor peak current"},
275 {IDN(0,0,0,0, 110), "Amplifier peak current"},
276 {IDN(0,0,0,0, 111), "Motor continuous stall current"},
277 {IDN(0,0,0,0, 112), "Amplifier rated current"},
278 {IDN(0,0,0,0, 113), "Maximum motor speed"},
279 {IDN(0,0,0,0, 114), "Load limit of the motor"},
280 {IDN(0,0,0,0, 115), "Position feedback 2 type"},
281 {IDN(0,0,0,0, 116), "Resolution of feedback 1"},
282 {IDN(0,0,0,0, 117), "Resolution of feedback 2"},
283 {IDN(0,0,0,0, 118), "Resolution of linear feedback"},
284 {IDN(0,0,0,0, 119), "Current loop proportional gain 2"},
285 {IDN(0,0,0,0, 120), "Current loop integral action time 2"},
286 {IDN(0,0,0,0, 121), "Input revolutions of load gear"},
287 {IDN(0,0,0,0, 122), "Output revolutions of load gear"},
288 {IDN(0,0,0,0, 123), "Feed constant"},
289 {IDN(0,0,0,0, 124), "Standstill window"},
290 {IDN(0,0,0,0, 125), "Velocity threshold (nx)"},
291 {IDN(0,0,0,0, 126), "Torque threshold (Tx)"},
292 {IDN(0,0,0,0, 127), "CP3 transition check"},
293 {IDN(0,0,0,0, 128), "CP4 transition check"},
294 {IDN(0,0,0,0, 129), "Manufacturer class 1 diagnostic"},
295 {IDN(0,0,0,0, 130), "Probe value 1 positive edge"},
296 {IDN(0,0,0,0, 131), "Probe value 1 negative edge"},
297 {IDN(0,0,0,0, 132), "Probe value 2 positive edge"},
298 {IDN(0,0,0,0, 133), "Probe value 2 negative edge"},
299 {IDN(0,0,0,0, 134), "Drive control"},
300 {IDN(0,0,0,0, 135), "Drive status"},
301 {IDN(0,0,0,0, 136), "Positive acceleration limit value"},
302 {IDN(0,0,0,0, 137), "Negative acceleration limit value"},
303 {IDN(0,0,0,0, 138), "Bipolar acceleration limit value"},
304 {IDN(0,0,0,0, 139), "Park axis procedure command"},
305 {IDN(0,0,0,0, 143), "SERCOS Interface version"},
306 {IDN(0,0,0,0, 144), "Signal status word"},
307 {IDN(0,0,0,0, 145), "Signal control word"},
308 {IDN(0,0,0,0, 146), "Control unit controlled homing procedure command"},
309 {IDN(0,0,0,0, 147), "Homing parameter"},
310 {IDN(0,0,0,0, 148), "Drive controlled homing procedure command"},
311 {IDN(0,0,0,0, 149), "Position drive stop procedure command"},
312 {IDN(0,0,0,0, 150), "Reference offset 1"},
313 {IDN(0,0,0,0, 151), "Reference offset 2"},
314 {IDN(0,0,0,0, 152), "Position spindle procedure command"},
315 {IDN(0,0,0,0, 153), "Spindle angle position"},
316 {IDN(0,0,0,0, 154), "Spindle positioning parameter"},
317 {IDN(0,0,0,0, 155), "Friction torque compensation"},
318 {IDN(0,0,0,0, 156), "Velocity feedback value 2"},
319 {IDN(0,0,0,0, 157), "Velocity window"},
320 {IDN(0,0,0,0, 158), "Power threshold (Px)"},
321 {IDN(0,0,0,0, 159), "Monitoring window"},
322 {IDN(0,0,0,0, 161), "Acceleration data scaling factor"},
323 {IDN(0,0,0,0, 162), "Acceleration data scaling exponent"},
324 {IDN(0,0,0,0, 163), "Weight counterbalance"},
325 {IDN(0,0,0,0, 164), "Acceleration feedback value 1"},
326 {IDN(0,0,0,0, 165), "Distance-coded reference marks A"},
327 {IDN(0,0,0,0, 166), "Distance-coded reference marks B"},
328 {IDN(0,0,0,0, 167), "Frequency limit of feedback 1"},
329 {IDN(0,0,0,0, 169), "Probe control"},
330 {IDN(0,0,0,0, 170), "Probing cycle procedure command"},
331 {IDN(0,0,0,0, 171), "Calculate displacement procedure command"},
332 {IDN(0,0,0,0, 172), "Displacement to the referenced system procedure command"},
333 {IDN(0,0,0,0, 173), "Marker position A"},
334 {IDN(0,0,0,0, 174), "Marker position B"},
335 {IDN(0,0,0,0, 175), "Displacement parameter 1"},
336 {IDN(0,0,0,0, 176), "Displacement parameter 2"},
337 {IDN(0,0,0,0, 177), "Absolute distance 1"},
338 {IDN(0,0,0,0, 178), "Absolute distance 2"},
339 {IDN(0,0,0,0, 179), "Probe status"},
340 {IDN(0,0,0,0, 180), "Spindle relative offset"},
341 {IDN(0,0,0,0, 181), "Manufacturer class 2 diagnostic"},
342 {IDN(0,0,0,0, 183), "Synchronization velocity window"},
343 {IDN(0,0,0,0, 184), "Synchronization velocity error limit"},
344 {IDN(0,0,0,0, 185), "Length of the configurable data record in the AT"},
345 {IDN(0,0,0,0, 186), "Length of the configurable data record in the MDT"},
346 {IDN(0,0,0,0, 187), "IDN list of configurable data in the AT"},
347 {IDN(0,0,0,0, 188), "IDN list of configurable data in the MDT"},
348 {IDN(0,0,0,0, 189), "Following distance"},
349 {IDN(0,0,0,0, 190), "Drive controlled gear engaging procedure command"},
350 {IDN(0,0,0,0, 191), "Cancel reference point procedure command"},
351 {IDN(0,0,0,0, 192), "IDN-list of all backup operation data"},
352 {IDN(0,0,0,0, 193), "Positioning jerk"},
353 {IDN(0,0,0,0, 194), "Acceleration command time"},
354 {IDN(0,0,0,0, 195), "Acceleration feedback value 2"},
355 {IDN(0,0,0,0, 196), "Motor rated current"},
356 {IDN(0,0,0,0, 197), "Set coordinate system procedure command"},
357 {IDN(0,0,0,0, 198), "Initial coordinate value"},
358 {IDN(0,0,0,0, 199), "Shift coordinate system procedure command"},
359 {IDN(0,0,0,0, 200), "Amplifier warning temperature"},
360 {IDN(0,0,0,0, 201), "Motor warning temperature"},
361 {IDN(0,0,0,0, 202), "Cooling error warning temperature"},
362 {IDN(0,0,0,0, 203), "Amplifier shut-down temperature"},
363 {IDN(0,0,0,0, 204), "Motor shut-down temperature"},
364 {IDN(0,0,0,0, 205), "Cooling error shut-down temperature"},
365 {IDN(0,0,0,0, 206), "Drive on delay time"},
366 {IDN(0,0,0,0, 207), "Drive off delay time"},
367 {IDN(0,0,0,0, 208), "Temperature data scaling type"},
368 {IDN(0,0,0,0, 209), "Lower adaptation limit"},
369 {IDN(0,0,0,0, 210), "Upper adaptation limit"},
370 {IDN(0,0,0,0, 211), "Adaptation proportional gain"},
371 {IDN(0,0,0,0, 212), "Adaptation integral action time"},
372 {IDN(0,0,0,0, 213), "Engaging dither amplitude"},
373 {IDN(0,0,0,0, 214), "Average engaging speed"},
374 {IDN(0,0,0,0, 215), "Engaging dither period"},
375 {IDN(0,0,0,0, 216), "Switch parameter set procedure command"},
376 {IDN(0,0,0,0, 217), "Parameter set preselection"},
377 {IDN(0,0,0,0, 218), "Gear-ration preselection"},
378 {IDN(0,0,0,0, 219), "IDN-list of parameter set"},
379 {IDN(0,0,0,0, 220), "Minimum spindle speed"},
380 {IDN(0,0,0,0, 221), "Maximum spindle speed"},
381 {IDN(0,0,0,0, 222), "Spindle positioning speed"},
382 {IDN(0,0,0,0, 223), "Drive controlled synchronous operation procedure command"},
383 {IDN(0,0,0,0, 224), "Lead Spindle Address"},
384 {IDN(0,0,0,0, 225), "Synchronous spindle revolutions"},
385 {IDN(0,0,0,0, 226), "Lead spindle revolutions"},
386 {IDN(0,0,0,0, 227), "Synchronous spindle revolutions"},
387 {IDN(0,0,0,0, 228), "Synchronization position window"},
388 {IDN(0,0,0,0, 229), "Synchronization position error limit"},
389 {IDN(0,0,0,0, 230), "Synchronization position offset"},
390 {IDN(0,0,0,0, 254), "Actual parameter set"},
391 {IDN(0,0,0,0, 255), "Actual gear ration"},
392 {IDN(0,0,0,0, 256), "Multiplication factor 1"},
393 {IDN(0,0,0,0, 257), "Multiplication factor 2"},
394 {IDN(0,0,0,0, 258), "Target position"},
395 {IDN(0,0,0,0, 259), "Positioning velocity"},
396 {IDN(0,0,0,0, 260), "Positioning acceleration"},
397 {IDN(0,0,0,0, 261), "Coarse position window"},
398 {IDN(0,0,0,0, 262), "Load defaults procedure command"},
399 {IDN(0,0,0,0, 263), "Load working memory procedure command"},
400 {IDN(0,0,0,0, 264), "Backup working memory procedure command"},
401 {IDN(0,0,0,0, 265), "Language selection"},
402 {IDN(0,0,0,0, 266), "List of available languages"},
403 {IDN(0,0,0,0, 267), "Password"},
404 {IDN(0,0,0,0, 268), "Angular setting"},
405 {IDN(0,0,0,0, 269), "Storage mode"},
406 {IDN(0,0,0,0, 270), "IDN-list of selected backup operation data"},
407 {IDN(0,0,0,0, 272), "Velocity window percentage"},
408 {IDN(0,0,0,0, 273), "Maximum drive off delay time"},
409 {IDN(0,0,0,0, 275), "Coordinate offset value"},
410 {IDN(0,0,0,0, 276), "Return to Modulo range procedure command"},
411 {IDN(0,0,0,0, 277), "Position feedback 1 type"},
412 {IDN(0,0,0,0, 278), "Maximum travel range"},
413 {IDN(0,0,0,0, 279), "IDN list of password protected data"},
414 {IDN(0,0,0,0, 280), "Underflow threshold"},
415 {IDN(0,0,0,0, 282), "Positioning command value"},
416 {IDN(0,0,0,0, 283), "Current coordinate offset"},
417 {IDN(0,0,0,0, 292), "List of supported operation modes"},
418 {IDN(0,0,0,0, 293), "Selectively backup working memory procedure command"},
419 {IDN(0,0,0,0, 294), "Divider modulo value"},
420 {IDN(0,0,0,0, 295), "Drive enable delay time"},
421 {IDN(0,0,0,0, 296), "Velocity feed forward gain"},
422 {IDN(0,0,0,0, 297), "Homing distance"},
423 {IDN(0,0,0,0, 298), "Suggest home switch distance"},
424 {IDN(0,0,0,0, 299), "Home switch offset 1"},
425 {IDN(0,0,0,0, 300), "Real-time control bit 1"},
426 {IDN(0,0,0,0, 301), "Allocation of real-time control bit 1",},
427 {IDN(0,0,0,0, 302), "Real-time control bit 2"},
428 {IDN(0,0,0,0, 303), "Allocation of real-time control bit 2"},
429 {IDN(0,0,0,0, 304), "Real-time status bit 1"},
430 {IDN(0,0,0,0, 305), "Allocation of real-time status bit 1"},
431 {IDN(0,0,0,0, 306), "Real-time status-bit 2"},
432 {IDN(0,0,0,0, 307), "Allocation of real-time status bit 2"},
433 {IDN(0,0,0,0, 308), "Synchronization operation status"},
434 {IDN(0,0,0,0, 309), "Synchronization error status"},
435 {IDN(0,0,0,0, 310), "Overload warning"},
436 {IDN(0,0,0,0, 311), "Amplifier overtemperature warning"},
437 {IDN(0,0,0,0, 312), "Motor overtemperature warning"},
438 {IDN(0,0,0,0, 313), "Cooling error warning"},
439 {IDN(0,0,0,0, 315), "Positioning velocity higher than n Limit"},
440 {IDN(0,0,0,0, 323), "Target position outside of travel range"},
441 {IDN(0,0,0,0, 326), "Parameter checksum"},
442 {IDN(0,0,0,0, 327), "IDN list of checksum parameter"},
443 {IDN(0,0,0,0, 328), "Bit number allocation list for signal status word"},
444 {IDN(0,0,0,0, 329), "Bit number allocation list for signal control word"},
445 {IDN(0,0,0,0, 330), "Status 'nfeedback = ncommand'"},
446 {IDN(0,0,0,0, 331), "Status 'nfeedback = 0'"},
447 {IDN(0,0,0,0, 332), "Status 'nfeedback less then nx'"},
448 {IDN(0,0,0,0, 333), "Status 'T higher than Tx'"},
449 {IDN(0,0,0,0, 334), "Status 'T greater than Tlimit '"},
450 {IDN(0,0,0,0, 335), "Status 'ncommand greater than nlimit'"},
451 {IDN(0,0,0,0, 336), "Status 'In position'"},
452 {IDN(0,0,0,0, 337), "Status 'P greater Px'"},
453 {IDN(0,0,0,0, 338), "Status 'Position feedback = active target position'"},
454 {IDN(0,0,0,0, 339), "Status 'nfeedback less than minimum spindle speed'"},
455 {IDN(0,0,0,0, 340), "Status 'nfeedback exceeds maximum spindle speed'"},
456 {IDN(0,0,0,0, 341), "Status 'In Coarse position'"},
457 {IDN(0,0,0,0, 342), "Status 'Target position attained'"},
458 {IDN(0,0,0,0, 343), "Status 'Interpolator halted'"},
459 {IDN(0,0,0,0, 346), "Positioning control"},
460 {IDN(0,0,0,0, 347), "Velocity error"},
461 {IDN(0,0,0,0, 348), "Acceleration feed forward gain"},
462 {IDN(0,0,0,0, 349), "Bipolar jerk limit"},
463 {IDN(0,0,0,0, 356), "Distance home switch - marker puls"},
464 {IDN(0,0,0,0, 357), "Marker pulse distance"},
465 {IDN(0,0,0,0, 358), "Home switch offset 2"},
466 {IDN(0,0,0,0, 359), "Positioning deceleration"},
467 {IDN(0,0,0,0, 360), "MDT data container"},
468 {IDN(0,0,0,0, 362), "MDT data container A list index"},
469 {IDN(0,0,0,0, 364), "AT data container A1"},
470 {IDN(0,0,0,0, 366), "AT data container A list index"},
471 {IDN(0,0,0,0, 368), "Data container A pointer"},
472 {IDN(0,0,0,0, 370), "MDT data container A/B configuration list"},
473 {IDN(0,0,0,0, 371), "AT data container A/B configuration list"},
474 {IDN(0,0,0,0, 372), "Drive Halt acceleration bipolar"},
475 {IDN(0,0,0,0, 377), "Velocity feedback monitoring window"},
476 {IDN(0,0,0,0, 378), "Absolute encoder range 1"},
477 {IDN(0,0,0,0, 379), "Absolute encoder range 2"},
478 {IDN(0,0,0,0, 380), "DC bus voltage"},
479 {IDN(0,0,0,0, 381), "DC bus current"},
480 {IDN(0,0,0,0, 382), "DC bus power"},
481 {IDN(0,0,0,0, 383), "Motor temperature"},
482 {IDN(0,0,0,0, 384), "Amplifier temperature"},
483 {IDN(0,0,0,0, 385), "Active power"},
484 {IDN(0,0,0,0, 386), "Active position feedback value"},
485 {IDN(0,0,0,0, 387), "Power overload"},
486 {IDN(0,0,0,0, 388), "Braking current limit"},
487 {IDN(0,0,0,0, 389), "Effective current"},
488 {IDN(0,0,0,0, 390), "DiagnosticNumber"},
489 {IDN(0,0,0,0, 391), "Position feedback monitoring window"},
490 {IDN(0,0,0,0, 392), "Velocity feedback filter"},
491 {IDN(0,0,0,0, 393), "Command value mode"},
492 {IDN(0,0,0,0, 398), "IDN list of configurable real-time/status bits"},
493 {IDN(0,0,0,0, 399), "IDN list of configurable real-time/control bits"},
494 {IDN(0,0,0,0, 400), "Home switch"},
495 {IDN(0,0,0,0, 401), "Probe 1"},
496 {IDN(0,0,0,0, 402), "Probe 2"},
497 {IDN(0,0,0,0, 403), "Position feedback value status"},
498 {IDN(0,0,0,0, 404), "Position command value status"},
499 {IDN(0,0,0,0, 405), "Probe 1 enable"},
500 {IDN(0,0,0,0, 406), "Probe 2 enable"},
501 {IDN(0,0,0,0, 407), "Homing enable"},
502 {IDN(0,0,0,0, 408), "Reference marker pulse registered"},
503 {IDN(0,0,0,0, 409), "Probe 1 positive latched"},
504 {IDN(0,0,0,0, 410), "Probe 1 negative latched"},
505 {IDN(0,0,0,0, 411), "Probe 2 positive latched"},
506 {IDN(0,0,0,0, 412), "Probe 2 negative latched"},
507 {IDN(0,0,0,0, 413), "Bit number allocation of real-time control bit 1"},
508 {IDN(0,0,0,0, 414), "Bit number allocation of real-time control bit 2"},
509 {IDN(0,0,0,0, 415), "Bit number allocation of real-time status bit 1"},
510 {IDN(0,0,0,0, 416), "Bit number allocation of real-time status bit 2"},
511 {IDN(0,0,0,0, 417), "Positioning velocity threshold in modulo mode"},
512 {IDN(0,0,0,0, 418), "Target position window in modulo mode"},
513 {IDN(0,0,0,0, 419), "Positioning acknowledge"},
514 {IDN(0,0,0,0, 420), "Activate parameterization level procedure command (PL)"},
515 {IDN(0,0,0,0, 422), "Exit parameterization level procedure command"},
516 {IDN(0,0,0,0, 423), "IDN-list of invalid data for parameterization level"},
517 {IDN(0,0,0,0, 426), "Measuring data allocation 1"},
518 {IDN(0,0,0,0, 427), "Measuring data allocation 2"},
519 {IDN(0,0,0,0, 428), "IDN list of configurable measuring data"},
520 {IDN(0,0,0,0, 429), "Emergency stop deceleration"},
521 {IDN(0,0,0,0, 430), "Active target position"},
522 {IDN(0,0,0,0, 431), "Spindle positioning acceleration bipolar"},
523 {IDN(0,0,0,0, 437), "Positioning status"},
524 {IDN(0,0,0,0, 446), "Ramp reference velocity"},
525 {IDN(0,0,0,0, 447), "Set absolute position procedure command"},
526 {IDN(0,0,0,0, 448), "Set absolute position control word"},
527 {IDN(0,0,0,0, 460), "Position switches (position switch points off 1-16)"},
528 {IDN(0,0,0,0, 476), "Position switch control"},
529 {IDN(0,0,0,0, 477), "Position switch hysteresis"},
530 {IDN(0,0,0,0, 478), "Limit switch status"},
531 {IDN(0,0,0,0, 509), "Extended probe control"},
532 {IDN(0,0,0,0, 510), "Difference value probe 1"},
533 {IDN(0,0,0,0, 511), "Difference value probe 2"},
534 {IDN(0,0,0,0, 512), "Start position probing window 1"},
535 {IDN(0,0,0,0, 513), "End position probing window 1"},
536 {IDN(0,0,0,0, 514), "Start position probing window 2"},
537 {IDN(0,0,0,0, 515), "End position probing window 2"},
538 {IDN(0,0,0,0, 516), "Marker losses probe 1"},
539 {IDN(0,0,0,0, 517), "Marker losses probe 2"},
540 {IDN(0,0,0,0, 518), "Maximum marker losses probe 1"},
541 {IDN(0,0,0,0, 519), "Maximum marker losses probe 2"},
542 {IDN(0,0,0,0, 520), "Axis control word"},
543 {IDN(0,0,0,0, 521), "Axis status word"},
544 {IDN(0,0,0,0, 522), "Difference value 1 latched"},
545 {IDN(0,0,0,0, 523), "Difference value 2 latched"},
546 {IDN(0,0,0,0, 524), "Probe 1 delay positive"},
547 {IDN(0,0,0,0, 525), "Delay Negative Edge, Probe 1"},
548 {IDN(0,0,0,0, 526), "Delay positive Edge, Probe 2"},
549 {IDN(0,0,0,0, 527), "Delay Negative Edge, Probe 2"},
550 {IDN(0,0,0,0, 530), "Clamping torque"},
551 {IDN(0,0,0,0, 531), "Checksum for backup operation data"},
552 {IDN(0,0,0,0, 532), "Limit switch control"},
553 {IDN(0,0,0,0, 533), "Motor continuous stall torque/force"},
554 {IDN(0,0,0,0,1000), "SCP Type & Version"},
555 {IDN(0,0,0,0,1001), "SERCOS III: Control unit cycle time (tNcyc)"},
556 {IDN(0,0,0,0,1002), "SERCOS III: Communication cycle time (tScyc)"},
557 {IDN(0,0,0,0,1003), "SERCOS III: Number of successive MDT errors"},
558 {IDN(0,0,0,0,1005), "SERCOS III: Feedback value computation time (t5)"},
559 {IDN(0,0,0,0,1006), "SERCOS III: AT transmission starting time (t1)"},
560 {IDN(0,0,0,0,1007), "SERCOS III: Synchronization time (t8)"},
561 {IDN(0,0,0,0,1008), "SERCOS III: Command value valid time (t3)"},
562 {IDN(0,0,0,0,1009), "SERCOS III: Device Control offset in MDT"},
563 {IDN(0,0,0,0,1010), "SERCOS III: Length of MDT"},
564 {IDN(0,0,0,0,1011), "SERCOS III: Device Status offset in AT"},
565 {IDN(0,0,0,0,1012), "SERCOS III: Length of AT"},
566 {IDN(0,0,0,0,1013), "SERCOS III: SVC offset in MDT"},
567 {IDN(0,0,0,0,1014), "SERCOS III: SVC offset in AT"},
568 {IDN(0,0,0,0,1015), "SERCOS III: Ring delay"},
569 {IDN(0,0,0,0,1016), "SERCOS III: Slave delay"},
570 {IDN(0,0,0,0,1017), "SERCOS III: Transmission starting time IP channel"},
571 {IDN(0,0,0,0,1018), "SERCOS III: SYNC delay"},
572 {IDN(0,0,0,0,1019), "SERCOS III: MAC address"},
573 {IDN(0,0,0,0,1020), "SERCOS III: IP address"},
574 {IDN(0,0,0,0,1021), "SERCOS III: Network mask"},
575 {IDN(0,0,0,0,1022), "SERCOS III: Gateway address"},
576 {IDN(0,0,0,0,1023), "SERCOS III: Sync jitter"},
577 {IDN(0,0,0,0,1024), "SERCOS III: Ring control - node control"},
578 {IDN(0,0,0,0,1025), "SERCOS III: Ring status - node status"},
579 {IDN(0,0,0,0,1026), "SERCOS III: Hardware identification"},
580 {IDN(0,0,0,0,1028), "SERCOS III: Error counter MDT0 MST"},
581 {IDN(0,0,0,0,1029), "SERCOS III: Error counter MDT0-3"},
582 {IDN(0,0,0,0,1030), "SERCOS III: Error counter AT0-3"},
583 {IDN(0,0,0,0,1031), "Signal assignment Port 1 & Port 2"},
584 {IDN(0,0,0,0,1035), "Error counter Port1 and Port2"},
585 {IDN(0,0,0,0,1040), "SERCOSAddress"},
586 {IDN(0,0,0,0,1041), "AT Command value valid time (t9)"},
587 {IDN(0,0,0,0,1044), "Device Control"},
588 {IDN(0,0,0,0,1045), "Device Status"},
589 {IDN(0,0,0,0,1046), "IDN-list of SERCOS addresses in device"},
590 {IDN(0,0,0,0,1134), "SERCOS III: Device control"},
591 {IDN(0,0,0,0,1135), "SERCOS III: Device status"},
592 {IDN(1,0,0,0,1027), "Requested MTU"},
593 {IDN(2,0,0,0,1027), "Effective MTU"},
594 {0, NULL}
596 static value_string_ext siii_mdt_idn_text_ext = VALUE_STRING_EXT_INIT(siii_mdt_idn_text);
598 static const value_string siii_mdt_svch_dbe_text[]=
600 {0x00, "Element 0: Closed SVC"},
601 {0x01, "Element 1: Opening IDN"},
602 {0x02, "Element 2: Name of operation data"},
603 {0x03, "Element 3: Attribute of operation data"},
604 {0x04, "Element 4: Unit of operation data"},
605 {0x05, "Element 5: Minimum value of operation data"},
606 {0x06, "Element 6: Maximum value of operation data"},
607 {0x07, "Element 7: Operation data"},
608 {0, NULL}
611 static const true_false_string siii_mdt_svch_eot_text = {
612 "Transmission in progress",
613 "Last transmission"
616 static const true_false_string siii_mdt_svch_rw_text = {
617 "Read SVC INFO",
618 "Write SVC INFO"
621 static const value_string siii_mdt_devcontrol_topcontrol_text[]=
623 {0x00, "Fast Forward on P/S-Channel"},
624 {0x01, "Loopback on P-Channel and Fast Forward"},
625 {0x02, "Loopback on S-Channel and Fast Forward"},
626 {0, NULL}
629 static const true_false_string siii_at_svch_error_text = {
630 "No error",
631 "Error in SVC"
634 static const true_false_string siii_at_svch_busy_text = {
635 "Step finished, slave ready for new step",
636 "Step in process, new step not allowed"
640 static const value_string siii_mst_phase_text[]=
642 {0x00, "CP0"},
643 {0x01, "CP1"},
644 {0x02, "CP2"},
645 {0x03, "CP3"},
646 {0x04, "CP4"},
647 {0x80, "CP0 (Phase Change)"},
648 {0x81, "CP1 (Phase Change)"},
649 {0x82, "CP2 (Phase Change)"},
650 {0x83, "CP3 (Phase Change)"},
651 {0x84, "CP4 (Phase Change)"},
652 {0, NULL}
655 #if 0
656 static const value_string siii_mst_teltype_text[]=
658 {0x00, "CP0"},
659 {0x01, "CP1"},
660 {0x02, "CP2"},
661 {0x03, "CP3"},
662 {0x04, "CP4"},
663 {0x80, "CP0 (Phase Change)"},
664 {0x81, "CP1 (Phase Change)"},
665 {0x82, "CP2 (Phase Change)"},
666 {0x83, "CP3 (Phase Change)"},
667 {0x84, "CP4 (Phase Change)"},
668 {0, NULL}
670 #endif
672 static const value_string siii_mst_channel_text[]=
674 {0x00, "P-Telegram"},
675 {0x01, "S-Telegram"},
676 {0, NULL}
679 static const value_string siii_mst_type_text[]=
681 {0x00, "MDT"},
682 {0x01, "AT"},
683 {0, NULL}
686 static const value_string siii_at_devstatus_errorconnection_text[]=
688 {0x00, "Error-free connection"},
689 {0x01, "Error in the connection occurs"},
690 {0, NULL}
693 static const value_string siii_at_devstatus_topstatus_text[]=
695 {0x00, "Fast Forward on P/S-Channel"},
696 {0x01, "Loopback on P-Channel and Fast Forward"},
697 {0x02, "Loopback on S-Channel and Fast Forward"},
698 {0, NULL}
701 static const true_false_string siii_at_cp0_support_functions_text = {
702 "Slave doesn't support one or more of the requested functions",
703 "Slave supports all requested functions"
706 static const value_string siii_at_devstatus_inactiveportstatus_text[]=
708 {0x00, "No link on port"},
709 {0x01, "Link on port"},
710 {0x02, "S III P-Telegram on port"},
711 {0x03, "S III S-Telegram on port"},
712 {0, NULL}
715 static const value_string siii_at_dev_status_proc_command_change_text[]=
717 {0x00, "No change in procedure command acknowledgement"},
718 {0x01, "Changing procedure command acknowledgement"},
719 {0, NULL}
723 static const value_string siii_mdt_hotplug_control_functioncode_text[]=
725 {0x00, "No data"},
726 {0x01, "tScyc"},
727 {0x02, "t1"},
728 {0x03, "t6"},
729 {0x04, "t7"},
730 {0x05, "Communication Version"},
731 {0x06, "Communication timeout"},
732 {0x10, "MDT0 Length"},
733 {0x11, "MDT1 Length"},
734 {0x12, "MDT2 Length"},
735 {0x13, "MDT3 Length"},
736 {0x20, "AT0 Length"},
737 {0x21, "AT1 Length"},
738 {0x22, "AT2 Length"},
739 {0x23, "AT3 Length"},
740 {0x80, "MDT-SVC pointer"},
741 {0x81, "MDT-RTD pointer"},
742 {0x82, "AT-SVC pointer"},
743 {0x83, "AT-RTD pointer"},
744 {0, NULL}
746 static value_string_ext siii_mdt_hotplug_control_functioncode_text_ext =
747 VALUE_STRING_EXT_INIT(siii_mdt_hotplug_control_functioncode_text);
749 static const value_string siii_mdt_hotplug_control_svc_switch_text[]=
751 {0, "Transmission via HP-field"},
752 {1, "Switch to SVC"},
753 {0, NULL}
756 static const value_string siii_mdt_hotplug_status_ackcode_text[]=
758 {0x80, "MDT-SVC pointer"},
759 {0x81, "MDT-RTD pointer"},
760 {0x82, "AT-SVC pointer"},
761 {0x83, "AT-RTD pointer"},
762 {255, "Next Sercos Slave has same address"},
763 {0, NULL}
766 static const value_string siii_at_hotplug_status_error_text[]=
768 {0, "Acknowledgement in HP-1"},
769 {1, "Error in HP-1"},
770 {0, NULL}
777 static void dissect_siii_mst(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
779 proto_tree *subtree;
780 proto_tree *subtree2;
782 subtree = proto_tree_add_subtree(tree, tvb, 0, 6, ett_siii_mst, NULL, "MST");
784 subtree2 = proto_tree_add_subtree(subtree, tvb, 0, 1, ett_siii_mst_teltype, NULL, "Telegram Type");
786 proto_tree_add_item(subtree2, hf_siii_mst_channel, tvb, 0, 1, ENC_LITTLE_ENDIAN);
787 proto_tree_add_item(subtree2, hf_siii_mst_type, tvb, 0, 1, ENC_LITTLE_ENDIAN);
788 proto_tree_add_item(subtree2, hf_siii_mst_cyclecntvalid, tvb, 0, 1, ENC_LITTLE_ENDIAN);
789 proto_tree_add_item(subtree2, hf_siii_mst_telno, tvb, 0, 1, ENC_LITTLE_ENDIAN);
791 subtree2 = proto_tree_add_subtree(subtree, tvb, 1, 1, ett_siii_mst_phase, NULL, "Phase Field");
793 proto_tree_add_item(subtree2, hf_siii_mst_phase, tvb, 1, 1, ENC_LITTLE_ENDIAN);
794 proto_tree_add_item(subtree2, hf_siii_mst_cyclecnt, tvb, 1, 1, ENC_LITTLE_ENDIAN);
795 proto_tree_add_item(subtree, hf_siii_mst_crc32, tvb, 2, 4, ENC_LITTLE_ENDIAN);
799 static void dissect_siii_mdt_hp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
801 proto_tree *subtree;
803 static int * const ctrl_fields[] = {
804 &hf_siii_mdt_hotplug_control_svc_switch,
805 &hf_siii_mdt_hotplug_control_param,
806 NULL
809 subtree = proto_tree_add_subtree(tree, tvb, 0, 8, ett_siii_mdt_hp, NULL, "Hot-Plug");
811 proto_tree_add_item(subtree, hf_siii_mdt_hotplug_address, tvb, 0, 2, ENC_LITTLE_ENDIAN);
813 proto_tree_add_bitmask(subtree, tvb, 2, hf_siii_mdt_hp_ctrl,
814 ett_siii_mdt_hp_ctrl, ctrl_fields, ENC_LITTLE_ENDIAN);
816 proto_tree_add_item(subtree, hf_siii_mdt_hp_info, tvb, 4, 4, ENC_NA);
819 static void dissect_siii_mdt_devctrl(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
821 static int * const ctrl_fields[] = {
822 &hf_siii_at_dev_control_ident,
823 &hf_siii_mdt_dev_control_change_topology,
824 &hf_siii_mdt_dev_control_top_control,
825 NULL
828 proto_tree_add_bitmask(tree, tvb, 0, hf_siii_mdt_dev_control,
829 ett_siii_mdt_devctrl, ctrl_fields, ENC_LITTLE_ENDIAN);
832 static void dissect_siii_mdt_svc(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned devno _U_) /* devno will be needed in later versions */
834 proto_tree *subtree;
835 proto_item *ti;
837 static int * const svch_fields[] = {
838 &hf_siii_mdt_svch_dbe, /* data block element */
839 &hf_siii_mdt_svch_eot, /* end of transmission */
840 &hf_siii_mdt_svch_rw, /* read or write */
841 &hf_siii_mdt_svch_mhs, /* master hand shake */
842 NULL
845 uint16_t svc_ctrl = tvb_get_letohs(tvb, 0); /* service channel header */
846 uint8_t svc_dbe = (svc_ctrl>>3) & 7; /* accessed data block element */
848 proto_tree_add_bitmask(tree, tvb, 0, hf_siii_mdt_svch_ctrl,
849 ett_siii_mdt_svcctrl, svch_fields, ENC_LITTLE_ENDIAN);
851 ti = proto_tree_add_item(tree, hf_siii_mdt_svch_info, tvb, 2, 4, ENC_NA);
853 if (1 == svc_dbe)
855 subtree = proto_item_add_subtree(ti, ett_siii_mdt_svcinfo);
856 proto_tree_add_item(subtree, hf_siii_idn_code, tvb, 2, 4, ENC_LITTLE_ENDIAN);
857 proto_tree_add_item(subtree, hf_siii_mdt_svch_idn, tvb, 2, 4, ENC_LITTLE_ENDIAN);
861 static void dissect_siii_mdt_cp0(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
863 static int * const version_fields[] = {
864 &hf_siii_mdt_version_switch_off_sercos_telegrams,
865 &hf_siii_mdt_version_fast_cp_switch,
866 &hf_siii_mdt_version_transmission_of_communication_parameters_mdt0_cp0,
867 &hf_siii_mdt_version_num_mdt_at_cp1_2,
868 &hf_siii_mdt_version_initprocvers,
869 NULL
872 proto_tree_add_bitmask(tree, tvb, 0, hf_siii_mdt_version,
873 ett_siii_mdt_version, version_fields, ENC_LITTLE_ENDIAN);
876 static void dissect_siii_mdt_cp1_2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned telno)
878 unsigned devstart = telno * SERCOS_SLAVE_GROUP_SIZE; /* MDT0: slaves 0-127; MDT1: slaves 128-255; ... */
879 tvbuff_t *tvb_n;
881 unsigned idx;
882 proto_tree *subtree;
883 proto_tree *subtree_svc;
884 proto_tree *subtree_devctrl;
886 subtree_svc = proto_tree_add_subtree(tree, tvb, 0, SERCOS_SLAVE_GROUP_SIZE * 6, ett_siii_mdt_svc, NULL, "Service Channels");
888 subtree_devctrl = proto_tree_add_subtree(tree, tvb, SERCOS_SLAVE_GROUP_SIZE * 6, 512, ett_siii_mdt_svc, NULL, "Device Control");
890 for (idx = 0; idx < SERCOS_SLAVE_GROUP_SIZE; ++idx) /* each MDT of CP1/2 has data for 128 different slaves */
892 tvb_n = tvb_new_subset_length(tvb, 6 * idx, 6); /* subset for service channel data */
894 subtree = proto_tree_add_subtree_format(subtree_svc, tvb_n, 0, 6, ett_siii_mdt_svc_channel, NULL, "Device %u", idx + devstart);
895 dissect_siii_mdt_svc(tvb_n, pinfo, subtree, idx + devstart);
897 tvb_n = tvb_new_subset_length(tvb, SERCOS_SLAVE_GROUP_SIZE * 6 + 4 * idx, 2); /* subset for device control information */
899 subtree = proto_tree_add_subtree_format(subtree_devctrl, tvb_n, 0, 2, ett_siii_mdt_dev_control, NULL, "Device %u", idx + devstart);
901 dissect_siii_mdt_devctrl(tvb_n, pinfo, subtree);
905 static void dissect_siii_mdt_cp3_4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned telno)
907 /* unsigned devstart _U_ = telno * SERCOS_SLAVE_GROUP_SIZE; */
909 if (0 == telno) /* dissect hotplug field in MDT0 only */
910 dissect_siii_mdt_hp(tvb, pinfo, tree);
912 /* offsets of service channel, device status and connections are unknown
913 * this data could be extracted from svc communication during CP2
915 proto_tree_add_item(tree, hf_siii_service_channels, tvb, 0, 0, ENC_NA);
917 proto_tree_add_item(tree, hf_siii_device_controls, tvb, 0, 0, ENC_NA);
920 static void dissect_siii_mdt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
922 proto_tree *subtree;
923 tvbuff_t *tvb_n;
925 unsigned t_phase;
926 unsigned telno;
928 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SIII MDT");
930 t_phase = (tvb_get_uint8(tvb, 1)&0x8F); /* read communication phase out of SERCOS III header */
931 telno = (tvb_get_uint8(tvb, 0) & 0xF); /* read number of MDT out of SERCOS III header */
933 if (t_phase & 0x80) /* communication phase switching in progress */
935 col_append_fstr(pinfo->cinfo, COL_INFO, " Phase=CP?s -> CP%u",
936 (t_phase&0x0f));
938 else /* communication as usual */
940 col_append_fstr(pinfo->cinfo, COL_INFO, " Phase=CP%u",
941 (t_phase&0x0f));
944 subtree = proto_tree_add_subtree_format(tree, tvb, 0, -1, ett_siii_mdt, NULL, "MDT%u", telno);
946 dissect_siii_mst(tvb, pinfo, subtree); /* dissect SERCOS III header */
948 switch (t_phase) /* call the MDT dissector depending on the current communication phase */
950 case COMMUNICATION_PHASE_0: /* CP0 */
951 tvb_n = tvb_new_subset_length(tvb, 6, 40);
952 dissect_siii_mdt_cp0(tvb_n, pinfo, subtree);
953 break;
955 case COMMUNICATION_PHASE_1: /* CP1 */
956 case COMMUNICATION_PHASE_2: /* CP2 */
957 tvb_n = tvb_new_subset_length(tvb, 6, 1280);
958 dissect_siii_mdt_cp1_2(tvb_n, pinfo, subtree, telno);
959 break;
961 case COMMUNICATION_PHASE_3: /* CP3 */
962 case COMMUNICATION_PHASE_4: /* CP4 */
963 tvb_n = tvb_new_subset_remaining(tvb, 6);
964 dissect_siii_mdt_cp3_4(tvb_n, pinfo, subtree, telno);
965 break;
967 default:
968 proto_tree_add_expert(tree, pinfo, &ei_siii_cp_unknown, tvb, 6, -1);
973 static void dissect_siii_at_svc(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned devno _U_) /* devno will be used in later versions */
975 static int * const svch_fields[] = {
976 &hf_siii_at_svch_valid,
977 &hf_siii_at_svch_error,
978 &hf_siii_at_svch_busy,
979 &hf_siii_at_svch_ahs,
980 NULL
983 proto_tree_add_bitmask(tree, tvb, 0, hf_siii_at_svch_stat,
984 ett_siii_at_svcstat, svch_fields, ENC_LITTLE_ENDIAN);
986 proto_tree_add_item(tree, hf_siii_at_svch_info, tvb, 2, 4, ENC_NA);
989 static void dissect_siii_at_devstat(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
991 static int * const status[] = {
992 &hf_siii_at_dev_status_commwarning,
993 &hf_siii_at_dev_status_change_topology,
994 &hf_siii_at_dev_status_top_status,
995 &hf_siii_at_dev_status_inactive_port_status,
996 &hf_siii_at_dev_status_errorconnection,
997 &hf_siii_at_dev_status_slave_valid,
998 &hf_siii_at_dev_status_proc_command_change,
999 &hf_siii_at_dev_status_parameterization_level_active,
1000 NULL
1003 proto_tree_add_bitmask(tree, tvb, 0, hf_siii_at_dev_status,
1004 ett_siii_at_devstatus, status, ENC_LITTLE_ENDIAN);
1007 static void dissect_siii_at_hp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1009 proto_tree *subtree;
1011 static int * const status[] = {
1012 &hf_siii_at_hotplug_status_error,
1013 &hf_siii_at_hotplug_status_hp0_finished,
1014 &hf_siii_at_hotplug_status_param,
1015 NULL
1018 subtree = proto_tree_add_subtree(tree, tvb, 0, 8, ett_siii_at_hp, NULL, "Hot-Plug");
1020 proto_tree_add_item(subtree, hf_siii_at_hotplug_address, tvb, 0, 2, ENC_LITTLE_ENDIAN);
1022 proto_tree_add_bitmask(subtree, tvb, 2, hf_siii_at_hp_stat, ett_siii_at_hp_stat, status, ENC_LITTLE_ENDIAN);
1024 proto_tree_add_item(subtree, hf_siii_at_hp_info, tvb, 4, 4, ENC_NA);
1027 static void dissect_siii_at_cp0(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1029 uint16_t seqcnt; /* sequence counter */
1030 uint16_t tfield; /* topology field for sercos addresses */
1031 uint16_t i;
1032 proto_tree *subtree, *subtree2;
1033 proto_item* ti;
1035 subtree = proto_tree_add_subtree(tree, tvb, 0, 1024, ett_siii_recognized_devices, NULL, "Recognized Devices");
1037 /* check sequence count field */
1038 seqcnt = tvb_get_letohs(tvb, 0);
1039 proto_tree_add_uint(subtree, hf_siii_at_cp0_num_devices, tvb, 0, 2, (MAX_SERCOS_ADDRESS & seqcnt)-1);
1041 /* check SERCOS address of each topology field */
1042 for (i = 1; i < MAX_SERCOS_DEVICES; ++i)
1044 tfield = tvb_get_letohs(tvb, i*2);
1046 if (tfield == 0xFFFF)
1048 proto_tree_add_uint_format(subtree, hf_siii_at_cp0_sercos_address, tvb, i*2, 2, 0xFFFF, "Sercos Address %u: No Device", i);
1050 else
1052 ti = proto_tree_add_uint_format(subtree, hf_siii_at_cp0_sercos_address, tvb, i*2, 2, (tfield & MAX_SERCOS_ADDRESS), "Sercos Address %u: %u", i, (tfield & MAX_SERCOS_ADDRESS));
1053 subtree2 = proto_item_add_subtree(ti, ett_siii_at_sercos_address);
1054 proto_tree_add_item(subtree2, hf_siii_at_cp0_support_functions, tvb, i*2, 2, ENC_LITTLE_ENDIAN);
1055 proto_tree_add_item(subtree2, hf_siii_at_cp0_device_address, tvb, i*2, 2, ENC_LITTLE_ENDIAN);
1060 static void dissect_siii_at_cp1_2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned telno)
1062 unsigned devstart = telno * SERCOS_SLAVE_GROUP_SIZE; /* AT0: slaves 0-127; AT1: slaves 128-255; ... */
1063 tvbuff_t *tvb_n;
1065 unsigned idx;
1067 proto_tree *subtree;
1068 proto_tree *subtree_svc;
1069 proto_tree *subtree_devstat;
1071 subtree_svc = proto_tree_add_subtree(tree, tvb, 0, SERCOS_SLAVE_GROUP_SIZE * 6, ett_siii_at_svc, NULL, "Service Channel");
1073 subtree_devstat = proto_tree_add_subtree(tree, tvb, SERCOS_SLAVE_GROUP_SIZE * 6, 512, ett_siii_at_devstats, NULL, "Device Status");
1075 for (idx = 0; idx < SERCOS_SLAVE_GROUP_SIZE; ++idx) /* each AT of CP1/2 has data of 128 different slaves */
1077 tvb_n = tvb_new_subset_length(tvb, 6 * idx, 6); /* subset for service channel data */
1079 subtree = proto_tree_add_subtree_format(subtree_svc, tvb_n, 0, 6, ett_siii_at_svc_channel, NULL, "Device %u", idx + devstart);
1080 dissect_siii_at_svc(tvb_n, pinfo, subtree, idx + devstart);
1082 tvb_n = tvb_new_subset_length(tvb, SERCOS_SLAVE_GROUP_SIZE * 6 + 4 * idx, 2); /* subset for device status information */
1084 subtree = proto_tree_add_subtree_format(subtree_devstat, tvb_n, 0, 2, ett_siii_at_dev_status, NULL, "Device %u", idx + devstart);
1085 dissect_siii_at_devstat(tvb_n, pinfo, subtree);
1089 static void dissect_siii_at_cp3_4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned telno)
1091 if (0 == telno) /* dissect hotplug field in AT0 only */
1092 dissect_siii_at_hp(tvb, pinfo, tree);
1094 /* offsets of service channel, device status and connections are unknown
1095 * this data could be extracted from svc communication during CP2
1097 proto_tree_add_item(tree, hf_siii_service_channels, tvb, 0, 0, ENC_NA);
1098 proto_tree_add_item(tree, hf_siii_device_status, tvb, 0, 0, ENC_NA);
1102 static void dissect_siii_at(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1104 proto_tree *subtree;
1105 tvbuff_t *tvb_n;
1107 uint8_t phase;
1108 unsigned telno;
1110 phase = (tvb_get_uint8(tvb, 1)&0x8F); /* read communication phase out of SERCOS III header*/
1111 telno = (tvb_get_uint8(tvb, 0) & 0xF); /* read number of AT out of SERCOS III header */
1113 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SIII AT");
1115 if (phase & 0x80) /* communication phase switching in progress */
1117 col_append_fstr(pinfo->cinfo, COL_INFO, " Phase=CP?s -> CP%u",
1118 (phase&0x0f));
1120 else /* communication as usual */
1122 col_append_fstr(pinfo->cinfo, COL_INFO, " Phase=CP%u",
1123 (phase&0x0f));
1126 subtree = proto_tree_add_subtree_format(tree, tvb, 0, -1, ett_siii_at, NULL, "AT%u", telno);
1128 dissect_siii_mst(tvb, pinfo, subtree); /* dissect SERCOS III header */
1130 switch (phase) /* call the AT dissector depending on the current communication phase */
1132 case COMMUNICATION_PHASE_0: /* CP0 */
1133 tvb_n = tvb_new_subset_length(tvb, 6, 1024);
1134 dissect_siii_at_cp0(tvb_n, pinfo, subtree);
1135 break;
1137 case COMMUNICATION_PHASE_1: /* CP1 */
1138 case COMMUNICATION_PHASE_2: /* CP2 */
1139 tvb_n = tvb_new_subset_length(tvb, 6, 1280);
1140 dissect_siii_at_cp1_2(tvb_n, pinfo, subtree, telno);
1141 break;
1143 case COMMUNICATION_PHASE_3: /* CP3 */
1144 case COMMUNICATION_PHASE_4: /* CP4 */
1145 tvb_n = tvb_new_subset_remaining(tvb, 6);
1146 dissect_siii_at_cp3_4(tvb_n, pinfo, subtree, telno);
1147 break;
1149 default:
1150 proto_tree_add_expert(tree, pinfo, &ei_siii_cp_unknown, tvb, 6, -1);
1151 break;
1155 /* Main dissector entry */
1156 static int
1157 dissect_siii(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
1159 proto_item *ti;
1160 proto_tree *siii_tree;
1161 unsigned type;
1162 const char *tel_ch;
1163 const char *tel_type;
1164 unsigned tel_no = 0;
1165 heur_dtbl_entry_t *hdtbl_entry;
1167 /* setup columns */
1168 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SERCOS III V1.1");
1169 col_clear(pinfo->cinfo, COL_INFO);
1172 * In case the packet is a protocol encoded in the basic SercosIII transport stream,
1173 * give that protocol a chance to make a heuristic dissection, before we continue
1174 * to dissect it as a normal SercosIII packet.
1176 if (dissector_try_heuristic(heur_subdissector_list, tvb, pinfo, tree, &hdtbl_entry, NULL))
1177 return tvb_captured_length(tvb);
1179 /* check what we got on our hand */
1180 type = tvb_get_uint8(tvb, 0);
1181 if (type & 0x80) /* primary or secondary channel */
1182 tel_ch = "S";
1183 else
1184 tel_ch = "P";
1186 if (type & 0x40) /* master data telegram (mdt) or slave telegram (at) */
1187 tel_type = "AT ";
1188 else
1189 tel_type = "MDT";
1191 tel_no = type &0xF; /* even though it's reserved (the V1.1 spec states that it is reserved for additional MDT/AT) */
1193 col_append_fstr(pinfo->cinfo, COL_INFO, "%s%u Channel=%s", tel_type, tel_no, tel_ch);
1195 ti = proto_tree_add_item(tree, proto_siii, tvb, 0, -1, ENC_NA);
1197 siii_tree = proto_item_add_subtree(ti, ett_siii);
1199 /* enter the specific dissector for AT or MDT */
1200 if (type & 0x40)
1201 dissect_siii_at(tvb, pinfo, siii_tree);
1202 else
1203 dissect_siii_mdt(tvb, pinfo, siii_tree);
1205 return tvb_captured_length(tvb);
1208 static void
1209 sercosiii_idn_code_format( char *result, uint32_t svc_info )
1211 snprintf( result, ITEM_LABEL_LENGTH, "%c-%u-%04d.%d.%d",
1212 ((0xFFFF & svc_info)>>15)?'P':'S', /* private or sercos IDN */
1213 (svc_info>>12)&7, /* parameter record */
1214 (svc_info&4095), /* IDN */
1215 (svc_info>>24) & 0xFF, /* structure index */
1216 (svc_info>>16) & 0xFF); /* structure element */
1219 void
1220 proto_register_sercosiii(void)
1222 static hf_register_info hf[] = {
1224 { &hf_siii_mdt_version,
1225 { "Communication Version", "siii.mdt.version",
1226 FT_UINT32, BASE_HEX, NULL, 0,
1227 NULL, HFILL }
1229 { &hf_siii_mdt_version_num_mdt_at_cp1_2,
1230 { "Number of MDTs and ATS in CP1 and CP2", "siii.mdt.version.num_mdt_at_cp1_2",
1231 FT_UINT32, BASE_HEX, VALS(siii_mdt_version_num_mdtat_cp1_2_text), 0x00030000,
1232 NULL, HFILL }
1234 { &hf_siii_mdt_version_transmission_of_communication_parameters_mdt0_cp0,
1235 { "Transmission of Communication parameters", "siii.mdt.version.mdt0_cp0_transm_comm_parameter",
1236 FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00100000,
1237 NULL, HFILL }
1239 { &hf_siii_mdt_version_fast_cp_switch,
1240 { "Fast CP switch", "siii.mdt.version.mdt0_cp0_fast_cp_switch",
1241 FT_BOOLEAN, 32, TFS(&siii_mdt_version_fast_cp_switch_text), 0x00200000,
1242 NULL, HFILL }
1245 { &hf_siii_mdt_version_switch_off_sercos_telegrams,
1246 { "Switch off Sercos III telegrams", "siii.mdt.version.mdt0_cp0_switch_off_sercos_telegram",
1247 FT_BOOLEAN, 32, TFS(&siii_switch_off_sercos_telegram_text), 0x00400000,
1248 NULL, HFILL }
1250 { &hf_siii_mdt_version_initprocvers,
1251 { "Initialization Procedure Version Number", "siii.mdt.version.initprocvers",
1252 FT_BOOLEAN, 32, TFS(&siii_mdt_version_initprocvers_text), 0x0000FF00,
1253 NULL, HFILL }
1256 { &hf_siii_mdt_dev_control_top_control,
1257 { "Topology Control", "siii.mdt.devcontrol.topcontrol",
1258 FT_UINT16, BASE_DEC, VALS(siii_mdt_devcontrol_topcontrol_text), 3<<(12),
1259 NULL, HFILL }
1261 { &hf_siii_at_dev_control_ident,
1262 { "Identification", "siii.mdt.devcontrol.identrequest",
1263 FT_UINT16, BASE_DEC, NULL, 0x8000,
1264 NULL, HFILL }
1266 { &hf_siii_mdt_dev_control_change_topology,
1267 { "Changing Topology", "siii.mdt.devcontrol.topologychange",
1268 FT_UINT16, BASE_DEC, NULL, 1<<14,
1269 NULL, HFILL }
1271 { &hf_siii_mdt_dev_control,
1272 { "Word", "siii.mdt.devcontrol",
1273 FT_UINT16, BASE_DEC, NULL, 0,
1274 NULL, HFILL }
1277 { &hf_siii_at_dev_status,
1278 { "Word", "siii.at.devstatus",
1279 FT_UINT16, BASE_HEX, NULL, 0,
1280 NULL, HFILL }
1283 { &hf_siii_at_dev_status_commwarning,
1284 { "Communication Warning", "siii.at.devstatus.commwarning",
1285 FT_UINT16, BASE_DEC, NULL, 1<<15,
1286 NULL, HFILL }
1289 { &hf_siii_at_cp0_support_functions,
1290 { "Support of requested functions", "siii.at.supfunctions",
1291 FT_BOOLEAN, 16, TFS(&siii_at_cp0_support_functions_text), 1<<15,
1292 NULL, HFILL }
1295 { &hf_siii_at_cp0_device_address,
1296 { "Sercos Address", "siii.at.sercosaddress",
1297 FT_UINT16, BASE_DEC, NULL, MAX_SERCOS_ADDRESS,
1298 NULL, HFILL }
1301 { &hf_siii_at_dev_status_change_topology,
1302 { "Topology Change", "siii.at.devstatus.topologychanged",
1303 FT_UINT16, BASE_DEC, NULL, 1<<14,
1304 NULL, HFILL }
1306 { &hf_siii_at_dev_status_top_status,
1307 { "Topology Status", "siii.at.devstatus.topstatus",
1308 FT_UINT16, BASE_DEC, VALS(siii_at_devstatus_topstatus_text), 0x3<<(12),
1309 NULL, HFILL }
1311 { &hf_siii_at_dev_status_inactive_port_status,
1312 { "Port 1 Status", "siii.at.devstatus.inactportstatus",
1313 FT_UINT16, BASE_DEC, VALS(siii_at_devstatus_inactiveportstatus_text), 0x3<<(10),
1314 NULL, HFILL }
1316 { &hf_siii_at_dev_status_errorconnection,
1317 { "Topology Status", "siii.at.devstatus.errorconnection",
1318 FT_UINT16, BASE_DEC, VALS(siii_at_devstatus_errorconnection_text), 1<<9,
1319 NULL, HFILL }
1321 { &hf_siii_at_dev_status_slave_valid,
1322 { "Slave data valid", "siii.at.devstatus.slavevalid",
1323 FT_UINT16, BASE_DEC, NULL, 1<<8,
1324 NULL, HFILL }
1326 { &hf_siii_at_dev_status_proc_command_change,
1327 { "Procedure Command Change", "siii.at.devstatus.proccmdchange",
1328 FT_UINT16, BASE_DEC, VALS(siii_at_dev_status_proc_command_change_text), 1<<5,
1329 NULL, HFILL }
1331 { &hf_siii_at_dev_status_parameterization_level_active,
1332 { "Parameterization level active", "siii.at.devstatus.paralevelactive",
1333 FT_UINT16, BASE_DEC, NULL, 1<<4,
1334 NULL, HFILL }
1337 { &hf_siii_mdt_svch_ctrl,
1338 {"SvcCtrl", "siii.mdt.svch.ctrl",
1339 FT_UINT16, BASE_HEX, NULL, 0,
1340 NULL, HFILL }
1342 { &hf_siii_at_svch_stat,
1343 {"SvcStat", "siii.mdt.svch.stat",
1344 FT_UINT16, BASE_HEX, NULL, 0,
1345 NULL, HFILL }
1347 { &hf_siii_mdt_svch_info,
1348 {"Svc Info", "siii.mdt.svch.info",
1349 FT_BYTES, BASE_NONE, NULL, 0,
1350 NULL, HFILL }
1352 { &hf_siii_at_svch_info,
1353 {"Svc Info", "siii.at.svch.info",
1354 FT_BYTES, BASE_NONE, NULL, 0,
1355 NULL, HFILL }
1357 { &hf_siii_mdt_svch_idn,
1358 {"IDN", "siii.mdt.svch.idn",
1359 FT_UINT32, BASE_HEX | BASE_EXT_STRING, &siii_mdt_idn_text_ext, 0,
1360 NULL, HFILL }
1362 { &hf_siii_mdt_svch_dbe,
1363 { "Data block element", "siii.mdt.svch.dbe",
1364 FT_UINT16, BASE_DEC, VALS(siii_mdt_svch_dbe_text), 0x0038,
1365 NULL, HFILL }
1367 { &hf_siii_mdt_svch_eot,
1368 {"End of element transmission", "siii.mdt.svch.eot",
1369 FT_BOOLEAN, 16, TFS(&siii_mdt_svch_eot_text), 0x0004,
1370 NULL, HFILL }
1372 { &hf_siii_mdt_svch_rw,
1373 {"Read/Write", "siii.mdt.svch.rw",
1374 FT_BOOLEAN, 16, TFS(&siii_mdt_svch_rw_text), 0x0002,
1375 NULL, HFILL }
1377 { &hf_siii_mdt_svch_mhs,
1378 {"Master Handshake", "siii.mdt.svch.mhs",
1379 FT_UINT16, BASE_DEC, NULL, 0x0001,
1380 NULL, HFILL }
1382 { &hf_siii_at_svch_valid,
1383 { "SVC process", "siii.mdt.svch.proc",
1384 FT_BOOLEAN, 16, TFS(&tfs_valid_not_valid), 0x0008,
1385 NULL, HFILL }
1387 { &hf_siii_at_svch_error,
1388 {"SVC Error", "siii.mdt.svch.error",
1389 FT_BOOLEAN, 16, TFS(&siii_at_svch_error_text), 0x0004,
1390 NULL, HFILL }
1392 { &hf_siii_at_svch_busy,
1393 {"Busy", "siii.mdt.svch.busy",
1394 FT_BOOLEAN, 16, TFS(&siii_at_svch_busy_text), 0x0002,
1395 NULL, HFILL }
1397 { &hf_siii_at_svch_ahs,
1398 {"Handshake", "siii.at.svch.ahs",
1399 FT_UINT16, BASE_DEC, NULL, 0x01,
1400 NULL, HFILL }
1402 #if 0
1403 { &hf_siii_svch_data_telofs_telno,
1404 {"Telegram Number", "siii.mdt.svch.data.telassign.telno",
1405 FT_UINT16, BASE_DEC, NULL, 0xF000,
1406 NULL, HFILL }
1408 #endif
1409 #if 0
1410 { &hf_siii_svch_data_telofs_mdt_at,
1411 {"Telegram Type", "siii.mdt.svch.data.telassign.mdt_at",
1412 FT_UINT16, BASE_DEC, VALS(siii_svch_data_mdt_at_text), 0x0800,
1413 NULL, HFILL }
1415 #endif
1416 #if 0
1417 { &hf_siii_svch_data_telofs_offset,
1418 {"Telegram Offset", "siii.mdt.svch.data.telassign.offset",
1419 FT_UINT16, BASE_DEC, NULL, 0x07FF,
1420 NULL, HFILL }
1422 #endif
1423 #if 0
1424 { &hf_siii_svch_data_proccmd_proccmdexec,
1425 {"Procedure Command Execution", "siii.mdt.svch.data.proccmd.interrupt",
1426 FT_UINT16, BASE_DEC, VALS(siii_svch_data_proccmd_proccmdexec_text), 0x0002,
1427 NULL, HFILL }
1429 #endif
1430 #if 0
1431 { &hf_siii_svch_data_proccmd_proccmd,
1432 {"Procedure Command", "siii.mdt.svch.data.proccmd.set",
1433 FT_UINT16, BASE_DEC, VALS(siii_svch_data_proccmd_proccmd_text), 0x0001,
1434 NULL, HFILL }
1436 #endif
1437 { &hf_siii_mst_channel,
1438 { "Channel", "siii.channel",
1439 FT_UINT8, BASE_DEC, VALS(siii_mst_channel_text), 0x80,
1440 NULL, HFILL }
1442 { &hf_siii_mst_type,
1443 { "Telegram Type", "siii.type",
1444 FT_UINT8, BASE_DEC, VALS(siii_mst_type_text), 0x40,
1445 NULL, HFILL }
1447 { &hf_siii_mst_cyclecntvalid,
1448 { "Cycle Count Valid", "siii.cyclecntvalid",
1449 FT_BOOLEAN, 8, TFS(&tfs_valid_invalid), 0x20,
1450 NULL, HFILL }
1452 { &hf_siii_mst_telno,
1453 { "Telegram Number", "siii.telno",
1454 FT_UINT8, BASE_DEC, NULL, 0x0F,
1455 NULL, HFILL }
1457 { &hf_siii_mst_phase,
1458 { "Phase", "siii.mst.phase",
1459 FT_UINT8, BASE_HEX, VALS(siii_mst_phase_text), 0x8F, /* CHANGED: SB: new value is 0x8F for masking out phase */
1460 NULL, HFILL }
1462 { &hf_siii_mst_cyclecnt,
1463 { "Cycle Cnt", "siii.mst.cyclecnt",
1464 FT_UINT8, BASE_DEC, NULL, 0x70, /* CHANGED: SB: new value is 0x70 for masking out cycle cnt */
1465 NULL, HFILL }
1467 { &hf_siii_mst_crc32,
1468 { "CRC32", "siii.mst.crc32",
1469 FT_UINT32, BASE_HEX, NULL, 0,
1470 NULL, HFILL }
1473 { &hf_siii_mdt_hotplug_address,
1474 {"Sercos address", "siii.mdt.hp.sercosaddress",
1475 FT_UINT16, BASE_HEX, NULL, 0,
1476 NULL, HFILL }
1478 { &hf_siii_mdt_hp_ctrl,
1479 {"HP control", "siii.mdt.hp.ctrl",
1480 FT_UINT16, BASE_HEX, NULL, 0,
1481 NULL, HFILL }
1483 { &hf_siii_mdt_hp_info,
1484 {"HP info", "siii.mdt.hp.info",
1485 FT_BYTES, BASE_NONE, NULL, 0,
1486 NULL, HFILL }
1488 { &hf_siii_at_hotplug_address,
1489 {"Sercos address", "siii.at.hp.sercosaddress",
1490 FT_UINT16, BASE_HEX, NULL, 0,
1491 NULL, HFILL }
1493 { &hf_siii_at_hp_stat,
1494 {"HP status", "siii.mdt.hp.stat",
1495 FT_UINT16, BASE_HEX, NULL, 0,
1496 NULL, HFILL }
1498 { &hf_siii_at_hp_info,
1499 {"HP info", "siii.at.hp.info",
1500 FT_BYTES, BASE_NONE, NULL, 0,
1501 NULL, HFILL }
1503 { &hf_siii_mdt_hotplug_control_param,
1504 {"Parameter", "siii.mdt.hp.parameter",
1505 FT_UINT16, BASE_DEC | BASE_EXT_STRING, &siii_mdt_hotplug_control_functioncode_text_ext, 0xFF,
1506 NULL, HFILL }
1508 { &hf_siii_mdt_hotplug_control_svc_switch,
1509 {"Switch to SVC", "siii.mdt.hp.switch",
1510 FT_UINT16, BASE_DEC, VALS(siii_mdt_hotplug_control_svc_switch_text), 0x0100,
1511 NULL, HFILL }
1514 { &hf_siii_at_hotplug_status_param,
1515 {"Parameter Received", "siii.at.hp.parameter",
1516 FT_UINT16, BASE_DEC, VALS(siii_mdt_hotplug_status_ackcode_text), 0x00FF,
1517 NULL, HFILL }
1519 { &hf_siii_at_hotplug_status_hp0_finished,
1520 {"HP/SVC", "siii.at.hp.hp0_finished",
1521 FT_UINT16, BASE_DEC, NULL, 0x0100,
1522 NULL, HFILL }
1524 { &hf_siii_at_hotplug_status_error,
1525 {"Error", "siii.at.hp.error",
1526 FT_UINT16, BASE_DEC, VALS(siii_at_hotplug_status_error_text), 0x0200,
1527 NULL, HFILL }
1529 { &hf_siii_service_channels,
1530 {"Service Channels", "siii.service_channels",
1531 FT_NONE, BASE_NONE, NULL, 0x0,
1532 NULL, HFILL }
1534 { &hf_siii_device_controls,
1535 {"Device Controls", "siii.device_controls",
1536 FT_NONE, BASE_NONE, NULL, 0x0,
1537 NULL, HFILL }
1539 { &hf_siii_device_status,
1540 {"Device Status", "siii.device_status",
1541 FT_NONE, BASE_NONE, NULL, 0x0,
1542 NULL, HFILL }
1544 { &hf_siii_idn_code,
1545 {"IDN code", "siii.idn_code",
1546 FT_UINT32, BASE_CUSTOM, CF_FUNC(sercosiii_idn_code_format), 0x0,
1547 NULL, HFILL }
1549 { &hf_siii_at_cp0_num_devices,
1550 {"Number of Devices", "siii.at.cp0.num_devices",
1551 FT_UINT16, BASE_DEC, NULL, 0x0,
1552 NULL, HFILL }
1554 { &hf_siii_at_cp0_sercos_address,
1555 {"Sercos Address", "siii.at.cp0.sercos_address",
1556 FT_UINT16, BASE_DEC, NULL, 0x0,
1557 NULL, HFILL }
1561 /* Setup protocol subtree array */
1562 static int *ett[] = {
1563 &ett_siii,
1564 &ett_siii_header,
1566 &ett_siii_mdt,
1567 &ett_siii_mdt_version,
1568 &ett_siii_mdt_svc,
1569 &ett_siii_mdt_devctrls,
1570 &ett_siii_mdt_svc_channel,
1571 &ett_siii_mdt_dev_control,
1573 &ett_siii_at,
1574 &ett_siii_at_svc,
1575 &ett_siii_at_sercos_address,
1576 &ett_siii_at_devstats,
1577 &ett_siii_at_svc_channel,
1578 &ett_siii_at_dev_status,
1580 &ett_siii_mdt_devctrl,
1581 &ett_siii_at_devstatus,
1582 &ett_siii_at_sercosaddress,
1584 &ett_siii_mdt_svcctrl,
1585 &ett_siii_mdt_svcinfo,
1586 &ett_siii_at_svcstat,
1587 &ett_siii_at_svcinfo,
1588 &ett_siii_mdt_svch_data_error_info,
1589 &ett_siii_mdt_svch_data,
1591 &ett_siii_mst,
1592 &ett_siii_mst_teltype,
1593 &ett_siii_mst_phase,
1595 &ett_siii_mdt_hp,
1596 &ett_siii_at_hp,
1597 &ett_siii_mdt_hp_ctrl,
1598 &ett_siii_mdt_hp_info,
1599 &ett_siii_at_hp_stat,
1600 &ett_siii_at_hp_info,
1601 &ett_siii_recognized_devices
1604 static ei_register_info ei[] = {
1605 { &ei_siii_cp_unknown, { "siii.cp_unknown", PI_PROTOCOL, PI_WARN, "CP is unknown", EXPFILL }},
1608 expert_module_t* expert_siii;
1610 /* Register the protocol name and description */
1611 proto_siii = proto_register_protocol("SERCOS III V1.1",
1612 "SERCOS III V1.1", "siii");
1614 siii_handle = register_dissector("sercosiii", dissect_siii, proto_siii);
1616 /* subdissector code */
1617 heur_subdissector_list = register_heur_dissector_list_with_description("sercosiii", "SERCOS III payload pre-check", proto_siii);
1619 /* Required function calls to register the header fields and subtrees used */
1620 proto_register_field_array(proto_siii, hf, array_length(hf));
1621 proto_register_subtree_array(ett, array_length(ett));
1622 expert_siii = expert_register_protocol(proto_siii);
1623 expert_register_field_array(expert_siii, ei, array_length(ei));
1626 void
1627 proto_reg_handoff_sercosiii(void)
1629 dissector_add_uint("ethertype", ETHERTYPE_SERCOS, siii_handle);
1633 * Editor modelines
1635 * Local Variables:
1636 * c-basic-offset: 2
1637 * tab-width: 8
1638 * indent-tabs-mode: nil
1639 * End:
1641 * ex: set shiftwidth=2 tabstop=8 expandtab:
1642 * :indentSize=2:tabSize=8:noTabs=true: