This perl script can be used to post messages to the display using pipes. For example, after connecting the controller to the display and the controller to the computer, the following command can be issued to display the phrase hello world
onto the display:
echo "hello world" | ./bv4511ctl.pl
bv4511ctl.pl --light=on
and off:
bv4511ctl.pl --light=off
bv4511ctl.pl --clear
#!/usr/bin/perl ########################################################################### ## Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 ## ## Please see: http://www.gnu.org/licenses/gpl.html for legal details, ## ## rights of fair usage, the disclaimer and warranty conditions. ## ########################################################################### use strict; use constant true => 1; use constant false => 0; # Packages use Device::SerialPort qw( :PARAM :STAT 0.07 ); use Term::ReadKey; use Time::HiRes qw(usleep); use Getopt::Long; use Switch 'fallthrough'; use Pod::Usage; # Autoflush $| = 1; # Map EOF $/ = eof; # Defaults my $baud = 9600; my $sleep = 1e9/$baud; my $opt_port = "/dev/ttyUSB0"; my $opt_clear = false; my $opt_reset = false; my $opt_light=""; my $result; GetOptions( # "help|?" => \$opt_help, "clear" => \$opt_clear, "reset" => \$opt_reset, # "fg=s" => \$opt_fg, # "bg=s" => \$opt_bg, # "port=s" => \$opt_port, # "line=s" => \$opt_line, # "box=s" => \$opt_box, # "circle=s" => \$opt_circle, # "cursor=s" => \$opt_cursor, "light=s" => \$opt_light ); # Reopen as brand new and commit my $serialPort = Device::SerialPort->new($opt_port) or die "Cannot open port: $!.\n"; $serialPort->baudrate($baud); $serialPort->databits(8); $serialPort->parity("none"); $serialPort->stopbits(1); $serialPort->handshake("rts"); $serialPort->lookclear; $serialPort->write_settings; send_serial("\r"); usleep($sleep); # Sending subroutine sub send_serial { my $data = shift; $result = $serialPort->write($data) or die "Unable to write to port: $!.\n"; } # Toggle Backlight if($opt_light) { switch($opt_light) { case "on" { send_serial("\033[?26h"); last; } case "off" { send_serial("\033[?26I"); } } goto END; } # Clear screen if($opt_clear) { send_serial("\033[2J"); goto END; } # Reset if($opt_reset) { send_serial("\033c"); goto END; } # Process input # Grab STDIN my $input; while(<>) { $input.=$_; } chomp $input; # Split each character for VAC my $out = 0; my @data = split(//,$input); foreach (@data) { if($_ eq "\n") { while($out != 21) { send_serial(" "); ++$out; } send_serial("\n\r"); $out = 0; next; } send_serial($_); ++$out; } while($out % 21 != 0) { send_serial(" "); ++$out; } send_serial("\n\r"); END: # Close port. $serialPort->close(); exit 0;