#!/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 ) # 30-Jan-05 amo "\n" is needed and use 16char string to print to the lcd # # # #--------------------------------------- # # which serial port is the display attached to # #y ( $SERIALPORT ) = "/dev/ttyS0"; #xx( $SERIALPORT ) = "/dev/ttyS1"; # my ( $SERIALPORT ) = "/dev/ttyUSB0"; # # end of User Changes... # # ------------------------------------------- # # # Get some info about the hosts # ----------------------------- # my ( $NM ) = "test_lcd.pl"; # my ( $host ) = `hostname -s`; chomp ( $host ); # my ( $dom ) = `hostname -d`; chomp ( $dom ); # # # 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 ) = split ( /\s+/, $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 ); # # # ------------------------------- # Rotate among the 16x2 LCD data # ------------------------------- my ( $width ) = 16; # my ( @LCDATA ) = (); $LCDATA[0] = ""; # empty $LCDATA[1] = sprintf ( "%*s", -$width, $NM ); $LCDATA[2] = sprintf ( "%*s", -$width, $pid ); $LCDATA[3] = sprintf ( "%*s", -$width, $host ); $LCDATA[4] = sprintf ( "%*s", -$width, $dom ); $LCDATA[5] = sprintf ( "%*s", -$width, $ip ); $LCDATA[6] = sprintf ( "%*s", -$width, "192.168.1.1" ); # # # 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"; # $r = 1; while ( 1 ) { # # Clear and home the LCD display # ------------------------------ # printf LCDOUT "$cls"; #rintf LCDOUT "$cursorhome"; # #rintf LCDOUT "$cls"; # $s = $r; $s += 1; # $rs = $LCDATA[$r]; $ss = $LCDATA[$s]; # # printf "..$#LCDATA..data[$r]=$rs....$ss..\n"; # # # 30-Jan-05 amo "\n" is needed and use 16char string to print to the lcd # printf LCDOUT "$cursorhome$rs$line2$ss\n"; # $r += 1; $r = 1 if ( $r >= $#LCDATA ); # sleep 5 ; # } # loop forever # close ( LCDOUT ); # } # se_text # # end of file