42
42
#include < string>
43
43
#include < stdio.h>
44
44
#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"
47
48
#include " smartnet_crc.h"
48
49
#include " smartnet_deinterleave.h"
49
50
@@ -102,8 +103,13 @@ osmosdr_source_c_sptr src;
102
103
/* static loggers
103
104
vector<log_dsd_sptr> loggers;*/
104
105
105
- vector<log_dsd_sptr> active_loggers;
106
+ // vector<log_dsd_sptr> active_loggers;
107
+ vector<log_p25_sptr> active_loggers;
106
108
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
+ }
107
113
108
114
void init_loggers (int num, float center_freq) {
109
115
@@ -171,9 +177,11 @@ float parse_message(string s) {
171
177
}
172
178
173
179
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) {
175
182
176
- log_dsd_sptr rx = *it;
183
+ // log_dsd_sptr rx = *it;
184
+ log_p25_sptr rx = *it;
177
185
178
186
179
187
if (rx->get_talkgroup () == address) {
@@ -208,7 +216,9 @@ float parse_message(string s) {
208
216
// tb->wait();
209
217
210
218
// 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
+
212
222
active_loggers.push_back (log);
213
223
214
224
tb->connect (src, 0 , log, 0 );
@@ -223,12 +233,15 @@ float parse_message(string s) {
223
233
// cout << "smartnet.cc: Activated logger & unlocked" << endl;
224
234
}
225
235
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 << " \t Freq: " << retfreq << " \t Active Loggers: " << active_loggers.size () << " \t Cmd: " << command << " \t LastCmd: " <<lastcmd << endl;
227
237
}
228
238
239
+ /*
229
240
for(vector<log_dsd_sptr>::iterator it = active_loggers.begin(); it != active_loggers.end();) {
230
241
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;
232
245
233
246
if (rx->timeout () > 5.0 ) {
234
247
// cout << "smartnet.cc: Deleting Logger - TG: " << rx->get_talkgroup() << "\t Freq: " << rx->get_freq() << endl;
@@ -238,7 +251,10 @@ float parse_message(string s) {
238
251
// tb->wait();
239
252
240
253
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 ();
242
258
243
259
tb->unlock ();
244
260
@@ -252,7 +268,7 @@ rx->deactivate();
252
268
// cout << "smartnet.cc: Moved Active Logger, Loggers " << loggers.size() << " Active Loggers " << active_loggers.size() << endl;
253
269
254
270
sprintf (shell_command," ./encode-upload.sh %s &" , rx->get_filename ());
255
- system (shell_command);
271
+ // system(shell_command);
256
272
257
273
/* static loggers
258
274
loggers.push_back(move(rx));
@@ -310,7 +326,7 @@ std::string device_addr;
310
326
311
327
312
328
313
-
329
+ signal (SIGINT, exit_interupt);
314
330
tb = gr_make_top_block (" smartnet" );
315
331
316
332
@@ -423,6 +439,11 @@ usleep(1000);
423
439
it = active_loggers.erase(it);
424
440
}*/
425
441
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
+ }
426
447
if (!queue->empty_p ())
427
448
{
428
449
std::string sentence;
0 commit comments