Here is the script..Or click here for
the screen shot..
#! /usr/local/bin/wish8.0
#
# FreeBSD Packet
# writen by
# Scott Billingsley
(KB5RYO)
# using TCL/TK 8.0
# for FreeBSD 3.1
#
# FreeBSD Packet is a very basic terminal program
# for packet under FreeBSD..It was written as the
# first part of a small network because I couldn't
# find a packet program for FreeBSD..I will be adding
# more to the program as I go..Maybe a network socket
# to work on the LAN..
# I have tested FreeBSD Packet under FreeBSD 3.1,
# Linux Mandrake 7 and Windows 98 (why???)...Change
# the first line and the serial port lines to match
# your setup..
#
#
#-------- Set the serial port
#
set serial_port "/dev/cuaa0"
set baudrate 9600
#
#-------- Window Manager Section
wm title . "FreeBSD Packet"
set text ""
#
font create myfont -family Courier -size 12
text .rx -width 80 -height 15 -bg white -fg darkblue \
-yscrollcommand ".rxs set" -font myfont -takefocus 1
text .tx -width 80 -height 5 -bg white -yscrollcommand ".txs set" -font
myfont
label .l -width 80 -height 1 -font myfont -relief raised -justify right
label .l2 -width 80 -height 1 -font myfont -relief raised
#
scrollbar .rxs -orient vertical -command ".rx yview"
scrollbar .txs -orient vertical -command ".tx yview"
#
grid .rx -row 0 -column 0 -sticky "news"
grid .tx -row 2 -column 0 -sticky "news"
grid .rxs -row 0 -column 1 -sticky "ns"
grid .txs -row 2 -column 1 -sticky "ns"
grid .l2 -row 1 -column 0 -sticky "ew"
grid .l -row 3 -column 0 -sticky "sew"
#
#---------- Menu Section
menu .menu -tearoff 0 -type menubar
set m .menu.file
menu $m -tearoff 0
.menu add cascade -label "File " -menu $m -underline 0
$m add command -label "Exit..." -command "ExitProgram 0" -underline
0
#
set m .menu.option
menu $m -tearoff 0
.menu add cascade -label "Options" -menu $m -underline 0
. configure -menu .menu
#### Bind the keyrelease event to the form
bind .tx <KeyRelease> {
read_key
}
#
#------- Setup the comport
#
proc setup { } {
global serial_port
global serID
global baudrate
# Open the port for reading and writing..
if [catch "open $serial_port
RDWR" serID ] {
puts stdout "Problems opening serial port: $serial_port"
puts stderr "Could not open serial port"
ExitProgram 1
}
# Set the baudrate and asynchronous format
# translation auto in and cr out works for packet modem...
#
if [catch "fconfigure $serID
-mode $baudrate,n,8,1 -blocking 0 \
-translation {auto cr} -buffering none"] {
puts stdout "Problems attempting to set baudrate"
puts stderr "Could not set baudrate"
ExitProgram 1
}
# Set a fileevent to read the incoming data...
#
fileevent $serID readable read_byte
}
#######################
# Start the comport....
setup
#######################
#
# read the keyboard
#
proc read_key { } {
global text
global serID
####Find the current cursor position
set cursor_pos [.tx index
insert]
.l configure -text $cursor_pos
####Find the current line number
set line_number [string
range $cursor_pos 0 \
[string first "." $cursor_pos]]
####Find the current column number
set column_number [string
range $cursor_pos \
[expr [string first "." $cursor_pos] + 1] \
[string length $cursor_pos]]
####Find the position before the key was released
set cursor_current [string
trim "$line_number [expr $column_number - 1]" " "]
####Get the character before the key release
set key [.tx get $cursor_current]
####If the key was the enter key lets put some text out
if {$key == "\n" } {
####Set the line back one
set line_start [expr $cursor_pos
- 1.0]
####Get the text from that line
set text [.tx get $line_start
$cursor_current]
####Put the text in the .rx window
# .rx insert end $text
####If it's the bottom of the text box; scroll!!
.rx yview scroll 1 unit
####Send the text to the comport.
puts -nonewline $serID $text
}
}
#######################
#
# read the serial port
#
proc read_byte {} {
global serID
set value [read $serID 1]
.rx insert end $value
.rx yview scroll 1 unit
}
proc ExitProgram {exitvalue} {
global serID
close $serID
exit $exitvalue
}
Screen shot....FreeBSD Packet on Icewm...
I hope you find some of this useful..Enjoy...