Skip to content

Commit

Permalink
version used on kcmscanner.ddns.net
Browse files Browse the repository at this point in the history
  • Loading branch information
rosecitytransit committed Dec 12, 2017
1 parent bd93f8e commit b703e3b
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 64 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ sys_*/
junk/
tester/
fake/
2015/
2016/
logs/
2???/
wmata/
CMakeFiles/
build/
Expand Down
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ endif()
#find_package(LibRTLSDR)
#find_package(LibMiriSDR)
#find_package(LibbladeRF)
find_package(GnuradioUHD)
##find_package(GnuradioUHD)
find_package(GrOsmoSDR)
find_package(LibHackRF)
find_package(UHD)
##find_package(LibHackRF)
##find_package(UHD)
find_package(OpenSSL REQUIRED)

if(NOT GNURADIO_RUNTIME_FOUND)
Expand Down Expand Up @@ -169,8 +169,8 @@ link_directories(
${Boost_LIBRARY_DIRS}
${GNURADIO_RUNTIME_LIBRARY_DIRS}
${GROSMOSDR_LIBRARIES_DIRS}
${GNURADIO_UHD_LIBRARIES_DIRS}
${UHD_LIBRARIES_DIRS}
## ${GNURADIO_UHD_LIBRARIES_DIRS}
## ${UHD_LIBRARIES_DIRS}
${OPENSSL_ROOT_DIR}/lib
)

Expand Down Expand Up @@ -220,4 +220,4 @@ list(APPEND trunk_recorder_sources

add_executable(recorder ${trunk_recorder_sources})

target_link_libraries(recorder ssl crypto ${GNURADIO_PMT_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_FILTER_LIBRARIES} ${GNURADIO_DIGITAL_LIBRARIES} ${GNURADIO_ANALOG_LIBRARIES} ${GNURADIO_AUDIO_LIBRARIES} ${GNURADIO_UHD_LIBRARIES} ${UHD_LIBRARIES} ${GNURADIO_BLOCKS_LIBRARIES} ${GROSMOSDR_LIBRARIES} ${Boost_LIBRARIES} ${LIBOP25_REPEATER_LIBRARIES} gnuradio-op25_repeater imbe_vocoder)
target_link_libraries(recorder ssl crypto ${GNURADIO_PMT_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_FILTER_LIBRARIES} ${GNURADIO_DIGITAL_LIBRARIES} ${GNURADIO_ANALOG_LIBRARIES} ${GNURADIO_AUDIO_LIBRARIES} ${GNURADIO_BLOCKS_LIBRARIES} ${GROSMOSDR_LIBRARIES} ${Boost_LIBRARIES} ${LIBOP25_REPEATER_LIBRARIES} gnuradio-op25_repeater imbe_vocoder)
6 changes: 6 additions & 0 deletions encode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /bin/bash
filesize=$(stat -c %s "$1")
if [[ $filesize -gt "10240" ]]; then
eval "nice -n 19 lame --silent --preset voice $1"
rm $1
fi
39 changes: 17 additions & 22 deletions trunk-recorder/call.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ void Call::create_filename() {

std::stringstream path_stream;

path_stream << this->config.capture_dir << "/" << sys->get_short_name() << "/" << 1900 + ltm->tm_year << "/" << 1 + ltm->tm_mon << "/" << ltm->tm_mday;
path_stream << this->config.capture_dir << "/" << 1900 + ltm->tm_year << "/" << 1 + ltm->tm_mon << "/" << ltm->tm_mday;

boost::filesystem::create_directories(path_stream.str());
int nchars;
nchars = snprintf(filename, 255, "%s/%ld-%ld_%g.wav", path_stream.str().c_str(), talkgroup, start_time, curr_freq);
nchars = snprintf(filename, 255, "%s/%02d%02d%02d-%ld.wav", path_stream.str().c_str(), ltm->tm_hour, ltm->tm_min, ltm->tm_sec, talkgroup);

if (nchars >= 255) {
BOOST_LOG_TRIVIAL(error) << "Call: Path longer than 160 charecters";
}
nchars = snprintf(status_filename, 255, "%s/%ld-%ld_%g.json", path_stream.str().c_str(), talkgroup, start_time, curr_freq);
nchars = snprintf(status_filename, 255, "%s/calllog.txt", path_stream.str().c_str());

if (nchars >= 255) {
BOOST_LOG_TRIVIAL(error) << "Call: Path longer than 160 charecters";
Expand All @@ -26,6 +26,8 @@ void Call::create_filename() {
BOOST_LOG_TRIVIAL(error) << "Call: Path longer than 255 charecters";
}

sprintf(filetime, "%02d%02d%02d", ltm->tm_hour, ltm->tm_min, ltm->tm_sec);

// sprintf(filename, "%s/%ld-%ld.wav",
// path_stream.str().c_str(),talkgroup,start_time);
// sprintf(status_filename, "%s/%ld-%ld.json",
Expand Down Expand Up @@ -129,37 +131,26 @@ void Call::end_call() {
}

if (sys->get_call_log()) {
std::ofstream myfile(status_filename);
std::ofstream myfile(status_filename, std::ofstream::app);


if (myfile.is_open())
{
myfile << "{\n";
myfile << "\"freq\": " << this->curr_freq << ",\n";
myfile << "\"start_time\": " << this->start_time << ",\n";
myfile << "\"stop_time\": " << this->stop_time << ",\n";
myfile << "\"emergency\": " << this->emergency << ",\n";
myfile << "\n";
myfile << this->get_filetime() << "," << (this->stop_time - this->start_time) << "," << this->talkgroup << "," << this->emergency << ";";
//myfile << "\"source\": \"" << this->get_recorder()->get_source()->get_device() << "\",\n";
myfile << "\"talkgroup\": " << this->talkgroup << ",\n";
myfile << "\"srcList\": [ ";

for (int i = 0; i < src_count; i++) {
if (i != 0) {
myfile << ", ";
myfile << src_list[i].source;
if (i < (src_count-1)) {
myfile << ",";
}
myfile << "{\"src\": " << std::fixed << src_list[i].source << ", \"time\": " << src_list[i].time << ", \"pos\": " << src_list[i].position << "}";
}
myfile << " ],\n";
myfile << "\"freqList\": [ ";
//myfile << ";";

for (int i = 0; i < freq_count; i++) {
if (i != 0) {
myfile << ", ";
}
myfile << "{ \"freq\": " << std::fixed << freq_list[i].freq << ", \"time\": " << freq_list[i].time << ", \"pos\": " << freq_list[i].position << ", \"len\": " << freq_list[i].total_len << ", \"error_count\": " << freq_list[i].error_count << ", \"spike_count\": " << freq_list[i].spike_count << "}";
myfile << ";" << (freq_list[i].freq/1000000) << "," << freq_list[i].total_len << "," << freq_list[i].error_count << "," << freq_list[i].spike_count;
}
myfile << " ]\n";
myfile << "}\n";
myfile.close();
}
}
Expand Down Expand Up @@ -413,3 +404,7 @@ char * Call::get_converted_filename() {
char * Call::get_filename() {
return filename;
}

char * Call::get_filetime() {
return filetime;
}
2 changes: 2 additions & 0 deletions trunk-recorder/call.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Call {

char *get_converted_filename();
char *get_filename();
char *get_filetime();
int get_sys_num();
std::string get_short_name();
void create_filename();
Expand Down Expand Up @@ -114,6 +115,7 @@ class Call {
bool emergency;
bool conventional;
char filename[255];
char filetime[7];
char converted_filename[255];
char status_filename[255];
bool phase2_tdma;
Expand Down
8 changes: 4 additions & 4 deletions trunk-recorder/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

#include <osmosdr/source.h>

#include <gnuradio/uhd/usrp_source.h>
////#include <gnuradio/uhd/usrp_source.h>
#include <gnuradio/msg_queue.h>
#include <gnuradio/message.h>
#include <gnuradio/blocks/file_sink.h>
Expand Down Expand Up @@ -795,9 +795,9 @@ void check_message_count(float timeDiff) {
}
}

if (msgs_decoded_per_second < 10) {
// if (msgs_decoded_per_second < 10) {
BOOST_LOG_TRIVIAL(error) << "[" << sys->get_short_name() << "]\t Control Channel Message Decode Rate: " << msgs_decoded_per_second << "/sec, count: " << sys->message_count;
}
// }
sys->message_count = 0;
}
}
Expand Down Expand Up @@ -863,7 +863,7 @@ void monitor_messages() {
}
float timeDiff = currentTime - lastMsgCountTime;

if (timeDiff >= 3.0) {
if (timeDiff >= 60.0) {
check_message_count(timeDiff);
lastMsgCountTime = currentTime;
}
Expand Down
25 changes: 0 additions & 25 deletions trunk-recorder/source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ int Source::rec_num = 0;
void Source::set_antenna(std::string ant)
{
antenna = ant;

if (driver == "usrp") {
BOOST_LOG_TRIVIAL(info) << "Setting antenna to [" << antenna << "]";
cast_to_usrp_sptr(source_block)->set_antenna(antenna, 0);
}
}

std::string Source::get_antenna() {
Expand Down Expand Up @@ -142,10 +137,6 @@ void Source::set_gain(int r)
BOOST_LOG_TRIVIAL(info) << "Gain set to: " << cast_to_osmo_sptr(source_block)->get_gain();
}

if (driver == "usrp") {
gain = r;
cast_to_usrp_sptr(source_block)->set_gain(gain);
}
}

int Source::get_gain() {
Expand Down Expand Up @@ -414,20 +405,4 @@ Source::Source(double c, double r, double e, std::string drv, std::string dev, C
source_block = osmo_src;
}

if (driver == "usrp") {
gr::uhd::usrp_source::sptr usrp_src;
usrp_src = gr::uhd::usrp_source::make(device, uhd::stream_args_t("fc32"));

BOOST_LOG_TRIVIAL(info) << "SOURCE TYPE USRP (UHD)";

BOOST_LOG_TRIVIAL(info) << "Setting sample rate to: " << rate;
usrp_src->set_samp_rate(rate);
actual_rate = usrp_src->get_samp_rate();
BOOST_LOG_TRIVIAL(info) << "Actual sample rate: " << actual_rate;
BOOST_LOG_TRIVIAL(info) << "Tunning to " << center + error << "hz";
usrp_src->set_center_freq(center + error, 0);


source_block = usrp_src;
}
}
6 changes: 1 addition & 5 deletions trunk-recorder/source.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <gnuradio/basic_block.h>
#include <gnuradio/top_block.h>
#include <osmosdr/source.h>
#include <gnuradio/uhd/usrp_source.h>
////#include <gnuradio/uhd/usrp_source.h>
#include "config.h"
//#include "recorders/recorder.h"
#include "recorders/analog_recorder.h"
Expand Down Expand Up @@ -99,9 +99,5 @@ class Source
return boost::dynamic_pointer_cast<osmosdr::source, gr::basic_block>(p);
}

inline gr::uhd::usrp_source::sptr cast_to_usrp_sptr(gr::basic_block_sptr p)
{
return boost::dynamic_pointer_cast<gr::uhd::usrp_source, gr::basic_block>(p);
}
};
#endif

0 comments on commit b703e3b

Please sign in to comment.