From 0758e2e50daf4323395aa2c38e81cca5abdea553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Thu, 30 Jul 2015 08:57:00 +0200 Subject: [PATCH] improve print order --- mitm.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) 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"