4 This file is part of the AVR-Crypto-Lib.
5 Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 $sp.print("echo off \r")
28 # line = $sp.readlines()
32 $sp.print("shavs_set a \r")
33 # line = $sp.readlines()
37 $sp.print("shavs_test1 \r")
38 # line = $sp.readlines()
46 line = "" if line==nil
47 # puts("DBG g: "+line)
48 end while not /[\s]*MD[\s]*=.*/.match(line)
52 def run_test(filename)
53 if not File.exist?(filename)
54 puts("ERROR file "+filename+" does not exist!")
57 file = File.new(filename, "r");
61 end while not (file.eof or (/[\s]*Len[\s]*=.*/.match(lb)))
62 # puts("DBG sending: "+lb);
68 end while not (file.eof or (/[\s]*Msg[\s]*=.*/.match(lb)))
70 # puts("DBG sending: "+lb);
75 end while not /[\s]*MD[\s]*=.*/.match(lb)
76 a = (/[\s]*MD[\s]*=[\s]*([0-9a-fA-F]*).*/.match(lb))[1];
77 b = (/[\s]*MD[\s]*=[\s]*([0-9a-fA-F]*).*/.match(avr_md))[1];
80 puts("") if (pos%$linewidth==0 and $linewidth!=0)
89 Usage: ruby #{$0} port bps nbits stopb testfile ...
94 puts("\nPort: "+ARGV[0]+ "@"+ARGV[1]+" "+ARGV[2]+"N"+ARGV[3]+"\n");
96 $sp = SerialPort.new(ARGV[0], ARGV[1].to_i, ARGV[2].to_i, ARGV[3].to_i, SerialPort::NONE);
97 $sp.read_timeout=1000; # 5 minutes
103 for i in (4..(ARGV.size-1))