diff options
| author | s-ol <s+removethis@s-ol.nu> | 2024-02-18 19:42:30 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2024-02-19 21:32:41 +0000 |
| commit | 20d2dd4e331fbbaf6aea12c8a51d733c1a1c5355 (patch) | |
| tree | c92bcf3aac44900c695dd43c2c60161205997719 | |
| parent | clean up and add README (diff) | |
| download | t937-serial-20d2dd4e331fbbaf6aea12c8a51d733c1a1c5355.tar.gz t937-serial-20d2dd4e331fbbaf6aea12c8a51d733c1a1c5355.zip | |
dissectors/t937: dissect TEMP_STATUS messages
| -rwxr-xr-x | dissectors/t937.lua | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/dissectors/t937.lua b/dissectors/t937.lua index 9d37ba6..cec6e9a 100755 --- a/dissectors/t937.lua +++ b/dissectors/t937.lua @@ -18,7 +18,11 @@ proto.fields.fun = ProtoField.uint8("t937.function", "Function", base.HEX, FUN_T proto.fields.len = ProtoField.uint8("t937.length", "Data Length", base.HEX)
proto.fields.checksum = ProtoField.uint16("t937.checksum", "Message Checksum", base.HEX)
-proto.fields.data = ProtoField.bytes("t937.data", "Data")
+proto.fields.temp1 = ProtoField.uint16("t937.temp1", "Chamber Temp 1", base.UNIT_STRING, {"°C"})
+proto.fields.temp2 = ProtoField.uint16("t937.temp2", "Chamber Temp 2", base.UNIT_STRING, {"°C"})
+proto.fields.temp3 = ProtoField.uint16("t937.temp3", "Control Board Temp", base.UNIT_STRING, {"°C"})
+
+proto.fields.data = ProtoField.bytes("t937.data", "Raw Data")
local function try_dissect(bytes, pinfo, tree)
-- minimum len is header + checksum
@@ -28,34 +32,40 @@ local function try_dissect(bytes, pinfo, tree) if bytes:len() < 4 + raw_len + 2 then return end
local buffer = bytes:subset(0, 4+raw_len+2):tvb("T-937 Frame")
- local address = buffer(0, 2)
- local fun = buffer(2, 1)
- local len = buffer(3, 1)
+ local sub = tree:add(proto, buffer())
+
+ local i = 0
+ sub:add_packet_field(proto.fields.addr, buffer(0, 2), ENC_BIG_ENDIAN)
+ local funf, fun, i = sub:add_packet_field(proto.fields.fun, buffer(2, 1), ENC_BIG_ENDIAN)
+ sub:add_packet_field(proto.fields.len, buffer(3, 1), ENC_BIG_ENDIAN)
local data = buffer(4, raw_len)
- local checksum = buffer(4+raw_len, 2)
+ sub:add_packet_field(proto.fields.data, data, ENC_BIG_ENDIAN)
+ local csf, cs = sub:add_packet_field(proto.fields.checksum, buffer(4+raw_len), ENC_BIG_ENDIAN)
local sum = 0
for i=0,4+raw_len-1 do
sum = sum + buffer(i, 1):uint()
end
- pinfo.cols.info:set("T937 " .. (FUN_TABLE[fun:uint()] or ""))
- pinfo.cols.dst:clear_fence()
- pinfo.cols.dst:set(address:bytes():tohex())
-
- local sub = tree:add(proto, buffer())
- sub:add(proto.fields.addr, address)
- sub:add(proto.fields.fun, fun)
- sub:add(proto.fields.len, len)
- sub:add(proto.fields.data, data)
-
- local cs = sub:add(proto.fields.checksum, checksum)
- if sum ~= checksum:uint() then
- cs:add_proto_expert_info(proto.experts.checksum, string.format(
- "expected 0x%04x, got 0x%04x", checksum:uint(), sum
+ if sum ~= cs then
+ csf:add_proto_expert_info(proto.experts.checksum, string.format(
+ "expected 0x%04x, got 0x%04x", cs, sum
))
end
+ local fun_name = FUN_TABLE[fun]
+ pinfo.cols.info:set("T937 " .. (fun_name or ""))
+
+ if fun_name then
+ sub = sub:add(data, fun_name)
+ end
+
+ if fun_name == "TEMP_STATUS" then
+ sub:add(proto.fields.temp1, data(0,2))
+ sub:add(proto.fields.temp2, data(2,2))
+ sub:add(proto.fields.temp3, data(4,2))
+ end
+
return buffer:len()
end
@@ -106,9 +116,9 @@ function proto.dissector(_buf, pinfo, tree) while rest:len() > 0 do
local ok, len = pcall(try_dissect, rest, pinfo, tree)
if not ok then
- print("GOT ERR", len, pinfo.number)
state.error[pinfo.p2p_dir] = len
state.last_number = pinfo.number
+ print(len)
error(len)
elseif not len then
break
|
