2 * Routines for Ether-S-Bus dissection
3 * Copyright 2010, Christian Durrer <christian.durrer@sensemail.ch>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include <epan/packet.h>
30 #include <epan/conversation.h>
31 #include <epan/emem.h>
32 #include <epan/expert.h>
35 #define SBUS_REQUEST 0x00
36 #define SBUS_RESPONSE 0x01
37 #define SBUS_ACKNAK 0x02
39 /*SBus command codes*/
40 #define SBUS_RD_COUNTER 0x00
41 #define SBUS_RD_DISPLAY_REGISTER 0x01
42 #define SBUS_RD_FLAG 0x02
43 #define SBUS_RD_INPUT 0x03
44 #define SBUS_RD_RTC 0x04
45 #define SBUS_RD_OUTPUT 0x05
46 #define SBUS_RD_REGISTER 0x06
47 #define SBUS_RD_TIMER 0x07
48 #define SBUS_WR_COUNTER 0x0A
49 #define SBUS_WR_FLAG 0x0B
50 #define SBUS_WR_RTC 0x0C
51 #define SBUS_WR_OUTPUT 0x0D
52 #define SBUS_WR_REGISTER 0x0E
53 #define SBUS_WR_TIMER 0x0F
54 #define SBUS_RDWR_MULTI_MEDIAS 0x13
55 #define SBUS_RD_PCD_STATUS_CPU0 0x14
56 #define SBUS_RD_PCD_STATUS_CPU1 0x15
57 #define SBUS_RD_PCD_STATUS_CPU2 0x16
58 #define SBUS_RD_PCD_STATUS_CPU3 0x17
59 #define SBUS_RD_PCD_STATUS_CPU4 0x18
60 #define SBUS_RD_PCD_STATUS_CPU5 0x19
61 #define SBUS_RD_PCD_STATUS_CPU6 0x1A
62 #define SBUS_RD_PCD_STATUS_OWN 0x1B
63 #define SBUS_RD_SBUS_STN_NBR 0x1D
64 #define SBUS_RD_USER_MEMORY 0x1E
65 #define SBUS_RD_PROGRAM_LINE 0x1F
66 #define SBUS_RD_PROGRAM_VERSION 0x20
67 #define SBUS_RD_TEXT 0x21
68 #define SBUS_RD_ACTIVE_TRANSITION 0x22
69 #define SBUS_WR_USER_MEMORY 0x23
70 #define SBUS_WR_PROGRAM_LINE 0x24
71 #define SBUS_WR_TEXT 0x25
72 #define SBUS_RUN_PROCEDURE_CPU0 0x28
73 #define SBUS_RUN_PROCEDURE_CPU1 0x29
74 #define SBUS_RUN_PROCEDURE_CPU2 0x2A
75 #define SBUS_RUN_PROCEDURE_CPU3 0x2B
76 #define SBUS_RUN_PROCEDURE_CPU4 0x2C
77 #define SBUS_RUN_PROCEDURE_CPU5 0x2D
78 #define SBUS_RUN_PROCEDURE_CPU6 0x2E
79 #define SBUS_RUN_PROCEDURE_OWN 0x2F
80 #define SBUS_RUN_PROCEDURE_ALL 0x30
81 #define SBUS_RESTART_COLD_CPU1 0x32
82 #define SBUS_RESTART_COLD_CPU2 0x33
83 #define SBUS_RESTART_COLD_CPU3 0x34
84 #define SBUS_RESTART_COLD_CPU4 0x35
85 #define SBUS_RESTART_COLD_CPU5 0x36
86 #define SBUS_RESTART_COLD_CPU6 0x37
87 #define SBUS_RESTART_COLD_OWN 0x38
88 #define SBUS_RESTART_COLD_ALL 0x39
89 #define SBUS_STOP_PROCEDURE_CPU0 0x3C
90 #define SBUS_STOP_PROCEDURE_CPU1 0x3D
91 #define SBUS_STOP_PROCEDURE_CPU2 0x3E
92 #define SBUS_STOP_PROCEDURE_CPU3 0x3F
93 #define SBUS_STOP_PROCEDURE_CPU4 0x40
94 #define SBUS_STOP_PROCEDURE_CPU5 0x41
95 #define SBUS_STOP_PROCEDURE_CPU6 0x42
96 #define SBUS_STOP_PROCEDURE_OWN 0x43
97 #define SBUS_STOP_PROCEDURE_ALL 0x44
98 #define SBUS_RD_STATUSFLAG_ACCU 0x46
99 #define SBUS_RD_BYTE 0x47
100 #define SBUS_RD_HALT_FAILURE_REG 0x48
101 #define SBUS_RD_INDEX_REGISTER 0x49
102 #define SBUS_RD_INSTRUCTION_POINTER 0x4A
103 #define SBUS_FIND_HISTORY 0x4B
104 #define SBUS_WR_STATUSFLAG_ACCU 0x50
105 #define SBUS_WR_BYTE 0x51
106 #define SBUS_WR_INDEX_REGISTER 0x52
107 #define SBUS_WR_INSTRUCTION_POINTER 0x53
108 #define SBUS_CLEAR_ALL 0x5A
109 #define SBUS_CLEAR_FLAGS 0x5B
110 #define SBUS_CLEAR_OUTPUTS 0x5C
111 #define SBUS_CLEAR_REGISTERS 0x5D
112 #define SBUS_CLEAR_TIMERS 0x5E
113 #define SBUS_RESTART_WARM_CPU1 0x64
114 #define SBUS_RESTART_WARM_CPU2 0x65
115 #define SBUS_RESTART_WARM_CPU3 0x66
116 #define SBUS_RESTART_WARM_CPU4 0x67
117 #define SBUS_RESTART_WARM_CPU5 0x68
118 #define SBUS_RESTART_WARM_CPU6 0x69
119 #define SBUS_RESTART_WARM_OWN 0x6A
120 #define SBUS_RESTART_WARM_ALL 0x6B
121 #define SBUS_CHANGE_BLOCK 0x6E
122 #define SBUS_CLEAR_HISTORY_FAILURE 0x6F
123 #define SBUS_DELETE_PROGRAM_LINE 0x70
124 #define SBUS_GO_CONDITIONAL 0x71
125 #define SBUS_INSERT_PROGRAM_LINE 0x72
126 #define SBUS_LOCAL_CYCLE 0x73
127 #define SBUS_ALL_CYCLES 0x74
128 #define SBUS_MAKE_TEXT 0x75
129 #define SBUS_EXECUTE_SINGLE_INSTR 0x76
130 #define SBUS_SINGLE_STEP 0x77
131 #define SBUS_XOB_17_INTERRUPT 0x82
132 #define SBUS_XOB_18_INTERRUPT 0x83
133 #define SBUS_XOB_19_INTERRUPT 0x84
134 #define SBUS_RD_HANGUP_TIMEOUT 0x91
135 #define SBUS_RD_DATA_BLOCK 0x96
136 #define SBUS_WR_DATA_BLOCK 0x97
137 #define SBUS_MAKE_DATA_BLOCK 0x98
138 #define SBUS_CLEAR_DATA_BLOCK 0x99
139 #define SBUS_CLEAR_TEXT 0x9A
140 #define SBUS_RD_BLOCK_ADDRESSES 0x9B
141 #define SBUS_RD_BLOCK_SIZES 0x9C
142 #define SBUS_RD_CURRENT_BLOCK 0x9D
143 #define SBUS_RD_CALL_STACK 0x9E
144 #define SBUS_RD_DBX 0x9F
145 #define SBUS_RD_USER_EEPROM_REGISTER 0xA1
146 #define SBUS_WR_USER_EEPROM_REGISTER 0xA3
147 #define SBUS_ERASE_FLASH 0xA5
148 #define SBUS_RESTART_COLD_FLAG 0xA6
149 #define SBUS_WR_SYSTEM_BUFFER 0xA7
150 #define SBUS_RD_SYSTEM_BUFFER 0xA8
151 #define SBUS_RD_WR_PCD_BLOCK 0xA9
152 #define SBUS_GET_DIAGNOSTIC 0xAA
153 #define SBUS_RD_SYSTEM_INFORMATION 0xAB
154 #define SBUS_CHANGE_BLOCKS_ON_RUN 0xAC
155 #define SBUS_FLASHCARD_TELEGRAM 0xAD
156 #define SBUS_DOWNLOAD_FIRMWARE 0xAE
157 #define SBUS_WEB_SERVER_SERIAL_COMM 0xAF
159 /* Bitfield in the arithmetic flags and accu*/
160 #define F_ACCU (1<<0) /* Accumulator of PCD */
161 #define F_ERROR (1<<1) /* Error flag of PCD */
162 #define F_NEGATIVE (1<<2) /* Negative arithmetic status flag */
163 #define F_ZERO (1<<3) /* Zero arithmetic status flag */
165 /* Bitfield in the system information*/
166 /*#define F_EMPTY (1<<0) always 0 */
167 #define F_MEMSIZE (1<<1) /* Memory size information */
168 #define F_TRACE (1<<2) /* Trace buffer feature */
169 #define F_INFO_B1 (1<<3) /* EEPROM information of slot B1 */
170 #define F_INFO_B2 (1<<4) /* EEPROM information of slot B2 */
171 #define F_PGU_BAUD (1<<5) /* PGU baudrate can be switched */
174 /* Read/write block command codes*/
175 #define SBUS_WR_START_OF_STREAM 0x00
176 #define SBUS_WR_BLOCK_DATA_STREAM 0x01
177 #define SBUS_WR_BLOCK_END_OF_STREAM 0x02
178 #define SBUS_WR_ABORT_BLOCK_STREAM 0x07
179 #define SBUS_WR_BLOCK_DATA_BYTES 0x08
180 #define SBUS_RD_BLOCK_START_OF_STREAM 0X10
181 #define SBUS_RD_BLOCK_DATA_STREAM 0x11
182 #define SBUS_RD_ABORT_BLOCK_STREAM 0x17
183 #define SBUS_RD_BLOCK_DATA_BYTES 0x18
184 #define SBUS_DELETE_BLOCK 0x20
185 #define SBUS_GET_BLOCK_SIZE 0x21
186 #define SBUS_GET_PROGRAM_BLOCK_LIST 0x22
188 /* Read/write block types*/
189 #define SBUS_RD_WR_CONFIGURATION_FILE 0x20
190 #define SBUS_RD_WR_PROGRAM_BLOCK_FILE 0x21
191 #define SBUS_RD_WR_UNKNOWN_BLOCK_TYPE 0x83
193 /* Read/write block error codes*/
194 #define SBUS_RD_WR_NAK 0x80
195 #define SBUS_RD_WR_NAK_INVALID_SIZE 0x8A
197 /* Initialize the protocol and registered fields */
198 static int proto_sbus = -1;
199 static int hf_sbus_length = -1;
200 static int hf_sbus_version = -1;
201 static int hf_sbus_protocol = -1;
202 static int hf_sbus_sequence = -1;
203 static int hf_sbus_attribut = -1;
204 static int hf_sbus_dest = -1;
205 static int hf_sbus_address = -1;
206 static int hf_sbus_command = -1;
207 static int hf_sbus_command_extension = -1;
208 static int hf_sbus_rcount = -1;
209 static int hf_sbus_wcount = -1;
210 static int hf_sbus_wcount_calculated = -1;
211 static int hf_sbus_fio_count = -1;
212 static int hf_sbus_addr_rtc = -1;
213 static int hf_sbus_addr_iof = -1;
214 static int hf_sbus_addr_eeprom = -1;
215 static int hf_sbus_addr_prog = -1;
216 static int hf_sbus_addr_68k = -1;
217 static int hf_sbus_block_type = -1;
218 static int hf_sbus_block_nr = -1;
219 static int hf_sbus_nbr_elements = -1;
220 static int hf_sbus_display_register = -1;
221 static int hf_sbus_data_rtc = -1;
222 static int hf_sbus_data_byte = -1;
223 static int hf_sbus_data_byte_hex = -1;
224 static int hf_sbus_data_iof = -1;
225 static int hf_sbus_cpu_type = -1;
226 static int hf_sbus_fw_version = -1;
227 static int hf_sbus_sysinfo_nr = -1;
228 static int hf_sbus_sysinfo0_1 = -1;
229 static int hf_sbus_sysinfo0_2 = -1;
230 static int hf_sbus_sysinfo0_3 = -1;
231 static int hf_sbus_sysinfo0_4 = -1;
232 static int hf_sbus_sysinfo0_5 = -1;
233 static int hf_sbus_sysinfo_length = -1;
234 static int hf_sbus_f_module_type = -1;
235 static int hf_sbus_harware_version = -1;
236 static int hf_sbus_hardware_modification = -1;
237 static int hf_sbus_various = -1;
238 static int hf_sbus_acknackcode = -1;
239 static int hf_sbus_cpu_status = -1;
240 static int hf_sbus_week_day = -1;
241 static int hf_sbus_date = -1;
242 static int hf_sbus_time = -1;
243 static int hf_sbus_crc = -1;
244 static int hf_sbus_crc_bad = -1;
245 static int hf_sbus_retry = -1;
246 static int hf_sbus_flags_accu = -1;
247 static int hf_sbus_flags_error = -1;
248 static int hf_sbus_flags_negative = -1;
249 static int hf_sbus_flags_zero = -1;
250 /* Web server telegram */
251 static int hf_sbus_web_size = -1;
252 static int hf_sbus_web_aid = -1;
253 static int hf_sbus_web_seq = -1;
254 /* Read/Write block telegram*/
255 static int hf_sbus_rdwr_block_length = -1;
256 static int hf_sbus_rdwr_block_length_ext = -1;
257 static int hf_sbus_rdwr_telegram_type = -1;
258 static int hf_sbus_rdwr_telegram_sequence = -1;
259 static int hf_sbus_rdwr_block_size = -1;
260 static int hf_sbus_rdwr_block_addr = -1;
261 static int hf_sbus_rdwr_file_name = -1;
262 static int hf_sbus_rdwr_list_type = -1;
263 static int hf_sbus_rdwr_acknakcode = -1;
264 /* Request-Response tracking */
265 static int hf_sbus_response_in = -1;
266 static int hf_sbus_response_to = -1;
267 static int hf_sbus_response_time = -1;
268 static int hf_sbus_timeout = -1;
269 static int hf_sbus_request_in = -1;
271 /* Initialize the subtree pointers */
272 static gint ett_sbus = -1;
273 static gint ett_sbus_ether = -1;
274 static gint ett_sbus_data = -1;
276 /* True/False strings*/
277 static const true_false_string tfs_sbus_flags= {
282 static const true_false_string tfs_sbus_present= {
287 /* value to string definitions*/
289 static const value_string sbus_att_vals[] = {
296 static const value_string sbus_block_types[] = {
297 {0x00, "COB"}, /* Cyclic organization block */
298 {0x01, "XOB"}, /* Exception organization block */
299 {0x02, "PB"}, /* Program block */
300 {0x03, "FB"}, /* Function block */
301 {0x04, "ST"}, /* Step of Graftec structure*/
302 {0x05, "TR"}, /* Transition of Graftec structure*/
303 {0x04, "TEXT"}, /* Text*/
304 {0x05, "DB"}, /* Data Block*/
305 {0x08, "SB"}, /* Sequential Block (Graftec)*/
306 {0x09, "DBX"}, /* Special Data Block*/
307 {0x10, "BACnet"}, /* BACnet configuration block */
308 {0x11, "CANopen"}, /* CANopen configuration */
309 {0x12, "LONIP"}, /* LONIP configuration */
310 {0x20, "Configuration file"}, /* LONIP configuration */
311 {0x21, "Program block file"}, /* LONIP configuration */
312 {0xFE, "All configuration blocks"}, /* all configuration blocks (delete blocks only) */
313 {0xFF, "All blocks"}, /* all blocks (incl. program blocks) (delete blocks only) */
317 static const value_string sbus_CPU_status[] = {
323 {0x58, "X, Exceptional Intermediate Status (MODEMS+)"},
327 static const value_string sbus_ack_nak_vals[] = {
328 {0, "ACK (Acknowledged)"},
329 {1, "NAK, no reason specified"},
330 {2, "NAK, because of password"},
331 {3, "NAK, PGU port is in reduced protocol"},
332 {4, "NAK, PGU port is already used"},
336 static const value_string sbus_command_vals[] = {
337 {0x00, "Read counter(s)"},
338 {0x01, "Read display register"},
339 {0x02, "Read flag(s)"},
340 {0x03, "Read input(s)"},
341 {0x04, "Read real time clock"},
342 {0x05, "Read output(s)"},
343 {0x06, "Read register(s)"},
344 {0x07, "Read timer(s)"},
345 {0x0A, "Write counter(s)"},
346 {0x0B, "Write flag(s)"},
347 {0x0C, "Write real time clock"},
348 {0x0D, "Write output(s)"},
349 {0x0E, "Write register(s)"},
350 {0x0F, "Write timer(s)"},
351 {0x14, "Read PCD status, CPU 0"},
352 {0x15, "Read PCD status, CPU 1"},
353 {0x16, "Read PCD status, CPU 2"},
354 {0x17, "Read PCD status, CPU 3"},
355 {0x18, "Read PCD status, CPU 4"},
356 {0x19, "Read PCD status, CPU 5"},
357 {0x1A, "Read PCD status, CPU 6"},
358 {0x1B, "Read PCD status (own)"},
359 {0x1D, "Read S-Bus station number"},
360 {0x1E, "Read user memory*"},
361 {0x1F, "Read program line*"},
362 {0x20, "Read firmware version"},
363 {0x21, "Read text*"},
364 {0x22, "Read active transition*"},
365 {0x23, "Write user memory*"},
366 {0x24, "Write program line*"},
367 {0x25, "Write text*"},
368 {0x28, "Run procedure*, CPU 0"},
369 {0x29, "Run procedure*, CPU 1"},
370 {0x2A, "Run procedure*, CPU 2"},
371 {0x2B, "Run procedure*, CPU 3"},
372 {0x2C, "Run procedure*, CPU 4"},
373 {0x2D, "Run procedure*, CPU 5"},
374 {0x2E, "Run procedure*, CPU 6"},
375 {0x2F, "Run procedure* (own CPU)"},
376 {0x30, "Run procedure* (All CPUs)"},
377 {0x32, "Restart cold CPU 1*"},
378 {0x33, "Restart cold CPU 2*"},
379 {0x34, "Restart cold CPU 3*"},
380 {0x35, "Restart cold CPU 4*"},
381 {0x36, "Restart cold CPU 5*"},
382 {0x37, "Restart cold CPU 6*"},
383 {0x38, "Restart cold own CPU*"},
384 {0x39, "Restart cold all CPUs*"},
385 {0x3C, "Stop procedure*, CPU 0"},
386 {0x3D, "Stop procedure*, CPU 1"},
387 {0x3E, "Stop procedure*, CPU 2"},
388 {0x3F, "Stop procedure*, CPU 3"},
389 {0x40, "Stop procedure*, CPU 4"},
390 {0x41, "Stop procedure*, CPU 5"},
391 {0x42, "Stop procedure*, CPU 6"},
392 {0x43, "Stop procedure*, (own CPU)"},
393 {0x44, "Stop procedure*, (All CPUs)"},
394 {0x46, "Read arithmetic status and ACCU*"},
396 {0x48, "Read halt failure register*"},
397 {0x49, "Read index register*"},
398 {0x4A, "Read instruction pointer*"},
399 {0x4B, "Find history*"},
400 {0x50, "Write arithmetic staus and ACCU*"},
401 {0x51, "Write byte*"},
402 {0x52, "Write index register"},
403 {0x53, "Write instruction pointer*"},
404 {0x5A, "Clear all (F, O, R, T)*"},
405 {0x5B, "Clear flags*"},
406 {0x5C, "Clear outputs*"},
407 {0x5D, "Clear registers*"},
408 {0x5E, "Clear timers*"},
409 {0x64, "Restart warm CPU 1*"},
410 {0x65, "Restart warm CPU 2*"},
411 {0x66, "Restart warm CPU 3*"},
412 {0x67, "Restart warm CPU 4*"},
413 {0x68, "Restart warm CPU 5*"},
414 {0x69, "Restart warm CPU 6*"},
415 {0x6A, "Restart warm (own CPU)*"},
416 {0x6B, "Restart warm (All CPUs)*"},
417 {0x6E, "Change block*"},
418 {0x6F, "Clear history failure*"},
419 {0x70, "Delete program line*"},
420 {0x71, "Go conditional*"},
421 {0x72, "Insert program line*"},
422 {0x73, "Local cycles*"},
423 {0x74, "All cycles*"},
424 {0x75, "Make text*"},
425 {0x76, "Execute single instruction*"},
426 {0x77, "Single step*"},
427 {0x82, "XOB 17 interrupt"},
428 {0x83, "XOB 18 interrupt"},
429 {0x84, "XOB 19 interrupt"},
430 {0x91, "Read hangup timeout"},
431 {0x96, "Read data block"},
432 {0x97, "Write data block"},
433 {0x98, "Make data block*"},
434 {0x99, "Clear data block*"},
435 {0x9A, "Clear text*"},
436 {0x9B, "Read block address"},
437 {0x9C, "Read block sizes"},
438 {0x9D, "Read current block*"},
439 {0x9E, "Read call stack*"},
441 {0xA1, "Read user EEPROM register"},
442 {0xA3, "Write user EEPROM register"},
443 {0xA5, "Erase flash*"},
444 {0xA6, "Restart cold flag*"},
445 {0xA7, "Write system buffer"},
446 {0xA8, "Read system buffer"},
447 {0xA9, "Read/write block data*"},
448 {0xAA, "Get diagnostic*"},
449 {0xAB, "Read system information*"},
450 {0xAC, "Changes blocks on run*"},
451 {0xAD, "Flashcard telegram*"},
452 {0xAE, "Download FW*"},
453 {0xAF, "Web server serial communication*"},
457 static const value_string webserver_aid_vals[] = {
458 {0x01, "Partial request"},
459 {0x02, "Request end"},
461 {0x10, "Transfer OK"},
462 {0x11, "Partial answer"},
463 {0x12, "Last part of answer"},
464 {0x13, "Server not ready"},
467 static const value_string rdwrblock_vals[] = {
468 {0x00, "WR block start of stream"},
469 {0x01, "WR block data stream"},
470 {0x02, "WR block end of stream"},
471 {0x07, "Abort block WR stream"},
472 {0x08, "WR block data"},
473 {0x10, "RD block start of stream"},
474 {0x11, "RD block data stream"},
475 {0x17, "Abort block RD stream"},
476 {0x18, "RD block data"},
477 {0x20, "Delete block"},
478 {0x21, "Get block size"},
479 {0x22, "Get program block list"},
483 static const value_string rdwrblock_sts[] = {
484 {0x00, "ACK (Acknowledged)"},
487 {0x03, "End of stream"},
488 {0x04, "Data EOF reached"},
490 {0x81, "NAK, unknown Tlg_Type"},
491 {0x82, "NAK, not supported Tlg_Type"},
492 {0x83, "NAK, unknown Block Type"},
493 {0x84, "NAK, out of sequence"},
494 {0x85, "NAK, not supported Block number"},
495 {0x86, "NAK, Block Size invalid (to big)"},
496 {0x87, "NAK, Block Address invalid"},
497 {0x88, "NAK, CRC invalid"},
498 {0x89, "NAK, invalid status"},
499 {0x8A, "NAK, invalid command size (w-count)"},
500 {0xFF, "Abort (stream)"},
504 static const value_string rdwrblock_list_type_vals[] = {
505 {0x40, "Start request of program block"},
506 {0x41, "Get next program block"},
507 {0xFF, "Abort get list"},
511 static const guint crc_table[] = {
512 0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7,0x8108,0x9129,0xa14a,0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef,
513 0x1231,0x0210,0x3273,0x2252,0x52b5,0x4294,0x72f7,0x62d6,0x9339,0x8318,0xb37b,0xa35a,0xd3bd,0xc39c,0xf3ff,0xe3de,
514 0x2462,0x3443,0x0420,0x1401,0x64e6,0x74c7,0x44a4,0x5485,0xa56a,0xb54b,0x8528,0x9509,0xe5ee,0xf5cf,0xc5ac,0xd58d,
515 0x3653,0x2672,0x1611,0x0630,0x76d7,0x66f6,0x5695,0x46b4,0xb75b,0xa77a,0x9719,0x8738,0xf7df,0xe7fe,0xd79d,0xc7bc,
516 0x48c4,0x58e5,0x6886,0x78a7,0x0840,0x1861,0x2802,0x3823,0xc9cc,0xd9ed,0xe98e,0xf9af,0x8948,0x9969,0xa90a,0xb92b,
517 0x5af5,0x4ad4,0x7ab7,0x6a96,0x1a71,0x0a50,0x3a33,0x2a12,0xdbfd,0xcbdc,0xfbbf,0xeb9e,0x9b79,0x8b58,0xbb3b,0xab1a,
518 0x6ca6,0x7c87,0x4ce4,0x5cc5,0x2c22,0x3c03,0x0c60,0x1c41,0xedae,0xfd8f,0xcdec,0xddcd,0xad2a,0xbd0b,0x8d68,0x9d49,
519 0x7e97,0x6eb6,0x5ed5,0x4ef4,0x3e13,0x2e32,0x1e51,0x0e70,0xff9f,0xefbe,0xdfdd,0xcffc,0xbf1b,0xaf3a,0x9f59,0x8f78,
520 0x9188,0x81a9,0xb1ca,0xa1eb,0xd10c,0xc12d,0xf14e,0xe16f,0x1080,0x00a1,0x30c2,0x20e3,0x5004,0x4025,0x7046,0x6067,
521 0x83b9,0x9398,0xa3fb,0xb3da,0xc33d,0xd31c,0xe37f,0xf35e,0x02b1,0x1290,0x22f3,0x32d2,0x4235,0x5214,0x6277,0x7256,
522 0xb5ea,0xa5cb,0x95a8,0x8589,0xf56e,0xe54f,0xd52c,0xc50d,0x34e2,0x24c3,0x14a0,0x0481,0x7466,0x6447,0x5424,0x4405,
523 0xa7db,0xb7fa,0x8799,0x97b8,0xe75f,0xf77e,0xc71d,0xd73c,0x26d3,0x36f2,0x0691,0x16b0,0x6657,0x7676,0x4615,0x5634,
524 0xd94c,0xc96d,0xf90e,0xe92f,0x99c8,0x89e9,0xb98a,0xa9ab,0x5844,0x4865,0x7806,0x6827,0x18c0,0x08e1,0x3882,0x28a3,
525 0xcb7d,0xdb5c,0xeb3f,0xfb1e,0x8bf9,0x9bd8,0xabbb,0xbb9a,0x4a75,0x5a54,0x6a37,0x7a16,0x0af1,0x1ad0,0x2ab3,0x3a92,
526 0xfd2e,0xed0f,0xdd6c,0xcd4d,0xbdaa,0xad8b,0x9de8,0x8dc9,0x7c26,0x6c07,0x5c64,0x4c45,0x3ca2,0x2c83,0x1ce0,0x0cc1,
527 0xef1f,0xff3e,0xcf5d,0xdf7c,0xaf9b,0xbfba,0x8fd9,0x9ff8,0x6e17,0x7e36,0x4e55,0x5e74,0x2e93,0x3eb2,0x0ed1,0x1ef0
530 /* Conversion values passing structure*/
532 guint32 conversation; /*Conversation ID*/
533 guint16 sequence; /*Sequence number of request telegram*/
537 guint8 cmd_code; /*command code from request*/
538 guint8 count; /*rcount value*/
539 guint8 sysinfo; /*system information number*/
540 guint8 block_tlg; /*telegram type of RD/WR block telegrams*/
541 guint8 retry_count; /*number of retries*/
542 guint32 req_frame; /*frame number of last request*/
543 guint32 resp_frame; /*frame number of response*/
544 nstime_t req_time; /*time of the last request*/
547 /* The hash structure (for conversations)*/
548 static GHashTable *sbus_request_hash = NULL;
550 static guint crc_calc (guint crc, guint val)
555 indx = (((crc >> 8) ^ val) & 0xff);
556 ncrc = crc_table[indx] ^ ((crc << 8) & 0xffff);
562 static gint sbus_equal(gconstpointer v, gconstpointer w)
564 sbus_request_key *v1 = (sbus_request_key *)v;
565 sbus_request_key *v2 = (sbus_request_key *)w;
567 if (v1->conversation == v2->conversation &&
568 v1->sequence == v2->sequence) {
574 static guint sbus_hash(gconstpointer v)
576 sbus_request_key *key = (sbus_request_key *)v;
578 val = key->conversation + key->sequence;
582 /*Protocol initialisation*/
583 static void sbus_init_protocol(void){
584 if (sbus_request_hash){
585 g_hash_table_destroy(sbus_request_hash);
587 sbus_request_hash = g_hash_table_new(sbus_hash, sbus_equal);
590 /* check whether the packet looks like SBUS or not */
592 is_sbus_pdu(tvbuff_t *tvb)
596 /* we need at least 8 bytes to determine whether this is sbus or
598 if(tvb_length(tvb)<8){
602 /* the length must be >= 8 bytes to accomodate the header,
603 it also must be <65536 to fit inside a udp packet
605 length=tvb_get_ntohl(tvb, 0);
606 if ( (length<8) || (length>65535) ) {
609 if (tvb_reported_length(tvb) != length) {
612 /* First four byte indicate the length which must be at least 12 bytes*/
613 if (tvb_get_ntohl(tvb, 0) < 12) {
616 /* Fifth byte indicates protocol version which can be 0 or 1*/
617 if (tvb_get_guint8(tvb, 4) > 0x01) {
620 /* Sixth byte indicates protocol type and must be 0*/
621 if ( tvb_get_guint8(tvb, 5) > 0x01 ) {
624 /* Seventh and eigth byte indicates the packet sequence number and can
625 be 0 to 65565 (--> check does not make sense)*/
626 /* Ninth byte the "attributes character" and must be either 0, 1 or 2
627 (request, response or ACK/NAK)*/
628 if (tvb_get_guint8(tvb, 8) > 0x02 ) {
634 /*Dissect the telegram*/
636 dissect_sbus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
639 /* Set up structures needed to add the protocol subtree and manage it */
640 proto_item *ti, *et, *dt, *hi, *cs;
641 proto_tree *sbus_tree, *ethsbus_tree, *sbusdata_tree;
643 gint i; /*for CRC calculation*/
644 gint j; /*for CRC calculation*/
648 guint8 sbus_attribut;
649 guint8 sbus_media_cnt;
651 guint8 sbus_cmd_code;
652 guint8 sbus_web_size;
655 guint8 sbus_rdwr_type;
656 guint8 sbus_rdwr_sequence;
657 guint8 sbus_rdwr_block_tlg;
658 guint8 sbus_rdwr_block_type;
659 guint8 sbus_rdwr_ack_nak;
660 guint8 sbus_quint8_helper0;
661 guint32 sbus_binarymasked;
662 guint32 sbus_binaries;
663 guint16 sbus_ack_code;
664 guint32 sbus_show_bin;
665 guint32 sbus_rdwr_length;
667 guint32 sbus_helper1;
668 guint32 sbus_helper2;
670 nstime_t ns; /*we use this for the response time*/
672 /* Set up conversations*/
673 conversation_t *conversation = NULL;
674 sbus_request_key request_key, *new_request_key;
675 sbus_request_val *request_val = NULL;
677 /* does this look like an sbus pdu? */
678 if(!is_sbus_pdu(tvb)){
682 conversation = find_or_create_conversation(pinfo);
684 request_key.conversation = conversation->index;
685 request_key.sequence = tvb_get_ntohs(tvb,6);
687 request_val = (sbus_request_val *) g_hash_table_lookup(sbus_request_hash,
689 /*Get type of telegram for finding retries
690 *As we are storing the info in a hash table we need to update the info
691 *also in case this is no retry*/
692 sbus_attribut = tvb_get_guint8(tvb,8);
693 if (request_val && sbus_attribut == SBUS_REQUEST) {
694 if (request_val->req_frame < pinfo->fd->num){ /*a retry; req_frame smaller this frame*/
695 request_val->retry_count +=1;
697 else { /*we have a conversation but this is not a retry so we store the packet info*/
698 request_val->retry_count = 0;
699 request_val->req_frame = pinfo->fd->num; /*store actual frame nr.*/
700 request_val->req_time = pinfo->fd->abs_ts;
703 if (request_val && (sbus_attribut == SBUS_RESPONSE ||
704 sbus_attribut == SBUS_ACKNAK)) { /*a response*/
705 request_val->resp_frame = pinfo->fd->num; /*so store this frame nr.*/
707 /* Only allocate a new hash element when it's a request*/
708 sbus_attribut = tvb_get_guint8(tvb,8);
710 if ( !request_val && sbus_attribut == 0 ) {/* request telegram */
711 new_request_key = se_alloc(sizeof(sbus_request_key));
712 *new_request_key = request_key;
714 request_val = se_alloc(sizeof(sbus_request_val));
715 request_val->cmd_code=tvb_get_guint8(tvb,10);
716 request_val->retry_count=0;
717 request_val->req_frame = pinfo->fd->num; /*store actual frame nr.*/
718 request_val->req_time = pinfo->fd->abs_ts;
719 request_val->resp_frame = 0; /*response frame is not known yet*/
721 if (((request_val->cmd_code) == SBUS_RD_USER_EEPROM_REGISTER) ||
722 ((request_val->cmd_code) == SBUS_WR_USER_EEPROM_REGISTER)) {
723 request_val->count=((tvb_get_guint8(tvb,12))+1);
725 request_val->count=((tvb_get_guint8(tvb,11))+1);
728 /*Enter system info or telegram type (for rd/wr block telegrams)*/
729 if ((request_val->cmd_code) == SBUS_RD_SYSTEM_INFORMATION) {
730 request_val->sysinfo=(tvb_get_guint8(tvb,12));
731 request_val->block_tlg=0x0;
732 } else if ((request_val->cmd_code) == SBUS_RD_WR_PCD_BLOCK) {
733 request_val->sysinfo=0x0;
734 request_val->block_tlg=(tvb_get_guint8(tvb,12));
736 request_val->sysinfo=0x0;
737 request_val->block_tlg=0x0;
740 g_hash_table_insert(sbus_request_hash, new_request_key, request_val);
742 /* End of attaching data to hash table*/
744 /* Make entries in Protocol column and Info column on summary display */
745 col_set_str(pinfo->cinfo, COL_PROTOCOL, "S-Bus");
747 col_clear(pinfo->cinfo, COL_INFO);
750 if (check_col(pinfo->cinfo, COL_INFO)) {
751 switch (sbus_attribut){
753 sbus_cmd_code = tvb_get_guint8(tvb,10);
754 switch (sbus_cmd_code){
755 case SBUS_WEB_SERVER_SERIAL_COMM:
756 /* Special treatment of web server request
757 * as is is very helpful to see more information in the packetlist */
758 sbus_web_aid = tvb_get_guint8(tvb,12);
759 sbus_web_seq = tvb_get_guint8(tvb,13);
760 col_add_fstr(pinfo->cinfo, COL_INFO,
761 "Web Server Request: %s (Seq No: %d)",
762 val_to_str_const(sbus_web_aid,
763 webserver_aid_vals, "Unknown Request!"),
766 case SBUS_RD_WR_PCD_BLOCK:
767 sbus_rdwr_type = tvb_get_guint8(tvb, 12);
768 col_add_fstr( pinfo->cinfo, COL_INFO,
769 "Request: %s", val_to_str_const( sbus_rdwr_type, rdwrblock_vals,
770 "This RD/WR block telegram is not implemented"));
771 /* Add name of file to be written in case of start of file stream */
772 if (sbus_rdwr_type == SBUS_WR_START_OF_STREAM) {
773 sbus_rdwr_block_type = tvb_get_guint8(tvb, 14);
774 if ((sbus_rdwr_block_type == SBUS_RD_WR_CONFIGURATION_FILE) ||
775 (sbus_rdwr_block_type == SBUS_RD_WR_PROGRAM_BLOCK_FILE)) {
776 sbus_quint8_helper0=0;
777 for (i=19; i<43; i++) { /*max length is 24 chars*/
778 /*find zero-termination of string*/
779 if ((tvb_get_guint8(tvb, i)) == 0x00) {
782 sbus_quint8_helper0 += 1;
784 tmp_string = tvb_get_ephemeral_string(tvb , 19,
785 sbus_quint8_helper0);
786 col_append_fstr(pinfo->cinfo, COL_INFO,
787 ": (File: %s)", tmp_string);
789 } else if (sbus_rdwr_type == SBUS_RD_BLOCK_START_OF_STREAM) {
790 sbus_rdwr_block_type = tvb_get_guint8(tvb, 14);
791 if ((sbus_rdwr_block_type == SBUS_RD_WR_CONFIGURATION_FILE) ||
792 (sbus_rdwr_block_type == SBUS_RD_WR_PROGRAM_BLOCK_FILE)) {
793 sbus_quint8_helper0=0;
794 for (i=15; i<39; i++) { /*max length is 24 chars*/
795 /*find zero-termination of string*/
796 if ((tvb_get_guint8(tvb, i)) == 0x00) {
799 sbus_quint8_helper0 += 1;
801 tmp_string = tvb_get_ephemeral_string(tvb , 15,
802 sbus_quint8_helper0);
803 col_append_fstr(pinfo->cinfo, COL_INFO,
804 ": (File: %s)", tmp_string);
812 /* All other requests */
813 col_add_fstr(pinfo->cinfo, COL_INFO,
814 "Request: %s", val_to_str_const(sbus_cmd_code,
815 sbus_command_vals, "Unknown Command!"));
819 if (request_val->retry_count>0) {
820 col_append_str(pinfo->cinfo, COL_INFO,
822 } /*no retry number as it is not always correctly calculated*/
826 /* Special treatment of web server request
827 * as is is very helpful to see more information in the packetlist */
828 if (request_val && ((request_val->cmd_code) == SBUS_WEB_SERVER_SERIAL_COMM)) {
829 sbus_web_size = tvb_get_guint8(tvb,9);
830 sbus_web_aid = tvb_get_guint8(tvb,10);
831 col_add_fstr(pinfo->cinfo, COL_INFO,
833 val_to_str_const(sbus_web_aid,
834 webserver_aid_vals, "Unknown Request!"));
835 if (sbus_web_size > 1) {
836 sbus_web_seq = tvb_get_guint8(tvb,11);
837 col_append_fstr(pinfo->cinfo, COL_INFO,
841 } else if (request_val && ((request_val->cmd_code) == SBUS_RD_WR_PCD_BLOCK)) {
842 /* Treat the ACK/NAK telgrams in a special way*/
843 switch (request_val->block_tlg) {
844 case SBUS_WR_START_OF_STREAM:
845 case SBUS_WR_BLOCK_DATA_STREAM:
846 case SBUS_WR_BLOCK_END_OF_STREAM:
847 case SBUS_WR_ABORT_BLOCK_STREAM:
848 case SBUS_WR_BLOCK_DATA_BYTES:
849 case SBUS_DELETE_BLOCK:
850 case SBUS_RD_ABORT_BLOCK_STREAM:
851 sbus_rdwr_ack_nak = tvb_get_guint8(tvb, 10);
852 col_add_fstr( pinfo->cinfo, COL_INFO,
853 "Response: %s", val_to_str_const(sbus_rdwr_ack_nak,
854 rdwrblock_sts, "Unknown response!"));
857 sbus_rdwr_type = tvb_get_guint8(tvb, 9);
858 col_add_fstr( pinfo->cinfo, COL_INFO,
859 "Response: (%d byte)", sbus_rdwr_type);
864 col_set_str(pinfo->cinfo, COL_INFO, "Response");
869 sbus_ack_code = tvb_get_ntohs(tvb,9);
870 col_add_fstr(pinfo->cinfo, COL_INFO,
871 "%s", val_to_str_const(sbus_ack_code,
873 "Unknown NAK response code!"));
877 col_set_str(pinfo->cinfo, COL_INFO, "Unknown attribute");
882 /* create display subtree for the protocol */
885 ti = proto_tree_add_item(tree, proto_sbus, tvb, offset, -1, ENC_NA);
886 sbus_tree = proto_item_add_subtree(ti, ett_sbus);
888 /*Add subtree for Ether-S-Bus header*/
889 et = proto_tree_add_text(sbus_tree, tvb, offset, 8, "Ether-S-Bus header");
890 ethsbus_tree = proto_item_add_subtree(et, ett_sbus_ether);
892 /* add an item to the subtree*/
893 sbus_eth_len = tvb_get_ntohl(tvb,offset);
894 proto_tree_add_item(ethsbus_tree,
895 hf_sbus_length, tvb, offset, 4, ENC_BIG_ENDIAN);
898 proto_tree_add_item(ethsbus_tree,
899 hf_sbus_version, tvb, offset, 1, ENC_BIG_ENDIAN);
902 proto_tree_add_item(ethsbus_tree,
903 hf_sbus_protocol, tvb, offset, 1, ENC_BIG_ENDIAN);
906 proto_tree_add_item(ethsbus_tree,
907 hf_sbus_sequence, tvb, offset, 2, ENC_BIG_ENDIAN);
910 /* Continue adding stuff to the main tree*/
911 sbus_attribut = tvb_get_guint8(tvb,offset);
912 proto_tree_add_item(sbus_tree,
913 hf_sbus_attribut, tvb, offset, 1, ENC_BIG_ENDIAN);
916 if (sbus_attribut == SBUS_REQUEST) {
917 proto_tree_add_item(sbus_tree,
918 hf_sbus_dest, tvb, offset, 1, ENC_BIG_ENDIAN);
920 sbus_cmd_code = tvb_get_guint8(tvb,offset);
921 proto_tree_add_item(sbus_tree,
922 hf_sbus_command, tvb, offset, 1, ENC_BIG_ENDIAN);
924 if (request_val && request_val->retry_count > 0) {/*this is a retry telegram*/
925 hi = proto_tree_add_boolean(sbus_tree,
926 hf_sbus_retry, tvb, 0, 0, TRUE);
927 PROTO_ITEM_SET_GENERATED(hi);
928 expert_add_info_format(pinfo, hi, PI_SEQUENCE, PI_NOTE,
929 "Repeated telegram (due to timeout?)");
930 nstime_delta(&ns, &pinfo->fd->abs_ts, &request_val->req_time);
931 proto_tree_add_time(sbus_tree, hf_sbus_timeout,
933 proto_tree_add_uint(sbus_tree, hf_sbus_request_in, tvb, 0, 0,
934 request_val->req_frame);
936 if (request_val && request_val->resp_frame > pinfo->fd->num){
937 proto_tree_add_uint(sbus_tree, hf_sbus_response_in, tvb, 0, 0,
938 request_val->resp_frame);
940 switch (sbus_cmd_code) {
941 /*Read Counter, Register or Timer*/
942 case SBUS_RD_COUNTER:
943 case SBUS_RD_REGISTER:
945 sbus_media_cnt = (tvb_get_guint8(tvb,offset))+1;
946 proto_tree_add_uint(sbus_tree,
947 hf_sbus_rcount, tvb, offset, 1, sbus_media_cnt);
949 proto_tree_add_item(sbus_tree,
950 hf_sbus_addr_rtc, tvb, offset, 2, ENC_BIG_ENDIAN);
954 /*Read Flag, Input or Output*/
958 sbus_media_cnt = (tvb_get_guint8(tvb,offset))+1;
959 proto_tree_add_uint(sbus_tree,
960 hf_sbus_rcount, tvb, offset, 1, sbus_media_cnt);
962 proto_tree_add_item(sbus_tree,
963 hf_sbus_addr_iof, tvb, offset, 2, ENC_BIG_ENDIAN);
967 /*Write Register Timer Counter*/
968 case SBUS_WR_COUNTER:
969 case SBUS_WR_REGISTER:
971 sbus_media_cnt = (tvb_get_guint8(tvb,offset));
972 sbus_media_cnt = ((sbus_media_cnt - 1)/4);
973 proto_tree_add_uint(sbus_tree,
974 hf_sbus_wcount_calculated, tvb, offset,
976 proto_tree_add_item(sbus_tree,
977 hf_sbus_wcount, tvb, offset, 1, ENC_BIG_ENDIAN);
979 proto_tree_add_item(sbus_tree,
980 hf_sbus_addr_rtc, tvb, offset, 2, ENC_BIG_ENDIAN);
982 /*Add subtree for Data*/
983 dt = proto_tree_add_text(sbus_tree, tvb, offset,
984 ((sbus_media_cnt) * 4),"Data");
986 sbusdata_tree = proto_item_add_subtree(dt, ett_sbus_data);
987 for (i=((sbus_media_cnt)); i>0; i--) {
988 proto_tree_add_item(sbusdata_tree,
989 hf_sbus_data_rtc, tvb, offset,
995 /* Write flags and outputs*/
998 sbus_media_cnt = (tvb_get_guint8(tvb,offset));
999 sbus_media_cnt = (sbus_media_cnt - 2);
1000 proto_tree_add_uint(sbus_tree,
1001 hf_sbus_wcount_calculated, tvb, offset,
1003 proto_tree_add_item(sbus_tree,
1004 hf_sbus_wcount, tvb, offset, 1, ENC_BIG_ENDIAN);
1006 proto_tree_add_item(sbus_tree,
1007 hf_sbus_addr_iof, tvb, offset, 2, ENC_BIG_ENDIAN);
1009 sbus_fio_cnt = (tvb_get_guint8(tvb,offset));
1010 sbus_fio_cnt = ((sbus_fio_cnt + 1));
1011 proto_tree_add_uint(sbus_tree,
1012 hf_sbus_fio_count, tvb, offset, 1, sbus_fio_cnt);
1014 /*Add subtree for Data*/
1015 dt = proto_tree_add_text(sbus_tree, tvb, offset,
1016 sbus_media_cnt,"Data");
1018 sbusdata_tree = proto_item_add_subtree(dt, ett_sbus_data);
1019 for (i=sbus_media_cnt; i>0; i--) {
1022 sbus_binarymasked = 0x01;
1023 sbus_binaries = tvb_get_guint8(tvb, offset);
1024 for (j=0; j<8; j++) {
1025 if ((sbus_binarymasked & sbus_binaries) != 0) {
1026 sbus_show_bin = (sbus_show_bin + sbus_helper);
1028 sbus_binarymasked = sbus_binarymasked<<1;
1029 sbus_helper = 10 * sbus_helper;
1032 proto_tree_add_uint_format(sbusdata_tree,
1033 hf_sbus_data_iof, tvb, offset, 1, sbus_show_bin,
1034 "Binary data: %08u", sbus_show_bin);
1039 /* Request: Write Real time clock*/
1041 sbus_helper = tvb_get_guint8(tvb, (offset +5)); /*hours*/
1042 sbus_helper1 = tvb_get_guint8(tvb, (offset +6)); /*minutes*/
1043 sbus_helper2 = tvb_get_guint8(tvb, (offset +7)); /*seconds*/
1044 proto_tree_add_text(sbus_tree, tvb, (offset +5), 3,
1045 "Time (HH:MM:SS): %02x:%02x:%02x", sbus_helper, sbus_helper1, sbus_helper2);
1046 sbus_helper = tvb_get_guint8(tvb, (offset +2)); /*year*/
1047 sbus_helper1 = tvb_get_guint8(tvb, (offset +3)); /*month*/
1048 sbus_helper2 = tvb_get_guint8(tvb, (offset +4)); /*day*/
1049 proto_tree_add_text(sbus_tree, tvb, (offset +2), 3,
1050 "Date (YY/MM/DD): %02x/%02x/%02x", sbus_helper, sbus_helper1, sbus_helper2);
1051 sbus_helper = tvb_get_guint8(tvb, (offset)); /*year-week*/
1052 sbus_helper1 = tvb_get_guint8(tvb, (offset +1)); /*week-day*/
1053 proto_tree_add_text(sbus_tree, tvb, offset, 2,
1054 "Calendar week: %x, Week day: %x", sbus_helper, sbus_helper1);
1055 /*Add subtree for Data*/
1056 dt = proto_tree_add_text(sbus_tree, tvb, offset,
1058 sbusdata_tree = proto_item_add_subtree(dt, ett_sbus_data);
1060 proto_tree_add_item(sbusdata_tree,
1061 hf_sbus_week_day, tvb, offset, 2, ENC_BIG_ENDIAN);
1063 proto_tree_add_item(sbusdata_tree,
1064 hf_sbus_date, tvb, offset, 3, ENC_BIG_ENDIAN);
1066 proto_tree_add_item(sbusdata_tree,
1067 hf_sbus_time, tvb, offset, 3, ENC_BIG_ENDIAN);
1071 /* Read user memory or program line*/
1072 case SBUS_RD_USER_MEMORY:
1073 case SBUS_RD_PROGRAM_LINE:
1074 sbus_media_cnt = (tvb_get_guint8(tvb,offset))+1;
1075 proto_tree_add_uint(sbus_tree,
1076 hf_sbus_rcount, tvb, offset, 1, sbus_media_cnt);
1078 proto_tree_add_item(sbus_tree,
1079 hf_sbus_addr_prog, tvb, offset, 3, ENC_BIG_ENDIAN);
1083 /*Write user memory*/
1084 case SBUS_WR_USER_MEMORY:
1085 sbus_media_cnt = (tvb_get_guint8(tvb,offset));
1086 sbus_media_cnt = ((sbus_media_cnt - 2)/4);
1087 proto_tree_add_uint(sbus_tree,
1088 hf_sbus_wcount_calculated, tvb, offset,
1090 proto_tree_add_item(sbus_tree,
1091 hf_sbus_wcount, tvb, offset, 1, ENC_BIG_ENDIAN);
1093 proto_tree_add_item(sbus_tree,
1094 hf_sbus_addr_68k, tvb, offset, 3, ENC_BIG_ENDIAN);
1096 /*Add subtree for Data*/
1097 dt = proto_tree_add_text(sbus_tree, tvb, offset,
1098 ((sbus_media_cnt) * 4),"Program lines");
1100 sbusdata_tree = proto_item_add_subtree(dt, ett_sbus_data);
1101 for (i=((sbus_media_cnt)); i>0; i--) {
1102 proto_tree_add_item(sbusdata_tree,
1103 hf_sbus_data_rtc, tvb, offset,
1112 sbus_media_cnt = (tvb_get_guint8(tvb,offset))+1;
1113 proto_tree_add_uint(sbus_tree,
1114 hf_sbus_rcount, tvb, offset, 1, sbus_media_cnt);
1116 proto_tree_add_item(sbus_tree,
1117 hf_sbus_addr_68k, tvb, offset, 3, ENC_BIG_ENDIAN);
1123 sbus_media_cnt = (tvb_get_guint8(tvb,offset));
1124 sbus_media_cnt = (sbus_media_cnt - 2);
1125 proto_tree_add_uint(sbus_tree,
1126 hf_sbus_wcount_calculated, tvb, offset,
1128 proto_tree_add_item(sbus_tree,
1129 hf_sbus_wcount, tvb, offset, 1, ENC_BIG_ENDIAN);
1131 proto_tree_add_item(sbus_tree,
1132 hf_sbus_addr_68k, tvb, offset, 3, ENC_BIG_ENDIAN);
1134 /*Add subtree for Data*/
1135 dt = proto_tree_add_text(sbus_tree, tvb, offset,
1136 ((sbus_media_cnt) * 4),"Data (bytes)");
1138 sbusdata_tree = proto_item_add_subtree(dt, ett_sbus_data);
1139 for (i=sbus_media_cnt; i>0; i--) {
1140 proto_tree_add_item(sbusdata_tree,
1141 hf_sbus_data_byte, tvb, offset,
1147 /*Read EEPROM register*/
1148 case SBUS_RD_USER_EEPROM_REGISTER:
1149 proto_tree_add_item(sbus_tree,
1150 hf_sbus_command_extension, tvb, offset, 1, ENC_BIG_ENDIAN);
1152 sbus_media_cnt = (tvb_get_guint8(tvb,offset))+1;
1153 proto_tree_add_uint(sbus_tree,
1154 hf_sbus_rcount, tvb, offset, 1, sbus_media_cnt);
1156 proto_tree_add_item(sbus_tree,
1157 hf_sbus_addr_eeprom, tvb, offset, 2, ENC_BIG_ENDIAN);
1161 /*Request for reading system info*/
1162 /*Syinfo 05 is not implemented as no serial baud is possible*/
1163 case SBUS_RD_SYSTEM_INFORMATION:
1164 proto_tree_add_item(sbus_tree,
1165 hf_sbus_sysinfo_nr, tvb, offset, 1, ENC_BIG_ENDIAN);
1167 proto_tree_add_item(sbus_tree,
1168 hf_sbus_sysinfo_nr, tvb, offset, 1, ENC_BIG_ENDIAN);
1172 /* WebServer Request */
1173 case SBUS_WEB_SERVER_SERIAL_COMM:
1174 sbus_web_size = tvb_get_guint8(tvb,offset);
1175 proto_tree_add_uint(sbus_tree,
1176 hf_sbus_web_size, tvb, offset,
1180 sbus_web_aid = tvb_get_guint8(tvb,offset);
1181 proto_tree_add_uint(sbus_tree,
1182 hf_sbus_web_aid, tvb, offset,
1186 sbus_web_seq = tvb_get_guint8(tvb,offset);
1187 proto_tree_add_uint(sbus_tree,
1188 hf_sbus_web_seq, tvb, offset,
1192 if (sbus_web_size > 1) {
1193 dt = proto_tree_add_text(sbus_tree, tvb, offset,
1194 (sbus_web_size - 1),"Data (bytes)");
1196 sbusdata_tree = proto_item_add_subtree(dt, ett_sbus_data);
1197 for (i=sbus_web_size -1 ; i>0; i--) {
1198 proto_tree_add_item(sbusdata_tree,
1199 hf_sbus_data_byte, tvb, offset,
1205 /* Read/write block request */
1206 case SBUS_RD_WR_PCD_BLOCK:
1207 if (tvb_get_guint8(tvb,offset) == 0xff){
1208 sbus_rdwr_length = ((tvb_get_ntohl(tvb,0))-15);
1209 proto_tree_add_uint(sbus_tree,
1210 hf_sbus_rdwr_block_length_ext, tvb, 0, 4, sbus_rdwr_length);
1213 sbus_rdwr_length = tvb_get_guint8(tvb,offset);
1214 proto_tree_add_uint(sbus_tree,
1215 hf_sbus_rdwr_block_length, tvb, offset,
1216 1, sbus_rdwr_length);
1219 sbus_rdwr_type = tvb_get_guint8(tvb,offset);
1220 proto_tree_add_uint(sbus_tree,
1221 hf_sbus_rdwr_telegram_type, tvb, offset,
1224 switch(sbus_rdwr_type) {
1225 case SBUS_WR_START_OF_STREAM:
1226 sbus_rdwr_block_type = tvb_get_guint8(tvb, 14);
1227 proto_tree_add_item(sbus_tree,
1228 hf_sbus_rdwr_telegram_sequence, tvb, offset,
1231 proto_tree_add_item(sbus_tree,
1232 hf_sbus_block_type, tvb, offset,
1236 /* Check for file or block download */
1237 if ((sbus_rdwr_block_type == SBUS_RD_WR_CONFIGURATION_FILE) ||
1238 (sbus_rdwr_block_type == SBUS_RD_WR_PROGRAM_BLOCK_FILE)) {
1239 proto_tree_add_item(sbus_tree,
1240 hf_sbus_rdwr_block_size, tvb, offset,
1243 sbus_quint8_helper0=0;
1244 /*find zero-termination of string*/
1245 for (i=19; i<43; i++) { /*max length string is 24 char*/
1246 if ((tvb_get_guint8(tvb, i)) == 0x00) {
1249 sbus_quint8_helper0 += 1;
1251 tmp_string = tvb_get_ephemeral_string(tvb , 19, sbus_quint8_helper0);
1252 proto_tree_add_string(sbus_tree,
1253 hf_sbus_rdwr_file_name, tvb, offset,
1254 sbus_quint8_helper0, tmp_string);
1255 offset += sbus_quint8_helper0;
1256 /*do not display a field for block data (skip)*/
1257 offset += (sbus_rdwr_length-6-sbus_quint8_helper0);
1258 } else { /* block write telegram, no file write*/
1259 proto_tree_add_item(sbus_tree,
1260 hf_sbus_block_nr, tvb, offset,
1263 proto_tree_add_item(sbus_tree,
1264 hf_sbus_rdwr_block_size, tvb, offset,
1267 /*do not display a field for block data (skip)*/
1268 offset += (sbus_rdwr_length-8);
1271 case SBUS_WR_BLOCK_DATA_STREAM:
1272 sbus_rdwr_sequence = tvb_get_guint8(tvb,offset);
1273 proto_tree_add_uint(sbus_tree,
1274 hf_sbus_rdwr_telegram_sequence, tvb, offset,
1275 1, sbus_rdwr_sequence);
1277 /*do not display a field for block data (skip)*/
1278 offset += (sbus_rdwr_length-1);
1280 case SBUS_WR_BLOCK_END_OF_STREAM:
1281 sbus_rdwr_sequence = tvb_get_guint8(tvb,offset);
1282 proto_tree_add_uint(sbus_tree,
1283 hf_sbus_rdwr_telegram_sequence, tvb, offset,
1284 1, sbus_rdwr_sequence);
1286 /*do not display a field for block data (skip it)*/
1287 offset += (sbus_rdwr_length-5);
1288 /*do not display a field for block CRC (skip it)*/
1291 case SBUS_WR_ABORT_BLOCK_STREAM:
1292 case SBUS_RD_ABORT_BLOCK_STREAM:
1294 case SBUS_WR_BLOCK_DATA_BYTES:
1295 sbus_rdwr_block_type = tvb_get_guint8(tvb, 14);
1296 proto_tree_add_item(sbus_tree,
1297 hf_sbus_block_type, tvb, offset,
1301 /* Check for file or block download */
1302 if ((sbus_rdwr_block_type == SBUS_RD_WR_CONFIGURATION_FILE) ||
1303 (sbus_rdwr_block_type == SBUS_RD_WR_PROGRAM_BLOCK_FILE)) {
1304 proto_tree_add_item(sbus_tree,
1305 hf_sbus_rdwr_block_addr, tvb, offset,
1308 sbus_quint8_helper0=0;
1309 /*find zero-termination of string*/
1310 for (i=19; i<43; i++) { /*max length string is 24 char*/
1311 if ((tvb_get_guint8(tvb, i)) == 0x00) {
1314 sbus_quint8_helper0 += 1;
1316 tmp_string = tvb_get_ephemeral_string(tvb, 19, sbus_quint8_helper0);
1317 proto_tree_add_string(sbus_tree,
1318 hf_sbus_rdwr_file_name, tvb, offset,
1319 sbus_quint8_helper0, tmp_string);
1320 offset += sbus_quint8_helper0;
1321 /*do not display a field for block data (skip)*/
1322 offset += (sbus_rdwr_length-6-sbus_quint8_helper0);
1323 } else { /* block write telegram, no file write*/
1324 proto_tree_add_item(sbus_tree,
1325 hf_sbus_block_nr, tvb, offset,
1328 proto_tree_add_item(sbus_tree,
1329 hf_sbus_rdwr_block_addr, tvb, offset,
1332 /*do not display a field for block data (skip)*/
1333 offset += (sbus_rdwr_length-8);
1336 case SBUS_RD_BLOCK_START_OF_STREAM:
1337 sbus_rdwr_block_type = tvb_get_guint8(tvb, 14);
1338 proto_tree_add_item(sbus_tree,
1339 hf_sbus_rdwr_telegram_sequence, tvb, offset,
1342 proto_tree_add_item(sbus_tree,
1343 hf_sbus_block_type, tvb, offset,
1347 /* Check for file or block download */
1348 if ((sbus_rdwr_block_type == SBUS_RD_WR_CONFIGURATION_FILE) ||
1349 (sbus_rdwr_block_type == SBUS_RD_WR_PROGRAM_BLOCK_FILE)) {
1350 sbus_quint8_helper0=0;
1351 /*find zero-termination of string*/
1352 for (i=14; i<38; i++) { /*max length string is 24 char*/
1353 if ((tvb_get_guint8(tvb, i)) == 0x00) {
1356 sbus_quint8_helper0 += 1;
1358 tmp_string = tvb_get_ephemeral_string(tvb, 14, sbus_quint8_helper0);
1359 proto_tree_add_string(sbus_tree,
1360 hf_sbus_rdwr_file_name, tvb, offset,
1361 sbus_quint8_helper0, tmp_string);
1362 offset += sbus_quint8_helper0;
1363 } else { /* block write telegram, no file write*/
1364 proto_tree_add_item(sbus_tree,
1365 hf_sbus_block_nr, tvb, offset,
1370 case SBUS_RD_BLOCK_DATA_STREAM:
1371 proto_tree_add_item(sbus_tree,
1372 hf_sbus_rdwr_telegram_sequence, tvb, offset,
1376 case SBUS_RD_BLOCK_DATA_BYTES:
1377 sbus_rdwr_block_type = tvb_get_guint8(tvb, 13);
1378 proto_tree_add_item(sbus_tree,
1379 hf_sbus_block_type, tvb, offset,
1382 /* Check for file or block read */
1383 if ((sbus_rdwr_block_type == SBUS_RD_WR_CONFIGURATION_FILE) ||
1384 (sbus_rdwr_block_type == SBUS_RD_WR_PROGRAM_BLOCK_FILE)) {
1385 /*reading from a file*/
1386 proto_tree_add_item(sbus_tree,
1387 hf_sbus_rdwr_block_addr, tvb, offset,
1390 proto_tree_add_item(sbus_tree,
1391 hf_sbus_rdwr_block_size, tvb, offset,
1394 sbus_quint8_helper0=0;
1395 /*find zero-termination of string*/
1396 for (i=22; i<46; i++) { /*max length string is 24 char*/
1397 if ((tvb_get_guint8(tvb, i)) == 0x00) {
1400 sbus_quint8_helper0 += 1;
1402 tmp_string = tvb_get_ephemeral_string(tvb, 22, sbus_quint8_helper0);
1403 proto_tree_add_string(sbus_tree,
1404 hf_sbus_rdwr_file_name, tvb, offset,
1405 sbus_quint8_helper0, tmp_string);
1406 offset += sbus_quint8_helper0 + 1;
1407 } else { /* block read telegram, no file read*/
1408 proto_tree_add_item(sbus_tree,
1409 hf_sbus_block_nr, tvb, offset,
1412 proto_tree_add_item(sbus_tree,
1413 hf_sbus_rdwr_block_addr, tvb, offset,
1416 proto_tree_add_item(sbus_tree,
1417 hf_sbus_rdwr_block_size, tvb, offset,
1422 case SBUS_DELETE_BLOCK:
1423 case SBUS_GET_BLOCK_SIZE:
1424 sbus_rdwr_block_type = tvb_get_guint8(tvb, 13);
1425 proto_tree_add_item(sbus_tree,
1426 hf_sbus_block_type, tvb, offset,
1429 /* Check for file or block deletion */
1430 if ((sbus_rdwr_block_type == SBUS_RD_WR_CONFIGURATION_FILE) ||
1431 (sbus_rdwr_block_type == SBUS_RD_WR_PROGRAM_BLOCK_FILE)) {
1433 sbus_quint8_helper0=0;
1434 /*find zero-termination of string*/
1435 for (i=14; i<38; i++) { /*max length string is 24 char*/
1436 if ((tvb_get_guint8(tvb, i)) == 0x00) {
1439 sbus_quint8_helper0 += 1;
1441 tmp_string = tvb_get_ephemeral_string(tvb, 14, sbus_quint8_helper0);
1442 proto_tree_add_string(sbus_tree,
1443 hf_sbus_rdwr_file_name, tvb, offset,
1444 sbus_quint8_helper0, tmp_string);
1445 offset += sbus_quint8_helper0 + 1;
1446 } else { /* delete a block*/
1447 proto_tree_add_item(sbus_tree,
1448 hf_sbus_block_nr, tvb, offset,
1453 case SBUS_GET_PROGRAM_BLOCK_LIST:
1454 proto_tree_add_item(sbus_tree,
1455 hf_sbus_rdwr_list_type, tvb, offset,
1466 /*Inform that command was not dissected and add remaining length*/
1468 if (sbus_eth_len > 13) { /*13 bytes is the minimal length of a request telegram...*/
1469 sbus_helper = sbus_eth_len - (offset + 2);
1470 proto_tree_add_text(sbus_tree, tvb, offset, sbus_helper,
1471 "This telegram isn't implemented in the dissector.");
1472 offset = offset + sbus_helper;
1478 /* Response dissection*/
1479 if (sbus_attribut == SBUS_RESPONSE && request_val) {
1480 /*add response time*/
1481 nstime_delta(&ns, &pinfo->fd->abs_ts, &request_val->req_time);
1482 proto_tree_add_time(sbus_tree, hf_sbus_response_time,
1484 /*add reference to request telegram*/
1485 proto_tree_add_uint(sbus_tree, hf_sbus_response_to, tvb, 0, 0,
1486 request_val->req_frame);
1488 switch (request_val->cmd_code) {
1489 /* Response: 32 bit values*/
1490 case SBUS_RD_COUNTER:
1491 case SBUS_RD_REGISTER:
1493 case SBUS_RD_USER_MEMORY:
1494 case SBUS_RD_PROGRAM_LINE:
1495 case SBUS_RD_USER_EEPROM_REGISTER:
1496 /*Add subtree for Data*/
1497 dt = proto_tree_add_text(sbus_tree, tvb, offset,
1498 ((request_val->count) * 4),"Data");
1499 sbusdata_tree = proto_item_add_subtree(dt, ett_sbus_data);
1500 for (i=(request_val->count); i>0; i--) {
1501 proto_tree_add_item(sbusdata_tree,
1502 hf_sbus_data_rtc, tvb, offset,
1508 /* Response: PCD Display register*/
1509 case SBUS_RD_DISPLAY_REGISTER:
1510 proto_tree_add_item(sbus_tree,
1511 hf_sbus_display_register, tvb, offset, 4, ENC_BIG_ENDIAN);
1515 /* Add binary data I, O, F*/
1518 case SBUS_RD_OUTPUT:
1519 /*Add subtree for Data*/
1520 dt = proto_tree_add_text(sbus_tree, tvb, offset,
1521 (((request_val->count) + 7) / 8), "Data");
1522 sbusdata_tree = proto_item_add_subtree(dt, ett_sbus_data);
1524 for (i=(((request_val->count) + 7) / 8); i>0; i--) {
1527 sbus_binarymasked = 0x01;
1528 sbus_binaries = tvb_get_guint8(tvb, offset);
1529 for (j=0; j<8; j++){
1530 if ((sbus_binarymasked & sbus_binaries) != 0) {
1531 sbus_show_bin = (sbus_show_bin + sbus_helper);
1533 sbus_binarymasked = sbus_binarymasked<<1;
1534 sbus_helper = 10 * sbus_helper;
1537 proto_tree_add_uint_format(sbusdata_tree,
1538 hf_sbus_data_iof, tvb, offset, 1, sbus_show_bin,
1539 "Binary data: %08u", sbus_show_bin);
1544 /* Response: Real time clock value*/
1546 sbus_helper = tvb_get_guint8(tvb, (offset +5)); /*hours*/
1547 sbus_helper1 = tvb_get_guint8(tvb, (offset +6)); /*minutes*/
1548 sbus_helper2 = tvb_get_guint8(tvb, (offset +7)); /*seconds*/
1549 proto_tree_add_text(sbus_tree, tvb, (offset +5), 3,
1550 "Time (HH:MM:SS): %02x:%02x:%02x", sbus_helper, sbus_helper1, sbus_helper2);
1551 sbus_helper = tvb_get_guint8(tvb, (offset +2)); /*year*/
1552 sbus_helper1 = tvb_get_guint8(tvb, (offset +3)); /*month*/
1553 sbus_helper2 = tvb_get_guint8(tvb, (offset +4)); /*day*/
1554 proto_tree_add_text(sbus_tree, tvb, (offset +2), 3,
1555 "Date (YY/MM/DD): %02x/%02x/%02x", sbus_helper, sbus_helper1, sbus_helper2);
1556 sbus_helper = tvb_get_guint8(tvb, (offset)); /*year-week*/
1557 sbus_helper1 = tvb_get_guint8(tvb, (offset +1)); /*week-day*/
1558 proto_tree_add_text(sbus_tree, tvb, offset, 2,
1559 "Calendar week: %x, Week day: %x", sbus_helper, sbus_helper1);
1560 /*Add subtree for Data*/
1561 dt = proto_tree_add_text(sbus_tree, tvb, offset,
1563 sbusdata_tree = proto_item_add_subtree(dt, ett_sbus_data);
1565 proto_tree_add_item(sbusdata_tree,
1566 hf_sbus_week_day, tvb, offset, 2, ENC_BIG_ENDIAN);
1568 proto_tree_add_item(sbusdata_tree,
1569 hf_sbus_date, tvb, offset, 3, ENC_BIG_ENDIAN);
1571 proto_tree_add_item(sbusdata_tree,
1572 hf_sbus_time, tvb, offset, 3, ENC_BIG_ENDIAN);
1576 /* Response: CPU status, the command codes 14..1B are concerned*/
1577 case SBUS_RD_PCD_STATUS_CPU0:
1578 case SBUS_RD_PCD_STATUS_CPU1:
1579 case SBUS_RD_PCD_STATUS_CPU2:
1580 case SBUS_RD_PCD_STATUS_CPU3:
1581 case SBUS_RD_PCD_STATUS_CPU4:
1582 case SBUS_RD_PCD_STATUS_CPU5:
1583 case SBUS_RD_PCD_STATUS_CPU6:
1584 case SBUS_RD_PCD_STATUS_OWN:
1585 proto_tree_add_item(sbus_tree,
1586 hf_sbus_cpu_status, tvb, offset, 1, ENC_BIG_ENDIAN);
1590 /* Response: Station address*/
1591 case SBUS_RD_SBUS_STN_NBR:
1592 proto_tree_add_item(sbus_tree,
1593 hf_sbus_address, tvb, offset, 1, ENC_BIG_ENDIAN);
1597 /* Response: Firmware version */
1598 case SBUS_RD_PROGRAM_VERSION:
1600 tmp_string = tvb_get_ephemeral_string(tvb , offset, 5);
1601 proto_tree_add_string(sbus_tree,
1602 hf_sbus_cpu_type, tvb, offset, 5, tmp_string);
1605 tmp_string = tvb_get_ephemeral_string(tvb , offset, 3);
1606 proto_tree_add_string(sbus_tree,
1607 hf_sbus_fw_version, tvb, offset, 3, tmp_string);
1611 /* Response for Status Flags*/
1612 case SBUS_RD_STATUSFLAG_ACCU:
1613 /*Add subtree for Data*/
1614 dt = proto_tree_add_text(sbus_tree, tvb, offset,
1615 1,"ACCU and arithmetic status");
1616 sbusdata_tree = proto_item_add_subtree(dt, ett_sbus_data);
1618 proto_tree_add_item(sbusdata_tree, hf_sbus_flags_accu,
1619 tvb, offset, 1, ENC_BIG_ENDIAN);
1620 proto_tree_add_item(sbusdata_tree, hf_sbus_flags_error,
1621 tvb, offset, 1, ENC_BIG_ENDIAN);
1622 proto_tree_add_item(sbusdata_tree, hf_sbus_flags_negative,
1623 tvb, offset, 1, ENC_BIG_ENDIAN);
1624 proto_tree_add_item(sbusdata_tree, hf_sbus_flags_zero,
1625 tvb, offset, 1, ENC_BIG_ENDIAN);
1629 /* Response for Read byte */
1631 /*Add subtree for Data*/
1632 dt = proto_tree_add_text(sbus_tree, tvb, offset,
1633 (request_val->count),"Data (bytes)");
1635 sbusdata_tree = proto_item_add_subtree(dt, ett_sbus_data);
1636 for (i=(request_val->count); i>0; i--) {
1637 proto_tree_add_item(sbusdata_tree,
1638 hf_sbus_data_byte, tvb, offset,
1644 /* Response for Read Index register */
1645 case SBUS_RD_INDEX_REGISTER:
1646 /*Add subtree for Data*/
1647 dt = proto_tree_add_text(sbus_tree, tvb, offset,
1648 2,"Data (hex bytes)");
1650 sbusdata_tree = proto_item_add_subtree(dt, ett_sbus_data);
1651 for (i=0; i<2; i++) { /*2 bytes*/
1652 proto_tree_add_item(sbusdata_tree,
1653 hf_sbus_data_byte_hex, tvb, offset,
1659 /* Response: Instruction pointer*/
1660 case SBUS_RD_INSTRUCTION_POINTER:
1661 proto_tree_add_item(sbus_tree,
1662 hf_sbus_addr_prog, tvb, offset, 3, ENC_BIG_ENDIAN);
1666 /*Response for Find History*/
1667 case SBUS_FIND_HISTORY:
1668 proto_tree_add_item(sbus_tree,
1669 hf_sbus_addr_68k, tvb, offset, 3, ENC_BIG_ENDIAN);
1671 proto_tree_add_item(sbus_tree,
1672 hf_sbus_nbr_elements, tvb, offset, 2, ENC_BIG_ENDIAN);
1676 /* Response: Read current block*/
1677 case SBUS_RD_CURRENT_BLOCK:
1678 proto_tree_add_item(sbus_tree,
1679 hf_sbus_block_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1681 proto_tree_add_item(sbus_tree,
1682 hf_sbus_block_nr, tvb, offset, 2, ENC_BIG_ENDIAN);
1686 /* Response: Read system infomation (without interpretation of module info)*/
1687 case SBUS_RD_SYSTEM_INFORMATION:
1688 if (request_val->sysinfo == 0x00){ /*sysinfo 0*/
1689 offset += 1; /* this byte is always 0x01*/
1690 /*Add subtree for Data*/
1691 dt = proto_tree_add_text(sbus_tree, tvb, offset,
1693 sbusdata_tree = proto_item_add_subtree(dt, ett_sbus_data);
1695 proto_tree_add_item(sbusdata_tree, hf_sbus_sysinfo0_1,
1696 tvb, offset, 1, ENC_BIG_ENDIAN);
1697 proto_tree_add_item(sbusdata_tree, hf_sbus_sysinfo0_2,
1698 tvb, offset, 1, ENC_BIG_ENDIAN);
1699 proto_tree_add_item(sbusdata_tree, hf_sbus_sysinfo0_3,
1700 tvb, offset, 1, ENC_BIG_ENDIAN);
1701 proto_tree_add_item(sbusdata_tree, hf_sbus_sysinfo0_4,
1702 tvb, offset, 1, ENC_BIG_ENDIAN);
1703 proto_tree_add_item(sbusdata_tree, hf_sbus_sysinfo0_5,
1704 tvb, offset, 1, ENC_BIG_ENDIAN);
1707 /*do not dissect all system info telegrams as there is no need*/
1708 offset = (tvb_get_guint8(tvb,9) + 10);
1712 /* Response: Webserver request */
1713 case SBUS_WEB_SERVER_SERIAL_COMM:
1714 sbus_web_size = tvb_get_guint8(tvb,offset);
1715 proto_tree_add_uint(sbus_tree,
1716 hf_sbus_web_size, tvb, offset,
1720 sbus_web_aid = tvb_get_guint8(tvb,offset);
1721 proto_tree_add_uint(sbus_tree,
1722 hf_sbus_web_aid, tvb, offset,
1726 if (sbus_web_size > 1) {
1727 sbus_web_seq = tvb_get_guint8(tvb,offset);
1728 proto_tree_add_uint(sbus_tree,
1729 hf_sbus_web_seq, tvb, offset,
1733 dt = proto_tree_add_text(sbus_tree, tvb, offset,
1734 (sbus_web_size - 2),"Data (bytes)");
1736 sbusdata_tree = proto_item_add_subtree(dt, ett_sbus_data);
1737 for (i=sbus_web_size - 2; i>0; i--) {
1738 proto_tree_add_item(sbusdata_tree,
1739 hf_sbus_data_byte, tvb, offset,
1745 /* Response: Read/Write block data */
1746 case SBUS_RD_WR_PCD_BLOCK:
1747 sbus_rdwr_block_tlg = request_val->block_tlg;
1748 sbus_rdwr_length = tvb_get_guint8(tvb,offset);
1749 proto_tree_add_uint(sbus_tree,
1750 hf_sbus_rdwr_block_length, tvb, offset,
1751 1, sbus_rdwr_length);
1753 hi = proto_tree_add_item(sbus_tree,
1754 hf_sbus_rdwr_acknakcode, tvb, offset,
1756 if ((tvb_get_guint8(tvb, offset) >= SBUS_RD_WR_NAK)&&
1757 (tvb_get_guint8(tvb, offset) <= SBUS_RD_WR_NAK_INVALID_SIZE)) {
1758 expert_add_info_format(pinfo, hi, PI_RESPONSE_CODE, PI_CHAT,
1759 "Telegram not acknowledged by PCD");
1762 switch(sbus_rdwr_block_tlg) {
1763 case SBUS_WR_START_OF_STREAM:
1764 case SBUS_WR_BLOCK_DATA_STREAM:
1765 case SBUS_WR_BLOCK_END_OF_STREAM:
1766 proto_tree_add_item(sbus_tree,
1767 hf_sbus_rdwr_telegram_sequence, tvb, offset,
1771 case SBUS_WR_ABORT_BLOCK_STREAM:
1772 case SBUS_RD_ABORT_BLOCK_STREAM:
1773 case SBUS_WR_BLOCK_DATA_BYTES:
1774 case SBUS_DELETE_BLOCK:
1776 case SBUS_RD_BLOCK_START_OF_STREAM:
1777 proto_tree_add_item(sbus_tree,
1778 hf_sbus_rdwr_telegram_sequence, tvb, offset,
1781 proto_tree_add_item(sbus_tree,
1782 hf_sbus_rdwr_block_size, tvb, offset,
1785 /*do not display a field for block data (skip)*/
1786 offset += (sbus_rdwr_length-6);
1788 case SBUS_RD_BLOCK_DATA_STREAM:
1789 proto_tree_add_item(sbus_tree,
1790 hf_sbus_rdwr_telegram_sequence, tvb, offset,
1793 /*do not display a field for block data (skip)*/
1794 offset += (sbus_rdwr_length-2);
1796 case SBUS_RD_BLOCK_DATA_BYTES:
1797 /*do not display a field for block data (skip)*/
1798 offset += (sbus_rdwr_length-1);
1800 case SBUS_GET_BLOCK_SIZE:
1801 sbus_rdwr_block_type = tvb_get_guint8(tvb, 10);
1802 /* Check for unknown block type */
1803 if (sbus_rdwr_block_type == SBUS_RD_WR_UNKNOWN_BLOCK_TYPE) {
1804 /*unknown block, no more data follows*/
1805 } else { /* add block size and CRC32 in case of known block*/
1806 proto_tree_add_item(sbus_tree,
1807 hf_sbus_rdwr_block_size, tvb, offset,
1810 /*Now the CRC32 follows, but I don't bother calculating it*/
1814 case SBUS_GET_PROGRAM_BLOCK_LIST:
1815 proto_tree_add_item(sbus_tree,
1816 hf_sbus_block_type, tvb, offset,
1819 proto_tree_add_item(sbus_tree,
1820 hf_sbus_block_nr, tvb, offset,
1823 proto_tree_add_item(sbus_tree,
1824 hf_sbus_rdwr_block_size, tvb, offset,
1827 /*do not display block_timestamp as no description is available*/
1828 offset += (sbus_rdwr_length-8);
1835 /*Inform that response was not dissected and add remaining length*/
1837 sbus_helper = sbus_eth_len - (offset + 2);
1838 proto_tree_add_text(sbus_tree, tvb, offset, sbus_helper,
1839 "This telegram isn't implemented in the dissector.");
1840 offset = offset + sbus_helper;
1843 } else if (sbus_attribut == SBUS_RESPONSE && (!request_val)) {
1844 /*calculate the offset in case the request telegram was not found or was broadcasted*/
1845 sbus_eth_len = tvb_get_ntohl(tvb,0);
1846 sbus_helper = sbus_eth_len - 11;
1847 proto_tree_add_text(sbus_tree, tvb, offset, sbus_helper,
1848 "Not dissected, could not find request telegram");
1849 offset = sbus_eth_len - 2;
1852 if (sbus_attribut == SBUS_ACKNAK) {
1853 /*Add response time if possible*/
1855 nstime_delta(&ns, &pinfo->fd->abs_ts, &request_val->req_time);
1856 proto_tree_add_time(sbus_tree, hf_sbus_response_time,
1858 /*add reference to request telegram*/
1859 proto_tree_add_uint(sbus_tree, hf_sbus_response_to, tvb, 0, 0,
1860 request_val->req_frame);
1862 hi = proto_tree_add_item(sbus_tree,
1863 hf_sbus_acknackcode, tvb, offset, 2, ENC_BIG_ENDIAN);
1864 if (tvb_get_guint8(tvb, (offset+1)) > 0) {
1865 expert_add_info_format(pinfo, hi, PI_RESPONSE_CODE, PI_CHAT,
1866 "Telegram not acknowledged by PCD");
1871 /* Calclulate CRC */
1873 for (i = 0; i < sbus_eth_len - 2; i++)
1874 sbus_crc_calc = crc_calc (sbus_crc_calc, tvb_get_guint8(tvb, i));
1875 /*Show CRC and add hidden item for wrong CRC*/
1876 sbus_helper = tvb_get_ntohs(tvb, offset);
1877 if (sbus_helper == sbus_crc_calc) {
1878 proto_tree_add_uint_format(sbus_tree,
1879 hf_sbus_crc, tvb, offset, 2, sbus_helper,
1880 "Checksum: 0x%04x (correct)", sbus_helper);
1882 cs = proto_tree_add_uint_format(sbus_tree,
1883 hf_sbus_crc, tvb, offset, 2, sbus_helper,
1884 "Checksum: 0x%04x (NOT correct)", sbus_helper);
1885 expert_add_info_format(pinfo, cs, PI_CHECKSUM, PI_ERROR,
1887 hi = proto_tree_add_boolean(sbus_tree,
1888 hf_sbus_crc_bad, tvb, offset, 2, TRUE);
1889 PROTO_ITEM_SET_HIDDEN(hi);
1890 PROTO_ITEM_SET_GENERATED(hi);
1892 offset += 2; /*now at the end of the telegram*/
1894 return tvb_length(tvb);
1895 /*End of dissect_sbus*/
1898 /* Register the protocol with Wireshark */
1901 proto_register_sbus(void)
1904 /* Setup list of header fields See Section 1.6.1 for details*/
1905 static hf_register_info hf[] = {
1907 { "Length (bytes)", "sbus.len",
1908 FT_UINT32, BASE_DEC, NULL, 0,
1909 "SAIA Ether-S-Bus telegram length", HFILL }
1912 { "Version", "sbus.vers",
1913 FT_UINT8, BASE_DEC, NULL, 0,
1914 "SAIA Ether-S-Bus version", HFILL }
1916 { &hf_sbus_protocol,
1917 { "Protocol type", "sbus.proto",
1918 FT_UINT8, BASE_DEC, NULL, 0,
1919 "SAIA Ether-S-Bus protocol type", HFILL }
1921 { &hf_sbus_sequence,
1922 { "Sequence", "sbus.seq",
1923 FT_UINT16, BASE_DEC, NULL, 0,
1924 "SAIA Ether-S-Bus sequence number", HFILL }
1927 { &hf_sbus_attribut,
1928 { "Telegram attribute", "sbus.att",
1929 FT_UINT8, BASE_HEX, VALS(sbus_att_vals), 0,
1930 "SAIA Ether-S-Bus telegram attribute, indicating type of telegram", HFILL }
1934 { "Destination", "sbus.destination",
1935 FT_UINT8, BASE_DEC, NULL, 0,
1936 "SAIA S-Bus destination address", HFILL }
1940 { "S-Bus address", "sbus.address",
1941 FT_UINT8, BASE_DEC, NULL, 0,
1942 "SAIA S-Bus station address", HFILL }
1946 { "Command", "sbus.cmd",
1947 FT_UINT8, BASE_HEX, VALS(sbus_command_vals), 0,
1948 "SAIA S-Bus command", HFILL }
1951 { &hf_sbus_command_extension,
1952 { "Command extension", "sbus.cmd_extn",
1953 FT_UINT8, BASE_HEX, NULL, 0,
1954 "SAIA S-Bus command extension", HFILL }
1958 { "R-count", "sbus.rcount",
1959 FT_UINT8, BASE_DEC, NULL, 0,
1960 "Number of elements expected in response", HFILL }
1964 { "W-count (raw)", "sbus.wcount",
1965 FT_UINT8, BASE_DEC, NULL, 0,
1966 "Number of bytes to be written", HFILL }
1969 { &hf_sbus_wcount_calculated,
1970 { "W-count (32 bit values)", "sbus.wcount_calc",
1971 FT_UINT8, BASE_DEC, NULL, 0,
1972 "Number of elements to be written", HFILL }
1975 { &hf_sbus_fio_count,
1976 { "FIO Count (amount of bits)", "sbus.fio_count",
1977 FT_UINT8, BASE_DEC, NULL, 0,
1978 "Number of binary elements to be written", HFILL }
1981 { &hf_sbus_addr_rtc,
1982 { "Base address RTC", "sbus.addr_RTC",
1983 FT_UINT16, BASE_DEC, NULL, 0,
1984 "Base address of 32 bit elements to read", HFILL }
1987 { &hf_sbus_addr_iof,
1988 { "Base address IOF", "sbus.addr_IOF",
1989 FT_UINT16, BASE_DEC, NULL, 0,
1990 "Base address of binary elements to read", HFILL }
1993 { &hf_sbus_addr_eeprom,
1994 { "Base address of EEPROM register", "sbus.addr_EEPROM",
1995 FT_UINT16, BASE_DEC, NULL, 0,
1996 "Base address of 32 bit EEPROM register to read or write", HFILL }
1999 { &hf_sbus_addr_prog,
2000 { "Base address of user memory or program lines", "sbus.addr_prog",
2001 FT_UINT24, BASE_DEC, NULL, 0,
2002 "Base address of the user memory or program lines (read or write)", HFILL }
2005 { &hf_sbus_addr_68k,
2006 { "Base address of bytes", "sbus.addr_68k",
2007 FT_UINT24, BASE_HEX, NULL, 0,
2008 "Base address of bytes to read or write (68k address)", HFILL }
2011 { &hf_sbus_block_type,
2012 { "Block type", "sbus.block_type",
2013 FT_UINT8, BASE_HEX, VALS(sbus_block_types), 0,
2014 "Program block type", HFILL }
2017 { &hf_sbus_block_nr,
2018 { "Block/Element nr", "sbus.block_nr",
2019 FT_UINT16, BASE_DEC, NULL, 0,
2020 "Program block / DatatBlock number", HFILL }
2023 { &hf_sbus_nbr_elements,
2024 { "Number of elements", "sbus.nbr_elements",
2025 FT_UINT16, BASE_DEC, NULL, 0,
2026 "Number of elements or characters", HFILL }
2029 { &hf_sbus_display_register,
2030 { "PCD Display register", "sbus.data_display_register",
2031 FT_UINT32, BASE_DEC, NULL, 0,
2032 "The PCD display register (32 bit value)", HFILL }
2035 { &hf_sbus_data_rtc,
2036 { "S-Bus 32-bit data", "sbus.data_rtc",
2037 FT_UINT32, BASE_DEC, NULL, 0,
2038 "One regiser/timer of counter (32 bit value)", HFILL }
2041 { &hf_sbus_data_byte,
2042 { "Data bytes", "sbus.data_byte",
2043 FT_UINT8, BASE_DEC, NULL, 0,
2044 "One byte from PCD", HFILL }
2047 { &hf_sbus_data_byte_hex,
2048 { "Data bytes (hex)", "sbus.data_byte_hex",
2049 FT_UINT8, BASE_HEX, NULL, 0,
2050 "One byte from PCD (hexadecimal)", HFILL }
2053 { &hf_sbus_data_iof,
2054 { "S-Bus binary data", "sbus.data_iof",
2055 FT_UINT32, BASE_DEC, NULL, 0,
2056 "8 binaries", HFILL }
2059 { &hf_sbus_cpu_type,
2060 { "PCD type", "sbus.pcd_type",
2061 FT_STRING, BASE_NONE, NULL, 0,
2062 "PCD type (short form)", HFILL }
2065 { &hf_sbus_fw_version,
2066 { "Firmware version", "sbus.fw_version",
2067 FT_STRING, BASE_NONE, NULL, 0,
2068 "Firmware version of the PCD or module", HFILL }
2071 { &hf_sbus_sysinfo_nr,
2072 { "System information number", "sbus.sysinfo",
2073 FT_UINT8, BASE_HEX, NULL, 0,
2074 "System information number (extension to command code)", HFILL }
2077 { &hf_sbus_sysinfo0_1,
2078 { "Mem size info", "sbus.sysinfo0.mem",
2079 FT_BOOLEAN, 8, TFS(&tfs_sbus_present), F_MEMSIZE,
2080 "Availability of memory size information", HFILL }
2082 { &hf_sbus_sysinfo0_2,
2083 { "Trace buffer", "sbus.sysinfo0.trace",
2084 FT_BOOLEAN, 8, TFS(&tfs_sbus_present), F_TRACE,
2085 "Availability of trace buffer feature", HFILL }
2087 { &hf_sbus_sysinfo0_3,
2088 { "Slot B1", "sbus.sysinfo0.b1",
2089 FT_BOOLEAN, 8, TFS(&tfs_sbus_present), F_INFO_B1,
2090 "Presence of EEPROM information on slot B1", HFILL }
2092 { &hf_sbus_sysinfo0_4,
2093 { "Slot B2", "sbus.sysinfo0.b2",
2094 FT_BOOLEAN, 8, TFS(&tfs_sbus_present), F_INFO_B2,
2095 "Presence of EEPROM information on slot B2", HFILL }
2097 { &hf_sbus_sysinfo0_5,
2098 { "PGU baud", "sbus.sysinfo0.pgubaud",
2099 FT_BOOLEAN, 8, TFS(&tfs_sbus_present), F_PGU_BAUD,
2100 "Availability of PGU baud switch feature", HFILL }
2103 { &hf_sbus_sysinfo_length,
2104 { "System information length", "sbus.sysinfo_length",
2105 FT_UINT8, BASE_HEX, NULL, 0,
2106 "System information length in response", HFILL }
2109 { &hf_sbus_f_module_type,
2110 { "F-module type", "sbus.fmodule_type",
2111 FT_STRING, BASE_NONE, NULL, 0,
2112 "Module type mounted on B1/2 slot", HFILL }
2115 { &hf_sbus_harware_version,
2116 { "Hardware version", "sbus.hw_version",
2117 FT_STRING, BASE_NONE, NULL, 0,
2118 "Hardware version of the PCD or the module", HFILL }
2121 { &hf_sbus_hardware_modification,
2122 { "Hardware modification", "sbus.hw_modification",
2123 FT_UINT8, BASE_DEC, NULL, 0,
2124 "Hardware modification of the PCD or module", HFILL }
2128 { "Various data", "sbus.various",
2129 FT_NONE, BASE_NONE, NULL, 0,
2130 "Various data contained in telegrams but nobody will search for it", HFILL }
2133 { &hf_sbus_acknackcode,
2134 { "ACK/NAK code", "sbus.nakcode",
2135 FT_UINT16, BASE_HEX, VALS(sbus_ack_nak_vals), 0,
2136 "SAIA S-Bus ACK/NAK response", HFILL }
2139 { &hf_sbus_cpu_status,
2140 { "CPU status", "sbus.CPU_status",
2141 FT_UINT8, BASE_HEX, VALS(sbus_CPU_status), 0,
2142 "SAIA PCD CPU status", HFILL }
2145 { &hf_sbus_week_day,
2146 { "RTC calendar week and week day", "sbus.rtc.week_day",
2147 FT_UINT16, BASE_HEX, NULL, 0,
2148 "Calendar week and week day number of the real time clock", HFILL }
2152 { "RTC date (YYMMDD)", "sbus.rtc.date",
2153 FT_UINT24, BASE_HEX, NULL, 0,
2154 "Year, month and day of the real time clock", HFILL }
2158 { "RTC time (HHMMSS)", "sbus.rtc.time",
2159 FT_UINT24, BASE_HEX, NULL, 0,
2160 "Time of the real time clock", HFILL }
2163 { &hf_sbus_web_size,
2164 { "Web server packet size", "sbus.web.size",
2165 FT_UINT8, BASE_HEX, NULL, 0,
2170 { "AID", "sbus.web.aid",
2171 FT_UINT8, BASE_HEX, NULL, 0,
2172 "Web server command/status code (AID)", HFILL }
2176 { "Sequence", "sbus.web.seq",
2177 FT_UINT8, BASE_HEX, NULL, 0,
2178 "Web server sequence nr (PACK_N)", HFILL }
2181 { &hf_sbus_rdwr_block_length,
2182 { "Read/write block telegram length", "sbus.block.length",
2183 FT_UINT8, BASE_DEC, NULL, 0,
2187 { &hf_sbus_rdwr_block_length_ext,
2188 { "Extended length (bytes)", "sbus.len_ext",
2189 FT_UINT32, BASE_DEC, NULL, 0,
2193 { &hf_sbus_rdwr_telegram_type,
2194 { "Read/write block telegram type", "sbus.block.tlgtype",
2195 FT_UINT8, BASE_HEX, VALS(rdwrblock_vals), 0,
2196 "Type of RD/WR block telegram", HFILL }
2199 { &hf_sbus_rdwr_telegram_sequence,
2200 { "Sequence", "sbus.block.seq",
2201 FT_UINT8, BASE_DEC, NULL, 0,
2202 "Sequence number of block data stream telegram", HFILL }
2205 { &hf_sbus_rdwr_block_size,
2206 { "Block size in bytes", "sbus.block.size",
2207 FT_UINT32, BASE_DEC, NULL, 0,
2208 "The size of the block in bytes", HFILL }
2211 { &hf_sbus_rdwr_block_addr,
2212 { "Address inside block", "sbus.block.addr",
2213 FT_UINT32, BASE_DEC, NULL, 0,
2214 "The address inside a block", HFILL }
2218 { &hf_sbus_rdwr_file_name,
2219 { "File name", "sbus.block.filename",
2220 FT_STRING, BASE_NONE, NULL, 0,
2221 "Name of file to in RD/WR block telegram", HFILL }
2224 { &hf_sbus_rdwr_list_type,
2225 { "Get program block list, command type", "sbus.block.getlisttype",
2226 FT_UINT8, BASE_HEX, VALS(rdwrblock_list_type_vals), 0,
2227 "Type of the Get Program Block list request", HFILL }
2230 { &hf_sbus_rdwr_acknakcode,
2231 { "ACK/NAK code", "sbus.block.nakcode",
2232 FT_UINT8, BASE_HEX, VALS(rdwrblock_sts), 0,
2233 "ACK/NAK response for block write requests", HFILL }
2237 { "Checksum", "sbus.crc",
2238 FT_UINT16, BASE_HEX, NULL, 0,
2243 { "Bad Checksum", "sbus.crc_bad",
2244 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
2245 "A bad checksum in the telegram", HFILL }},
2248 { "Retry", "sbus.retry", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
2249 "Repeated request telegram (due to wrong or missing answer)", HFILL }},
2251 { &hf_sbus_flags_accu,
2252 { "ACCU", "sbus.flags.accu",
2253 FT_BOOLEAN, 8, TFS(&tfs_sbus_flags), F_ACCU,
2254 "PCD Accumulator", HFILL }
2257 { &hf_sbus_flags_error,
2258 { "Error flag", "sbus.flags.error",
2259 FT_BOOLEAN, 8, TFS(&tfs_sbus_flags), F_ERROR,
2260 "PCD error flag", HFILL }
2263 { &hf_sbus_flags_negative,
2264 { "N-flag", "sbus.flags.nflag",
2265 FT_BOOLEAN, 8, TFS(&tfs_sbus_flags), F_NEGATIVE,
2266 "Negative status flag", HFILL }
2269 { &hf_sbus_flags_zero,
2270 { "Z-flag", "sbus.flags.zflag",
2271 FT_BOOLEAN, 8, TFS(&tfs_sbus_flags), F_ZERO,
2272 "Zero status flag", HFILL }
2275 { &hf_sbus_response_in,
2276 { "Response in frame nr.", "sbus.response_in",
2277 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
2278 "The response to this Ether-S-Bus request is in this frame", HFILL }
2281 { &hf_sbus_response_to,
2282 { "Request in frame nr.", "sbus.response_to",
2283 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
2284 "This is a response to the Ether-S-Bus request in this frame", HFILL }
2287 { &hf_sbus_response_time,
2288 { "Response time", "sbus.response_time",
2289 FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
2290 "The time between the request and the response", HFILL }
2294 { "Time passed since first request", "sbus.timeout",
2295 FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
2296 "The time between the first (identical) request and the repetition", HFILL }
2299 { &hf_sbus_request_in,
2300 { "First request in frame nr.", "sbus.request_in",
2301 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
2302 "The first request of this repeated request is in this frame", HFILL }
2307 /* Setup protocol subtree array */
2308 static gint *ett[] = {
2314 /* Register the protocol name and description */
2315 proto_sbus = proto_register_protocol("SAIA S-Bus", "SBUS", "sbus");
2317 /* Required function calls to register the header fields and subtrees used */
2318 proto_register_field_array(proto_sbus, hf, array_length(hf));
2319 proto_register_subtree_array(ett, array_length(ett));
2320 register_init_routine(&sbus_init_protocol);
2324 proto_reg_handoff_sbus(void)
2326 dissector_handle_t sbus_handle;
2328 sbus_handle = new_create_dissector_handle(dissect_sbus, proto_sbus);
2329 dissector_add_uint("udp.port", 5050, sbus_handle);
2338 * indent-tabs-mode: nil
2341 * ex: set shiftwidth=7 tabstop=8 expandtab:
2342 * :indentSize=7:tabSize=8:noTabs=true: