improve print order

This commit is contained in:
King Kévin 2015-07-30 08:57:00 +02:00
parent cd543b92bd
commit 0758e2e50d
1 changed files with 12 additions and 7 deletions

19
mitm.rb
View File

@ -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"