sensor_dissector.lua 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. function sensor_dissector(buffer, pinfo, subtree1, sensor_protocol, offset, num_of_instance, queue_id)
  2. if queue_id == 0 then
  3. require("sensor_dissector")
  4. sensor_dissector_0(buffer, pinfo, subtree1, sensor_protocol, offset, num_of_instance)
  5. elseif queue_id == 1 then
  6. require("sensor_dissector")
  7. sensor_dissector_1(buffer, pinfo, subtree1, sensor_protocol, offset, num_of_instance)
  8. elseif queue_id == 2 then
  9. require("sensor_dissector")
  10. sensor_dissector_2(buffer, pinfo, subtree1, sensor_protocol, offset, num_of_instance)
  11. elseif queue_id == 3 then
  12. require("sensor_dissector")
  13. sensor_dissector_3(buffer, pinfo, subtree1, sensor_protocol, offset, num_of_instance)
  14. elseif queue_id == 4 then
  15. require("sensor_dissector")
  16. sensor_dissector_4(buffer, pinfo, subtree1, sensor_protocol, offset, num_of_instance)
  17. elseif queue_id == 5 then
  18. require("sensor_dissector")
  19. sensor_dissector_5(buffer, pinfo, subtree1, sensor_protocol, offset, num_of_instance)
  20. elseif queue_id == 6 then
  21. require("sensor_dissector")
  22. sensor_dissector_6(buffer, pinfo, subtree1, sensor_protocol, offset, num_of_instance)
  23. elseif queue_id == 7 then
  24. require("sensor_dissector")
  25. sensor_dissector_7(buffer, pinfo, subtree1, sensor_protocol, offset, num_of_instance)
  26. elseif queue_id == 8 then
  27. require("sensor_dissector")
  28. sensor_dissector_8(buffer, pinfo, subtree1, sensor_protocol, offset, num_of_instance)
  29. elseif queue_id == 9 then
  30. require("sensor_dissector")
  31. sensor_dissector_9(buffer, pinfo, subtree1, sensor_protocol, offset, num_of_instance)
  32. elseif queue_id == 10 then
  33. require("sensor_dissector")
  34. sensor_dissector_10(buffer, pinfo, subtree1, sensor_protocol, offset, num_of_instance)
  35. elseif queue_id == 11 then
  36. require("sensor_dissector")
  37. sensor_dissector_11(buffer, pinfo, subtree1, sensor_protocol, offset, num_of_instance)
  38. elseif queue_id == 12 then
  39. require("sensor_dissector")
  40. sensor_dissector_12(buffer, pinfo, subtree1, sensor_protocol, offset, num_of_instance)
  41. elseif queue_id == 13 then
  42. require("sensor_dissector")
  43. sensor_dissector_13(buffer, pinfo, subtree1, sensor_protocol, offset, num_of_instance)
  44. elseif queue_id == 14 then
  45. require("sensor_dissector")
  46. sensor_dissector_14(buffer, pinfo, subtree1, sensor_protocol, offset, num_of_instance)
  47. elseif queue_id == 15 then
  48. require("sensor_dissector")
  49. sensor_dissector_15(buffer, pinfo, subtree1, sensor_protocol, offset, num_of_instance)
  50. end
  51. end
  52. ---------------------------------------------------------------------------------------
  53. function sensor_dissector_0(buffer, pinfo, tree, sensor_protocol, offset, num_of_instance)
  54. -- Define the fields of the protocol
  55. local f_vbus_voltage = ProtoField.float("psm.vbus_voltage", "Vbus Voltage")
  56. local f_vshunt_voltage = ProtoField.float("psm.vshunt_voltage", "Vshunt Voltage")
  57. local f_current = ProtoField.float("psm.current", "Current")
  58. local f_power = ProtoField.uint32("psm.power", "Power")
  59. local f_epoch_time = ProtoField.uint32("psm.epoch_time", "Epoch Time")
  60. -- Add the fields to the protocol
  61. sensor_protocol.fields = { f_vbus_voltage, f_vshunt_voltage, f_current, f_power, f_epoch_time }
  62. local subtree = tree:add(sensor_protocol, buffer(), "SENSOR")
  63. for i = 0, num_of_instance - 1 do
  64. local subtree1 = subtree:add(sensor_protocol, buffer(), "INSTANCE "..i)
  65. subtree1:add(f_vbus_voltage, buffer(offset, 4):le_float()) -- 4 bytes for float
  66. offset = offset + 4
  67. subtree1:add(f_vshunt_voltage, buffer(offset, 4):le_float()) -- 4 bytes for float
  68. offset = offset + 4
  69. subtree1:add(f_current, buffer(offset, 4):le_float()) -- 4 bytes for float
  70. offset = offset + 4
  71. subtree1:add(f_power, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  72. offset = offset + 4
  73. subtree1:add(f_epoch_time, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  74. offset = offset + 4
  75. end
  76. end
  77. ---------------------------------------------------------------------------------------------------
  78. function sensor_dissector_1(buffer, pinfo, tree, sensor_protocol, offset, num_of_instance)
  79. -- Define the fields of the protocol
  80. local f_vbus_voltage = ProtoField.float("psm.vbus_voltage", "Vbus Voltage")
  81. local f_vshunt_voltage = ProtoField.float("psm.vshunt_voltage", "Vshunt Voltage")
  82. local f_current = ProtoField.float("psm.current", "Current")
  83. local f_power = ProtoField.uint32("psm.power", "Power")
  84. local f_epoch_time = ProtoField.uint32("psm.epoch_time", "Epoch Time")
  85. -- Add the fields to the protocol
  86. sensor_protocol.fields = { f_vbus_voltage, f_vshunt_voltage, f_current, f_power, f_epoch_time }
  87. local subtree = tree:add(sensor_protocol, buffer(), "SENSOR")
  88. for i = 0, num_of_instance - 1 do
  89. local subtree1 = subtree:add(sensor_protocol, buffer(), "INSTANCE "..i)
  90. subtree1:add(f_vbus_voltage, buffer(offset, 4):le_float()) -- 4 bytes for float
  91. offset = offset + 4
  92. subtree1:add(f_vshunt_voltage, buffer(offset, 4):le_float()) -- 4 bytes for float
  93. offset = offset + 4
  94. subtree1:add(f_current, buffer(offset, 4):le_float()) -- 4 bytes for float
  95. offset = offset + 4
  96. subtree1:add(f_power, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  97. offset = offset + 4
  98. subtree1:add(f_epoch_time, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  99. offset = offset + 4
  100. end
  101. end
  102. -----------------------------------------------------------------------------------------------------------------
  103. function sensor_dissector_2(buffer, pinfo, tree, sensor_protocol, offset, num_of_instance)
  104. -- Define the fields for the protocol
  105. local f_temperature = ProtoField.float("sensor_protocol.temperature", "Temperature")
  106. local f_temp_epoch_time = ProtoField.uint32("sensor_protocol.temp_epoch_time", "Temp Epoch Time")
  107. -- Add the fields to the protocol
  108. sensor_protocol.fields = { f_temperature, f_temp_epoch_time }
  109. local subtree = tree:add(sensor_protocol, buffer(), "SENSOR")
  110. -- Loop through the data (num_of_instance could represent the number of instances or packets to dissect)
  111. for i = 0, num_of_instance - 1 do
  112. -- Add the new structure data as a subtree
  113. local subtree1 = subtree:add(sensor_protocol, buffer(), "INSTANCE "..i)
  114. -- dissect temperature (4 bytes for float)
  115. local temperature = buffer(offset, 4):le_float() -- Float type is 4 bytes (32 bits)
  116. subtree1:add(f_temperature, temperature)
  117. offset = offset + 4
  118. -- dissect dt_epoch_time (4 bytes for uint32)
  119. local temp_epoch_time = buffer(offset, 4):le_uint() -- uint32 is 4 bytes
  120. subtree1:add(f_temp_epoch_time, temp_epoch_time)
  121. offset = offset + 4
  122. end
  123. end
  124. ------------------------------------------------------------------------------------------------------------------------
  125. function sensor_dissector_3(buffer, pinfo, tree, sensor_protocol, offset, num_of_instance)
  126. -- Define the fields for the protocol
  127. local f_temperature = ProtoField.float("sensor_protocol.temperature", "Temperature")
  128. local f_temp_epoch_time = ProtoField.uint32("sensor_protocol.temp_epoch_time", "Temp Epoch Time")
  129. -- Add the fields to the protocol
  130. sensor_protocol.fields = { f_temperature, f_temp_epoch_time }
  131. local subtree = tree:add(sensor_protocol, buffer(), "SENSOR")
  132. -- Loop through the data (num_of_instance could represent the number of instances or packets to dissect)
  133. for i = 0, num_of_instance - 1 do
  134. -- Add the new structure data as a subtree
  135. local subtree1 = subtree:add(sensor_protocol, buffer(), "INSTANCE "..i)
  136. -- dissect temperature (4 bytes for float)
  137. local temperature = buffer(offset, 4):le_float() -- Float type is 4 bytes (32 bits)
  138. subtree1:add(f_temperature, temperature)
  139. offset = offset + 4
  140. -- dissect dt_epoch_time (4 bytes for uint32)
  141. local temp_epoch_time = buffer(offset, 4):le_uint() -- uint32 is 4 bytes
  142. subtree1:add(f_temp_epoch_time, temp_epoch_time)
  143. offset = offset + 4
  144. end
  145. end
  146. -------------------------------------------------------------------------------------------------------------------------
  147. function sensor_dissector_4(buffer, pinfo, tree, sensor_protocol, offset, num_of_instance)
  148. -- Define the fields for the protocol
  149. local f_temperature = ProtoField.float("sensor_protocol.temperature", "Temperature")
  150. local f_temp_epoch_time = ProtoField.uint32("sensor_protocol.temp_epoch_time", "Temp Epoch Time")
  151. -- Add the fields to the protocol
  152. sensor_protocol.fields = { f_temperature, f_temp_epoch_time }
  153. local subtree = tree:add(sensor_protocol, buffer(), "SENSOR")
  154. -- Loop through the data (num_of_instance could represent the number of instances or packets to dissect)
  155. for i = 0, num_of_instance - 1 do
  156. -- Add the new structure data as a subtree
  157. local subtree1 = subtree:add(sensor_protocol, buffer(), "INSTANCE "..i)
  158. -- dissect temperature (4 bytes for float)
  159. local temperature = buffer(offset, 4):le_float() -- Float type is 4 bytes (32 bits)
  160. subtree1:add(f_temperature, temperature)
  161. offset = offset + 4
  162. -- dissect dt_epoch_time (4 bytes for uint32)
  163. local temp_epoch_time = buffer(offset, 4):le_uint() -- uint32 is 4 bytes
  164. subtree1:add(f_temp_epoch_time, temp_epoch_time)
  165. offset = offset + 4
  166. end
  167. end
  168. -------------------------------------------------------------------------------------------------------------------------
  169. function sensor_dissector_5(buffer, pinfo, tree, sensor_protocol, offset, num_of_instance)
  170. -- Define the fields for the protocol
  171. local f_temperature = ProtoField.float("sensor_protocol.temperature", "Temperature")
  172. local f_temp_epoch_time = ProtoField.uint32("sensor_protocol.temp_epoch_time", "Temp Epoch Time")
  173. -- Add the fields to the protocol
  174. sensor_protocol.fields = { f_temperature, f_temp_epoch_time }
  175. local subtree = tree:add(sensor_protocol, buffer(), "SENSOR")
  176. -- Loop through the data (num_of_instance could represent the number of instances or packets to dissect)
  177. for i = 0, num_of_instance - 1 do
  178. -- Add the new structure data as a subtree
  179. local subtree1 = subtree:add(sensor_protocol, buffer(), "INSTANCE "..i)
  180. -- dissect temperature (4 bytes for float)
  181. local temperature = buffer(offset, 4):le_float() -- Float type is 4 bytes (32 bits)
  182. subtree1:add(f_temperature, temperature)
  183. offset = offset + 4
  184. -- dissect dt_epoch_time (4 bytes for uint32)
  185. local temp_epoch_time = buffer(offset, 4):le_uint() -- uint32 is 4 bytes
  186. subtree1:add(f_temp_epoch_time, temp_epoch_time)
  187. offset = offset + 4
  188. end
  189. end
  190. -------------------------------------------------------------------------------------------------------------------------
  191. function sensor_dissector_6(buffer, pinfo, tree, sensor_protocol, offset, num_of_instance)
  192. -- Define the fields for the protocol
  193. local f_temperature = ProtoField.float("sensor_protocol.temperature", "Temperature")
  194. local f_temp_epoch_time = ProtoField.uint32("sensor_protocol.temp_epoch_time", "Temp Epoch Time")
  195. -- Add the fields to the protocol
  196. sensor_protocol.fields = { f_temperature, f_temp_epoch_time }
  197. local subtree = tree:add(sensor_protocol, buffer(), "SENSOR")
  198. -- Loop through the data (num_of_instance could represent the number of instances or packets to dissect)
  199. for i = 0, num_of_instance - 1 do
  200. -- Add the new structure data as a subtree
  201. local subtree1 = subtree:add(sensor_protocol, buffer(), "INSTANCE "..i)
  202. -- dissect temperature (4 bytes for float)
  203. local temperature = buffer(offset, 4):le_float() -- Float type is 4 bytes (32 bits)
  204. subtree1:add(f_temperature, temperature)
  205. offset = offset + 4
  206. -- dissect dt_epoch_time (4 bytes for uint32)
  207. local temp_epoch_time = buffer(offset, 4):le_uint() -- uint32 is 4 bytes
  208. subtree1:add(f_temp_epoch_time, temp_epoch_time)
  209. offset = offset + 4
  210. end
  211. end
  212. -------------------------------------------------------------------------------------------------------------------------
  213. function sensor_dissector_7(buffer, pinfo, tree, sensor_protocol, offset, num_of_instance)
  214. -- Define the fields for the protocol
  215. local f_temperature = ProtoField.float("sensor_protocol.temperature", "Temperature")
  216. local f_temp_epoch_time = ProtoField.uint32("sensor_protocol.temp_epoch_time", "Temp Epoch Time")
  217. -- Add the fields to the protocol
  218. sensor_protocol.fields = { f_temperature, f_temp_epoch_time }
  219. local subtree = tree:add(sensor_protocol, buffer(), "SENSOR")
  220. -- Loop through the data (num_of_instance could represent the number of instances or packets to dissect)
  221. for i = 0, num_of_instance - 1 do
  222. -- Add the new structure data as a subtree
  223. local subtree1 = subtree:add(sensor_protocol, buffer(), "INSTANCE "..i)
  224. -- dissect temperature (4 bytes for float)
  225. local temperature = buffer(offset, 4):le_float() -- Float type is 4 bytes (32 bits)
  226. subtree1:add(f_temperature, temperature)
  227. offset = offset + 4
  228. -- dissect dt_epoch_time (4 bytes for uint32)
  229. local temp_epoch_time = buffer(offset, 4):le_uint() -- uint32 is 4 bytes
  230. subtree1:add(f_temp_epoch_time, temp_epoch_time)
  231. offset = offset + 4
  232. end
  233. end
  234. -------------------------------------------------------------------------------------------------------------------------
  235. function sensor_dissector_8(buffer, pinfo, tree, sensor_protocol, offset, num_of_instance)
  236. -- Define the fields for the protocol
  237. local f_temperature = ProtoField.float("sensor_protocol.temperature", "Temperature")
  238. local f_temp_epoch_time = ProtoField.uint32("sensor_protocol.temp_epoch_time", "Temp Epoch Time")
  239. -- Add the fields to the protocol
  240. sensor_protocol.fields = { f_temperature, f_temp_epoch_time }
  241. local subtree = tree:add(sensor_protocol, buffer(), "SENSOR")
  242. -- Loop through the data (num_of_instance could represent the number of instances or packets to dissect)
  243. for i = 0, num_of_instance - 1 do
  244. -- Add the new structure data as a subtree
  245. local subtree1 = subtree:add(sensor_protocol, buffer(), "INSTANCE "..i)
  246. -- dissect temperature (4 bytes for float)
  247. local temperature = buffer(offset, 4):le_float() -- Float type is 4 bytes (32 bits)
  248. subtree1:add(f_temperature, temperature)
  249. offset = offset + 4
  250. -- dissect dt_epoch_time (4 bytes for uint32)
  251. local temp_epoch_time = buffer(offset, 4):le_uint() -- uint32 is 4 bytes
  252. subtree1:add(f_temp_epoch_time, temp_epoch_time)
  253. offset = offset + 4
  254. end
  255. end
  256. -------------------------------------------------------------------------------------------------------------------------
  257. function sensor_dissector_9(buffer, pinfo, tree, sensor_protocol, offset, num_of_instance)
  258. -- Define the fields for the protocol
  259. local f_temperature = ProtoField.float("sensor_protocol.temperature", "Temperature")
  260. local f_temp_epoch_time = ProtoField.uint32("sensor_protocol.temp_epoch_time", "Temp Epoch Time")
  261. -- Add the fields to the protocol
  262. sensor_protocol.fields = { f_temperature, f_temp_epoch_time }
  263. local subtree = tree:add(sensor_protocol, buffer(), "SENSOR")
  264. -- Loop through the data (num_of_instance could represent the number of instances or packets to dissect)
  265. for i = 0, num_of_instance - 1 do
  266. -- Add the new structure data as a subtree
  267. local subtree1 = subtree:add(sensor_protocol, buffer(), "INSTANCE "..i)
  268. -- dissect temperature (4 bytes for float)
  269. local temperature = buffer(offset, 4):le_float() -- Float type is 4 bytes (32 bits)
  270. subtree1:add(f_temperature, temperature)
  271. offset = offset + 4
  272. -- dissect dt_epoch_time (4 bytes for uint32)
  273. local temp_epoch_time = buffer(offset, 4):le_uint() -- uint32 is 4 bytes
  274. subtree1:add(f_temp_epoch_time, temp_epoch_time)
  275. offset = offset + 4
  276. end
  277. end
  278. -------------------------------------------------------------------------------------------------------------------------
  279. function sensor_dissector_10(buffer, pinfo, tree, sensor_protocol, offset, num_of_instance)
  280. -- Define the fields for the protocol
  281. local f_temperature = ProtoField.float("sensor_protocol.temperature", "Temperature")
  282. local f_temp_epoch_time = ProtoField.uint32("sensor_protocol.temp_epoch_time", "Temp Epoch Time")
  283. -- Add the fields to the protocol
  284. sensor_protocol.fields = { f_temperature, f_temp_epoch_time }
  285. local subtree = tree:add(sensor_protocol, buffer(), "SENSOR")
  286. -- Loop through the data (num_of_instance could represent the number of instances or packets to dissect)
  287. for i = 0, num_of_instance - 1 do
  288. -- Add the new structure data as a subtree
  289. local subtree1 = subtree:add(sensor_protocol, buffer(), "INSTANCE "..i)
  290. -- dissect temperature (4 bytes for float)
  291. local temperature = buffer(offset, 4):le_float() -- Float type is 4 bytes (32 bits)
  292. subtree1:add(f_temperature, temperature)
  293. offset = offset + 4
  294. -- dissect dt_epoch_time (4 bytes for uint32)
  295. local temp_epoch_time = buffer(offset, 4):le_uint() -- uint32 is 4 bytes
  296. subtree1:add(f_temp_epoch_time, temp_epoch_time)
  297. offset = offset + 4
  298. end
  299. end
  300. -------------------------------------------------------------------------------------------------------------------------
  301. function sensor_dissector_11(buffer, pinfo, tree, sensor_protocol, offset, num_of_instance)
  302. -- Define ProtoFields for the new structure fields
  303. local f_voltage = ProtoField.float("SensorData.voltage", "Voltage", base.DEC)
  304. local f_current = ProtoField.float("SensorData.current", "Current", base.DEC)
  305. local f_adm_epoch_time = ProtoField.uint32("SensorData.adm_epoch_time", "Epoch Time", base.DEC)
  306. -- Add the fields to the protocol
  307. sensor_protocol.fields = {
  308. f_voltage, f_current, f_adm_epoch_time
  309. }
  310. local subtree = tree:add(sensor_protocol, buffer(), "SENSOR")
  311. -- Loop through the data (num_of_instance could represent the number of instances or packets to dissect)
  312. for i = 0, num_of_instance - 1 do
  313. -- Add the new structure data as a subtree
  314. local subtree1 = subtree:add(sensor_protocol, buffer(), "INSTANCE "..i)
  315. -- dissect voltage (4 bytes for float)
  316. local voltage = buffer(offset, 4):le_float() -- Float type is 4 bytes (32 bits)
  317. subtree1:add(f_voltage, voltage)
  318. offset = offset + 4
  319. -- dissect current (4 bytes for float)
  320. local current = buffer(offset, 4):le_float() -- Float type is 4 bytes (32 bits)
  321. subtree1:add(f_current, current)
  322. offset = offset + 4
  323. -- dissect adm_epoch_time (4 bytes for uint32)
  324. local adm_epoch_time = buffer(offset, 4):le_uint() -- uint32 is 4 bytes
  325. subtree1:add(f_adm_epoch_time, adm_epoch_time)
  326. offset = offset + 4
  327. end
  328. end
  329. ---------------------------------------------------------------------------------------------------------------------------
  330. function sensor_dissector_12(buffer, pinfo, tree, sensor_protocol, offset, num_of_instance)
  331. -- Define ProtoFields for the new structure fields
  332. local f_voltage = ProtoField.float("SensorData.voltage", "Voltage", base.DEC)
  333. local f_current = ProtoField.float("SensorData.current", "Current", base.DEC)
  334. local f_adm_epoch_time = ProtoField.uint32("SensorData.adm_epoch_time", "Epoch Time", base.DEC)
  335. -- Add the fields to the protocol
  336. sensor_protocol.fields = {
  337. f_voltage, f_current, f_adm_epoch_time
  338. }
  339. local subtree = tree:add(sensor_protocol, buffer(), "SENSOR")
  340. -- Loop through the data (num_of_instance could represent the number of instances or packets to dissect)
  341. for i = 0, num_of_instance - 1 do
  342. -- Add the new structure data as a subtree
  343. local subtree1 = subtree:add(sensor_protocol, buffer(), "INSTANCE "..i)
  344. -- dissect voltage (4 bytes for float)
  345. local voltage = buffer(offset, 4):le_float() -- Float type is 4 bytes (32 bits)
  346. subtree1:add(f_voltage, voltage)
  347. offset = offset + 4
  348. -- dissect current (4 bytes for float)
  349. local current = buffer(offset, 4):le_float() -- Float type is 4 bytes (32 bits)
  350. subtree1:add(f_current, current)
  351. offset = offset + 4
  352. -- dissect adm_epoch_time (4 bytes for uint32)
  353. local adm_epoch_time = buffer(offset, 4):le_uint() -- uint32 is 4 bytes
  354. subtree1:add(f_adm_epoch_time, adm_epoch_time)
  355. offset = offset + 4
  356. end
  357. end
  358. ---------------------------------------------------------------------------------------------------------------------------------------
  359. function sensor_dissector_13(buffer, pinfo, tree, sensor_protocol, offset, num_of_instance)
  360. -- Define ProtoFields for the new structure fields
  361. local f_voltage = ProtoField.float("SensorData.voltage", "Voltage", base.DEC)
  362. local f_current = ProtoField.float("SensorData.current", "Current", base.DEC)
  363. local f_adm_epoch_time = ProtoField.uint32("SensorData.adm_epoch_time", "Epoch Time", base.DEC)
  364. -- Add the fields to the protocol
  365. sensor_protocol.fields = {
  366. f_voltage, f_current, f_adm_epoch_time
  367. }
  368. local subtree = tree:add(sensor_protocol, buffer(), "SENSOR")
  369. -- Loop through the data (num_of_instance could represent the number of instances or packets to dissect)
  370. for i = 0, num_of_instance - 1 do
  371. -- Add the new structure data as a subtree
  372. local subtree1 = subtree:add(sensor_protocol, buffer(), "INSTANCE "..i)
  373. -- dissect voltage (4 bytes for float)
  374. local voltage = buffer(offset, 4):le_float() -- Float type is 4 bytes (32 bits)
  375. subtree1:add(f_voltage, voltage)
  376. offset = offset + 4
  377. -- dissect current (4 bytes for float)
  378. local current = buffer(offset, 4):le_float() -- Float type is 4 bytes (32 bits)
  379. subtree1:add(f_current, current)
  380. offset = offset + 4
  381. -- dissect adm_epoch_time (4 bytes for uint32)
  382. local adm_epoch_time = buffer(offset, 4):le_uint() -- uint32 is 4 bytes
  383. subtree1:add(f_adm_epoch_time, adm_epoch_time)
  384. offset = offset + 4
  385. end
  386. end
  387. ----------------------------------------------------------------------------------------------------------------------------------------
  388. function sensor_dissector_14(buffer, pinfo, tree, sensor_protocol, offset, num_of_instance)
  389. -- Define ProtoFields for the new structure fields
  390. local f_temperature = ProtoField.float("TemperatureData.temperature", "Temperature", base.DEC)
  391. local f_dt_epoch_time = ProtoField.uint32("TemperatureData.dt_epoch_time", "Epoch Time", base.DEC)
  392. -- Add the fields to the protocol
  393. sensor_protocol.fields = {
  394. f_temperature, f_dt_epoch_time
  395. }
  396. local subtree = tree:add(sensor_protocol, buffer(), "SENSOR")
  397. -- Loop through the data (num_of_instance could represent the number of instances or packets to dissect)
  398. for i = 0, num_of_instance - 1 do
  399. -- Add the new structure data as a subtree
  400. local subtree1 = subtree:add(sensor_protocol, buffer(), "INSTANCE"..i)
  401. -- dissect temperature (4 bytes for float)
  402. local temperature = buffer(offset, 4):le_float() -- Float type is 4 bytes (32 bits)
  403. subtree1:add(f_temperature, temperature)
  404. offset = offset + 4
  405. -- dissect dt_epoch_time (4 bytes for uint32)
  406. local dt_epoch_time = buffer(offset, 4):le_uint() -- uint32 is 4 bytes
  407. subtree1:add(f_dt_epoch_time, dt_epoch_time)
  408. offset = offset + 4
  409. end
  410. end
  411. ---------------------------------------------------------------------------------------------------------------------------------------
  412. function sensor_dissector_15(buffer, pinfo, tree, sensor_protocol, offset, num_of_instance)
  413. -- Define ProtoFields for the new structure fields
  414. local f_temperature = ProtoField.float("TemperatureData.temperature", "Temperature", base.DEC)
  415. local f_dt_epoch_time = ProtoField.uint32("TemperatureData.dt_epoch_time", "Epoch Time", base.DEC)
  416. -- Add the fields to the protocol
  417. sensor_protocol.fields = {
  418. f_temperature, f_dt_epoch_time
  419. }
  420. local subtree = tree:add(sensor_protocol, buffer(), "SENSOR")
  421. -- Loop through the data (num_of_instance could represent the number of instances or packets to dissect)
  422. for i = 1, num_of_instance do
  423. -- Add the new structure data as a subtree
  424. local subtree1 = subtree:add(sensor_protocol, buffer(), "INSTANCE"..i)
  425. -- dissect temperature (4 bytes for float)
  426. local temperature = buffer(offset, 4):le_float() -- Float type is 4 bytes (32 bits)
  427. subtree1:add(f_temperature, temperature)
  428. offset = offset + 4
  429. -- dissect dt_epoch_time (4 bytes for uint32)
  430. local dt_epoch_time = buffer(offset, 4):le_uint() -- uint32 is 4 bytes
  431. subtree1:add(f_dt_epoch_time, dt_epoch_time)
  432. offset = offset + 4
  433. end
  434. end
  435. ------------------------------------------------------------------------------------------------------------------------------------