Initial revision

This commit is contained in:
dcp1990 2005-01-05 03:41:41 +00:00
commit e973197842
15 changed files with 933 additions and 0 deletions

109
dumps/dump.chan Normal file
View File

@ -0,0 +1,109 @@
001:0154.8150,"Wakefield",-d yes
002:0155.5500,"Wakefield",-d yes
003:0155.9700,"Wakefield",-d yes
004:0460.1000,"Providence",-d yes
005:0460.2750,"Providence",-d yes
006:0460.3250,"Providence",-d yes
007:0154.7700,"East Providence",-d yes
008:0155.0100,"East Providence",-d yes
009:0155.4300,"Central Falls",-d yes
010:0155.6550,"Central Falls",-d yes
011:0154.8750,"Narragansett",-d yes
012:0482.8375,"Woonsocket",-d yes
013:0460.2000,"Providence",-d yes
014:0453.1500,"Providence",-d yes
015:0460.4250,"Providence",-d yes
016:0154.6950,"State",-d yes
017:0154.9050,"State",-d yes
018:0154.9350,"State",-d yes
019:0155.1900,"State",-d yes
020:0155.4450,"State",-d yes
021:0155.5050,"State",-d yes
022:0155.6100,"State",-d yes
023:0159.1500,"State",-d yes
024:0154.8000,"North Providence",-d yes
025:0158.9700,"North Providence",-d yes
026:0866.3500,"Providence",-d yes
027:0866.3875,"Providence",-d yes -l yes
028:0866.8875,"Providence",-d yes -l yes
029:0867.8125,"Providence",-d yes -l yes
030:0867.8375,"Providence",-d yes -l yes
031:0868.0625,"Providence",-d yes -l yes
032:0868.1000,"Providence",-d yes -l yes
033:0868.5875,"Providence",-d yes -l yes
034:0868.7875,"Providence",-d yes -l yes
035:0868.8375,"Providence",-d yes -l yes
036:0154.8900,"Warwick",-d yes
037:0155.1300,"Warwick",-d yes -l yes
038:0154.4300,"Pawtucket",-d yes
039:0154.8300,"Pawtucket",-d yes
040:0154.7250,"North Providence",-d yes
041:0156.3300,"Woonsocket",-d yes
042:0481.4125,"Cranston",-d yes
043:0482.4125,"Cranston",-d yes
044:0482.4625,"Cranston",-d yes
045:0482.5625,"Cranston",-d yes
046:0859.8375,"",-d yes -l yes
047:0860.3125,"",-d yes -l yes
048:0860.9875,"",-d yes -l yes
049:0866.9250,"A",-d yes -l yes
050:0155.6250,"Coventry",-d yes
051:0000.0000,"",-l yes
052:0000.0000,"",-l yes
053:0000.0000,"",-l yes
054:0000.0000,"",-l yes
055:0000.0000,"",-l yes
056:0000.0000,"",-l yes
057:0000.0000,"",-l yes
058:0000.0000,"",-l yes
059:0000.0000,"",-l yes
060:0000.0000,"",-l yes
061:0000.0000,"",-l yes
062:0000.0000,"",-l yes
063:0000.0000,"",-l yes
064:0000.0000,"",-l yes
065:0000.0000,"",-l yes
066:0000.0000,"",-l yes
067:0000.0000,"",-l yes
068:0000.0000,"",-l yes
069:0000.0000,"",-l yes
070:0000.0000,"",-l yes
071:0000.0000,"",-l yes
072:0000.0000,"",-l yes
073:0000.0000,"",-l yes
074:0000.0000,"",-l yes
075:0000.0000,"",-l yes
076:0000.0000,"",-l yes
077:0000.0000,"",-l yes
078:0000.0000,"",-l yes
079:0000.0000,"",-l yes
080:0000.0000,"",-l yes
081:0000.0000,"",-l yes
082:0000.0000,"",-l yes
083:0000.0000,"",-l yes
084:0000.0000,"",-l yes
085:0000.0000,"",-l yes
086:0000.0000,"",-l yes
087:0000.0000,"",-l yes
088:0000.0000,"",-l yes
089:0000.0000,"",-l yes
090:0000.0000,"",-l yes
091:0000.0000,"",-l yes
092:0000.0000,"",-l yes
093:0000.0000,"",-l yes
094:0000.0000,"",-l yes
095:0000.0000,"",-l yes
096:0000.0000,"",-l yes
097:0000.0000,"",-l yes
098:0000.0000,"",-l yes
099:0000.0000,"",-l yes
100:0000.0000,"",-l yes
101:0154.3700,"Providence",-d yes
102:0154.0700,"East Providence",-d yes
103:0154.4450,"Pawtucket",-d yes
104:0154.1300,"Woonsocket",-d yes
105:0046.4200,"Wakefield",-d yes
106:0155.2800,"Providence Amblc",-d yes
107:0155.3400,"Providence Amblc",-d yes
108:0154.1600,"Lincoln",-d yes
109:0123.1000,"Aircraft SAR",-d yes

BIN
dupl.rtf Normal file

Binary file not shown.

45
readme.txt Normal file
View File

@ -0,0 +1,45 @@
*******************************************************************************
*** ***
*** BearTKat Readme ***
*** PLEASE READ! PLEASE READ! PLEASE READ! PLEASE READ! PLEASE READ! ***
*** ***
*******************************************************************************
1.0 Introduction
Welcome to BearTKat, one of the most fully-featured free scanner control applications for the BC250D and other Bearcat series scanner radios from Uniden that runs on both Unix and Windows! For someone new to computing, the Tcl/Tk approach may seem awkward and overly complicated. However, it is very sensible in actuality. Using Tcl/Tk allows more time to be spent on the application than interface coding and having differing codebases for different platforms. It also makes the author's job easier by bringing some comforts of the Unix programming environment to Windows, while maintaining consistency with other applications on the platform.
If you have bug reports, fixes, suggestions, questions, comments, or anything else, feel free to direct them to Dan at dcp1990@cox.net.
1.1 System Prerequisites
*Tcl/Tk 8.4 (stock for Unix works fine, on Windows, ActiveTcl works very nicely) (available from http://www.tcl.tl/)
*A BC250D radio and cable, other models may work with modifications
*A Unix-like operating system, Windows, and possibly Mac Classic
*A text editor (Vim is a fine choice)
*425k of disk space on Windows, less on Unix. More for frequency databases.
1.2 Licensing
BearTKat is one of the first applications licensed under the DUPL. A copy of the DUPL should be in the source distribution or displayed during installation on Windows. Please take the time to read the license, and if you are a commercial entity, it is imperative that you do so. If you are unsure about any part, talk to qualified legal personnel.
1.3 Developer Test Platforms
Dan is able to test BearTKat on:
*FreeBSD (stock Unix Tcl/Tk 8.4)
*Windows XP (ActiveTcl/Tk 8.4)
*Linux (stock Unix Tcl/Tk 8.4)
2.0 Installation and execution
On Unix, simply run src/beartkat.tcl. If your radio is on a serial device other than /dev/cuaa0 and/or your radio's baud rate is not 19200bps, edit beartkat.conf accordingly before use. If the path to your wish binary is not /usr/local/bin/wish8.4 (as it is on FreeBSD), change the first line of beartkat.tcl accordingly.
On Windows, run Setup.exe and the wizard will guide you from there. After installation, click either of the shortcuts created on the Desktop or the Start Menu. If your radio is on a serial device other than COM1: and/or your radio is set to a speed other than 19200 baud, please edit beartkat.conf (in the beartkat installation directory) as such. There should be a configuration utility/dialog in the very near future to handle this.
I am unsure about MacOS Classic, but I would imagine OSX users would follow a combination of the Windows and Unix procedures outlined above.
2.1 Usage
Upon execution of BearTKat, it will probe for your radio (by sending an "SI" command). If, after 9 tries, the radio doesn't respond, it will notify the user. If the user chooses to ignore, they can re-probe for the radio by going to Help->About my radio (which resends an "SI" command). Upon sucessful probing, the "Model:" label is set accordingly. After that, you are presented with 3 windows: the main window, the LCD/Keypad window, and the Frequency Import/Exportation window. Each serves a particular purpose, being either of:
*Controling BearTKat itself
*Controling the radio and displaying it's status
*Managing memories within the radio
2.2 BearTKat dialogs
"Set Alpha Tags," available from the Scanner menu in the main window, as it's name implies, allows you to set, clear, and retreive alpha tags for a given channel. In the channel box, one must enter a three-digit channel number, 000 being channel 1000 and 001 being channel 1. You must pad the number with zeroes. Use is fairly self-explanatory besides that point.
The "About my radio" dialog, accessed from the Help menu, allows one to view information about their radio, including model number and battery status.
2.3 Radio control
The LCD/Keypad window emulates the LCD display of the radio and a select few buttons. To begin polling the radio for it's LCD contents, click the "Start Polling" button in the main window. When polling is enabled, BearTKat will request LCD contents every second (this is adjustable by using the "interval" configuration parameter) until the "Stop Polling" button is pressed. You may resume polling by clicking "Start Polling" again. Other than that, use is fairly self-explanatory.
2.4 Frequency Management
A frequency database is simply a file with lines in the form of:
Channel:freq.uency,"Alpha Tag",-d <yes|no>, -l <yes|no>
For example:
016:0154.6950,"State",-d yes -l no
Channel is a 3 digit number (padded with zeroes), frequency is the frequency in megahertz, -d specifies the delay flag, and -l specifies the lockout flag. An example is included in the file dumps/dump.chan.
To dump your frequencies, use the buttons in the "Frequencies" window.
2.5 Channel dialog
The channel dialog allows one to load a dump in the proper format and manage the channels. Currently, only tuning to a specific channel is supported (and the scanner and dump file must be in sync to work properly).

10
scripts/example.tcl Executable file
View File

@ -0,0 +1,10 @@
# Example BearTKat script
# gets info, toggles light, switches to weather and back again
# (C)2004, 2005 Dan Ponte
puts "Loading..."
puts [beartkat::docommand "SI"]
beartkat::togglelight
after 1000 {beartkat::togglelight; after 1000 {beartkat::togglelight;after 1000 beartkat::togglelight}}
beartkat::docommand "KEY10"
beartkat::docommand "KEY02 1"
after 5000 {beartkat::docommand "KEY01"}

10
src/api.tcl Normal file
View File

@ -0,0 +1,10 @@
#api
namespace eval beartkat {
namespace export docommand
proc docommand {cmd} {
return [scommand $cmd]
}
proc togglelight {} {
return [scommand "KEY08"]
}
}

11
src/beartkat.conf Normal file
View File

@ -0,0 +1,11 @@
# this file is source(n)'d from configns.tcl. Put tcl here if you want,
# but it isn't recommended.
baud 19200
# This sets the interval. Default is 1 second.
# interval 1
# simple default checks, change this if you want
if {$unix} {
serial /dev/cuaa0
} elseif {$windows} {
serial COM1:
}

315
src/beartkat.tcl Executable file
View File

@ -0,0 +1,315 @@
#!/usr/local/bin/wish8.4
# under the DUPL
# (C)2004-2005, Dan Ponte
#YA!!!
#package require wcb
set lastcmd ""
set version 0.1
set tries 1
set gotresp no
set donthandle no
proc setalpha {chan tag fhh mde} {
if {[expr [string length $chan] != 3]} {
return
}
if {[string equal $mde "set"]} {
sendcommand [list TA C $chan $tag]
} elseif {[string equal $mde "clear"]} {
sendcommand "TA C $chan "
} elseif {[string equal $mde "get"]} {
set algt [scommand "TA C $chan"]
if {[regexp -- "TA C (\[0-9\]{3}) (.{0,16})\$" $algt a cn ttag]} {
if {[string equal [.alp.mfr.chan get] $cn]} {
.alp.mfr.ent delete 0 end
.alp.mfr.ent insert 1 $ttag
}
}
}
}
proc rejmod {w args} {
# wcb::cancel
return
}
proc table {w content args} {
frame $w -bg black
set r 0
foreach row $content {
set fields {}
set c 0
foreach col $row {
lappend fields [label $w.$r/$c -text $col]
incr c
}
eval grid $fields -sticky news -padx 1 -pady 1
incr r
}
set w
}
proc dispol {} {
global fhn
every "cancel" {sendcommand "LCD"}
.mfr.openprt configure -text "Start Polling"
.mfr.openprt configure -command {enabpol $fhn}
}
proc gbatt {} {
set blvl [scommand "BL"]
if {[regexp "BAT (\[0-9\]{3})" $blvl a lvl]} {
set flvl [expr {int($lvl * .392156862745098)}]
.disp.scr.batt configure -text "Batt: $flvl%"
}
}
proc checkscanner {} {
global waitingresp
global gotresp
if {$gotresp} {
return
}
set gotresp no
global fhn
set waitingresp yes
global tries
if {$tries == 1} {
sendcommand SI
after 1000 {incr tries; checkscanner}
} elseif {$tries < 9} {
sendcommand SI
after 1000 {incr tries; checkscanner}
} elseif {$tries == 9} {
set res [tk_messageBox -message "Never got a response from the radio.\nCheck that it is plugged in, your serial settings are correct, and that it is powered on." -type abortretryignore -icon error]
if {$res == "abort"} {
exit -1
} elseif {$res == "retry"} {
set waitingresp yes
set gotresp no
set tries 1
checkscanner
} elseif {$res == "ignore"} {
.statusbar.scmodel configure -text "Goto Help->About my radio"
return
}
}
}
proc filedialog {w types oper ent} {
set file [realdialog $w $types $oper]
if [string compare $file ""] {
$ent delete 0 end
$ent insert 0 $file
$ent xview end
}
return $file
}
proc realdialog {w types oper} {
if {$oper == "open"} {
set file [tk_getOpenFile -filetypes $types -parent $w]
} else {
set file [tk_getSaveFile -filetypes $types -parent $w \
-initialfile Untitled -defaultextension .txt]
}
return $file
}
proc enabpol fhh {
global fhn
.mfr.openprt configure -text "Stop Polling"
.mfr.openprt configure -command {dispol}
every $btkConfig::interv {sendcommand "LCD"}
}
proc every {interval script} {
global everyIds
if {$interval eq "cancel"} {
catch {after cancel $everyIds($script)}
return
}
set everyIds($script) [after $interval [info level 0]]
uplevel #0 $script
}
set alphop no
proc oalphwind {} {
global alphop
toplevel .alp
set alphop yes
.menubar.scan activate "Set Alpha Tags"
wm resizable .alp no no
wm title .alp "Alpha Tags"
frame .alp.mfr -borderwidth 2
pack .alp.mfr
label .alp.mfr.cl -text "Channel number:"
entry .alp.mfr.chan -width 4 -validate key -vcmd {expr {[regexp "^\[0-9\]{0,3}\$" %P] && [string length %P]<4}}
pack .alp.mfr.cl .alp.mfr.chan -side left
label .alp.mfr.tl -text "Alpha Text:"
entry .alp.mfr.ent -width 16 -validate key -vcmd {expr {[string length %P] < 17}}
pack .alp.mfr.tl .alp.mfr.ent -side left
button .alp.mfr.setal -text "Set Alpha" -command {setalpha [.alp.mfr.chan get] [.alp.mfr.ent get] $fhn set}
button .alp.mfr.clral -text "Clear Alpha" -command {setalpha [.alp.mfr.chan get] [.alp.mfr.ent get] $fhn clear}
button .alp.mfr.getal -text "Get Alpha" -command {setalpha [.alp.mfr.chan get] "" $fhn get}
pack .alp.mfr.setal .alp.mfr.clral .alp.mfr.getal -side left
button .alp.mfr.close -text "Okay" -command "destroy .alp; set alphop no"
pack .alp.mfr.close -fill y
wm protocol .alp WM_DELETE_WINDOW {set alphop no}
}
proc handlefile fhh {
global lastin
global donthandle
global lastcmd
set curin [gets $fhh]
if {[regexp -- "LCD(\[1-4\]) \\\[(.{16})\\\]\\\[(.{16})\\\]" $curin oth lnum te fmt]} {
if {[expr $lnum == 1]} {
.disp.scr.lcd1 configure -text $te
} elseif {[expr $lnum == 2]} {
.disp.scr.lcd2 configure -text $te
} elseif {[expr $lnum == 3]} {
.disp.scr.lcd3 configure -text $te
} elseif {[expr $lnum == 4]} {
.disp.scr.lcd4 configure -text $te
}
return;
} elseif {[regexp -- "ERR" $curin]} {
tk_messageBox -message "Received ERR message from radio. Last command $lastcmd" -type ok -icon error
} elseif {[regexp -- {SI (.*),(.*),([0-9][0-9][0-9])$} $curin a model esn rcmdv]} {
global waitingresp
global gotresp
if {$waitingresp && !$gotresp} {
set waitingresp no
set gotresp yes
.statusbar.scmodel configure -text "Model: $model"
} elseif {$donthandle} {
set lastin $curin
set donthandle no
} else {
set blfs [scommand "BL"]
regexp "BAT (\[0-9\]{3})" $blfs a batl
set blevel [expr {int( $batl * .392156862745098)}]
tk_messageBox -message "Scanner reported the following:\nModel: $model\nRemote Command Version: $rcmdv\nESN (not used): $esn\nBattery Level: $batl ($blevel%)" -type ok -icon info -title "About my radio"
}
} elseif {[string length $curin] > 1} {
set lastin $curin
}
}
source scommand.tcl
source api.tcl
source configns.tcl
source dumpmem.tcl
source loadfreqs.tcl
wm geometry . "=200x100"
set fhn [ open $btkConfig::ttydev "r+" ]
fconfigure $fhn -mode $btkConfig::baudrate,n,8,1 -blocking no
wm title . "BearTkat v$version"
frame .mfr -borderwidth 2 -width 102c -height 30c
grid .mfr -sticky wwwwwnnnnn -row 0 -column 0
#frame .menubar -relief raised -bd 2
#pack .menubar -in .mfr -fill x -expand yes
menu .menubar -tearoff no
#menubutton .menubar.file -text "File" -menu .menubar.file.menu
#pack .menubar.file -side left
#menubutton .menubar.scan -text "Scanner" -menu .menubar.scan.menu
#pack .menubar.scan -side left
#menubutton .menubar.help -text "Help" -menu .menubar.help.menu
#pack .menubar.help -side right
menu .menubar.file -tearoff no
.menubar add cascade -label "File" -menu .menubar.file -underline 0
.menubar.file add command -label "Exit" -command "exit"
.menubar.file add command -label "Run Tcl Script" -command {set tscr [realdialog . {{"Tcl Script" {.tcl}}} open]; if {[string compare $tscr ""]} {source $tscr}}
menu .menubar.scan -tearoff no
.menubar add cascade -label "Scanner" -menu .menubar.scan -underline 0
.menubar.scan add command -label "Set Alpha Tags" -command {if {!$alphop} {oalphwind}}
menu .menubar.help -tearoff no
.menubar add cascade -label "Help" -menu .menubar.help -underline 0
.menubar.help add command -label "Help" -command {tk_messageBox -message "No online help yet. Try README.txt, included in the distribution." -type ok -icon info}
.menubar.help add command -label "About my radio" -command {sendcommand "SI"}
.menubar.help add command -label "About BearTKat" -command {tk_messageBox -message "BearTKat v$version - a scanner control app for the BC250D and other radios\n(C)2004-2005, Dan Ponte. Licensed under the DUPL.\nA copy of the DUPL should have been included with this application. If not, write dcp1990@cox.net.\nPortions (specifically the control protocol) are copyright (C)2003,2004 Uniden America, Inc.\nThis product is not endorsed by or affiliated with Uniden.\nThe \"Bearcat\" logo and the Bearcat name are property of Uniden America and are trademarked." -type ok -icon info -title "About BearTKat"}
if {$windows} {
menu .menubar.system -tearoff no
.menubar add cascade -label "System" -menu .menubar.system -underline 0
.menubar.system add command -label "About my radio" -command {sendcommand SI}
}
button .mfr.openprt -text "Start Polling" -command {enabpol $fhn}
button .mfr.quit -text "Exit" -command "exit"
pack .mfr.openprt .mfr.quit -side left
frame .statusbar
grid .statusbar -sticky s -row 4
label .statusbar.scmodel -text "Model: Waiting..."
pack .statusbar.scmodel
toplevel .disp
wm title .disp "LCD"
wm resizable .disp no no
frame .disp.scr -borderwidth 2 -width 16c -height 4c -relief sunken -background orange
pack .disp.scr
label .disp.scr.lcd1 -width 16 -text " " -background orange -font "Courier 10"
label .disp.scr.lcd2 -width 16 -text " " -background orange -font "Courier 10"
label .disp.scr.lcd3 -width 16 -text " " -background orange -font "Courier 10"
label .disp.scr.lcd4 -width 16 -text " " -background orange -font "Courier 10"
pack .disp.scr.lcd1 .disp.scr.lcd2 .disp.scr.lcd3 .disp.scr.lcd4
#label .disp.scr.batt -width 10 -text "Batt: ---" -background orange -font "Courier 10"
#pack .disp.scr.batt -side left
frame .disp.but -borderwidth 2 -width 16c -height 7c
pack .disp.but
set crow 0
button .disp.but.scan -text "SCAN" -command {sendcommand "KEY01"}
button .disp.but.rsm -text "RSM" -command {sendcommand KEY00}
button .disp.but.manual -text "MAN" -command {sendcommand KEY07}
button .disp.but.lgt -text "Light" -command {sendcommand "KEY08"}
button .disp.but.wx -text "WX" -command {sendcommand "KEY10"; sendcommand "KEY02 1"}
button .disp.but.lockout -text "L/O" -command {sendcommand "KEY06"}
grid .disp.but.manual .disp.but.rsm -sticky we -ipadx .2c
grid .disp.but.scan .disp.but.wx -sticky we
grid .disp.but.lgt .disp.but.lockout -sticky we
frame .disp.butk -width 7c
pack .disp.butk -expand yes -fill x
foreach cn {1 2 3} {
button .disp.butk.kn$cn -text $cn -command [list sendcommand [list KEY02 $cn]]
grid .disp.butk.kn$cn -row $crow -column [expr "$cn - 1"] -sticky we -ipadx .25c
}
incr crow
foreach cn {4 5 6} {
button .disp.butk.kn$cn -text $cn -command [list sendcommand [list KEY02 $cn]]
grid .disp.butk.kn$cn -row $crow -column [expr "$cn - 4"] -sticky we
}
incr crow
foreach cn {7 8 9} {
button .disp.butk.kn$cn -text $cn -command [list sendcommand [list KEY02 $cn]]
grid .disp.butk.kn$cn -row $crow -column [expr "$cn - 7"] -sticky we
}
unset cn
button .disp.butk.dec -text "." -command {sendcommand "KEY03"}
button .disp.butk.kn0 -text "0" -command {sendcommand "KEY02 0"}
button .disp.butk.enter -text "E" -command {sendcommand KEY04}
grid .disp.butk.dec .disp.butk.kn0 .disp.butk.enter -sticky we
fileevent $fhn readable {handlefile $fhn}
set tx .freq.outp
toplevel .freq
wm title .freq "Frequencies"
text .freq.outp -wrap word -width 78 -height 20 -setgrid on -yscrollcommand ".freq.ys set"
scrollbar .freq.ys -command ".freq.outp yview"
$tx insert end "This is the output area. Click the 'Open' button below to open a file in the following format:\n\tchannel#:freq.uency,\"Alpha tag\",-d yes|no -l yes|no\\n\nwhere -d is the delay flag and -l is the lockout flag\n"
pack .freq.ys -side right -fill y
pack .freq.outp -fill both -expand 1
frame .freq.mfr -height 24c -width 80c
pack .freq.mfr -side left -fill x
entry .freq.mfr.ftop -width 20
button .freq.mfr.browse -text "Browse..." -command {filedialog . {{"Frequency Database" {.fdb .chan}}} save .freq.mfr.ftop}
button .freq.mfr.dfreqs -text "Dump frequencies" -command {.freq.mfr.dfreqs configure -state disabled; dumpall [.freq.mfr.ftop get] $tx; .freq.mfr.dfreqs configure -state normal}
pack .freq.mfr.ftop .freq.mfr.browse .freq.mfr.dfreqs -side left
toplevel .chanl
wm title .chanl "Channels"
frame .chanl.f -height 16c -width 80c
frame .chanl.b -height 4c -width 80c
pack .chanl.f .chanl.b -side top -fill y
scrollbar .chanl.f.scb -command ".chanl.f.clist yview"
listbox .chanl.f.clist -height 14 -setgrid 1 -width 64 -yscroll ".chanl.f.scb set"
entry .chanl.b.fet -width 20
button .chanl.b.load -text "Load FDB" -command {filedialog . {{"Frequency Database" {.fdb .chan}}} open .chanl.b.fet; loadtolist [.chanl.b.fet get] .chanl.f.clist }
button .chanl.b.tune -text "Tune Selected" -command {set csel [.chanl.f.clist curselection] ; if {[string length $csel] == 0} {tk_messageBox -message "Nothing selected!" -type ok -icon error} else { tunechan [.chanl.f.clist get $csel]} }
pack .chanl.f.scb -side right -fill y
pack .chanl.f.clist -side left -fill x
pack .chanl.b.fet .chanl.b.load .chanl.b.tune -side left -fill y
#wcb::callback $tx before insert rejmod
#wcb::callback $tx before delete rejmod
wm protocol . WM_DELETE_WINDOW {exit}
wm protocol .disp WM_DELETE_WINDOW {exit}
wm resizable . no no
wm protocol .chanl WM_DELETE_WINDOW {exit}
. configure -menu .menubar
if {$windows} {
wm iconbitmap . -default "beartkat.ico"
}
checkscanner

36
src/configns.tcl Normal file
View File

@ -0,0 +1,36 @@
#config namespace
if {$tcl_platform(platform) == "unix"} {
set unix yes
set windows no
} elseif {$tcl_platform(platform) == "windows"} {
set unix no
set windows yes
}
namespace eval btkConfig {
variable ttydev "/dev/cuaa0"
variable baudrate 19200
variable interv 1000
namespace export baud
namespace export serial
namespace export interval
proc baud {rate} {
if {[string is integer $rate]} {
set btkConfig::baudrate $rate
} else {
tk_messageBox -message "Error: baud parameter only accepts arguments in the form of an integer. Using default." -type ok -icon error -title "Configuration error"
}
}
proc serial {device} {
set btkConfig::ttydev $device
}
proc interval {seconds} {
if {[string is double $seconds]} {
set btkConfig::interv [expr [list int( $seconds * 1000 )]]
} else {
tk_messageBox -message "Error: interval parameter only accepts arguments in the form of a number. Using default." -type ok -icon error -title "Configuration error"
}
}
}
namespace import btkConfig::baud btkConfig::serial btkConfig::interval
source beartkat.conf
namespace forget btkConfig::*

100
src/dumpmem.tcl Normal file
View File

@ -0,0 +1,100 @@
#!/usr/local/bin/tclsh8.4
# dumps the specified bank
set cr 1
proc getbank {chan} {
if {[expr $chan <= 100 && $chan >= 1]} {
return "A"
} elseif {[expr $chan >= 101 && $chan <= 200]} {
return "B"
} elseif {[expr $chan >= 201 && $chan <= 300]} {
return "C"
} elseif {[expr $chan >= 301 && $chan <= 400]} {
return "D"
} elseif {[expr $chan >= 401 && $chan <= 500]} {
return "E"
} elseif {[expr $chan >= 501 && $chan <= 600]} {
return "F"
} elseif {[expr $chan >= 601 && $chan <= 700]} {
return "G"
} elseif {[expr $chan >= 701 && $chan <= 800]} {
return "H"
} elseif {[expr $chan >= 801 && $chan <= 900]} {
return "I"
} elseif {[expr ($chan >= 901 && $chan <= 1000) || $chan == 0]} {
return "J"
}
}
proc getbankschan {bank} {
return [string map {A 1 B 101 C 201 D 301 E 401 F 501 G 601 H 701 I 801 J 901} $bank]
}
proc getbankechan {bank} {
return [string map {A 100 B 200 C 300 D 400 E 500 F 600 G 700 H 800 I 900 J 1000} $bank]
}
proc simulcommand {command} {
#puts [join [list "Running command" $command]]
if {[regexp -- "^TA (\[CB\]) (\[A-J\]|\[0-9\]{3}) (.{0,16})$" $command a mde bchan tag]} {
return "OK"
} elseif {[regexp -- "^TA C (\[0-9\]{3})$" $command a chan]} {
return "TA C $chan Some Tag"
} elseif {[regexp -- "^PM(\[0-9\]{3})$" $command a chan]} {
#C089 F08511625 TN DN LF AF RF N000
return "C$chan F01555500 TN DN LN AF RF N000"
}
}
proc dumpbank {bank file fhn} {
set bstart [getbankschan $bank]
set bend [getbankechan $bank]
set ccdbh [open $file "a"]
for {set cx $bstart} {$cx <= $bend} {incr cx} {
if {[expr [string length $cx] < 3]} {
lappend x [join [list [string repeat "0" [expr 3- [string length $cx]]] $cx] ""]
} elseif {[expr $cx == 1000]} {
set x "000"
} else {
set x $cx
}
set result [scommand [join [list "PM" $x] ""]]
set tag [scommand [list "TA" "C" $x]]
if {[regexp -- "^TA C $x (.{1,16})" $tag a ttg]} {
set fta [join [list ",\"" $ttg "\""] ""]
} else {
set fta ",\"\""
}
if {[regexp -- "^C(\[0-9\]{3}) F(\[0-9\]{4})(\[0-9\]{4}) T(\[TFNY\]) D(\[TFNY\]) L(\[TFNY\]) A(\[TFNY\]) R(\[TFNY\]) N(\[0-9\]{3})" $result a chan wmhz dmhz trunked delay lockout atten recording ctcss]} {
set flags " "
if {[string equal "N" $delay]} {
lappend flags -d yes
}
if {[string equal "N" $lockout]} {
lappend flags -l yes
}
puts $ccdbh [join [list $chan ":" $wmhz "." $dmhz $fta "," $flags] ""]
}
unset -nocomplain chan wmhz fta result x tag ttg
}
close $ccdbh
}
proc dumpall {filename clabel} {
$clabel insert end "Dumping to $filename\n"
$clabel insert end "Dumping bank A...\n"
dumpbank "A" $filename 0
$clabel insert end "Dumping bank B...\n"
dumpbank "B" $filename 0
$clabel insert end "Dumping bank C...\n"
dumpbank "C" $filename 0
$clabel insert end "Dumping bank D...\n"
dumpbank "D" $filename 0
$clabel insert end "Dumping bank E...\n"
dumpbank "E" $filename 0
$clabel insert end "Dumping bank F...\n"
dumpbank "F" $filename 0
$clabel insert end "Dumping bank G...\n"
dumpbank "G" $filename 0
$clabel insert end "Dumping bank H...\n"
dumpbank "H" $filename 0
$clabel insert end "Dumping bank I...\n"
dumpbank "I" $filename 0
$clabel insert end "Dumping bank J...\n"
dumpbank "J" $filename 0
$clabel insert end "Dumping Finished!"
}

65
src/loadfreqs.tcl Normal file
View File

@ -0,0 +1,65 @@
#!/usr/local/bin/tclsh8.4
proc loadfreqs {file range} {
set freqdbh [ open $file "r" ]
while {[gets $freqdbh cline] >= 0} {
if {[regexp -- "^(\[0-9\]{1,3}):(\[0-9\]{2,4})\\.(\[0-9\]{3,4}),\"(.{0,16})\",(.*)$" $cline a chan wmhz dmhz alpha flags]} {
if {[expr [string length $wmhz] != 4]} {
lappend mhz [join [list [string repeat "0" [expr 4- [string length $wmhz]]] $wmhz] ""]
} else {
lappend mhz $wmhz
}
if {[expr [string length $dmhz] != 4]} {
lappend mhz [join [list $dmhz [string repeat "0" [expr 4- [string length $dmhz]]]] ""]
} else {
lappend mhz $dmhz
}
set fmhz [join $mhz ""]
if {[expr [string length $chan] != 3]} {
lappend rchan [join [list [string repeat "0" [expr 3- [string length $chan]]] $chan] ""]
} else {
lappend rchan $chan
}
set fcmd [join [list PM $rchan] ""]
set fcmdl [join [list $fcmd $fmhz]]
puts $fcmdl
if {[expr [string length $alpha] > 0]} {
sendcommand "TA C $rchan $alpha"
}
foreach {key value} $flags {
if {[string equal $key "-d"] && [string is boolean $value] && $value} {
sendcommand "MA$rchan"
sendcommand "DLN"
} elseif {[string equal $key "-l"] && [string is boolean $value] && $value} {
sendcommand "MA$rchan"
sendcommand "LON"
}
}
unset -nocomplain mhz fcmd fcmdl rchan a chan wmhz dmhz wal alpha key value flags
} elseif {[regexp -- "^B(\[0-9\]|\[A-J\]):\"(.{0,16})\"$" $cline a bank btg]} {
if {[string is digit $bank]} {
set fbnk [string map {0 J 1 A 2 B 3 C 4 D 5 E 6 F 7 G 8 H 9 I} $bank]
} else {
set fbnk $bank
}
sendcommand "TA B $fbnk $btg"
unset -nocomplain a bank btg fbnk
}
}
close $freqdbh
}
proc loadtolist {file lb} {
if {[string length $file] == 0} {return}
set freqdbh [ open $file "r" ]
while {[gets $freqdbh cline] >= 0} {
if {[regexp -- "^(\[0-9\]{1,3}):(\[0-9\]{2,4})\\.(\[0-9\]{3,4}),\"(.{0,16})\",(.*)$" $cline a chan wmhz dmhz alpha flags]} {
if {$wmhz == 0} { continue }
$lb insert end [list [join [list $chan :] ""] [join [list $wmhz "." $dmhz] ""] $alpha]
}
}
close $freqdbh
}
proc tunechan {chanline} {
if {[regexp -- "^(\[0-9\]{1,3}):" $chanline a chan]} {
scommand [join [list "MA" $chan] ""]
}
}

18
src/scommand.tcl Normal file
View File

@ -0,0 +1,18 @@
# sourced from main
proc scommand {command} {
global fhn
global lastin
global lastcmd
puts $fhn $command
flush $fhn
set lastcmd $command
vwait lastin
return $lastin
}
proc sendcommand {cmd} {
global lastcmd
global fhn
puts $fhn $cmd
flush $fhn
set lastcmd $cmd
}

BIN
win32/beartkat.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
win32/beartkat_splash.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

BIN
win32/btkinstall.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

214
win32/installer.nsi Normal file
View File

@ -0,0 +1,214 @@
; Script generated by the HM NIS Edit Script Wizard.
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "BearTKat"
!define PRODUCT_VERSION "0.1"
!define PRODUCT_PUBLISHER "KiwiSoft"
!define PRODUCT_WEB_SITE "http://skynard.flinkpoyd.homeunix.com:88/beartkat.html"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\makensis.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
SetCompressor bzip2
; MUI 1.67 compatible ------
!include "MUI.nsh"
!include Sections.nsh
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
; Welcome page
!define MUI_WELCOMEPAGE_TEXT "Welcome to the BearTKat installer!\r\n\r\nPlease note that BearTKat needs both Tcl/Tk8.4 (tested with ActiveTcl) and Wcb3.0, both available online.\r\n\r\nAlso, please read all supplied documentation prior to use.\r\n\r\n\r\nClick Next to begin the install."
!insertmacro MUI_PAGE_WELCOME
; License page
!define MUI_LICENSEPAGE_CHECKBOX
!define MUI_LICENSEPAGE_TEXT_TOP "It is imperative that you read the license, especially if you are a commercial entity."
!insertmacro MUI_PAGE_LICENSE "dupl.rtf"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_COMPONENTS
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\README.txt"
!define MUI_FINISHPAGE_NOAUTOCLOSE
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "English"
; Reserve files
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; MUI end ------
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
XPStyle on
OutFile "BearTKatSetup.exe"
CRCCheck on
Icon btkinstall.ico
UninstallIcon btkinstall.ico
InstallDir "$PROGRAMFILES\BearTKat"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show
Function .onInit
SetOutPath $TEMP
InitPluginsDir
File /oname=splash.bmp beartkat_splash.bmp
advsplash::show 1000 600 400 -1 $TEMP\splash
Pop $0
Delete $TEMP\splash.bmp
functionend
Section "Main (required)" SEC01
SectionIn RO
SetDetailsPrint textonly
DetailPrint "Main Files"
SetDetailsPrint listonly
IfFileExists "C:\Tcl\bin\wish84.exe" sokt
MessageBox MB_OKCANCEL "Apparently Tcl/Tk 8.4 isn't installed. You can get it from http://www.tcl.tk/" IDOK sok
quit
sok:
ExecShell open "http://www.tcl.tk/"
sokt:
IfFileExists "C:\Tcl\lib\wcb3.0\wcb.tcl" tokt
MessageBox MB_okcancel "Apparently, Wcb3.0 isn't installed. Search http://wiki.tcl.tk/ for Wcb to find and install it." idok tok
quit
tok:
ExecShell open "http://wiki.tcl.tk/"
tokt:
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
; File "${NSISDIR}\makensis.exe"
CreateDirectory "$SMPROGRAMS\BearTKat"
CreateShortCut "$SMPROGRAMS\BearTKat\BearTKat.lnk" "$INSTDIR\main.tcl" parameters "$INSTDIR\beartkat.ico"
CreateShortCut "$DESKTOP\BearTKat.lnk" "$INSTDIR\main.tcl" parameters "$INSTDIR\beartkat.ico"
File "dupl.rtf"
File "beartkat.ico"
File "beartkat.tcl"
File "scommand.tcl"
File "dumpmem.tcl"
File "loadfreqs.tcl"
File "api.tcl"
File "configns.tcl"
File "dump.chan"
File "beartkat.conf"
File "README.txt"
File "beartkat_splash.bmp"
; Wrapper script (cd's to the install directory and sources beartkat.tcl, which does all the work)
DetailPrint "Writing main.tcl wrapper script..."
FileOpen $3 $INSTDIR\main.tcl w
FileWrite $3 "# Generated by the BearTKAT installer (NSIS) on ${__TIMESTAMP__}$\n"
FileWrite $3 'set appinstpath {$INSTDIR}$\n'
FileWrite $3 'cd $$appinstpath$\n'
FileWrite $3 'source beartkat.tcl'
FileClose $3
SectionEnd
Section "Example Scripts" SEC02
SetOutPath "$INSTDIR\scripts"
SetOverwrite ifnewer
File "scripts\example.tcl"
SectionEnd
Section -AdditionalIcons
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateShortCut "$SMPROGRAMS\BearTKat\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\BearTKat\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd
Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\makensis.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\beartkat.ico"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd
Function ConnectInternet
Push $R0
ClearErrors
Dialer::AttemptConnect
IfErrors noie3
Pop $R0
StrCmp $R0 "online" connected
MessageBox MB_OK|MB_ICONSTOP "Cannot connect to the internet."
Quit ;Remove to make error not fatal
noie3:
; IE3 not installed
MessageBox MB_OK|MB_ICONINFORMATION "Please connect to the internet now."
connected:
Pop $R0
FunctionEnd
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd
Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd
Section Uninstall
Delete "$INSTDIR\${PRODUCT_NAME}.url"
Delete "$INSTDIR\uninst.exe"
Delete "$INSTDIR\scommand.tcl"
Delete "$INSTDIR\main.tcl"
delete "$INSTDIR\beartkat.tcl"
Delete "$INSTDIR\dupl.rtf"
Delete "$INSTDIR\loadfreqs.tcl"
Delete "$INSTDIR\dumpmem.tcl"
Delete "$INSTDIR\api.tcl"
Delete "$INSTDIR\configns.tcl"
Delete "$INSTDIR\dump.chan"
Delete "$INSTDIR\beartkat.ico"
Delete "$INSTDIR\README.txt"
Delete "$INSTDIR\beartkat.conf"
Delete "$INSTDIR\License.txt"
; Delete "$INSTDIR\makensis.exe"
Delete "$INSTDIR\beartkat_splash.bmp"
Delete "$INSTDIR\scripts\example.tcl"
Delete "$SMPROGRAMS\BearTKat\Uninstall.lnk"
Delete "$SMPROGRAMS\BearTKat\Website.lnk"
Delete "$DESKTOP\BearTKat.lnk"
Delete "$SMPROGRAMS\BearTKat\BearTKat.lnk"
RMDir /r "$SMPROGRAMS\BearTKat"
RMDir "$INSTDIR\scripts"
RMDir "$INSTDIR"
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
SetAutoClose true
SectionEnd
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SEC01} "Core install files"
!insertmacro MUI_DESCRIPTION_TEXT ${SEC02} "Example scripts"
!insertmacro MUI_FUNCTION_DESCRIPTION_END