]>
iEval git - clump.git/blob - sendrecieve.pl
5 use Device
::SerialPort
;
8 use File
::Slurp
::Tiny qw
/read_file/;
13 $term = Term
::ReadLine
->new('YULE REPL');
17 my $port = Device
::SerialPort
->new($ARGV[0] // '/dev/ttyUSB1') or die "$!";
19 #$port->baudrate(4000000);
20 $port->parity('none');
23 $port->handshake('none');
24 $port->read_const_time(5000);
26 $port->write_settings or die "$!";
28 my $asm = read_file
'cells.clump';
31 my ($count_in, $string_in) = $port->read(5000);
32 my @memory = unpack 'v*', $string_in;
42 $sexp = $term->readline('* ');
45 exit unless defined $sexp;
50 exit unless defined $sexp;
52 my $compiler = App
::Scheme79asm
::Compiler
->new;
53 my $compiler_out = $compiler->compile_string($sexp);
55 # say 'Compiler says: ', dump_sexp($compiler_out);
57 my $asm = App
::Scheme79asm
->new(addr_bits
=> 13);
59 open my $asm_fh, '>', \
$asm_output;
60 $asm->process($compiler_out);
62 $asm->print_binary16($asm_fh);
65 # say "Writing: ", join ' ', uc join ' ', unpack '(H2)*', $asm_output;
66 my $bytes_written = $port->write($asm_output);
67 my $bytes_to_write = length $asm_output;
68 die "Only wrote $bytes_written instead of $bytes_to_write" unless $bytes_written == $bytes_to_write;
70 my ($count_in, $string_in) = $port->read(5000);
71 my @memory = unpack 'n*', $string_in;
72 # say 'Received: ', uc join ' ', unpack '(H2)*', $string_in;
73 unshift @memory, 0, 0, (1<<13), (1<<13);
74 princ
$compiler, \
@memory, 6;
This page took 0.054041 seconds and 5 git commands to generate.