Skip to content

Commit db06853

Browse files
committed
swapped in op25
1 parent 0a4b9e0 commit db06853

5 files changed

+80
-31
lines changed

Diff for: logging_receiver_dsd.cc

+14-12
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,26 @@ log_dsd::log_dsd(float f, float c, long t, int n)
5656

5757

5858

59-
60-
59+
60+
lpf_taps = gr_firdes::low_pass(1, samp_rate, xlate_bandwidth/2, 6000);
6161
prefilter = gr_make_freq_xlating_fir_filter_ccf(decim,
62-
gr_firdes::low_pass(1, samp_rate, xlate_bandwidth/2, 6000),
62+
lpf_taps,
6363
offset,
6464
samp_rate);
6565
unsigned int d = GCD(channel_rate, pre_channel_rate);
6666
channel_rate = floor(channel_rate / d);
6767
pre_channel_rate = floor(pre_channel_rate / d);
68+
resampler_taps = design_filter(channel_rate, pre_channel_rate);
6869

69-
downsample_sig = gr_make_rational_resampler_base_ccf(channel_rate, pre_channel_rate, design_filter(channel_rate, pre_channel_rate));
70+
downsample_sig = gr_make_rational_resampler_base_ccf(channel_rate, pre_channel_rate, resampler_taps);
7071

7172
demod = gr_make_quadrature_demod_cf(1.6);
7273

73-
const float a[] = { 0.1, 0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1};
74-
75-
std::vector<float> data( a,a + sizeof( a ) / sizeof( a[0] ) );
76-
sym_filter = gr_make_fir_filter_fff(1, data);
74+
75+
for (int i=0; i < 10; i++) {
76+
sym_taps.push_back(0.1);
77+
}
78+
sym_filter = gr_make_fir_filter_fff(1, sym_taps);
7779
if (!logging) {
7880
iam_logging = true;
7981
logging = true;
@@ -148,14 +150,14 @@ void log_dsd::close() {
148150

149151
std::cout<< "logging_receiver_dsd.cc: close()" <<std::endl;
150152
wav_sink->close();
151-
/*
153+
152154
disconnect(self(), 0, prefilter, 0);
153155
disconnect(prefilter, 0, downsample_sig, 0);
154156
disconnect(downsample_sig, 0, demod, 0);
155157
disconnect(demod, 0, sym_filter, 0);
156158
disconnect(sym_filter, 0, dsd, 0);
157159
disconnect(dsd, 0, wav_sink,0);
158-
*/
160+
159161
//std::cout<< "logging_receiver_dsd.cc: finished close()" <<std::endl;
160162
}
161163

@@ -178,14 +180,14 @@ void log_dsd::deactivate() {
178180

179181

180182

181-
/* disconnect(self(), 0, prefilter, 0);
183+
disconnect(self(), 0, prefilter, 0);
182184
disconnect(prefilter, 0, downsample_sig, 0);
183185
disconnect(downsample_sig, 0, demod, 0);
184186
disconnect(demod, 0, sym_filter, 0);
185187
disconnect(sym_filter, 0, dsd, 0);
186188
disconnect(dsd, 0, wav_sink,0);
187189

188-
*/
190+
189191

190192
/*
191193
wav_sink.reset();

Diff for: logging_receiver_dsd.h

+3
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ class log_dsd : public gr_hier_block2
7777
int num;
7878

7979
bool iam_logging;
80+
std::vector<float> lpf_taps;
81+
std::vector<float> resampler_taps;
82+
std::vector<float> sym_taps;
8083

8184
/* GR blocks */
8285
gr_fir_filter_ccf_sptr lpf;

Diff for: logging_receiver_p25.cc

+24-7
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@ log_p25::log_p25(float f, float c, long t)
4444
center = c;
4545
talkgroup = t;
4646
float offset = center - (f*1000000);
47-
char filename[160];
48-
//int samp_per_sym = 10;
49-
int samp_per_sym = 6;
50-
double samp_rate = 4000000;
51-
int decim = 80;
47+
48+
int samp_per_sym = 10; //6
49+
double samp_rate = 5000000;
50+
int decim = 160; //20
5251
float xlate_bandwidth = 14000; //24260.0;
5352
float channel_rate = 4800 * samp_per_sym;
5453
double pre_channel_rate = double(samp_rate/decim);
@@ -59,7 +58,7 @@ log_p25::log_p25(float f, float c, long t)
5958
const double pi = M_PI; //boost::math::constants::pi<double>();
6059

6160
timestamp = time(NULL);
62-
61+
starttime = time(NULL);
6362

6463

6564

@@ -114,7 +113,21 @@ null_sink = gr_make_null_sink(sizeof(float));
114113
copier = gr_make_kludge_copy(sizeof(gr_complex));
115114
head_source = gr_make_head(sizeof(gr_complex),0);
116115
sprintf(filename, "%ld-%ld.wav", talkgroup,timestamp);
117-
wav_sink = gr_make_wavfile_sink(filename,1,8000,16);
116+
117+
118+
tm *ltm = localtime(&starttime);
119+
120+
std::stringstream path_stream;
121+
path_stream << boost::filesystem::current_path().string() << "/" << 1900 + ltm->tm_year << "/" << 1 + ltm->tm_mon << "/" << ltm->tm_mday;
122+
123+
boost::filesystem::create_directories(path_stream.str());
124+
//sprintf(filename, "%s/%ld-%ld.wav", path_stream.str().c_str(),talkgroup,timestamp);
125+
126+
sprintf(filename, "%ld-%ld.wav",talkgroup,timestamp);
127+
128+
wav_sink = gr_make_wavfile_sink(filename,1,8000,16);
129+
130+
118131
//gr_file_sink_sptr fs = gr_make_file_sink(sizeof(float),"sym_filter.dat");
119132

120133

@@ -192,6 +205,10 @@ long log_p25::timeout() {
192205
return time(NULL) - timestamp;
193206
}
194207

208+
char *log_p25::get_filename() {
209+
return filename;
210+
}
211+
195212
void log_p25::close() {
196213
mute();
197214
wav_sink->close();

Diff for: logging_receiver_p25.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313

1414
#include <boost/shared_ptr.hpp>
15+
#include <boost/filesystem/operations.hpp>
16+
#include <boost/filesystem/path.hpp>
17+
1518
#include <gr_io_signature.h>
1619
#include <gr_hier_block2.h>
1720
#include <gr_firdes.h>
@@ -66,14 +69,17 @@ class log_p25 : public gr_hier_block2
6669
void close();
6770
void mute();
6871
void unmute();
72+
char *get_filename();
6973
//void forecast(int noutput_items, gr_vector_int &ninput_items_required);
7074

7175
private:
7276
float center, freq;
7377
bool muted;
7478
long talkgroup;
7579
time_t timestamp;
76-
80+
time_t starttime;
81+
82+
char filename[160];
7783

7884
/* GR blocks */
7985
gr_fir_filter_ccf_sptr lpf;

Diff for: smartnet.cc

+32-11
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@
4242
#include <string>
4343
#include <stdio.h>
4444
#include <stdlib.h>
45-
46-
#include "logging_receiver_dsd.h"
45+
#include <signal.h>
46+
//#include "logging_receiver_dsd.h"
47+
#include "logging_receiver_p25.h"
4748
#include "smartnet_crc.h"
4849
#include "smartnet_deinterleave.h"
4950

@@ -102,8 +103,13 @@ osmosdr_source_c_sptr src;
102103
/* static loggers
103104
vector<log_dsd_sptr> loggers;*/
104105

105-
vector<log_dsd_sptr> active_loggers;
106+
//vector<log_dsd_sptr> active_loggers;
107+
vector<log_p25_sptr> active_loggers;
106108

109+
volatile sig_atomic_t exit_flag = 0;
110+
void exit_interupt(int sig){ // can be called asynchronously
111+
exit_flag = 1; // set flag
112+
}
107113

108114
void init_loggers(int num, float center_freq) {
109115

@@ -171,9 +177,11 @@ float parse_message(string s) {
171177
}
172178

173179
if (retfreq) {
174-
for(vector<log_dsd_sptr>::iterator it = active_loggers.begin(); it != active_loggers.end(); ++it) {
180+
// for(vector<log_dsd_sptr>::iterator it = active_loggers.begin(); it != active_loggers.end(); ++it) {
181+
for(vector<log_p25_sptr>::iterator it = active_loggers.begin(); it != active_loggers.end(); ++it) {
175182

176-
log_dsd_sptr rx = *it;
183+
//log_dsd_sptr rx = *it;
184+
log_p25_sptr rx = *it;
177185

178186

179187
if (rx->get_talkgroup() == address) {
@@ -208,7 +216,9 @@ float parse_message(string s) {
208216
//tb->wait();
209217

210218
// Dynamic Logger
211-
log_dsd_sptr log = make_log_dsd( retfreq, center_freq, address, thread_num++);
219+
//log_dsd_sptr log = make_log_dsd( retfreq, center_freq, address, thread_num++);
220+
log_p25_sptr log = make_log_p25( retfreq, center_freq, address);
221+
212222
active_loggers.push_back(log);
213223

214224
tb->connect(src, 0, log, 0);
@@ -223,12 +233,15 @@ float parse_message(string s) {
223233
//cout << "smartnet.cc: Activated logger & unlocked" << endl;
224234
}
225235

226-
//cout << "TG: " << address << "\tFreq: " << retfreq << "\tActive Loggers: " << active_loggers.size() << "\tCmd: "<< command << "\t LastCmd: " <<lastcmd << "\t Flag: "<< groupflag << "\t Timeout: " << timeout << "\t Elapsed: " << elapsed << endl;
236+
cout << "TG: " << address << "\tFreq: " << retfreq << "\tActive Loggers: " << active_loggers.size() << "\tCmd: "<< command << "\t LastCmd: " <<lastcmd << endl;
227237
}
228238

239+
/*
229240
for(vector<log_dsd_sptr>::iterator it = active_loggers.begin(); it != active_loggers.end();) {
230241
log_dsd_sptr rx = *it;
231-
242+
*/
243+
for(vector<log_p25_sptr>::iterator it = active_loggers.begin(); it != active_loggers.end();) {
244+
log_p25_sptr rx = *it;
232245

233246
if (rx->timeout() > 5.0) {
234247
//cout << "smartnet.cc: Deleting Logger - TG: " << rx->get_talkgroup() << "\t Freq: " << rx->get_freq() << endl;
@@ -238,7 +251,10 @@ float parse_message(string s) {
238251
//tb->wait();
239252

240253
tb->disconnect(src, 0, rx, 0);
241-
rx->deactivate();
254+
255+
/* !!!!!!!!!!!!! don't forget to un comment this for log_dsd */
256+
//rx->deactivate();
257+
rx->close();
242258

243259
tb->unlock();
244260

@@ -252,7 +268,7 @@ rx->deactivate();
252268
//cout << "smartnet.cc: Moved Active Logger, Loggers " << loggers.size() << " Active Loggers " << active_loggers.size() << endl;
253269

254270
sprintf(shell_command,"./encode-upload.sh %s &", rx->get_filename());
255-
system(shell_command);
271+
//system(shell_command);
256272

257273
/* static loggers
258274
loggers.push_back(move(rx));
@@ -310,7 +326,7 @@ std::string device_addr;
310326

311327

312328

313-
329+
signal(SIGINT, exit_interupt);
314330
tb = gr_make_top_block("smartnet");
315331

316332

@@ -423,6 +439,11 @@ usleep(1000);
423439
it = active_loggers.erase(it);
424440
}*/
425441
while (1) {
442+
if(exit_flag){ // my action when signal set it 1
443+
printf("\n Signal caught!\n");
444+
tb->stop();
445+
return 0;
446+
}
426447
if (!queue->empty_p())
427448
{
428449
std::string sentence;

0 commit comments

Comments
 (0)