Re: modemlights for ISDN?



Hi,

I had a short look at the isdn4linux package and found out how it works:
It looks at /dev/isdninfo.

I am sending two short TCL scripts as attachment. They are together only
280 lines long and under GNU license. The first, 'isdnbar' displays a
light indicating whether you're online or not together with the phone
number. The second is required by the first.

That's in /dev/isdninfo when I'm online:

idmap:  Tel0 Tel0 - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
chmap:  0 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 
drmap:  0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 
usage:  131 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
flags:  1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
phone:  14667 ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ???
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ???
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ???
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? 

and that when I'm offline

idmap:  Tel0 Tel0 - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
chmap:  0 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 
drmap:  0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 
usage:  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
flags:  0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
phone:  ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ???
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ???
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ???
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? 

And that when the device is down:

idmap:  Tel0 Tel0 - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
chmap:  0 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 
drmap:  0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 
usage:  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
flags:  0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
phone:  ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ???
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ???
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ???
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? 

/dev/isdninfo is a little bit different from the /proc filesystem of
Linux, when you read from it (i.e 'cat /dev/isdninfo') it waits forever
and you get new data each time status changes.

I now have one week of hard work followed by one week of holidays, so can
add an ISDN part to the modemlight applet next week. GNOME is really nice,
but I really need something telling me when it's wasting money again ...

Last question: Is there a screenshot of the modemlight applet available
anywhere ?

Martin

-----------------------------------------------------------------
   Martin Baulig - Angewandte Mathematik - Universitaet Trier

   baulig@castor.uni-trier.de, http://www.home-of-linux.org/
   Key: 1024-bit key with ID C8178435 created 1997/01/24 
   ID:  67 C1 84 A0 47 F5 11 C5  5F 68 4C 84 99 05 C3 92
   Finger me for public key or fetch finger.txt from the url above
------------------------------------------------------------------
#!/usr/X11R6/bin/wish -f
#
#   isdnbar - tcl/tk script to view ISDN activities without
#             too much CPU-use :-)
#
#   Ver. 0.5
#
#   (c) 1997 F.Kalhammer (f.kalhammer@t-online.de)
#
#   This program may be used under the conditions of the 
#   GNU General Public Lizence.
#
######################################################################




#####################################################################
#
#  The configure part
#
#  You have to configure the following variables to fit 
#  with your installation. The most important settings are
#  the PROGPATH and LIBPATH variables.
#
#####################################################################

set PROGPATH /usr/X11R6/bin
set LIBPATH  /usr/X11R6/lib/isdnbar

set FILE_TO_TAIL /var/log/messages

set font -adobe-helvetica-medium-r-normal-*-11-80-*-*-*-*-iso8859-1



######### End of configure-part. Nothing to change below ############




proc show_logfile {} {

  global xpid
  global FILE_TO_TAIL

  if {$xpid == 0} {
    set xpid [exec xterm -T "$FILE_TO_TAIL" -e tail -f $FILE_TO_TAIL &]
  } else {
    set erg [catch {exec kill -9 $xpid}]
    if {$erg != 0} {
      set xpid [exec xterm -T "$FILE_TO_TAIL" -e tail -f $FILE_TO_TAIL &]
    } else {
      set xpid 0
    }
  }
}


proc ausgang {} {

  global WATCH_PID

  exec kill -9 $WATCH_PID
  exit 0
}



proc parse_input {} {
  
  global idmap
  global chmap
  global usage
  global phone  
  global numdev
  
  
  global I
  global C
  global U
  global P  
  global D
  set more 1
  for {set i 0} { $more } { incr i } {
    set I($i) [lindex $idmap [expr $i+1]]
    if { ! [string compare $I($i) "-"] } {
      set more 0
    } else {
      set C($i) [lindex $chmap [expr $i+1]]
      set U($i) [lindex $usage [expr $i+1]]
      set X($i) $U($i)
      set P($i) [format "%15s" [lindex $phone [expr $i+1]]]
      if {$X($i) >= 128} {set X($i) [expr $X($i) -128]}
      if {$X($i) >= 64} {set X($i) [expr $X($i) -64] }
      switch $X($i) {
        0 {set D($i) "None "}
        1 {set D($i) "Raw  "}
        2 {set D($i) "Modem"}
        3 {set D($i) "Net  "}
        4 {set D($i) "Voice"}
      }
    }
  }
  set numdev [expr $i-1]
}



proc update {} {
  
  global idmap
  global chmap
  global usage
  global phone  
  global numdev
  
  global I
  global C
  global U
  global P  
  global D

  global isdninfo

    set isdninfo [open /dev/isdninfo "r"]
    gets $isdninfo idmap
    gets $isdninfo chmap
    gets $isdninfo drmap
    gets $isdninfo usage
    gets $isdninfo flags
    gets $isdninfo phone
    close $isdninfo

    parse_input
      
    for {set i 0} {$i < $numdev} {incr i} {
        if {$U($i) == 0} {
          .isdnlog.zeile${i}.o configure -image ledg 
        } elseif {$U($i) >= 128} {
 	  .isdnlog.zeile${i}.o configure -image ledr
	} else {
          .isdnlog.zeile${i}.o configure -image ledy 
        }
        .isdnlog.zeile${i}.num.n configure -text $P($i) 
        .isdnlog.zeile${i}.use.u configure -text $D($i)   
        
    }
}






#####################################################################
#
#  The main part
#
#####################################################################


set x 1
set xpid 0

set WATCH_PID [exec ${PROGPATH}/isdnwatch &]


set isdninfo [open /dev/isdninfo "r"]
gets $isdninfo idmap
gets $isdninfo chmap
gets $isdninfo drmap
gets $isdninfo usage
gets $isdninfo flags
gets $isdninfo phone
close $isdninfo

parse_input



image create photo ledg -file ${LIBPATH}/led_gruen.gif
image create photo ledr -file ${LIBPATH}/led_rot.gif
image create photo ledy -file ${LIBPATH}/led_gelb.gif
image create photo exitgif -file ${LIBPATH}/exit.gif
image create photo filegif -file ${LIBPATH}/file.gif

frame .btn -relief groove -borderwidth 2

button .btn.b1 -image filegif -command show_logfile
button .btn.b2 -image exitgif -command ausgang

#pack .btn -side right



frame .isdnlog -relief groove -borderwidth 2
pack .isdnlog .btn -padx 1m -pady 1m -side left
pack .btn.b1 .btn.b2 -side left -padx 2m -pady 1m

for {set num 0} {$num < $numdev} {incr num} {

	frame .isdnlog.zeile${num} -relief flat 

	frame .isdnlog.zeile${num}.num -width 70m -relief ridge -borderwidth 2 
	frame .isdnlog.zeile${num}.use -width 70m -relief ridge -borderwidth 2 

	label .isdnlog.zeile${num}.ch -text "Ch:$num  -  $I($num)" -font $font 
	label .isdnlog.zeile${num}.o -image ledg -bd 1 -relief flat
	label .isdnlog.zeile${num}.num.n -text $P($num) -font $font -width 10 -anchor w
	label .isdnlog.zeile${num}.use.u -text $D($num) -font $font -width 5 -anchor w



	pack .isdnlog.zeile$num  -side top -padx 1m -pady 1m
	pack .isdnlog.zeile${num}.ch .isdnlog.zeile${num}.o\
	     .isdnlog.zeile${num}.num .isdnlog.zeile${num}.use -side left -padx 2m
	pack .isdnlog.zeile${num}.num.n .isdnlog.zeile${num}.use.u -side left \
	      -fill both -padx 3m 
}

#!/usr/X11R6/bin/wish -f
#########!/usr/bin/tclsh 
#
#   isdnbar - tcl/tk script to view ISDN activities without
#             too much CPU-use :-)
#
#   (c) 1997 F.Kalhammer (f.kalhammer@t-online.de)
#
######################################################################


proc init {} {

  global isdninfo  
  set isdninfo [open /dev/isdninfo "r"]  
}



########################################################
#
#  The main part
#
########################################################

init
set x 1




while {1} {

  gets $isdninfo idmap
  gets $isdninfo chmap
  gets $isdninfo drmap
  gets $isdninfo usage
  gets $isdninfo flags
  gets $isdninfo phone


  if {$x !=$usage} {
    set x $usage
    send isdnbar {
      update
    }
  }
}


PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]