diff --git a/mitm.rb b/mitm.rb index 288ce5f..efe69cb 100755 --- a/mitm.rb +++ b/mitm.rb @@ -16,18 +16,23 @@ while true activities[0].each do |activity| data = activity.readpartial(16+1+5) line = data.unpack("C*").collect { |b| sprintf("%02X ",b) }.join - begin - telegram = Telegram.parse(data) - rescue Exception => e - puts e.to_s - end if activity==pc_serial then puts "pc->ps: "+line - puts "pc->ps: "+telegram.to_s if telegram + begin + telegram = Telegram.parse(data) + puts "pc->ps: "+telegram.to_s if telegram + rescue Exception => e + puts e.to_s + end ps_serial.write(data) elsif activity==ps_serial then puts "ps->pc: "+line - puts "ps->pc: "+telegram.to_s if telegram + begin + telegram = Telegram.parse(data) + puts "ps->pc: "+telegram.to_s if telegram + rescue Exception => e + puts e.to_s + end pc_serial.write(data) else raise "unknown source"