X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=host%2Fget_test.rb;h=0c3eb1bea1ae0e8a2c5a466fcffd27fb860e8de5;hb=83d0614d8b17eac97f891f7de2bb3ef265751dea;hp=f917c331125a10d291fbb4b20c959e3d5b10f4e9;hpb=e5a49deb52521f019e37779d6e9d81ec4f02aba4;p=avr-crypto-lib.git diff --git a/host/get_test.rb b/host/get_test.rb index f917c33..0c3eb1b 100644 --- a/host/get_test.rb +++ b/host/get_test.rb @@ -1,11 +1,29 @@ #!/usr/bin/ruby +# get_test.rb +=begin + This file is part of the AVR-Crypto-Lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +=end require 'serialport' -def read_line +def read_line(error_msg=true) s = $sp.gets() if s==nil - puts "ERROR: read timeout!\n"; + puts("ERROR: read timeout!\n") if error_msg return nil end s.gsub(/\006/, ''); @@ -18,7 +36,7 @@ def readTestVector(param) set=0; vector=0; begin - lb = read_line() + lb = read_line(false) if (m=/unknown command/.match(lb) || m=/[Ee][Rr]{2}[Oo][Rr]/.match(lb)) puts("ERROR: "+lb); exit(2); @@ -42,8 +60,9 @@ def readTestVector(param) if(m) fname+=m[1]+"."; end + return false if lb==nil buffer+=lb; - lb = read_line(); + lb = read_line(); end if(param!="") fname+=param+"."; @@ -92,7 +111,7 @@ param=(ARGV.size>=7)?ARGV[6]:""; puts("\nPort: "+ARGV[0]+ "@"+ARGV[1]+" "+ARGV[2]+"N"+ARGV[3]+"\n"); $linewidth = 16 $sp = SerialPort.new(ARGV[0], ARGV[1].to_i, ARGV[2].to_i, ARGV[3].to_i, SerialPort::NONE); -$sp.read_timeout=1*60*1000; # 5 minutes +$sp.read_timeout=1000; # 1 secound $extended_wait=100; $sp.write(command);