Example now interactive shell

This commit is contained in:
pjht 2018-07-22 18:36:27 -05:00
parent ebb244c096
commit b3693c8d2d

View File

@ -7,8 +7,25 @@ dev3=EtherSocket.new(cable,"d2:f5:8a:34:6d:7e")
ipdriv1=IPDriver.new(dev1,"192.168.0.34",true)
ipdriv2=IPDriver.new(dev2,"192.168.0.40",true)
ipdriv3=IPDriver.new(dev3,"192.168.0.56",true)
ipdriv3.register_callback(254) do |from,data|
puts "#{data} from #{from}"
ipdriv1.register_callback(254) do |from,data|
puts "Got #{data} from #{from}"
end
ipdriv2.register_callback(254) do |from,data|
puts "Got #{data} from #{from}"
end
ipdriv3.register_callback(254) do |from,data|
puts "Got #{data} from #{from}"
end
numb_to_ip={"1"=>"192.168.0.34","2"=>"192.168.0.40","3"=>"192.168.0.56"}
numb_to_driv={"1"=>ipdriv1,"2"=>ipdriv2,"3"=>ipdriv3}
# ipdriv1.send_packet("Hello","192.168.0.56")
# ipdriv2.send_packet("Hi","192.168.0.56")
while true
print "From(1,2,or 3):"
from=numb_to_driv[gets.chomp]
print "To(1,2,or 3):"
to=numb_to_ip[gets.chomp]
print "Message:"
message=gets.chomp!
from.send_packet(message,to)
end
ipdriv1.send_packet("Hello","192.168.0.56")
ipdriv2.send_packet("Hi","192.168.0.56")