Browse Source

More fix for services

Per Mårtensson 1 month ago
parent
commit
748ce01194
2 changed files with 28 additions and 6 deletions
  1. 18 0
      banbel.service
  2. 10 6
      src/rtl_airband.cpp

+ 18 - 0
banbel.service

@@ -0,0 +1,18 @@
+[Unit]
+Description=SDR AM/NFM demodulator
+Documentation=https://github.com/charlie-foxtrot/RTLSDR-Airband/wiki
+Wants=network.target
+After=multi-user.target
+[Service]
+Type=simple
+Environment=XDG_RUNTIME_DIR=/run/user/1000
+ExecStart=/usr/local/bin/rtl_airband -fe
+# The program may exit only due to startup failure (eg. misconfiguration)
+# or due to failure of all SDR devices (eg. disconnection). In either case,
+# there is no point to restart it, because it would fail once again.
+Restart=always
+StartLimitBurst=0
+User=pm
+
+[Install]
+WantedBy=multi-user.target

+ 10 - 6
src/rtl_airband.cpp

@@ -185,7 +185,7 @@ void* belysning_control_thread(void*){
         int sem_try=0;
         bool activate=false;
         bool prolong=false;
-        if (clock_gettime(CLOCK_REALTIME, &ts) == -1)
+        if (clock_gettime(CLOCK_REALTIME, &ts) == -1 && tui)
             printf("clock_gettime");
         ts.tv_sec +=1;
         sem_try = sem_timedwait(&mutex_sem, &ts);
@@ -206,6 +206,7 @@ void* belysning_control_thread(void*){
             sem_post(&spooler_sem);
         }
         //printf("DATA %u, %ld, %ld, %ld %u\n",sq_status,sq_start_time,audio_start_time,tv.tv_sec,prolong);
+        //Check if we should start
         if (sq_status == true && sq_start_time+bel_open_time < tv.tv_sec && audio_start_time+bel_open_time < tv.tv_sec){
             sq_start_time=sq_start_time;
             sq_stop_time=sq_stop_time;
@@ -217,21 +218,24 @@ void* belysning_control_thread(void*){
             start_time=tv.tv_sec;
             stop_time=tv.tv_sec+bel_start_on_time;
             active=true;
-            printf("Start\n");
+            if (tui)
+                printf("Start\n");
 
         }
         // Prolong
         if (active==true && prolong==true){
             if (tv.tv_sec+10 >= stop_time){
                 stop_time=tv.tv_sec+bel_prolong_time;
-                printf("Prolong %u\n",bel_prolong_time);
+                if (tui)
+                    printf("Prolong %u\n",bel_prolong_time);
                 prolong = false;
             }
         }
         if (stop_time<=tv.tv_sec && active){
             active=false;
             start_time=start_time;
-            printf("Stop\n");
+            if (tui)
+                printf("Stop\n");
         }
         if (active)
             if ((stop_time<tv.tv_sec+bel_blink_time) && tv.tv_sec % 2 && bel_blink_time ){
@@ -752,7 +756,7 @@ void* demodulate(void* params) {
                 afc.finalize(dev, i, demod_params->fftout);
 #endif /* WITH_BCM_VC */
 
-                if (tui) {
+                if (tui || 1==1) {
                     char symbol = fparms->squelch.signal_outside_filter() ? '~' : (char)channel->axcindicate;
                     if (dev->mode == R_SCAN) {
                         //GOTOXY(0, device_num * 17 + dev->row + 3);
@@ -1214,7 +1218,7 @@ int main(int argc, char* argv[]) {
         log(LOG_ERR, "%d device(s) failed to initialize - aborting\n", device_count - devices_running);
         error();
     }
-    if (tui) {
+    if (tui && 1==0) { //PMPMPM
         printf("\e[1;1H\e[2J");
 
         GOTOXY(0, 0);