#!/bin/sh # # GBPPR Special Collection Service # # Extract new Radio and Talkgroup IDs from Control Channel data dumps made # via a Radio Shack PRO-651/PRO-652 (or GRE equiv.) scanner. # # It's a total hack, but seems to work... # # Create the logs under Linux using 'minicom' and a Radio Shack USB scanner # programming cable (Cat. No. 20-546). # # Usage: ./extractIDs.sh 'filename' # # Where 'filename' is the capture file of the Control Channel data made # using minicom. # # To enable text capture under minicom, use 'CTRL-A' then 'L'. # Enter the name of the file you want to save the data in. # Use 'CTRL-A' then 'L' again to stop or pause the capture of data. # #------------------------------------------------------------------------------ # Text database file containing known Radio IDs and Talkgroup IDs. # DATA=/var/www/html/gerp/GBPD_Radio_IDs.html CAP_FILE="${1}" if [ -f "$CAP_FILE" ]; then clear # Extract Radio IDs from the CC dump log file # grep RId $CAP_FILE | awk -F: {'print $4'} | awk -F- {'print $3'} | \ grep -v FFFFFFFF | sed -e 's/VC//g' | sort | uniq > /tmp/IDhex # Convert hex Radio IDs to decimal Radio IDs using Perl # perl -e "open ID,'/tmp/IDhex'; while () {print hex,\"\n\";}" > /tmp/IDdec # Remove Main Transmitter IDs which begin with '100' # grep -v ^100 /tmp/IDdec > /tmp/RadioIDs # Remove duplicates # /bin/cat /tmp/RadioIDs | sort | uniq > /tmp/RadioIDs.txt echo "\033[01;32mSearching for New Radio IDs\033[00m" echo "" echo "\033[01;31mUsing Data File:\033[00m $DATA" echo "" for i in `/bin/cat /tmp/RadioIDs.txt` do echo "Checking Radio ID: $i" grep -q $i $DATA echo "$? $i" >> /tmp/$$out done echo "" echo "\033[01;34mNew Radio ID(s):\033[00m" echo "" # Log & display new Radio IDs # grep -v ^0 /tmp/$$out | sed -e 's/1 //g' > New_RadioIDs.txt /bin/cat New_RadioIDs.txt echo "" echo "\033[01;32mSearching for New Talkgroups\033[00m" grep TGID- $CAP_FILE | awk -F: '{print $4}' | awk -F- '{print $2}' | \ sed -e 's/ RId//g' | sort | uniq > /tmp/tlkgrp for i in `/bin/cat /tmp/tlkgrp` do grep -q "\"$i\"" $DATA echo "$? $i" >> /tmp/tlkgrp2 done echo "" echo "\033[01;34mNew Talkgroup(s):\033[00m" echo "" # Log & display new talkgroups # grep -v ^0 /tmp/tlkgrp2 | sed -e 's/1 //g' > New_Talkgroups.txt /bin/cat New_Talkgroups.txt echo "" echo "\033[01;31mSaving New Talkgroups In:\033[00m New_Talkgroups.txt" echo "\033[01;31m Saving New Radio IDs In:\033[00m New_RadioIDs.txt" echo "" # Optional - Display main TX IDs, they start with '0027' hex # echo "\033[01;34mMain TX Radio IDs & Talkgroup:\033[00m" echo "" grep RId-0027 $CAP_FILE | awk -F: '{print $4}' | awk -F- '{print $2, $3}' | \ sed -e 's/RId//g' | sed -e 's/ VC//g' | sort | uniq > /tmp/tkgrp perl -e "open D,'/tmp/tkgrp';while(){(\$a,\$b)=split;print hex \$b,\"\t\",\$a,\"\n\";}"|sort|uniq rm /tmp/tkgrp # Clean up temp files # /bin/rm /tmp/tlkgrp /bin/rm /tmp/tlkgrp2 /bin/rm /tmp/IDhex /bin/rm /tmp/IDdec /bin/rm /tmp/RadioIDs /bin/rm /tmp/$$out /bin/rm /tmp/RadioIDs.txt else echo "File '$CAP_FILE' not found." exit fi