X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=write-to-serial.pl;fp=write-to-serial.pl;h=24c1d06ec554147f56c0efa9e4dd9a12ee3c8a9e;hb=52e4bb145ca19c9ef91f57f7ca8dab0a507cb03f;hp=0000000000000000000000000000000000000000;hpb=2dbe6ed85d0f9527c29584c2f38c5458642c3177;p=clump.git diff --git a/write-to-serial.pl b/write-to-serial.pl new file mode 100644 index 0000000..24c1d06 --- /dev/null +++ b/write-to-serial.pl @@ -0,0 +1,21 @@ +#!/usr/bin/perl +use v5.14; +use warnings; + +use Device::SerialPort; + +my $program; +read STDIN, $program, 1000000; + +my $port = Device::SerialPort->new($ARGV[0] // '/dev/ttyUSB1') or die "$!"; +$port->baudrate(300); +$port->parity('none'); +$port->databits(8); +$port->stopbits(2); +$port->handshake('none'); + +$port->write_settings or die "$!"; + +my $bytes_written = $port->write($program); +my $bytes_to_write = length $program; +die "Only wrote $bytes_written instead of $bytes_to_write" unless $bytes_written == $bytes_to_write;