#!/usr/bin/perl -w # #--------------------------------------- # # test_lcd.pl display stuff to the LCD # # 07-Jul-00 amo Date-of-Birth ( stolen from record_sensors.pl ) # 12-Mar-01 amo Fixed ip# # 20-Apr-01 amo Use ifconfig instead ( os independent ) # # # #--------------------------------------- # # which serial port is the display attached to # #y ( $SERIALPORT ) = "/dev/ttyS0"; my ( $SERIALPORT ) = "/dev/ttyS1"; # # end of User Changes... # # ------------------------------------------- # # # Get some info about the hosts # ----------------------------- # my ( $NM ) = "test_lcd.pl"; # my ( $host ) = `hostname`; chomp ( $host ); # # my ( @route ) = split ( /\s+/, `route -nv | grep 166 | grep UH ` ); # my ( $ip ) = $route[0]; # #y ( @ipaddr ) = split ( /=/, `grep -i ^ipaddr /etc/sysconfig/network-scripts/ifcfg-eth0 ` ); # # inet addr:166.90.172.11 Bcast:166.90.172.255 Mask:255.255.255.0 my ( @ipaddr ) = split ( /:/, `ifconfig -v | grep -i "inet addr" | grep -v 127.0.0 ` ); my ( $ip ) = $ipaddr[1]; chomp ( $ip ); # #y ( $pid ) = ` ps auxw | grep $NM | cut -d ' ' -f 8 `; # my ( $str ) = ` ps auxw | grep $NM `; my ( $x_y, $pid, @foo ) = split ( /\s+/, $str ); # # # Show Something on the LCD # -------------------------- # &se_text ; # exit ; # # --------------------------------------------- # sub se_text { # # info dumped to the screen # print "\n"; print "$NM: LCD on serial port=$SERIALPORT..pid=$pid..\n"; print "\n"; # # # set up the serial port for output # SE board can be set to 2400 or 9600 bps # #ystem ( "stty 2400 <$SERIALPORT" ); system ( "stty 9600 <$SERIALPORT" ); #ystem ( "stty 19200 <$SERIALPORT" ); # # open ( LCDOUT, "> $SERIALPORT"); # # LCD codes for this serial adapter $lcdcmd = "\xFE"; # general command prefix # $cls = $lcdcmd."\x01" ; # clear display $cursorhome = $lcdcmd."\x02".$lcdcmd."\xEF" ; $line2 = $lcdcmd."\xC0"; # $even = 1 ; while ( 1 ) { # # Clear and home the LCD display # ------------------------------ # printf LCDOUT "$cls"; printf LCDOUT "$cursorhome"; # printf LCDOUT "$cls"; # # printf "..host=$host...line2=$line2...ip=$ip..pid=$pid..\n"; # if ( $even == 1 ) { printf LCDOUT "..$host..$line2.$ip.\n"; $even = 0; } else { printf LCDOUT "..$NM..$line2..pid=$pid..\n"; $even = 1; } # # $even = ( $even + 1 ) % 2 ; sleep 5 ; # } close ( LCDOUT ); # } # se_text # # end of file