#!/usr/bin/env ruby if ARGV.size < 2 then puts "Usage: #{__FILE__} 0.dat 1.dat ... > combined.dat" exit end PAGE_SIZE = 32 last_target_A_packet_time = 0 ARGV.each_with_index{|target, i| current_target_A_packet_time_shift = last_target_A_packet_time open(target, 'r'){|io| page = nil while (page = io.read(PAGE_SIZE)) if page[0] == ?A then t = (page[2..5].unpack("V"))[0] #p page[2..5] == [t].pack("V") if i > 0 then last_target_A_packet_time = t + current_target_A_packet_time_shift page[2..5] = [last_target_A_packet_time].pack("V") else last_target_A_packet_time = t end end $stdout << page end } }