Coverage Report

Created: 2025-02-15 06:25

/src/wireshark/epan/dissectors/packet-sercosiii.c
Line
Count
Source (jump to first uncovered line)
1
/* packet-sercosiii.c
2
 * Routines for SERCOS III dissection
3
 *
4
 * Initial plugin code by,
5
 * Bosch Rexroth
6
 * Hilscher
7
 *
8
 * Hans-Peter Bock <hpbock@avaapgh.de>
9
 *
10
 * Convert to built-in dissector
11
 *   Michael Mann * Copyright 2011
12
 *
13
 * Wireshark - Network traffic analyzer
14
 * By Gerald Combs <gerald@wireshark.org>
15
 * Copyright 1998 Gerald Combs
16
 *
17
 * SPDX-License-Identifier: GPL-2.0-or-later
18
 */
19
20
#include "config.h"
21
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>
27
28
0
#define MAX_SERCOS_DEVICES (512)
29
14
#define MAX_SERCOS_ADDRESS (511)
30
240
#define SERCOS_SLAVE_GROUP_SIZE (128)
31
32
1
#define COMMUNICATION_PHASE_0 (0x0)
33
40
#define COMMUNICATION_PHASE_1 (0x1)
34
40
#define COMMUNICATION_PHASE_2 (0x2)
35
0
#define COMMUNICATION_PHASE_3 (0x3)
36
5
#define COMMUNICATION_PHASE_4 (0x4)
37
38
void proto_register_sercosiii(void);
39
void proto_reg_handoff_sercosiii(void);
40
41
static dissector_handle_t siii_handle;
42
43
/* Initialize the protocol and registered fields */
44
static int proto_siii;
45
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;
80
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;
144
145
static expert_field ei_siii_cp_unknown;
146
147
148
/* Allow heuristic dissection */
149
static heur_dissector_list_t heur_subdissector_list;
150
151
static const value_string siii_mdt_version_num_mdtat_cp1_2_text[]=
152
{
153
  {0x00, "2 MDTs/ATs in CP1/2"},
154
  {0x01, "4 MDTs/ATs in CP1/2"},
155
  {0, NULL}
156
};
157
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"
161
};
162
163
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"
167
};
168
169
static const true_false_string siii_mdt_version_initprocvers_text = {
170
  "No remote address allocation",
171
  "Remote address allocation"
172
};
173
174
#if 0
175
static const value_string siii_svch_data_proccmd_proccmdexec_text[]=
176
{
177
  {0, "Interrupt procedure command execution"},
178
  {1, "Enable procedure command execution"},
179
  {0, NULL}
180
};
181
182
static const value_string siii_svch_data_proccmd_proccmd_text[]=
183
{
184
  {0, "Cancel procedure command"},
185
  {1, "Set procedure command"},
186
  {0, NULL}
187
};
188
189
static const value_string siii_svch_data_mdt_at_text[]=
190
{
191
  {0, "AT-telegram"},
192
  {1, "MDT-telegram"},
193
  {0, NULL}
194
};
195
#endif
196
197
#define IDN(SI, SE, type, paramset, datablock) ((SI<<24)|(SE<<16)|(type<<15)|(paramset<<12)|(datablock))
198
199
static const value_string siii_mdt_idn_text[]=
200
{
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}
595
};
596
static value_string_ext siii_mdt_idn_text_ext = VALUE_STRING_EXT_INIT(siii_mdt_idn_text);
597
598
static const value_string siii_mdt_svch_dbe_text[]=
599
{
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}
609
};
610
611
static const true_false_string siii_mdt_svch_eot_text = {
612
  "Transmission in progress",
613
  "Last transmission"
614
};
615
616
static const true_false_string siii_mdt_svch_rw_text = {
617
  "Read SVC INFO",
618
  "Write SVC INFO"
619
};
620
621
static const value_string siii_mdt_devcontrol_topcontrol_text[]=
622
{
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}
627
};
628
629
static const true_false_string siii_at_svch_error_text = {
630
  "No error",
631
  "Error in SVC"
632
};
633
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"
637
};
638
639
640
static const value_string siii_mst_phase_text[]=
641
{
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}
653
};
654
655
#if 0
656
static const value_string siii_mst_teltype_text[]=
657
{
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}
669
};
670
#endif
671
672
static const value_string siii_mst_channel_text[]=
673
{
674
  {0x00, "P-Telegram"},
675
  {0x01, "S-Telegram"},
676
  {0, NULL}
677
};
678
679
static const value_string siii_mst_type_text[]=
680
{
681
  {0x00, "MDT"},
682
  {0x01, "AT"},
683
  {0, NULL}
684
};
685
686
static const value_string siii_at_devstatus_errorconnection_text[]=
687
{
688
  {0x00, "Error-free connection"},
689
  {0x01, "Error in the connection occurs"},
690
  {0, NULL}
691
};
692
693
static const value_string siii_at_devstatus_topstatus_text[]=
694
{
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}
699
};
700
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"
704
};
705
706
static const value_string siii_at_devstatus_inactiveportstatus_text[]=
707
{
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}
713
};
714
715
static const value_string siii_at_dev_status_proc_command_change_text[]=
716
{
717
  {0x00, "No change in procedure command acknowledgement"},
718
  {0x01, "Changing procedure command acknowledgement"},
719
  {0, NULL}
720
};
721
722
723
static const value_string siii_mdt_hotplug_control_functioncode_text[]=
724
{
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}
745
};
746
static value_string_ext siii_mdt_hotplug_control_functioncode_text_ext =
747
    VALUE_STRING_EXT_INIT(siii_mdt_hotplug_control_functioncode_text);
748
749
static const value_string siii_mdt_hotplug_control_svc_switch_text[]=
750
{
751
  {0, "Transmission via HP-field"},
752
  {1, "Switch to SVC"},
753
  {0, NULL}
754
};
755
756
static const value_string siii_mdt_hotplug_status_ackcode_text[]=
757
{
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}
764
};
765
766
static const value_string siii_at_hotplug_status_error_text[]=
767
{
768
  {0, "Acknowledgement in HP-1"},
769
  {1, "Error in HP-1"},
770
  {0, NULL}
771
};
772
773
774
775
776
777
static void dissect_siii_mst(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
778
59
{
779
59
  proto_tree *subtree;
780
59
  proto_tree *subtree2;
781
782
59
  subtree = proto_tree_add_subtree(tree, tvb, 0, 6, ett_siii_mst, NULL, "MST");
783
784
59
  subtree2 = proto_tree_add_subtree(subtree, tvb, 0, 1, ett_siii_mst_teltype, NULL, "Telegram Type");
785
786
59
  proto_tree_add_item(subtree2, hf_siii_mst_channel,       tvb, 0, 1, ENC_LITTLE_ENDIAN);
787
59
  proto_tree_add_item(subtree2, hf_siii_mst_type,          tvb, 0, 1, ENC_LITTLE_ENDIAN);
788
59
  proto_tree_add_item(subtree2, hf_siii_mst_cyclecntvalid, tvb, 0, 1, ENC_LITTLE_ENDIAN);
789
59
  proto_tree_add_item(subtree2, hf_siii_mst_telno,         tvb, 0, 1, ENC_LITTLE_ENDIAN);
790
791
59
  subtree2 = proto_tree_add_subtree(subtree, tvb, 1, 1, ett_siii_mst_phase, NULL, "Phase Field");
792
793
59
  proto_tree_add_item(subtree2, hf_siii_mst_phase,    tvb, 1, 1, ENC_LITTLE_ENDIAN);
794
59
  proto_tree_add_item(subtree2, hf_siii_mst_cyclecnt, tvb, 1, 1, ENC_LITTLE_ENDIAN);
795
59
  proto_tree_add_item(subtree, hf_siii_mst_crc32,     tvb, 2, 4, ENC_LITTLE_ENDIAN);
796
797
59
}
798
799
static void dissect_siii_mdt_hp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
800
0
{
801
0
  proto_tree *subtree;
802
803
0
  static int * const ctrl_fields[] = {
804
0
    &hf_siii_mdt_hotplug_control_svc_switch,
805
0
    &hf_siii_mdt_hotplug_control_param,
806
0
    NULL
807
0
  };
808
809
0
  subtree = proto_tree_add_subtree(tree, tvb, 0, 8, ett_siii_mdt_hp, NULL, "Hot-Plug");
810
811
0
  proto_tree_add_item(subtree, hf_siii_mdt_hotplug_address, tvb, 0, 2, ENC_LITTLE_ENDIAN);
812
813
0
  proto_tree_add_bitmask(subtree, tvb, 2, hf_siii_mdt_hp_ctrl,
814
0
                                   ett_siii_mdt_hp_ctrl, ctrl_fields, ENC_LITTLE_ENDIAN);
815
816
0
  proto_tree_add_item(subtree, hf_siii_mdt_hp_info, tvb, 4, 4, ENC_NA);
817
0
}
818
819
static void dissect_siii_mdt_devctrl(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
820
0
{
821
0
  static int * const ctrl_fields[] = {
822
0
    &hf_siii_at_dev_control_ident,
823
0
    &hf_siii_mdt_dev_control_change_topology,
824
0
    &hf_siii_mdt_dev_control_top_control,
825
0
    NULL
826
0
  };
827
828
0
  proto_tree_add_bitmask(tree, tvb, 0, hf_siii_mdt_dev_control,
829
0
                                   ett_siii_mdt_devctrl, ctrl_fields, ENC_LITTLE_ENDIAN);
830
0
}
831
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 */
833
40
{
834
40
  proto_tree *subtree;
835
40
  proto_item *ti;
836
837
40
  static int * const svch_fields[] = {
838
40
    &hf_siii_mdt_svch_dbe, /* data block element */
839
40
    &hf_siii_mdt_svch_eot, /* end of transmission */
840
40
    &hf_siii_mdt_svch_rw,  /* read or write */
841
40
    &hf_siii_mdt_svch_mhs, /* master hand shake */
842
40
    NULL
843
40
  };
844
845
40
  uint16_t svc_ctrl = tvb_get_letohs(tvb, 0); /* service channel header */
846
40
  uint8_t svc_dbe  = (svc_ctrl>>3) & 7;      /* accessed data block element */
847
848
40
  proto_tree_add_bitmask(tree, tvb, 0, hf_siii_mdt_svch_ctrl,
849
40
                                   ett_siii_mdt_svcctrl, svch_fields, ENC_LITTLE_ENDIAN);
850
851
40
  ti = proto_tree_add_item(tree, hf_siii_mdt_svch_info, tvb, 2, 4, ENC_NA);
852
853
40
  if (1 == svc_dbe)
854
0
  {
855
0
    subtree = proto_item_add_subtree(ti, ett_siii_mdt_svcinfo);
856
0
    proto_tree_add_item(subtree, hf_siii_idn_code, tvb, 2, 4, ENC_LITTLE_ENDIAN);
857
0
    proto_tree_add_item(subtree, hf_siii_mdt_svch_idn, tvb, 2, 4, ENC_LITTLE_ENDIAN);
858
0
  }
859
40
}
860
861
static void dissect_siii_mdt_cp0(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
862
1
{
863
1
  static int * const version_fields[] = {
864
1
    &hf_siii_mdt_version_switch_off_sercos_telegrams,
865
1
    &hf_siii_mdt_version_fast_cp_switch,
866
1
    &hf_siii_mdt_version_transmission_of_communication_parameters_mdt0_cp0,
867
1
    &hf_siii_mdt_version_num_mdt_at_cp1_2,
868
1
    &hf_siii_mdt_version_initprocvers,
869
1
    NULL
870
1
  };
871
872
1
  proto_tree_add_bitmask(tree, tvb, 0, hf_siii_mdt_version,
873
1
                                   ett_siii_mdt_version, version_fields, ENC_LITTLE_ENDIAN);
874
1
}
875
876
static void dissect_siii_mdt_cp1_2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned telno)
877
40
{
878
40
  unsigned  devstart = telno * SERCOS_SLAVE_GROUP_SIZE; /* MDT0: slaves 0-127; MDT1: slaves 128-255; ... */
879
40
  tvbuff_t *tvb_n;
880
881
40
  unsigned idx;
882
40
  proto_tree *subtree;
883
40
  proto_tree *subtree_svc;
884
40
  proto_tree *subtree_devctrl;
885
886
40
  subtree_svc = proto_tree_add_subtree(tree, tvb, 0, SERCOS_SLAVE_GROUP_SIZE * 6, ett_siii_mdt_svc, NULL, "Service Channels");
887
888
40
  subtree_devctrl = proto_tree_add_subtree(tree, tvb, SERCOS_SLAVE_GROUP_SIZE * 6, 512, ett_siii_mdt_svc, NULL, "Device Control");
889
890
80
  for (idx = 0; idx < SERCOS_SLAVE_GROUP_SIZE; ++idx) /* each MDT of CP1/2 has data for 128 different slaves */
891
40
  {
892
40
    tvb_n = tvb_new_subset_length(tvb, 6 * idx, 6); /* subset for service channel data */
893
894
40
    subtree = proto_tree_add_subtree_format(subtree_svc, tvb_n, 0, 6, ett_siii_mdt_svc_channel, NULL, "Device %u", idx + devstart);
895
40
    dissect_siii_mdt_svc(tvb_n, pinfo, subtree, idx + devstart);
896
897
40
    tvb_n = tvb_new_subset_length(tvb, SERCOS_SLAVE_GROUP_SIZE * 6 + 4 * idx, 2); /* subset for device control information */
898
899
40
    subtree = proto_tree_add_subtree_format(subtree_devctrl, tvb_n, 0, 2, ett_siii_mdt_dev_control, NULL, "Device %u", idx + devstart);
900
901
40
    dissect_siii_mdt_devctrl(tvb_n, pinfo, subtree);
902
40
  }
903
40
}
904
905
static void dissect_siii_mdt_cp3_4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned telno)
906
0
{
907
  /* unsigned devstart _U_ = telno * SERCOS_SLAVE_GROUP_SIZE; */
908
909
0
  if (0 == telno) /* dissect hotplug field in MDT0 only */
910
0
    dissect_siii_mdt_hp(tvb, pinfo, tree);
911
912
  /* offsets of service channel, device status and connections are unknown
913
   * this data could be extracted from svc communication during CP2
914
   */
915
0
  proto_tree_add_item(tree, hf_siii_service_channels, tvb, 0, 0, ENC_NA);
916
917
0
  proto_tree_add_item(tree, hf_siii_device_controls, tvb, 0, 0, ENC_NA);
918
0
}
919
920
static void dissect_siii_mdt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
921
48
{
922
48
  proto_tree *subtree;
923
48
  tvbuff_t   *tvb_n;
924
925
48
  unsigned    t_phase;
926
48
  unsigned    telno;
927
928
48
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "SIII MDT");
929
930
48
  t_phase = (tvb_get_uint8(tvb, 1)&0x8F); /* read communication phase out of SERCOS III header */
931
48
  telno   = (tvb_get_uint8(tvb, 0) & 0xF); /* read number of MDT out of SERCOS III header */
932
933
48
  if (t_phase & 0x80) /* communication phase switching in progress */
934
0
  {
935
0
    col_append_fstr(pinfo->cinfo, COL_INFO, " Phase=CP?s -> CP%u",
936
0
          (t_phase&0x0f));
937
0
  }
938
48
  else /* communication as usual */
939
48
  {
940
48
    col_append_fstr(pinfo->cinfo, COL_INFO, " Phase=CP%u",
941
48
          (t_phase&0x0f));
942
48
  }
943
944
48
  subtree = proto_tree_add_subtree_format(tree, tvb, 0, -1, ett_siii_mdt, NULL, "MDT%u", telno);
945
946
48
  dissect_siii_mst(tvb, pinfo, subtree); /* dissect SERCOS III header */
947
948
48
  switch (t_phase) /* call the MDT dissector depending on the current communication phase */
949
48
  {
950
1
  case COMMUNICATION_PHASE_0: /* CP0 */
951
1
    tvb_n = tvb_new_subset_length(tvb, 6, 40);
952
1
    dissect_siii_mdt_cp0(tvb_n, pinfo, subtree);
953
1
  break;
954
955
40
  case COMMUNICATION_PHASE_1: /* CP1 */
956
40
  case COMMUNICATION_PHASE_2: /* CP2 */
957
40
    tvb_n = tvb_new_subset_length(tvb, 6, 1280);
958
40
    dissect_siii_mdt_cp1_2(tvb_n, pinfo, subtree, telno);
959
40
  break;
960
961
0
  case COMMUNICATION_PHASE_3: /* CP3 */
962
0
  case COMMUNICATION_PHASE_4: /* CP4 */
963
0
    tvb_n = tvb_new_subset_remaining(tvb, 6);
964
0
    dissect_siii_mdt_cp3_4(tvb_n, pinfo, subtree, telno);
965
0
  break;
966
967
7
  default:
968
7
    proto_tree_add_expert(tree, pinfo, &ei_siii_cp_unknown, tvb, 6, -1);
969
48
  }
970
48
}
971
972
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 */
974
0
{
975
0
  static int * const svch_fields[] = {
976
0
    &hf_siii_at_svch_valid,
977
0
    &hf_siii_at_svch_error,
978
0
    &hf_siii_at_svch_busy,
979
0
    &hf_siii_at_svch_ahs,
980
0
    NULL
981
0
  };
982
983
0
  proto_tree_add_bitmask(tree, tvb, 0, hf_siii_at_svch_stat,
984
0
                                   ett_siii_at_svcstat, svch_fields, ENC_LITTLE_ENDIAN);
985
986
0
  proto_tree_add_item(tree, hf_siii_at_svch_info, tvb, 2, 4, ENC_NA);
987
0
}
988
989
static void dissect_siii_at_devstat(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
990
0
{
991
0
  static int * const status[] = {
992
0
    &hf_siii_at_dev_status_commwarning,
993
0
    &hf_siii_at_dev_status_change_topology,
994
0
    &hf_siii_at_dev_status_top_status,
995
0
    &hf_siii_at_dev_status_inactive_port_status,
996
0
    &hf_siii_at_dev_status_errorconnection,
997
0
    &hf_siii_at_dev_status_slave_valid,
998
0
    &hf_siii_at_dev_status_proc_command_change,
999
0
    &hf_siii_at_dev_status_parameterization_level_active,
1000
0
    NULL
1001
0
  };
1002
1003
0
  proto_tree_add_bitmask(tree, tvb, 0, hf_siii_at_dev_status,
1004
0
                                   ett_siii_at_devstatus, status, ENC_LITTLE_ENDIAN);
1005
0
}
1006
1007
static void dissect_siii_at_hp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1008
0
{
1009
0
  proto_tree *subtree;
1010
1011
0
  static int * const status[] = {
1012
0
    &hf_siii_at_hotplug_status_error,
1013
0
    &hf_siii_at_hotplug_status_hp0_finished,
1014
0
    &hf_siii_at_hotplug_status_param,
1015
0
    NULL
1016
0
  };
1017
1018
0
  subtree = proto_tree_add_subtree(tree, tvb, 0, 8, ett_siii_at_hp, NULL, "Hot-Plug");
1019
1020
0
  proto_tree_add_item(subtree, hf_siii_at_hotplug_address,              tvb, 0, 2, ENC_LITTLE_ENDIAN);
1021
1022
0
  proto_tree_add_bitmask(subtree, tvb, 2, hf_siii_at_hp_stat, ett_siii_at_hp_stat, status, ENC_LITTLE_ENDIAN);
1023
1024
0
  proto_tree_add_item(subtree, hf_siii_at_hp_info,                      tvb, 4, 4, ENC_NA);
1025
0
}
1026
1027
static void dissect_siii_at_cp0(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1028
0
{
1029
0
  uint16_t    seqcnt;           /* sequence counter */
1030
0
  uint16_t    tfield;           /* topology field for sercos addresses */
1031
0
  uint16_t    i;
1032
0
  proto_tree *subtree, *subtree2;
1033
0
  proto_item* ti;
1034
1035
0
  subtree = proto_tree_add_subtree(tree, tvb, 0, 1024, ett_siii_recognized_devices, NULL, "Recognized Devices");
1036
1037
  /* check sequence count field */
1038
0
  seqcnt = tvb_get_letohs(tvb, 0);
1039
0
  proto_tree_add_uint(subtree, hf_siii_at_cp0_num_devices, tvb, 0, 2, (MAX_SERCOS_ADDRESS & seqcnt)-1);
1040
1041
  /* check SERCOS address of each topology field */
1042
0
  for (i = 1; i < MAX_SERCOS_DEVICES; ++i)
1043
0
  {
1044
0
    tfield = tvb_get_letohs(tvb, i*2);
1045
1046
0
    if (tfield == 0xFFFF)
1047
0
    {
1048
0
      proto_tree_add_uint_format(subtree, hf_siii_at_cp0_sercos_address, tvb, i*2, 2, 0xFFFF, "Sercos Address %u: No Device", i);
1049
0
    }
1050
0
    else
1051
0
    {
1052
0
      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
0
      subtree2  = proto_item_add_subtree(ti, ett_siii_at_sercos_address);
1054
0
      proto_tree_add_item(subtree2, hf_siii_at_cp0_support_functions,  tvb, i*2, 2, ENC_LITTLE_ENDIAN);
1055
0
      proto_tree_add_item(subtree2, hf_siii_at_cp0_device_address,     tvb, i*2, 2, ENC_LITTLE_ENDIAN);
1056
0
    }
1057
0
  }
1058
0
}
1059
1060
static void dissect_siii_at_cp1_2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned telno)
1061
0
{
1062
0
  unsigned  devstart = telno * SERCOS_SLAVE_GROUP_SIZE; /* AT0: slaves 0-127; AT1: slaves 128-255; ... */
1063
0
  tvbuff_t *tvb_n;
1064
1065
0
  unsigned idx;
1066
1067
0
  proto_tree *subtree;
1068
0
  proto_tree *subtree_svc;
1069
0
  proto_tree *subtree_devstat;
1070
1071
0
  subtree_svc = proto_tree_add_subtree(tree, tvb, 0, SERCOS_SLAVE_GROUP_SIZE * 6, ett_siii_at_svc, NULL, "Service Channel");
1072
1073
0
  subtree_devstat = proto_tree_add_subtree(tree, tvb, SERCOS_SLAVE_GROUP_SIZE * 6, 512, ett_siii_at_devstats, NULL, "Device Status");
1074
1075
0
  for (idx = 0; idx < SERCOS_SLAVE_GROUP_SIZE; ++idx) /* each AT of CP1/2 has data of 128 different slaves */
1076
0
  {
1077
0
    tvb_n = tvb_new_subset_length(tvb, 6 * idx, 6); /* subset for service channel data */
1078
1079
0
    subtree = proto_tree_add_subtree_format(subtree_svc, tvb_n, 0, 6, ett_siii_at_svc_channel, NULL, "Device %u", idx + devstart);
1080
0
    dissect_siii_at_svc(tvb_n, pinfo, subtree, idx + devstart);
1081
1082
0
    tvb_n = tvb_new_subset_length(tvb, SERCOS_SLAVE_GROUP_SIZE * 6 + 4 * idx, 2); /* subset for device status information */
1083
1084
0
    subtree = proto_tree_add_subtree_format(subtree_devstat, tvb_n, 0, 2, ett_siii_at_dev_status, NULL, "Device %u", idx + devstart);
1085
0
    dissect_siii_at_devstat(tvb_n, pinfo, subtree);
1086
0
  }
1087
0
}
1088
1089
static void dissect_siii_at_cp3_4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned telno)
1090
5
{
1091
5
  if (0 == telno) /* dissect hotplug field in AT0 only */
1092
0
    dissect_siii_at_hp(tvb, pinfo, tree);
1093
1094
  /* offsets of service channel, device status and connections are unknown
1095
   * this data could be extracted from svc communication during CP2
1096
   */
1097
5
  proto_tree_add_item(tree, hf_siii_service_channels, tvb, 0, 0, ENC_NA);
1098
5
  proto_tree_add_item(tree, hf_siii_device_status, tvb, 0, 0, ENC_NA);
1099
5
}
1100
1101
1102
static void dissect_siii_at(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1103
11
{
1104
11
  proto_tree *subtree;
1105
11
  tvbuff_t   *tvb_n;
1106
1107
11
  uint8_t     phase;
1108
11
  unsigned    telno;
1109
1110
11
  phase = (tvb_get_uint8(tvb, 1)&0x8F); /* read communication phase out of SERCOS III header*/
1111
11
  telno = (tvb_get_uint8(tvb, 0) & 0xF); /* read number of AT out of SERCOS III header */
1112
1113
11
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "SIII AT");
1114
1115
11
  if (phase & 0x80) /* communication phase switching in progress */
1116
0
  {
1117
0
    col_append_fstr(pinfo->cinfo, COL_INFO, " Phase=CP?s -> CP%u",
1118
0
          (phase&0x0f));
1119
0
  }
1120
11
  else /* communication as usual */
1121
11
  {
1122
11
     col_append_fstr(pinfo->cinfo, COL_INFO, " Phase=CP%u",
1123
11
          (phase&0x0f));
1124
11
  }
1125
1126
11
  subtree = proto_tree_add_subtree_format(tree, tvb, 0, -1, ett_siii_at, NULL, "AT%u", telno);
1127
1128
11
  dissect_siii_mst(tvb, pinfo, subtree); /* dissect SERCOS III header */
1129
1130
11
    switch (phase) /* call the AT dissector depending on the current communication phase */
1131
11
    {
1132
0
    case COMMUNICATION_PHASE_0: /* CP0 */
1133
0
      tvb_n = tvb_new_subset_length(tvb, 6, 1024);
1134
0
      dissect_siii_at_cp0(tvb_n, pinfo, subtree);
1135
0
    break;
1136
1137
0
    case COMMUNICATION_PHASE_1: /* CP1 */
1138
0
    case COMMUNICATION_PHASE_2: /* CP2 */
1139
0
      tvb_n = tvb_new_subset_length(tvb, 6, 1280);
1140
0
      dissect_siii_at_cp1_2(tvb_n, pinfo, subtree, telno);
1141
0
    break;
1142
1143
0
    case COMMUNICATION_PHASE_3: /* CP3 */
1144
5
    case COMMUNICATION_PHASE_4: /* CP4 */
1145
5
      tvb_n = tvb_new_subset_remaining(tvb, 6);
1146
5
      dissect_siii_at_cp3_4(tvb_n, pinfo, subtree, telno);
1147
5
    break;
1148
1149
6
    default:
1150
6
      proto_tree_add_expert(tree, pinfo, &ei_siii_cp_unknown, tvb, 6, -1);
1151
6
    break;
1152
11
    }
1153
11
}
1154
1155
/* Main dissector entry */
1156
static int
1157
dissect_siii(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
1158
59
{
1159
59
  proto_item *ti;
1160
59
  proto_tree *siii_tree;
1161
59
  unsigned    type;
1162
59
  const char *tel_ch;
1163
59
  const char *tel_type;
1164
59
  unsigned    tel_no   = 0;
1165
59
  heur_dtbl_entry_t *hdtbl_entry;
1166
1167
  /* setup columns */
1168
59
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "SERCOS III V1.1");
1169
59
  col_clear(pinfo->cinfo, COL_INFO);
1170
1171
  /*
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.
1175
   */
1176
59
  if (dissector_try_heuristic(heur_subdissector_list, tvb, pinfo, tree, &hdtbl_entry, NULL))
1177
0
    return tvb_captured_length(tvb);
1178
1179
  /* check what we got on our hand */
1180
59
  type = tvb_get_uint8(tvb, 0);
1181
59
  if (type & 0x80) /* primary or secondary channel */
1182
4
    tel_ch = "S";
1183
55
  else
1184
55
    tel_ch = "P";
1185
1186
59
  if (type & 0x40) /* master data telegram (mdt) or slave telegram (at) */
1187
11
    tel_type = "AT ";
1188
48
  else
1189
48
    tel_type = "MDT";
1190
1191
59
  tel_no = type &0xF; /* even though it's reserved (the V1.1 spec states that it is reserved for additional MDT/AT) */
1192
1193
59
  col_append_fstr(pinfo->cinfo, COL_INFO, "%s%u Channel=%s", tel_type, tel_no, tel_ch);
1194
1195
59
  ti = proto_tree_add_item(tree, proto_siii, tvb, 0, -1, ENC_NA);
1196
1197
59
  siii_tree = proto_item_add_subtree(ti, ett_siii);
1198
1199
   /* enter the specific dissector for AT or MDT */
1200
59
  if (type & 0x40)
1201
11
    dissect_siii_at(tvb, pinfo, siii_tree);
1202
48
  else
1203
48
    dissect_siii_mdt(tvb, pinfo, siii_tree);
1204
1205
59
  return tvb_captured_length(tvb);
1206
59
}
1207
1208
static void
1209
sercosiii_idn_code_format( char *result, uint32_t svc_info )
1210
0
{
1211
0
   snprintf( result, ITEM_LABEL_LENGTH, "%c-%u-%04d.%d.%d",
1212
0
       ((0xFFFF & svc_info)>>15)?'P':'S', /* private or sercos IDN */
1213
0
      (svc_info>>12)&7,                  /* parameter record */
1214
0
      (svc_info&4095),                   /* IDN */
1215
0
      (svc_info>>24) & 0xFF,             /* structure index */
1216
0
      (svc_info>>16) & 0xFF);            /* structure element */
1217
0
}
1218
1219
void
1220
proto_register_sercosiii(void)
1221
14
{
1222
14
  static hf_register_info hf[] = {
1223
1224
14
    { &hf_siii_mdt_version,
1225
14
      { "Communication Version", "siii.mdt.version",
1226
14
      FT_UINT32, BASE_HEX, NULL, 0,
1227
14
      NULL, HFILL }
1228
14
    },
1229
14
    { &hf_siii_mdt_version_num_mdt_at_cp1_2,
1230
14
      { "Number of MDTs and ATS in CP1 and CP2", "siii.mdt.version.num_mdt_at_cp1_2",
1231
14
      FT_UINT32, BASE_HEX, VALS(siii_mdt_version_num_mdtat_cp1_2_text), 0x00030000,
1232
14
      NULL, HFILL }
1233
14
    },
1234
14
    { &hf_siii_mdt_version_transmission_of_communication_parameters_mdt0_cp0,
1235
14
      { "Transmission of Communication parameters", "siii.mdt.version.mdt0_cp0_transm_comm_parameter",
1236
14
      FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00100000,
1237
14
      NULL, HFILL }
1238
14
    },
1239
14
    { &hf_siii_mdt_version_fast_cp_switch,
1240
14
      { "Fast CP switch", "siii.mdt.version.mdt0_cp0_fast_cp_switch",
1241
14
      FT_BOOLEAN, 32, TFS(&siii_mdt_version_fast_cp_switch_text), 0x00200000,
1242
14
      NULL, HFILL }
1243
14
    },
1244
1245
14
    { &hf_siii_mdt_version_switch_off_sercos_telegrams,
1246
14
      { "Switch off Sercos III telegrams", "siii.mdt.version.mdt0_cp0_switch_off_sercos_telegram",
1247
14
      FT_BOOLEAN, 32, TFS(&siii_switch_off_sercos_telegram_text), 0x00400000,
1248
14
      NULL, HFILL }
1249
14
    },
1250
14
    { &hf_siii_mdt_version_initprocvers,
1251
14
      { "Initialization Procedure Version Number", "siii.mdt.version.initprocvers",
1252
14
      FT_BOOLEAN, 32, TFS(&siii_mdt_version_initprocvers_text), 0x0000FF00,
1253
14
      NULL, HFILL }
1254
14
    },
1255
1256
14
    { &hf_siii_mdt_dev_control_top_control,
1257
14
      { "Topology Control", "siii.mdt.devcontrol.topcontrol",
1258
14
      FT_UINT16, BASE_DEC, VALS(siii_mdt_devcontrol_topcontrol_text), 3<<(12),
1259
14
      NULL, HFILL }
1260
14
    },
1261
14
    { &hf_siii_at_dev_control_ident,
1262
14
      { "Identification", "siii.mdt.devcontrol.identrequest",
1263
14
      FT_UINT16, BASE_DEC, NULL, 0x8000,
1264
14
      NULL, HFILL }
1265
14
    },
1266
14
    { &hf_siii_mdt_dev_control_change_topology,
1267
14
      { "Changing Topology", "siii.mdt.devcontrol.topologychange",
1268
14
      FT_UINT16, BASE_DEC, NULL, 1<<14,
1269
14
      NULL, HFILL }
1270
14
    },
1271
14
    { &hf_siii_mdt_dev_control,
1272
14
      { "Word", "siii.mdt.devcontrol",
1273
14
      FT_UINT16, BASE_DEC, NULL, 0,
1274
14
      NULL, HFILL }
1275
14
    },
1276
1277
14
    { &hf_siii_at_dev_status,
1278
14
      { "Word", "siii.at.devstatus",
1279
14
      FT_UINT16, BASE_HEX, NULL, 0,
1280
14
      NULL, HFILL }
1281
14
    },
1282
1283
14
    { &hf_siii_at_dev_status_commwarning,
1284
14
      { "Communication Warning", "siii.at.devstatus.commwarning",
1285
14
      FT_UINT16, BASE_DEC, NULL, 1<<15,
1286
14
      NULL, HFILL }
1287
14
    },
1288
1289
14
    { &hf_siii_at_cp0_support_functions,
1290
14
      { "Support of requested functions", "siii.at.supfunctions",
1291
14
      FT_BOOLEAN, 16, TFS(&siii_at_cp0_support_functions_text), 1<<15,
1292
14
      NULL, HFILL }
1293
14
    },
1294
1295
14
    { &hf_siii_at_cp0_device_address,
1296
14
      { "Sercos Address", "siii.at.sercosaddress",
1297
14
      FT_UINT16, BASE_DEC, NULL, MAX_SERCOS_ADDRESS,
1298
14
      NULL, HFILL }
1299
14
    },
1300
1301
14
    { &hf_siii_at_dev_status_change_topology,
1302
14
      { "Topology Change", "siii.at.devstatus.topologychanged",
1303
14
      FT_UINT16, BASE_DEC, NULL, 1<<14,
1304
14
      NULL, HFILL }
1305
14
    },
1306
14
    { &hf_siii_at_dev_status_top_status,
1307
14
      { "Topology Status", "siii.at.devstatus.topstatus",
1308
14
      FT_UINT16, BASE_DEC, VALS(siii_at_devstatus_topstatus_text), 0x3<<(12),
1309
14
      NULL, HFILL }
1310
14
    },
1311
14
    { &hf_siii_at_dev_status_inactive_port_status,
1312
14
      { "Port 1 Status", "siii.at.devstatus.inactportstatus",
1313
14
      FT_UINT16, BASE_DEC, VALS(siii_at_devstatus_inactiveportstatus_text), 0x3<<(10),
1314
14
      NULL, HFILL }
1315
14
    },
1316
14
    { &hf_siii_at_dev_status_errorconnection,
1317
14
      { "Topology Status", "siii.at.devstatus.errorconnection",
1318
14
      FT_UINT16, BASE_DEC, VALS(siii_at_devstatus_errorconnection_text), 1<<9,
1319
14
      NULL, HFILL }
1320
14
    },
1321
14
    { &hf_siii_at_dev_status_slave_valid,
1322
14
      { "Slave data valid", "siii.at.devstatus.slavevalid",
1323
14
      FT_UINT16, BASE_DEC, NULL, 1<<8,
1324
14
      NULL, HFILL }
1325
14
    },
1326
14
    { &hf_siii_at_dev_status_proc_command_change,
1327
14
      { "Procedure Command Change", "siii.at.devstatus.proccmdchange",
1328
14
      FT_UINT16, BASE_DEC, VALS(siii_at_dev_status_proc_command_change_text), 1<<5,
1329
14
      NULL, HFILL }
1330
14
    },
1331
14
    { &hf_siii_at_dev_status_parameterization_level_active,
1332
14
      { "Parameterization level active", "siii.at.devstatus.paralevelactive",
1333
14
      FT_UINT16, BASE_DEC, NULL, 1<<4,
1334
14
      NULL, HFILL }
1335
14
    },
1336
1337
14
    { &hf_siii_mdt_svch_ctrl,
1338
14
      {"SvcCtrl", "siii.mdt.svch.ctrl",
1339
14
      FT_UINT16, BASE_HEX, NULL, 0,
1340
14
      NULL, HFILL }
1341
14
    },
1342
14
    { &hf_siii_at_svch_stat,
1343
14
      {"SvcStat", "siii.mdt.svch.stat",
1344
14
      FT_UINT16, BASE_HEX, NULL, 0,
1345
14
      NULL, HFILL }
1346
14
    },
1347
14
    { &hf_siii_mdt_svch_info,
1348
14
      {"Svc Info", "siii.mdt.svch.info",
1349
14
      FT_BYTES, BASE_NONE, NULL, 0,
1350
14
      NULL, HFILL }
1351
14
    },
1352
14
    { &hf_siii_at_svch_info,
1353
14
      {"Svc Info", "siii.at.svch.info",
1354
14
      FT_BYTES, BASE_NONE, NULL, 0,
1355
14
      NULL, HFILL }
1356
14
    },
1357
14
    { &hf_siii_mdt_svch_idn,
1358
14
      {"IDN", "siii.mdt.svch.idn",
1359
14
      FT_UINT32, BASE_HEX | BASE_EXT_STRING, &siii_mdt_idn_text_ext, 0,
1360
14
      NULL, HFILL }
1361
14
    },
1362
14
    { &hf_siii_mdt_svch_dbe,
1363
14
      { "Data block element", "siii.mdt.svch.dbe",
1364
14
      FT_UINT16, BASE_DEC, VALS(siii_mdt_svch_dbe_text), 0x0038,
1365
14
      NULL, HFILL }
1366
14
    },
1367
14
    { &hf_siii_mdt_svch_eot,
1368
14
      {"End of element transmission", "siii.mdt.svch.eot",
1369
14
      FT_BOOLEAN, 16, TFS(&siii_mdt_svch_eot_text), 0x0004,
1370
14
      NULL, HFILL }
1371
14
    },
1372
14
    { &hf_siii_mdt_svch_rw,
1373
14
      {"Read/Write", "siii.mdt.svch.rw",
1374
14
      FT_BOOLEAN, 16, TFS(&siii_mdt_svch_rw_text), 0x0002,
1375
14
      NULL, HFILL }
1376
14
    },
1377
14
    { &hf_siii_mdt_svch_mhs,
1378
14
      {"Master Handshake", "siii.mdt.svch.mhs",
1379
14
      FT_UINT16, BASE_DEC, NULL, 0x0001,
1380
14
      NULL, HFILL }
1381
14
    },
1382
14
    { &hf_siii_at_svch_valid,
1383
14
      { "SVC process", "siii.mdt.svch.proc",
1384
14
      FT_BOOLEAN, 16, TFS(&tfs_valid_not_valid), 0x0008,
1385
14
      NULL, HFILL }
1386
14
    },
1387
14
    { &hf_siii_at_svch_error,
1388
14
      {"SVC Error", "siii.mdt.svch.error",
1389
14
      FT_BOOLEAN, 16, TFS(&siii_at_svch_error_text), 0x0004,
1390
14
      NULL, HFILL }
1391
14
    },
1392
14
    { &hf_siii_at_svch_busy,
1393
14
      {"Busy", "siii.mdt.svch.busy",
1394
14
      FT_BOOLEAN, 16, TFS(&siii_at_svch_busy_text), 0x0002,
1395
14
      NULL, HFILL }
1396
14
    },
1397
14
    { &hf_siii_at_svch_ahs,
1398
14
      {"Handshake", "siii.at.svch.ahs",
1399
14
      FT_UINT16, BASE_DEC, NULL, 0x01,
1400
14
      NULL, HFILL }
1401
14
    },
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 }
1407
    },
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 }
1414
    },
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 }
1421
    },
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 }
1428
    },
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 }
1435
    },
1436
#endif
1437
14
    { &hf_siii_mst_channel,
1438
14
      { "Channel", "siii.channel",
1439
14
        FT_UINT8, BASE_DEC, VALS(siii_mst_channel_text), 0x80,
1440
14
        NULL, HFILL }
1441
14
    },
1442
14
    { &hf_siii_mst_type,
1443
14
      { "Telegram Type", "siii.type",
1444
14
        FT_UINT8, BASE_DEC, VALS(siii_mst_type_text), 0x40,
1445
14
        NULL, HFILL }
1446
14
    },
1447
14
    { &hf_siii_mst_cyclecntvalid,
1448
14
      { "Cycle Count Valid", "siii.cyclecntvalid",
1449
14
        FT_BOOLEAN, 8, TFS(&tfs_valid_invalid), 0x20,
1450
14
        NULL, HFILL }
1451
14
    },
1452
14
    { &hf_siii_mst_telno,
1453
14
      { "Telegram Number", "siii.telno",
1454
14
        FT_UINT8, BASE_DEC, NULL, 0x0F,
1455
14
        NULL, HFILL }
1456
14
    },
1457
14
    { &hf_siii_mst_phase,
1458
14
      { "Phase", "siii.mst.phase",
1459
14
        FT_UINT8, BASE_HEX, VALS(siii_mst_phase_text), 0x8F,    /* CHANGED: SB: new value is 0x8F for masking out phase */
1460
14
        NULL, HFILL }
1461
14
    },
1462
14
    { &hf_siii_mst_cyclecnt,
1463
14
      { "Cycle Cnt", "siii.mst.cyclecnt",
1464
14
        FT_UINT8, BASE_DEC, NULL, 0x70,    /* CHANGED: SB: new value is 0x70 for masking out cycle cnt */
1465
14
        NULL, HFILL }
1466
14
    },
1467
14
    { &hf_siii_mst_crc32,
1468
14
      { "CRC32", "siii.mst.crc32",
1469
14
        FT_UINT32, BASE_HEX, NULL, 0,
1470
14
        NULL, HFILL }
1471
14
    },
1472
1473
14
    { &hf_siii_mdt_hotplug_address,
1474
14
      {"Sercos address", "siii.mdt.hp.sercosaddress",
1475
14
        FT_UINT16, BASE_HEX, NULL, 0,
1476
14
        NULL, HFILL }
1477
14
    },
1478
14
    { &hf_siii_mdt_hp_ctrl,
1479
14
      {"HP control", "siii.mdt.hp.ctrl",
1480
14
        FT_UINT16, BASE_HEX, NULL, 0,
1481
14
        NULL, HFILL }
1482
14
    },
1483
14
    { &hf_siii_mdt_hp_info,
1484
14
      {"HP info", "siii.mdt.hp.info",
1485
14
        FT_BYTES, BASE_NONE, NULL, 0,
1486
14
        NULL, HFILL }
1487
14
    },
1488
14
    { &hf_siii_at_hotplug_address,
1489
14
      {"Sercos address", "siii.at.hp.sercosaddress",
1490
14
        FT_UINT16, BASE_HEX, NULL, 0,
1491
14
        NULL, HFILL }
1492
14
    },
1493
14
    { &hf_siii_at_hp_stat,
1494
14
      {"HP status", "siii.mdt.hp.stat",
1495
14
        FT_UINT16, BASE_HEX, NULL, 0,
1496
14
        NULL, HFILL }
1497
14
    },
1498
14
    { &hf_siii_at_hp_info,
1499
14
      {"HP info", "siii.at.hp.info",
1500
14
        FT_BYTES, BASE_NONE, NULL, 0,
1501
14
        NULL, HFILL }
1502
14
    },
1503
14
    { &hf_siii_mdt_hotplug_control_param,
1504
14
      {"Parameter", "siii.mdt.hp.parameter",
1505
14
        FT_UINT16, BASE_DEC | BASE_EXT_STRING, &siii_mdt_hotplug_control_functioncode_text_ext, 0xFF,
1506
14
        NULL, HFILL }
1507
14
    },
1508
14
    { &hf_siii_mdt_hotplug_control_svc_switch,
1509
14
      {"Switch to SVC", "siii.mdt.hp.switch",
1510
14
      FT_UINT16, BASE_DEC, VALS(siii_mdt_hotplug_control_svc_switch_text), 0x0100,
1511
14
        NULL, HFILL }
1512
14
    },
1513
1514
14
    { &hf_siii_at_hotplug_status_param,
1515
14
      {"Parameter Received", "siii.at.hp.parameter",
1516
14
      FT_UINT16, BASE_DEC, VALS(siii_mdt_hotplug_status_ackcode_text), 0x00FF,
1517
14
        NULL, HFILL }
1518
14
    },
1519
14
    { &hf_siii_at_hotplug_status_hp0_finished,
1520
14
      {"HP/SVC", "siii.at.hp.hp0_finished",
1521
14
      FT_UINT16, BASE_DEC, NULL, 0x0100,
1522
14
        NULL, HFILL }
1523
14
    },
1524
14
    { &hf_siii_at_hotplug_status_error,
1525
14
      {"Error", "siii.at.hp.error",
1526
14
      FT_UINT16, BASE_DEC, VALS(siii_at_hotplug_status_error_text), 0x0200,
1527
14
        NULL, HFILL }
1528
14
    },
1529
14
    { &hf_siii_service_channels,
1530
14
      {"Service Channels", "siii.service_channels",
1531
14
        FT_NONE, BASE_NONE, NULL, 0x0,
1532
14
        NULL, HFILL }
1533
14
    },
1534
14
    { &hf_siii_device_controls,
1535
14
      {"Device Controls", "siii.device_controls",
1536
14
        FT_NONE, BASE_NONE, NULL, 0x0,
1537
14
        NULL, HFILL }
1538
14
    },
1539
14
    { &hf_siii_device_status,
1540
14
      {"Device Status", "siii.device_status",
1541
14
        FT_NONE, BASE_NONE, NULL, 0x0,
1542
14
        NULL, HFILL }
1543
14
    },
1544
14
    { &hf_siii_idn_code,
1545
14
      {"IDN code", "siii.idn_code",
1546
14
        FT_UINT32, BASE_CUSTOM, CF_FUNC(sercosiii_idn_code_format), 0x0,
1547
14
        NULL, HFILL }
1548
14
    },
1549
14
    { &hf_siii_at_cp0_num_devices,
1550
14
      {"Number of Devices", "siii.at.cp0.num_devices",
1551
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
1552
14
        NULL, HFILL }
1553
14
    },
1554
14
    { &hf_siii_at_cp0_sercos_address,
1555
14
      {"Sercos Address", "siii.at.cp0.sercos_address",
1556
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
1557
14
        NULL, HFILL }
1558
14
    },
1559
14
  };
1560
1561
  /* Setup protocol subtree array */
1562
14
  static int *ett[] = {
1563
14
    &ett_siii,
1564
14
    &ett_siii_header,
1565
1566
14
    &ett_siii_mdt,
1567
14
    &ett_siii_mdt_version,
1568
14
    &ett_siii_mdt_svc,
1569
14
    &ett_siii_mdt_devctrls,
1570
14
    &ett_siii_mdt_svc_channel,
1571
14
    &ett_siii_mdt_dev_control,
1572
1573
14
    &ett_siii_at,
1574
14
    &ett_siii_at_svc,
1575
14
    &ett_siii_at_sercos_address,
1576
14
    &ett_siii_at_devstats,
1577
14
    &ett_siii_at_svc_channel,
1578
14
    &ett_siii_at_dev_status,
1579
1580
14
    &ett_siii_mdt_devctrl,
1581
14
    &ett_siii_at_devstatus,
1582
14
    &ett_siii_at_sercosaddress,
1583
1584
14
    &ett_siii_mdt_svcctrl,
1585
14
    &ett_siii_mdt_svcinfo,
1586
14
    &ett_siii_at_svcstat,
1587
14
    &ett_siii_at_svcinfo,
1588
14
    &ett_siii_mdt_svch_data_error_info,
1589
14
    &ett_siii_mdt_svch_data,
1590
1591
14
    &ett_siii_mst,
1592
14
    &ett_siii_mst_teltype,
1593
14
    &ett_siii_mst_phase,
1594
1595
14
    &ett_siii_mdt_hp,
1596
14
    &ett_siii_at_hp,
1597
14
    &ett_siii_mdt_hp_ctrl,
1598
14
    &ett_siii_mdt_hp_info,
1599
14
    &ett_siii_at_hp_stat,
1600
14
    &ett_siii_at_hp_info,
1601
14
    &ett_siii_recognized_devices
1602
14
  };
1603
1604
14
  static ei_register_info ei[] = {
1605
14
    { &ei_siii_cp_unknown, { "siii.cp_unknown", PI_PROTOCOL, PI_WARN, "CP is unknown", EXPFILL }},
1606
14
  };
1607
1608
14
  expert_module_t* expert_siii;
1609
1610
  /* Register the protocol name and description */
1611
14
  proto_siii = proto_register_protocol("SERCOS III V1.1",
1612
14
      "SERCOS III V1.1", "siii");
1613
1614
14
  siii_handle = register_dissector("sercosiii", dissect_siii, proto_siii);
1615
1616
  /* subdissector code */
1617
14
  heur_subdissector_list = register_heur_dissector_list_with_description("sercosiii", "SERCOS III payload pre-check", proto_siii);
1618
1619
  /* Required function calls to register the header fields and subtrees used */
1620
14
  proto_register_field_array(proto_siii, hf, array_length(hf));
1621
14
  proto_register_subtree_array(ett, array_length(ett));
1622
14
  expert_siii = expert_register_protocol(proto_siii);
1623
14
  expert_register_field_array(expert_siii, ei, array_length(ei));
1624
14
}
1625
1626
void
1627
proto_reg_handoff_sercosiii(void)
1628
14
{
1629
14
  dissector_add_uint("ethertype", ETHERTYPE_SERCOS, siii_handle);
1630
14
}
1631
1632
/*
1633
 * Editor modelines
1634
 *
1635
 * Local Variables:
1636
 * c-basic-offset: 2
1637
 * tab-width: 8
1638
 * indent-tabs-mode: nil
1639
 * End:
1640
 *
1641
 * ex: set shiftwidth=2 tabstop=8 expandtab:
1642
 * :indentSize=2:tabSize=8:noTabs=true:
1643
 */