4 This file is part of the AVR-Crypto-Lib.
5 Copyright (C) 2008, 2009 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/>.
25 $progress_dots = false
27 def read_line(error_msg=true)
35 puts("ERROR: read timeout!\n") if error_msg
38 putc('.') if s.include?(6.chr) && $progress_dots
39 puts(s.inspect) if $debug
44 def readTestVector(param)
52 if (m=/unknown command/.match(lb) || m=/[Ee][Rr]{2}[Oo][Rr]/.match(lb))
59 end while(m=/\*+/.match(lb));
68 end while(m=/\*.*/.match(lb));
70 while(!(m=/Test vectors/.match(lb)))
71 m=/[^:]*:[\s]([A-Za-z0-9_-]*)/.match(lb);
75 return false if lb==nil
82 puts("-> "+fname+"txt");
83 file=File.new(fname+"txt", "w");
88 if (m=/Test\ vectors\ \-\-\ set[\s]+([0-9]+)/.match(lb))
90 print("\nSet "+m[1]+":");
92 if (m=/Set [0-9]*, vector#[\s]*([0-9]+):/.match(lb))
95 if(vector!=0 && vector % $linewidth==0)
98 printf(" %4u", vector);
106 end while(!m=/End of test vectors/.match(lb));
115 Usage: ruby #{$0} port bps nbits stopb command [target_dir] [additional specifier]
120 command=ARGV[4]+"\r";
121 $dir=(ARGV.size>=6)?ARGV[5]:"";
122 param=(ARGV.size>=7)?ARGV[6]:"";
124 puts("\nPort: "+ARGV[0]+ "@"+ARGV[1]+" "+ARGV[2]+"N"+ARGV[3]+"\n");
126 $sp = SerialPort.new(ARGV[0], ARGV[1].to_i, ARGV[2].to_i, ARGV[3].to_i, SerialPort::NONE);
127 $sp.read_timeout=1000; # 1 second
128 $extended_wait=100000;
131 if(readTestVector(param)==false)
132 puts("ERROR: test seems not to be implemented");
136 while(readTestVector(param))