tm_comms_beacon_tx.lua 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. function tm_comms_beacon_tx(buffer, pinfo, tree, comms_beacon_tx, offset)
  2. -- Define the fields for the protocol based on the structure
  3. local f_bcon_msg = ProtoField.string("comms_beacon_tx.bcon_msg", "Bcon Msg")
  4. local f_utc_tim = ProtoField.uint32("comms_beacon_tx.utc_tim", "UTC Time", base.DEC)
  5. local f_utc_gps_tim_sts = ProtoField.uint8("comms_beacon_tx.utc_gps_tim_sts", "UTC GPS Time Status", base.DEC)
  6. local f_latitude = ProtoField.float("comms_beacon_tx.latitude", "Latitude", base.DEC)
  7. local f_longitude = ProtoField.float("comms_beacon_tx.longitude", "Longitude", base.DEC)
  8. local f_altitude = ProtoField.float("comms_beacon_tx.altitude", "Altitude", base.DEC)
  9. local f_x_pos = ProtoField.double("comms_beacon_tx.x_pos", "X Position", base.DEC)
  10. local f_y_pos = ProtoField.double("comms_beacon_tx.y_pos", "Y Position", base.DEC)
  11. local f_z_pos = ProtoField.double("comms_beacon_tx.z_pos", "Z Position", base.DEC)
  12. local f_x_vel = ProtoField.double("comms_beacon_tx.x_vel", "X Velocity", base.DEC)
  13. local f_y_vel = ProtoField.double("comms_beacon_tx.y_vel", "Y Velocity", base.DEC)
  14. local f_z_vel = ProtoField.double("comms_beacon_tx.z_vel", "Z Velocity", base.DEC)
  15. local f_fsm_state = ProtoField.uint8("comms_beacon_tx.fsm_state", "FSM State", base.DEC)
  16. local f_num_resets = ProtoField.uint8("comms_beacon_tx.num_resets", "Number of Resets", base.DEC)
  17. local f_zio_err = ProtoField.uint16("comms_beacon_tx.zio_err", "ZIO Error", base.DEC)
  18. local f_sys_err = ProtoField.uint8("comms_beacon_tx.sys_err", "System Error", base.DEC)
  19. local f_obc_volt_sensor = ProtoField.uint8("comms_beacon_tx.obc_volt_sensor", "OBC Volt Sensor", base.DEC)
  20. local f_ps_volt_sensor = ProtoField.uint8("comms_beacon_tx.ps_volt_sensor", "PS Volt Sensor", base.DEC)
  21. local f_temp_obc = ProtoField.uint8("comms_beacon_tx.temp_obc", "OBC Temperature", base.DEC)
  22. local f_temp_ps = ProtoField.uint8("comms_beacon_tx.temp_ps", "PS Temperature", base.DEC)
  23. local f_temp_es = ProtoField.uint8("comms_beacon_tx.temp_es", "ES Temperature", base.DEC)
  24. local f_temp_gps = ProtoField.uint8("comms_beacon_tx.temp_gps", "GPS Temperature", base.DEC)
  25. local f_totl_btry_volt = ProtoField.uint8("comms_beacon_tx.totl_btry_volt", "Total Battery Voltage", base.DEC)
  26. local f_totl_panel_pwr = ProtoField.uint8("comms_beacon_tx.totl_panel_pwr", "Total Panel Power", base.DEC)
  27. local f_chnl_sts = ProtoField.uint16("comms_beacon_tx.chnl_sts", "Channel Status", base.DEC)
  28. local f_overcrnt_err_flg_byte1 = ProtoField.uint8("comms_beacon_tx.overcrnt_err_flg_byte1", "Overcurrent Error Flag Byte1", base.DEC)
  29. local f_overcrnt_err_flg_byte2 = ProtoField.uint16("comms_beacon_tx.overcrnt_err_flg_byte2", "Overcurrent Error Flag Byte2", base.DEC)
  30. local f_fsm_state_mode = ProtoField.uint8("comms_beacon_tx.fsm_state_mode", "FSM State Mode", base.DEC)
  31. local f_sns_actr_pwr_sts = ProtoField.uint16("comms_beacon_tx.sns_actr_pwr_sts", "Sensor Actuator Power Status", base.DEC)
  32. local f_actrs_run_sts = ProtoField.uint8("comms_beacon_tx.actrs_run_sts", "Actuators Run Status", base.DEC)
  33. local f_sdr_fsm_st = ProtoField.uint8("comms_beacon_tx.sdr_fsm_st", "SDR FSM State", base.DEC)
  34. local f_rssi0 = ProtoField.uint8("comms_beacon_tx.rssi0", "RSSI0", base.DEC)
  35. local f_rssi1 = ProtoField.uint8("comms_beacon_tx.rssi1", "RSSI1", base.DEC)
  36. local f_rx_err_cnt = ProtoField.uint32("comms_beacon_tx.rx_err_cnt", "RX Error Count", base.DEC)
  37. local f_tx_frm_cnt = ProtoField.uint32("comms_beacon_tx.tx_frm_cnt", "TX Frame Count", base.DEC)
  38. local f_rx_freq = ProtoField.uint32("comms_beacon_tx.rx_freq", "RX Frequency", base.DEC)
  39. local f_symb_freq = ProtoField.uint16("comms_beacon_tx.symb_freq", "Symbol Frequency", base.DEC)
  40. local f_mod = ProtoField.uint16("comms_beacon_tx.mod", "Modulation", base.DEC)
  41. local f_roll_off = ProtoField.uint16("comms_beacon_tx.roll_off", "Roll Off", base.DEC)
  42. local f_rand_enb = ProtoField.uint16("comms_beacon_tx.rand_enb", "Random Enable", base.DEC)
  43. local f_cc_enb = ProtoField.uint16("comms_beacon_tx.cc_enb", "CC Enable", base.DEC)
  44. local f_ors_enb = ProtoField.uint16("comms_beacon_tx.ors_enb", "ORS Enable", base.DEC)
  45. local f_crc_enb = ProtoField.uint16("comms_beacon_tx.crc_enb", "CRC Enable", base.DEC)
  46. local f_dc_filter_enb = ProtoField.uint16("comms_beacon_tx.dc_filter_enb", "DC Filter Enable", base.DEC)
  47. local f_manchester_coding_en = ProtoField.uint16("comms_beacon_tx.manchester_coding_en", "Manchester Coding Enable", base.DEC)
  48. -- Add the fields to the protocol
  49. comms_beacon_tx.fields = {
  50. f_bcon_msg, f_utc_tim, f_utc_gps_tim_sts, f_latitude, f_longitude, f_altitude,
  51. f_x_pos, f_y_pos, f_z_pos, f_x_vel, f_y_vel, f_z_vel, f_fsm_state, f_num_resets,
  52. f_zio_err, f_sys_err, f_obc_volt_sensor, f_ps_volt_sensor, f_temp_obc, f_temp_ps,
  53. f_temp_es, f_temp_gps, f_totl_btry_volt, f_totl_panel_pwr, f_chnl_sts,
  54. f_overcrnt_err_flg_byte1, f_overcrnt_err_flg_byte2, f_fsm_state_mode, f_sns_actr_pwr_sts,
  55. f_actrs_run_sts, f_sdr_fsm_st, f_rssi0, f_rssi1, f_rx_err_cnt, f_tx_frm_cnt,
  56. f_rx_freq, f_symb_freq, f_mod, f_roll_off, f_rand_enb, f_cc_enb, f_ors_enb,
  57. f_crc_enb, f_dc_filter_enb, f_manchester_coding_en
  58. }
  59. local subtree = tree:add(comms_beacon_tx, buffer(), "TM COMMS BEACON TX")
  60. -- dissect bcon_msg
  61. local bcon_msg = buffer(offset, 18):string()
  62. subtree:add(f_bcon_msg, bcon_msg)
  63. offset = offset + 18
  64. -- dissect utc_tim
  65. local utc_tim = buffer(offset, 4):le_uint()
  66. subtree:add(f_utc_tim, utc_tim)
  67. offset = offset + 4
  68. -- dissect utc_gps_tim_sts
  69. local utc_gps_tim_sts = buffer(offset, 1):le_uint()
  70. subtree:add(f_utc_gps_tim_sts, utc_gps_tim_sts)
  71. offset = offset + 1
  72. -- dissect latitude
  73. local latitude = buffer(offset, 4):le_float()
  74. subtree:add(f_latitude, latitude)
  75. offset = offset + 4
  76. -- dissect longitude
  77. local longitude = buffer(offset, 4):le_float()
  78. subtree:add(f_longitude, longitude)
  79. offset = offset + 4
  80. -- dissect altitude
  81. local altitude = buffer(offset, 4):le_float()
  82. subtree:add(f_altitude, altitude)
  83. offset = offset + 4
  84. -- dissect x_pos
  85. local high = buffer(offset, 4):le_uint() -- First 4 bytes
  86. local low = buffer(offset + 4, 4):le_uint() -- Next 4 bytes
  87. -- Combine and unpack as a double (64-bit floating-point number)
  88. local x_pos = string.unpack("d", string.pack("<II", low, high))
  89. subtree:add(f_x_pos, x_pos)
  90. offset = offset + 8
  91. --local x_pos = buffer(offset, 8):le_uint()
  92. --subtree:add(f_x_pos, x_pos)
  93. --offset = offset + 8
  94. -- dissect y_pos
  95. local high_y_pos = buffer(offset, 4):le_uint() -- First 4 bytes for y_pos
  96. local low_y_pos = buffer(offset + 4, 4):le_uint() -- Next 4 bytes for y_pos
  97. local y_pos = string.unpack("d", string.pack("<II", low_y_pos, high_y_pos))
  98. subtree:add(f_y_pos, y_pos)
  99. offset = offset + 8
  100. -- dissect z_pos
  101. local high_z_pos = buffer(offset, 4):le_uint() -- First 4 bytes for z_pos
  102. local low_z_pos = buffer(offset + 4, 4):le_uint() -- Next 4 bytes for z_pos
  103. local z_pos = string.unpack("d", string.pack("<II", low_z_pos, high_z_pos))
  104. subtree:add(f_z_pos, z_pos)
  105. offset = offset + 8
  106. -- dissect x_vel
  107. local high_x_vel = buffer(offset, 4):le_uint() -- First 4 bytes for x_vel
  108. local low_x_vel = buffer(offset + 4, 4):le_uint() -- Next 4 bytes for x_vel
  109. local x_vel = string.unpack("d", string.pack("<II", low_x_vel, high_x_vel))
  110. subtree:add(f_x_vel, x_vel)
  111. offset = offset + 8
  112. -- dissect y_vel
  113. local high_y_vel = buffer(offset, 4):le_uint() -- First 4 bytes for y_vel
  114. local low_y_vel = buffer(offset + 4, 4):le_uint() -- Next 4 bytes for y_vel
  115. local y_vel = string.unpack("d", string.pack("<II", low_y_vel, high_y_vel))
  116. subtree:add(f_y_vel, y_vel)
  117. offset = offset + 8
  118. -- dissect z_vel
  119. local high_z_vel = buffer(offset, 4):le_uint() -- First 4 bytes for z_vel
  120. local low_z_vel = buffer(offset + 4, 4):le_uint() -- Next 4 bytes for z_vel
  121. local z_vel = string.unpack("d", string.pack("<II", low_z_vel, high_z_vel))
  122. subtree:add(f_z_vel, z_vel)
  123. offset = offset + 8
  124. -- dissect fsm_state
  125. local fsm_state = buffer(offset, 1):le_uint()
  126. subtree:add(f_fsm_state, fsm_state)
  127. offset = offset + 1
  128. -- dissect num_resets
  129. local num_resets = buffer(offset, 1):le_uint()
  130. subtree:add(f_num_resets, num_resets)
  131. offset = offset + 1
  132. -- dissect zio_err
  133. local zio_err = buffer(offset, 2):le_uint()
  134. subtree:add(f_zio_err, zio_err)
  135. offset = offset + 2
  136. -- dissect sys_err
  137. local sys_err = buffer(offset, 1):le_uint()
  138. subtree:add(f_sys_err, sys_err)
  139. offset = offset + 1
  140. -- dissect obc_volt_sensor
  141. local obc_volt_sensor = buffer(offset, 1):le_uint()
  142. subtree:add(f_obc_volt_sensor, obc_volt_sensor)
  143. offset = offset + 1
  144. -- dissect ps_volt_sensor
  145. local ps_volt_sensor = buffer(offset, 1):le_uint()
  146. subtree:add(f_ps_volt_sensor, ps_volt_sensor)
  147. offset = offset + 1
  148. -- dissect temp_obc
  149. local temp_obc = buffer(offset, 1):le_uint()
  150. subtree:add(f_temp_obc, temp_obc)
  151. offset = offset + 1
  152. -- dissect temp_ps
  153. local temp_ps = buffer(offset, 1):le_uint()
  154. subtree:add(f_temp_ps, temp_ps)
  155. offset = offset + 1
  156. -- dissect temp_es
  157. local temp_es = buffer(offset, 1):le_uint()
  158. subtree:add(f_temp_es, temp_es)
  159. offset = offset + 1
  160. -- dissect temp_gps
  161. local temp_gps = buffer(offset, 1):le_uint()
  162. subtree:add(f_temp_gps, temp_gps)
  163. offset = offset + 1
  164. -- dissect totl_btry_volt
  165. local totl_btry_volt = buffer(offset, 1):le_uint()
  166. subtree:add(f_totl_btry_volt, totl_btry_volt)
  167. offset = offset + 1
  168. -- dissect totl_panel_pwr
  169. local totl_panel_pwr = buffer(offset, 1):le_uint()
  170. subtree:add(f_totl_panel_pwr, totl_panel_pwr)
  171. offset = offset + 1
  172. -- dissect chnl_sts
  173. local chnl_sts = buffer(offset, 2):le_uint()
  174. subtree:add(f_chnl_sts, chnl_sts)
  175. offset = offset + 2
  176. -- dissect overcrnt_err_flg_byte1
  177. local overcrnt_err_flg_byte1 = buffer(offset, 1):le_uint()
  178. subtree:add(f_overcrnt_err_flg_byte1, overcrnt_err_flg_byte1)
  179. offset = offset + 1
  180. -- dissect overcrnt_err_flg_byte2
  181. local overcrnt_err_flg_byte2 = buffer(offset, 2):le_uint()
  182. subtree:add(f_overcrnt_err_flg_byte2, overcrnt_err_flg_byte2)
  183. offset = offset + 2
  184. -- dissect fsm_state_mode
  185. local fsm_state_mode = buffer(offset, 1):le_uint()
  186. subtree:add(f_fsm_state_mode, fsm_state_mode)
  187. offset = offset + 1
  188. -- dissect sns_actr_pwr_sts
  189. local sns_actr_pwr_sts = buffer(offset, 2):le_uint()
  190. subtree:add(f_sns_actr_pwr_sts, sns_actr_pwr_sts)
  191. offset = offset + 2
  192. -- dissect actrs_run_sts
  193. local actrs_run_sts = buffer(offset, 1):le_uint()
  194. subtree:add(f_actrs_run_sts, actrs_run_sts)
  195. offset = offset + 1
  196. -- dissect sdr_fsm_st
  197. local byte = buffer(offset, 1):le_uint() -- Read the full byte (8 bits)
  198. --local sdr_fsm_st = (byte >> 4) & 0x0F
  199. local sdr_fsm_st = byte & 0x0F
  200. subtree:add(f_sdr_fsm_st, sdr_fsm_st) ------------------------------------bit logic
  201. --offset = offset + 1
  202. -- dissect rssi0
  203. byte = buffer(offset, 1):le_uint()
  204. local rssi0 = (byte >> 4) & 0x03
  205. subtree:add(f_rssi0, rssi0)
  206. --offset = offset + 1
  207. -- dissect rssi1
  208. byte = buffer(offset, 1):le_uint()
  209. local rssi1 = (byte >> 6) &0x03
  210. subtree:add(f_rssi1, rssi1)
  211. offset = offset + 1
  212. -------------------------------------------one byte
  213. -- dissect rx_err_cnt
  214. local rx_err_cnt = buffer(offset, 4):le_uint()
  215. subtree:add(f_rx_err_cnt, rx_err_cnt)
  216. offset = offset + 4
  217. -- dissect tx_frm_cnt
  218. local tx_frm_cnt = buffer(offset, 4):le_uint()
  219. subtree:add(f_tx_frm_cnt, tx_frm_cnt)
  220. offset = offset + 4
  221. -- dissect rx_freq
  222. local rx_freq = buffer(offset, 4):le_uint()
  223. subtree:add(f_rx_freq, rx_freq)
  224. offset = offset + 4
  225. -- dissect symb_freq
  226. local symb_freq = buffer(offset, 1):le_uint()
  227. subtree:add(f_symb_freq, symb_freq)
  228. offset = offset + 1
  229. -------------------------------------------------------
  230. -- dissect mod
  231. byte = buffer(offset, 1):le_uint()
  232. local mod = byte & 0x03
  233. subtree:add(f_mod, mod)
  234. --offset = offset + 2
  235. -- dissect roll_off
  236. byte = buffer(offset, 1):le_uint()
  237. local roll_off = (byte >> 2) & 0x03
  238. subtree:add(f_roll_off, roll_off)
  239. --offset = offset + 2
  240. -- dissect rand_enb
  241. byte = buffer(offset, 1):le_uint()
  242. local rand_enb = (byte >> 4) & 0x03
  243. subtree:add(f_rand_enb, rand_enb)
  244. --offset = offset + 2
  245. -- dissect cc_enb
  246. byte = buffer(offset, 1):le_uint()
  247. local cc_enb = (byte >> 6) &0x01
  248. subtree:add(f_cc_enb, cc_enb)
  249. --offset = offset + 2
  250. -- dissect ors_enb
  251. byte = buffer(offset, 1):le_uint()
  252. local ors_enb = (byte >> 7) & 0x01
  253. subtree:add(f_ors_enb, ors_enb)
  254. offset = offset + 1
  255. ------------------------------------------------------------
  256. -- dissect sdr_fsm_st
  257. byte = buffer(offset, 1):le_uint()
  258. local x = byte & 0x0F
  259. subtree:add(f_sdr_fsm_st, x)
  260. -- dissect rssi0
  261. byte = buffer(offset, 1):le_uint()
  262. local rssi0 = (byte >> 4) & 0x03
  263. subtree:add(f_rssi0, rssi0)
  264. --offset = offset + 1
  265. -- dissect rssi1
  266. byte = buffer(offset, 1):le_uint()
  267. local rssi1 = (byte >> 6) & 0x03
  268. subtree:add(f_rssi1, rssi1)
  269. offset = offset + 1
  270. -----------------------------------------------------1byte
  271. -- dissect rx_err_cnt
  272. local rx_err_cnt = buffer(offset, 4):le_uint()
  273. subtree:add(f_rx_err_cnt, rx_err_cnt)
  274. offset = offset + 4
  275. -- dissect tx_frm_cnt
  276. local tx_frm_cnt = buffer(offset, 4):le_uint()
  277. subtree:add(f_tx_frm_cnt, tx_frm_cnt)
  278. offset = offset + 4
  279. -- dissect rx_freq
  280. local rx_freq = buffer(offset, 4):le_uint()
  281. subtree:add(f_rx_freq, rx_freq)
  282. offset = offset + 4
  283. ---------------------------------------------------------------
  284. -- dissect symb_freq
  285. byte = buffer(offset, 1):le_uint()
  286. local symb_freq = byte & 0x0f
  287. subtree:add(f_symb_freq, symb_freq)
  288. --offset = offset + 2
  289. -- dissect mod
  290. byte = buffer(offset, 1):le_uint()
  291. local mod = (byte >> 4) & 0x01
  292. subtree:add(f_mod, mod)
  293. --offset = offset + 2
  294. -- dissect roll_off
  295. byte = buffer(offset, 1):le_uint()
  296. local roll_off = (byte >> 5) & 0x01
  297. subtree:add(f_roll_off, roll_off)
  298. --offset = offset + 2
  299. -- dissect crc_enb
  300. byte = buffer(offset, 1):le_uint()
  301. local crc_enb = (byte >> 6) &0x03
  302. subtree:add(f_crc_enb, crc_enb)
  303. offset = offset + 1
  304. --------------------------------------------------------------------
  305. -- dissect dc_filter_enb
  306. byte = buffer(offset, 1):le_uint()
  307. --byte = 0x2c
  308. local dc_filter_enb = byte & 0x03
  309. subtree:add(f_dc_filter_enb, dc_filter_enb)
  310. --offset = offset + 2
  311. byte = buffer(offset, 1):le_uint()
  312. --byte = 0x2c
  313. local cc_enb = (byte >> 2) & 0x03
  314. subtree:add(f_cc_enb, cc_enb)
  315. --offset = offset + 2
  316. -- dissect rand_enb (2 bits)
  317. byte = buffer(offset, 1):le_uint()
  318. --byte = 0x2c
  319. local rand_enb = (byte >> 4) & 0x03
  320. subtree:add(f_rand_enb, rand_enb)
  321. --offset = offset + 2
  322. -- dissect manchester_coding_en
  323. byte = buffer(offset, 1):le_uint()
  324. --byte = 0x2c
  325. local manchester_coding_en = (byte >>6) & 0x03
  326. subtree:add(f_manchester_coding_en, manchester_coding_en)
  327. --offset = offset + 2
  328. end