#!/usr/bin/perl -w use strict; use warnings; use Data::Dumper; use Device::SerialPort ;#qw( :PARAM :STAT 0.07 ); my $PortObj ; use bytes; my $ezio = { cmd=> chr hex ( '0xFE' ), init=> chr hex ( '0x28' ), stopsend=>chr hex ( '0x37' ), cls=> chr ( 1 ) , home=> chr ( 2 ), blank=> chr ( 8 ), hide=>chr hex ( '0x0C' ), }; sub ShowMessage { my $text = shift; my $text2 = shift; use bytes ; my $textlength = length $text; my $textlength2 = length $text2; no bytes; my $textpos = 40 - $textlength; #print "$textpos\n"; $PortObj->write("$text"); $PortObj->write("$text,$textlength"); $PortObj->write(q{},$textpos); $PortObj->write($text2,$textlength2); #print FH $text,$textlength; #print FH q{},$textpos; #print FH $text2,$textlength2; return () } sub SerialInit { $PortObj = Device::SerialPort->new ( '/dev/cua01' ) || die "Can't open serialport: $!\n"; $PortObj->datatype('raw'); $PortObj->user_msg(1); # built-in instead of warn/die above $PortObj->error_msg(1); # translate error bitmasks and carp #$PortObj->debug(1); $PortObj->baudrate(2400); $PortObj->parity('none'); $PortObj->databits(8); $PortObj->stopbits(1); $PortObj->purge_all(); # $PortObj->dtr_active(1); # $PortObj->rts_active(0); # $PortObj->save('/tmp/settings.cua01'); # $PortObj->close(); return (); } sub Uninit_Serial { $PortObj->close(); return (); } sub Init { $PortObj->write("$ezio->{cmd}"); $PortObj->write("$ezio->{init}"); $PortObj->write("$ezio->{cmd}"); $PortObj->write("$ezio->{init}"); return (); } sub Cls { $PortObj->write("$ezio->{cmd}"); # initial prompt $PortObj->write("$ezio->{cls}"); # initial prompt return (); } SerialInit ; Uninit_Serial(); SerialInit(); Init(); Cls(); ShowMessage('*Portwell EZIO *','****************'); Uninit_Serial(); 1;