From 4edad93e718f82cf277ed5d241186e86af319f55 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 17 May 2019 14:14:51 +0200 Subject: firmware uploads --- usb/ncr-dispenser.lua | 101 +++++++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 46 deletions(-) diff --git a/usb/ncr-dispenser.lua b/usb/ncr-dispenser.lua index eba804e..e895038 100644 --- a/usb/ncr-dispenser.lua +++ b/usb/ncr-dispenser.lua @@ -45,6 +45,10 @@ d34_F = ProtoField.uint32("dispenser.d34", "Unknown 34", base.HEX) d38_F = ProtoField.uint32("dispenser.d38", "Unknown 38", base.HEX) d3c_F = ProtoField.uint32("dispenser.d3c", "Unknown 3c", base.HEX) +addr_F = ProtoField.uint32("dispenser.addr", "Upload Address", base.HEX) +size_F = ProtoField.uint32("dispenser.size", "Upload Size", base.HEX) +data_F = ProtoField.bytes("dispenser.data", "Upload Data") + -- add the field to the protocol dispenser_proto.fields = { dir_F, @@ -73,6 +77,10 @@ dispenser_proto.fields = { d34_F, d38_F, d3c_F, + + addr_F, + size_F, + data_F, } -- create a function to "postdissect" each frame @@ -87,12 +95,14 @@ function dispenser_proto.dissector(buffer,pinfo,tree) if usb_hl then off = usb_hl.value -- windows (https://desowin.org/usbpcap/) end + local mode = buffer(off + 0x00, 1) + local size = buffer(off + 0x18, 4) local magic = buffer(off + 0x08, 2) if magic:le_uint() == 0xbeef then local subtree = tree:add(dispenser_proto, "NCR S1 Dispenser") subtree:add(dir_F, usb_di.value) - subtree:add(b00_F, buffer(off + 0x00, 1)) + subtree:add(b00_F, mode) subtree:add(b01_F, buffer(off + 0x01, 1)) subtree:add_le(w02_F, buffer(off + 0x02, 2)) subtree:add_le(w04_F, buffer(off + 0x04, 2)) @@ -118,55 +128,54 @@ function dispenser_proto.dissector(buffer,pinfo,tree) if d10:le_uint() > 0 then subtree:add_le(d10_F, d10) end - local d14 = buffer(off + 0x14, 4) - if d14:le_uint() > 0 then - subtree:add_le(d14_F, d14) - end - local d18 = buffer(off + 0x18, 4) - if d18:le_uint() > 0 then - subtree:add_le(d18_F, d18) - end - local d1c = buffer(off + 0x1c, 4) - if d1c:le_uint() > 0 then - subtree:add_le(d1c_F, d1c) - end - local d20 = buffer(off + 0x20, 4) - if d20:le_uint() > 0 then - subtree:add_le(d20_F, d20) - end - local d24 = buffer(off + 0x24, 4) - if d24:le_uint() > 0 then - subtree:add_le(d24_F, d24) - end - local d28 = buffer(off + 0x28, 4) - if d28:le_uint() > 0 then - subtree:add_le(d28_F, d28) - end - local d2c = buffer(off + 0x2c, 4) - if d2c:le_uint() > 0 then - subtree:add_le(d2c_F, d2c) - end + if mode:uint() == 2 then + subtree:add_le(addr_F, buffer(off + 0x14, 4)) + subtree:add_le(size_F, size) + subtree:add_le(data_F, buffer(off + 0x1c, size:le_uint())) + else + local d14 = buffer(off + 0x14, 4) + if d14:le_uint() > 0 then + subtree:add_le(d14_F, d14) + end + local d18 = buffer(off + 0x18, 4) + if d18:le_uint() > 0 then + subtree:add_le(d18_F, d18) + end + local d1c = buffer(off + 0x1c, 4) + if d1c:le_uint() > 0 then + subtree:add_le(d1c_F, d1c) + end + local d20 = buffer(off + 0x20, 4) + if d20:le_uint() > 0 then + subtree:add_le(d20_F, d20) + end + local d24 = buffer(off + 0x24, 4) + if d24:le_uint() > 0 then + subtree:add_le(d24_F, d24) + end + local d28 = buffer(off + 0x28, 4) + if d28:le_uint() > 0 then + subtree:add_le(d28_F, d28) + end + local d2c = buffer(off + 0x2c, 4) + if d2c:le_uint() > 0 then + subtree:add_le(d2c_F, d2c) + end - local d30 = buffer(off + 0x30, 4) - if d30:le_uint() > 0 then - subtree:add_le(d30_F, d30) - end - local d34 = buffer(off + 0x34, 4) - if d34:le_uint() > 0 then - subtree:add_le(d34_F, d34) - end - local d38 = buffer(off + 0x38, 4) - if d38:le_uint() > 0 then - subtree:add_le(d38_F, d38) - end - if usb_dl.value >= 64 then - local d3c = buffer(off + 0x3c, 4) - if d3c:le_uint() > 0 then - subtree:add_le(d3c_F, d3c) + local d30 = buffer(off + 0x30, 4) + if d30:le_uint() > 0 then + subtree:add_le(d30_F, d30) + end + local d34 = buffer(off + 0x34, 4) + if d34:le_uint() > 0 then + subtree:add_le(d34_F, d34) + end + local d38 = buffer(off + 0x38, 4) + if d38:le_uint() > 0 then + subtree:add_le(d38_F, d38) end end - end end end -- cgit