]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/perl | |
2 | use v5.14; | |
3 | use warnings; | |
4 | ||
5 | use Device::SerialPort; | |
6 | ||
7 | my $program; | |
8 | read STDIN, $program, 1000000; | |
9 | ||
10 | my $port = Device::SerialPort->new($ARGV[0] // '/dev/ttyUSB1') or die "$!"; | |
11 | $port->baudrate(300); | |
12 | $port->parity('none'); | |
13 | $port->databits(8); | |
14 | $port->stopbits(2); | |
15 | $port->handshake('none'); | |
16 | ||
17 | $port->write_settings or die "$!"; | |
18 | ||
19 | my $bytes_written = $port->write($program); | |
20 | my $bytes_to_write = length $program; | |
21 | die "Only wrote $bytes_written instead of $bytes_to_write" unless $bytes_written == $bytes_to_write; |