X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=host%2Fget_test.rb;h=cfc3b33a093a67e2e6382c5638132ad1003e0f2c;hb=d3db763eeb456ce00849ecf658782f95b9f5634c;hp=2e5985cd4ca4aaef5e32c062fb338ab7c11e1e90;hpb=e9d58dce0a1eca2c78aec260406e1605ae29fff7;p=avr-crypto-lib.git diff --git a/host/get_test.rb b/host/get_test.rb index 2e5985c..cfc3b33 100644 --- a/host/get_test.rb +++ b/host/get_test.rb @@ -1,7 +1,34 @@ #!/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 + s = $sp.gets() + if s==nil + puts "ERROR: read timeout!\n"; + return nil + end + s.gsub(/\006/, ''); +end + def readTestVector(param) fname=$dir; lb=""; @@ -9,11 +36,8 @@ def readTestVector(param) set=0; vector=0; begin - ctr=$extended_wait; - while((lb=$sp.gets())==nil && ctr>=0)do - ctr -= 1; - end - if (m=/unknown command/.match(lb) || m=/[Ee][Rr]{2}[Oo][Rr]/.match(lb)) + lb = read_line() + if (m=/unknown command/.match(lb) || m=/[Ee][Rr]{2}[Oo][Rr]/.match(lb)) puts("ERROR: "+lb); exit(2); end @@ -24,10 +48,7 @@ def readTestVector(param) buffer += lb; begin - ctr=$extended_wait; - while((lb=$sp.gets())==nil && ctr>=0)do - ctr -= 1; - end + lb = read_line() if(lb==nil) return false; end @@ -40,10 +61,7 @@ def readTestVector(param) fname+=m[1]+"."; end buffer+=lb; - ctr=$extended_wait; - while((lb=$sp.gets())==nil && ctr>=0)do - ctr -= 1; - end + lb = read_line(); end if(param!="") fname+=param+"."; @@ -65,10 +83,7 @@ def readTestVector(param) end printf(" %4u", vector); end - ctr=$extended_wait; - while((lb=$sp.gets())==nil && ctr>=0)do - ctr -= 1; - end + lb=read_line(); if(lb==nil) file.close(); return false;