From fcf680a1383a88fb4953133bd742e267950c48bd Mon Sep 17 00:00:00 2001 From: lwvmobile <59371473+lwvmobile@users.noreply.github.com> Date: Thu, 10 Feb 2022 16:56:37 -0500 Subject: [PATCH 1/2] Direct all prints to STDERR Direct all prints to STDERR Take 2 --- src/dmr_data.c | 10 +- src/dmr_voice.c | 12 +- src/dsd_audio.c | 92 ++++++------ src/dsd_dibit.c | 32 ++--- src/dsd_file.c | 18 +-- src/dsd_frame.c | 48 +++---- src/dsd_frame_sync.c | 56 ++++---- src/dsd_main.c | 300 ++++++++++++++++++++-------------------- src/dsd_mbe.c | 8 +- src/dsd_serial.c | 4 +- src/dsd_symbol.c | 14 +- src/dstar.c | 23 ++- src/dstar_header.c | 18 +-- src/nxdn96.c | 24 ++-- src/nxdn_data.c | 10 +- src/nxdn_voice.c | 12 +- src/p25_lcw.c | 20 +-- src/p25p1_check_hdu.cpp | 71 +++++----- src/p25p1_check_ldu.cpp | 52 +++---- src/p25p1_check_nid.cpp | 2 +- src/p25p1_hdu.c | 12 +- src/p25p1_heuristics.c | 16 +-- src/p25p1_ldu.c | 51 ++++--- src/p25p1_ldu1.c | 8 +- src/p25p1_ldu2.c | 10 +- src/p25p1_tdu.c | 2 +- src/p25p1_tdulc.c | 30 ++-- src/pa_devs.c | 36 ++--- src/provoice.c | 150 ++++++++++---------- src/rtl_sdr_fm.cpp | 84 +++++------ src/x2tdma_data.c | 10 +- src/x2tdma_voice.c | 14 +- 32 files changed, 623 insertions(+), 626 deletions(-) diff --git a/src/dmr_data.c b/src/dmr_data.c index ab47f10..b1d870e 100644 --- a/src/dmr_data.c +++ b/src/dmr_data.c @@ -82,7 +82,7 @@ processDMRdata (dsd_opts * opts, dsd_state * state) k++; } cachbits[24] = 0; - printf ("%s ", cachbits); + fprintf (stderr, "%s ", cachbits); #endif // current slot @@ -203,7 +203,7 @@ processDMRdata (dsd_opts * opts, dsd_state * state) k++; } syncbits[48] = 0; - printf ("%s ", syncbits); + fprintf (stderr, "%s ", syncbits); #endif if ((strcmp (sync, DMR_BS_DATA_SYNC) == 0) || (strcmp (sync, DMR_MS_DATA_SYNC) == 0)) @@ -220,7 +220,7 @@ processDMRdata (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { - printf ("%s %s ", state->slot0light, state->slot1light); + fprintf (stderr, "%s %s ", state->slot0light, state->slot1light); } // current slot second half, cach, next slot 1st half @@ -230,11 +230,11 @@ processDMRdata (dsd_opts * opts, dsd_state * state) { if (strcmp (state->fsubtype, " ") == 0) { - printf (" Unknown burst type: %s\n", bursttype); + fprintf (stderr, " Unknown burst type: %s\n", bursttype); } else { - printf ("%s\n", state->fsubtype); + fprintf (stderr, "%s\n", state->fsubtype); } } } diff --git a/src/dmr_voice.c b/src/dmr_voice.c index b567e22..b7a76f7 100644 --- a/src/dmr_voice.c +++ b/src/dmr_voice.c @@ -114,7 +114,7 @@ processDMRvoice (dsd_opts * opts, dsd_state * state) k++; } cachbits[24] = 0; - printf ("%s ", cachbits); + fprintf (stderr, "%s ", cachbits); #endif // current slot frame 1 @@ -226,7 +226,7 @@ processDMRvoice (dsd_opts * opts, dsd_state * state) if ((j == 0) && (opts->errorbars == 1)) { - printf ("%s %s VOICE e:", state->slot0light, state->slot1light); + fprintf (stderr, "%s %s VOICE e:", state->slot0light, state->slot1light); } #ifdef DMR_DUMP @@ -240,7 +240,7 @@ processDMRvoice (dsd_opts * opts, dsd_state * state) k++; } syncbits[48] = 0; - printf ("%s ", syncbits); + fprintf (stderr, "%s ", syncbits); #endif // current slot frame 2 second half @@ -307,7 +307,7 @@ processDMRvoice (dsd_opts * opts, dsd_state * state) k++; } cachbits[24] = 0; - printf ("%s ", cachbits); + fprintf (stderr, "%s ", cachbits); #endif @@ -358,7 +358,7 @@ processDMRvoice (dsd_opts * opts, dsd_state * state) k++; } syncbits[48] = 0; - printf ("%s ", syncbits); + fprintf (stderr, "%s ", syncbits); #endif if (j == 5) @@ -376,7 +376,7 @@ processDMRvoice (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { - printf ("\n"); + fprintf (stderr, "\n"); } } diff --git a/src/dsd_audio.c b/src/dsd_audio.c index 186aaa3..b64381f 100644 --- a/src/dsd_audio.c +++ b/src/dsd_audio.c @@ -32,7 +32,7 @@ void openPulseOutput(dsd_opts * opts) tt.format = PA_SAMPLE_S16NE; tt.channels = 1; tt.rate = opts->pulse_digi_rate_out; //48000, switches to 8000 when using RTL dongle - //printf("digi rate out = %d\n", opts->pulse_digi_rate_out); + //fprintf (stderr,"digi rate out = %d\n", opts->pulse_digi_rate_out); //ss if (opts->monitor_input_audio == 1) @@ -117,7 +117,7 @@ void playRawAudio(dsd_opts * opts, dsd_state * state) { if (opts->audio_out_type == 0){ //write (opts->audio_out_fd, (void*)&obuf, outl); pa_simple_write(opts->pulse_raw_dev_out, (void*)&obuf, 2, NULL); - //printf("writing samples"); + //fprintf (stderr,"writing samples"); } #ifdef USE_PORTAUDIO //no idea if this method will work, since I can't test it @@ -128,11 +128,11 @@ void playRawAudio(dsd_opts * opts, dsd_state * state) { { err = Pa_StartStream( opts->audio_out_pa_stream ); if( err != paNoError ){ - printf("Can't Start PA Stream"); + fprintf (stderr,"Can't Start PA Stream"); } err = Pa_WriteStream( opts->audio_out_pa_stream, (void*)&obuf, outl ); if( err != paNoError ){ - printf("Can't Write PA Stream"); + fprintf (stderr,"Can't Write PA Stream"); } } } @@ -287,8 +287,8 @@ writeSynthesizedVoice (dsd_opts * opts, dsd_state * state) short *aout_buf_p; // for(n=0; n<160; n++) -// printf("%d ", ((short*)(state->audio_out_temp_buf))[n]); -// printf("\n"); +// fprintf (stderr,"%d ", ((short*)(state->audio_out_temp_buf))[n]); +// fprintf (stderr,"\n"); aout_buf_p = aout_buf; state->audio_out_temp_buf_p = state->audio_out_temp_buf; @@ -357,7 +357,7 @@ playSynthesizedVoice (dsd_opts * opts, dsd_state * state) long available = Pa_GetStreamWriteAvailable( opts->audio_out_pa_stream ); if(available < 0) err = available; - //printf("Frames available: %d\n", available); + //fprintf (stderr,"Frames available: %d\n", available); if( err != paNoError ) break; if(available > SAMPLE_RATE_OUT * PA_LATENCY_OUT) @@ -365,7 +365,7 @@ playSynthesizedVoice (dsd_opts * opts, dsd_state * state) //It looks like this might not be needed for very small latencies. However, it's definitely needed for a bit larger ones. //When PA_LATENCY_OUT == 0.500 I get output buffer underruns if I don't use this. With PA_LATENCY_OUT <= 0.100 I don't see those happen. //But with PA_LATENCY_OUT < 0.100 I run the risk of choppy audio and stream errors. - printf("\nSyncing voice output stream\n"); + fprintf (stderr,"\nSyncing voice output stream\n"); err = Pa_StopStream( opts->audio_out_pa_stream ); if( err != paNoError ) break; @@ -374,7 +374,7 @@ playSynthesizedVoice (dsd_opts * opts, dsd_state * state) err = Pa_IsStreamActive( opts->audio_out_pa_stream ); if(err == 0) { - printf("Start voice output stream\n"); + fprintf (stderr,"Start voice output stream\n"); err = Pa_StartStream( opts->audio_out_pa_stream ); } else if(err == 1) @@ -391,9 +391,9 @@ playSynthesizedVoice (dsd_opts * opts, dsd_state * state) if( err != paNoError ) { - fprintf( stderr, "An error occured while using the portaudio output stream\n" ); - fprintf( stderr, "Error number: %d\n", err ); - fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + fprintf (stderr, stderr, "An error occured while using the portaudio output stream\n" ); + fprintf (stderr, stderr, "Error number: %d\n", err ); + fprintf (stderr, stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); } #endif @@ -421,20 +421,20 @@ playSynthesizedVoice (dsd_opts * opts, dsd_state * state) int getPADevice(char* dev, int input, PaStream** stream) { int devnum = atoi(dev + 3); - printf("Using portaudio device %d.\n", devnum); + fprintf (stderr,"Using portaudio device %d.\n", devnum); PaError err; int numDevices = Pa_GetDeviceCount(); if( numDevices < 0 ) { - printf( "ERROR: Pa_GetDeviceCount returned 0x%x\n", numDevices ); + fprintf (stderr, "ERROR: Pa_GetDeviceCount returned 0x%x\n", numDevices ); err = numDevices; goto error; } if( devnum >= numDevices) { - printf( "ERROR: Requested device %d is larger than number of devices.\n", devnum ); + fprintf (stderr, "ERROR: Requested device %d is larger than number of devices.\n", devnum ); return(1); } @@ -445,19 +445,19 @@ int getPADevice(char* dev, int input, PaStream** stream) { /* Use wide char on windows, so we can show UTF-8 encoded device names */ wchar_t wideName[MAX_PATH]; MultiByteToWideChar(CP_UTF8, 0, deviceInfo->name, -1, wideName, MAX_PATH-1); - wprintf( L"Name = %s\n", wideName ); + wprintf ( L"Name = %s\n", wideName ); } #else - printf( "Name = %s\n", deviceInfo->name ); + fprintf (stderr, "Name = %s\n", deviceInfo->name ); #endif if((input == 1) && (deviceInfo->maxInputChannels == 0)) { - printf( "ERROR: Requested device %d is not an input device.\n", devnum ); + fprintf (stderr, "ERROR: Requested device %d is not an input device.\n", devnum ); return(1); } if((input == 0) && (deviceInfo->maxOutputChannels == 0)) { - printf( "ERROR: Requested device %d is not an output device.\n", devnum ); + fprintf (stderr, "ERROR: Requested device %d is not an output device.\n", devnum ); return(1); } @@ -484,9 +484,9 @@ int getPADevice(char* dev, int input, PaStream** stream) return 0; error: - fprintf( stderr, "An error occured while initializing a portaudio stream\n" ); - fprintf( stderr, "Error number: %d\n", err ); - fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + fprintf (stderr, stderr, "An error occured while initializing a portaudio stream\n" ); + fprintf (stderr, stderr, "Error number: %d\n", err ); + fprintf (stderr, stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); return err; } #endif @@ -509,7 +509,7 @@ openAudioOutDevice (dsd_opts * opts, int speed) if(err != 0) exit(err); #else - printf("Error, Portaudio support not compiled.\n"); + fprintf (stderr,"Error, Portaudio support not compiled.\n"); exit(1); #endif } @@ -522,14 +522,14 @@ openAudioOutDevice (dsd_opts * opts, int speed) struct stat stat_buf; if(stat(opts->audio_out_dev, &stat_buf) != 0 && strncmp(opts->audio_out_dev, "pulse", 5 != 0)) //HERE { - printf("Error, couldn't open %s\n", opts->audio_out_dev); + fprintf (stderr,"Error, couldn't open %s\n", opts->audio_out_dev); exit(1); } if( (!(S_ISCHR(stat_buf.st_mode) || S_ISBLK(stat_buf.st_mode))) && strncmp(opts->audio_out_dev, "pulse", 5 != 0)) { // this is not a device - printf("Error, %s is not a device. use -w filename for wav output.\n", opts->audio_out_dev); + fprintf (stderr,"Error, %s is not a device. use -w filename for wav output.\n", opts->audio_out_dev); exit(1); } /* @@ -539,7 +539,7 @@ openAudioOutDevice (dsd_opts * opts, int speed) opts->audio_out_fd = open (opts->audio_out_dev, O_WRONLY); if (opts->audio_out_fd == -1) { - printf ("Error, couldn't open %s\n", opts->audio_out_dev); + fprintf (stderr,"Error, couldn't open %s\n", opts->audio_out_dev); //exit (1); } @@ -556,7 +556,7 @@ openAudioOutDevice (dsd_opts * opts, int speed) if (ioctl (opts->audio_out_fd, AUDIO_SETINFO, &aset) == -1) { - printf ("Error setting sample device parameters\n"); + fprintf (stderr,"Error setting sample device parameters\n"); exit (1); } #endif @@ -568,7 +568,7 @@ openAudioOutDevice (dsd_opts * opts, int speed) opts->audio_out_fd = open (opts->audio_out_dev, O_WRONLY); if (opts->audio_out_fd == -1) { - printf ("Error, couldn't open %s\n", opts->audio_out_dev); + fprintf (stderr,"Error, couldn't open %s\n", opts->audio_out_dev); opts->audio_out = 0; //exit(1); } @@ -576,28 +576,28 @@ openAudioOutDevice (dsd_opts * opts, int speed) fmt = 0; if (ioctl (opts->audio_out_fd, SNDCTL_DSP_RESET) < 0) { - printf ("ioctl reset error \n"); + fprintf (stderr,"ioctl reset error \n"); } fmt = speed; if (ioctl (opts->audio_out_fd, SNDCTL_DSP_SPEED, &fmt) < 0) { - printf ("ioctl speed error \n"); + fprintf (stderr,"ioctl speed error \n"); } fmt = 0; if (ioctl (opts->audio_out_fd, SNDCTL_DSP_STEREO, &fmt) < 0) { - printf ("ioctl stereo error \n"); + fprintf (stderr,"ioctl stereo error \n"); } fmt = AFMT_S16_LE; if (ioctl (opts->audio_out_fd, SNDCTL_DSP_SETFMT, &fmt) < 0) { - printf ("ioctl setfmt error \n"); + fprintf (stderr,"ioctl setfmt error \n"); } #endif */ } - printf ("Audio Out Device: %s\n", opts->audio_out_dev); + fprintf (stderr,"Audio Out Device: %s\n", opts->audio_out_dev); } void @@ -616,7 +616,7 @@ openAudioInDevice (dsd_opts * opts) opts->audio_in_file = sf_open_fd(fileno(stdin), SFM_READ, opts->audio_in_file_info, 0); if(opts->audio_in_file == NULL) { - printf ("Error, couldn't open stdin with libsndfile: %s\n", sf_strerror(NULL)); + fprintf (stderr,"Error, couldn't open stdin with libsndfile: %s\n", sf_strerror(NULL)); exit(1); //had this one disabled, re-enabling it now } } @@ -636,7 +636,7 @@ openAudioInDevice (dsd_opts * opts) } #else - printf("Error, Portaudio support not compiled.\n"); + fprintf (stderr,"Error, Portaudio support not compiled.\n"); exit(1); #endif } @@ -653,7 +653,7 @@ openAudioInDevice (dsd_opts * opts) struct stat stat_buf; if (stat(opts->audio_in_dev, &stat_buf) != 0) { - printf("Error, couldn't open %s\n", opts->audio_in_dev); + fprintf (stderr,"Error, couldn't open %s\n", opts->audio_in_dev); exit(1); } if (S_ISREG(stat_buf.st_mode)) @@ -667,7 +667,7 @@ openAudioInDevice (dsd_opts * opts) if(opts->audio_in_file == NULL) { - printf ("Error, couldn't open file %s\n", opts->audio_in_dev); + fprintf (stderr,"Error, couldn't open file %s\n", opts->audio_in_dev); exit(1); } } @@ -692,7 +692,7 @@ openAudioInDevice (dsd_opts * opts) } if (opts->audio_in_fd == -1) { - printf ("Error, couldn't open %s\n", opts->audio_in_dev); + fprintf (stderr,"Error, couldn't open %s\n", opts->audio_in_dev); //exit(1); } @@ -712,7 +712,7 @@ openAudioInDevice (dsd_opts * opts) if (ioctl (opts->audio_in_fd, AUDIO_SETINFO, &aset) == -1) { - printf ("Error setting sample device parameters\n"); + fprintf (stderr,"Error setting sample device parameters\n"); exit (1); } #endif @@ -732,29 +732,29 @@ openAudioInDevice (dsd_opts * opts) if (opts->audio_in_fd == -1) { - printf ("Error, couldn't open %s\n", opts->audio_in_dev); + fprintf (stderr,"Error, couldn't open %s\n", opts->audio_in_dev); opts->audio_out = 0; } fmt = 0; if (ioctl (opts->audio_in_fd, SNDCTL_DSP_RESET) < 0) { - printf ("ioctl reset error \n"); + fprintf (stderr,"ioctl reset error \n"); } fmt = SAMPLE_RATE_IN; if (ioctl (opts->audio_in_fd, SNDCTL_DSP_SPEED, &fmt) < 0) { - printf ("ioctl speed error \n"); + fprintf (stderr,"ioctl speed error \n"); } fmt = 0; if (ioctl (opts->audio_in_fd, SNDCTL_DSP_STEREO, &fmt) < 0) { - printf ("ioctl stereo error \n"); + fprintf (stderr,"ioctl stereo error \n"); } fmt = AFMT_S16_LE; if (ioctl (opts->audio_in_fd, SNDCTL_DSP_SETFMT, &fmt) < 0) { - printf ("ioctl setfmt error \n"); + fprintf (stderr,"ioctl setfmt error \n"); } #endif */ @@ -763,10 +763,10 @@ openAudioInDevice (dsd_opts * opts) if (opts->split == 1) { - printf ("Audio In Device: %s\n", opts->audio_in_dev); + fprintf (stderr,"Audio In Device: %s\n", opts->audio_in_dev); } else { - printf ("Audio In/Out Device: %s\n", opts->audio_in_dev); + fprintf (stderr,"Audio In/Out Device: %s\n", opts->audio_in_dev); } } diff --git a/src/dsd_dibit.c b/src/dsd_dibit.c index ee3ea58..325d443 100644 --- a/src/dsd_dibit.c +++ b/src/dsd_dibit.c @@ -53,12 +53,12 @@ print_datascope(dsd_opts* opts, dsd_state* state, int* sbuf2) if (state->symbolcnt > (4800 / opts->scoperate)) { state->symbolcnt = 0; - printf ("\n"); - printf ("Demod mode: %s Nac: %4X\n", modulation, state->nac); - printf ("Frame Type: %s Talkgroup: %7i\n", state->ftype, state->lasttg); - printf ("Frame Subtype: %s Source: %12i\n", state->fsubtype, state->lastsrc); - printf ("TDMA activity: %s %s Voice errors: %s\n", state->slot0light, state->slot1light, state->err_str); - printf ("+----------------------------------------------------------------+\n"); + fprintf (stderr, "\n"); + fprintf (stderr, "Demod mode: %s Nac: %4X\n", modulation, state->nac); + fprintf (stderr, "Frame Type: %s Talkgroup: %7i\n", state->ftype, state->lasttg); + fprintf (stderr, "Frame Subtype: %s Source: %12i\n", state->fsubtype, state->lastsrc); + fprintf (stderr, "TDMA activity: %s %s Voice errors: %s\n", state->slot0light, state->slot1light, state->err_str); + fprintf (stderr, "+----------------------------------------------------------------+\n"); for (i = 0; i < 10; i++) { printf ("|"); @@ -68,25 +68,25 @@ print_datascope(dsd_opts* opts, dsd_state* state, int* sbuf2) { if ((j == ((state->min) + 32768) / 1024) || (j == ((state->max) + 32768) / 1024)) { - printf ("#"); + fprintf (stderr, "#"); } else if ((j == ((state->lmid) + 32768) / 1024) || (j == ((state->umid) + 32768) / 1024)) { - printf ("^"); + fprintf (stderr, "^"); } else if (j == (state->center + 32768) / 1024) { - printf ("!"); + fprintf (stderr, "!"); } else { if (j == 32) { - printf ("|"); + fprintf (stderr, "|"); } else { - printf (" "); + fprintf (stderr, " "); } } } @@ -94,24 +94,24 @@ print_datascope(dsd_opts* opts, dsd_state* state, int* sbuf2) { if (spectrum[j] > 9 - i) { - printf ("*"); + fprintf (stderr, "*"); } else { if (j == 32) { - printf ("|"); + fprintf (stderr, "|"); } else { - printf (" "); + fprintf (stderr, " "); } } } } - printf ("|\n"); + fprintf (stderr, "|\n"); } - printf ("+----------------------------------------------------------------+\n"); + fprintf (stderr, "+----------------------------------------------------------------+\n"); } } diff --git a/src/dsd_file.c b/src/dsd_file.c index 0eea94a..b27b67a 100644 --- a/src/dsd_file.c +++ b/src/dsd_file.c @@ -139,7 +139,7 @@ openMbeInFile (dsd_opts * opts, dsd_state * state) opts->mbe_in_f = fopen (opts->mbe_in_file, "ro"); if (opts->mbe_in_f == NULL) { - printf ("Error: could not open %s\n", opts->mbe_in_file); + fprintf (stderr,"Error: could not open %s\n", opts->mbe_in_file); } // read cookie @@ -159,7 +159,7 @@ openMbeInFile (dsd_opts * opts, dsd_state * state) else { state->mbe_file_type = -1; - printf ("Error - unrecognized file type\n"); + fprintf (stderr,"Error - unrecognized file type\n"); } } @@ -263,12 +263,12 @@ openMbeOutFile (dsd_opts * opts, dsd_state * state) gettimeofday (&tv, NULL); sprintf (opts->mbe_out_file, "%i%s", (int) tv.tv_sec, ext); - sprintf(opts->mbe_out_path, "%s%s", opts->mbe_out_dir, opts->mbe_out_file); + sprintf (opts->mbe_out_path, "%s%s", opts->mbe_out_dir, opts->mbe_out_file); opts->mbe_out_f = fopen (opts->mbe_out_path, "w"); if (opts->mbe_out_f == NULL) { - printf ("Error, couldn't open %s\n", opts->mbe_out_path); + fprintf (stderr,"Error, couldn't open %s\n", opts->mbe_out_path); } // write magic @@ -291,7 +291,7 @@ openWavOutFile (dsd_opts * opts, dsd_state * state) if (opts->wav_out_f == NULL) { - printf ("Error - could not open wav output file %s\n", opts->wav_out_file); + fprintf (stderr,"Error - could not open wav output file %s\n", opts->wav_out_file); return; } @@ -312,15 +312,15 @@ closeWavOutFile (dsd_opts * opts, dsd_state * state) rewind (opts->wav_out_f); length = state->wav_out_bytes; - fprintf (opts->wav_out_f, "RIFF"); + fprintf (stderr,opts->wav_out_f, "RIFF"); // total length fputc (((36 + length) & 0xff), opts->≈≈); fputc ((((36 + length) >> 8) & 0xff), opts->wav_out_f); fputc ((((36 + length) >> 16) & 0xff), opts->wav_out_f); fputc ((((36 + length) >> 24) & 0xff), opts->wav_out_f); - fprintf (opts->wav_out_f, "WAVE"); - fprintf (opts->wav_out_f, "fmt "); + fprintf (stderr,opts->wav_out_f, "WAVE"); + fprintf (stderr,opts->wav_out_f, "fmt "); // length of format chunk fputc (16, opts->wav_out_f); @@ -357,7 +357,7 @@ closeWavOutFile (dsd_opts * opts, dsd_state * state) fputc (0, opts->wav_out_f); // data chunk header - fprintf (opts->wav_out_f, "data"); + fprintf (stderr,opts->wav_out_f, "data"); // length of data fputc ((length & 0xff), opts->wav_out_f); diff --git a/src/dsd_frame.c b/src/dsd_frame.c index 1cd6077..28d68d0 100644 --- a/src/dsd_frame.c +++ b/src/dsd_frame.c @@ -31,18 +31,18 @@ printFrameInfo (dsd_opts * opts, dsd_state * state) level = (int) state->max / 164; if (opts->verbose > 0) { - printf ("inlvl: %2i%% ", level); + fprintf (stderr,"inlvl: %2i%% ", level); } if (state->nac != 0) { - printf ("nac: %4X ", state->nac); + fprintf (stderr,"nac: %4X ", state->nac); } if (opts->verbose > 1) { - printf ("src: %8i ", state->lastsrc); + fprintf (stderr,"src: %8i ", state->lastsrc); } - printf ("tg: %5i ", state->lasttg); + fprintf (stderr,"tg: %5i ", state->lasttg); } void @@ -89,7 +89,7 @@ processFrame (dsd_opts * opts, dsd_state * state) if (opts->verbose > 0) { level = (int) state->max / 164; - printf ("inlvl: %2i%% ", level); + fprintf (stderr,"inlvl: %2i%% ", level); } } state->nac = 0; @@ -134,7 +134,7 @@ processFrame (dsd_opts * opts, dsd_state * state) if (opts->verbose > 0) { level = (int) state->max / 164; - printf ("inlvl: %2i%% ", level); + fprintf (stderr,"inlvl: %2i%% ", level); } } state->nac = 0; @@ -156,7 +156,7 @@ processFrame (dsd_opts * opts, dsd_state * state) if (opts->verbose > 0) { level = (int) state->max / 164; - printf ("inlvl: %2i%% ", level); + fprintf (stderr,"inlvl: %2i%% ", level); } } state->nac = 0; @@ -179,7 +179,7 @@ processFrame (dsd_opts * opts, dsd_state * state) if (opts->verbose > 0) { level = (int) state->max / 164; - printf ("inlvl: %2i%% ", level); + fprintf (stderr,"inlvl: %2i%% ", level); } } if ((state->synctype == 11) || (state->synctype == 12)) @@ -233,7 +233,7 @@ processFrame (dsd_opts * opts, dsd_state * state) if (opts->verbose > 0) { level = (int) state->max / 164; - printf ("inlvl: %2i%% ", level); + fprintf (stderr,"inlvl: %2i%% ", level); } } if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL)) @@ -317,14 +317,14 @@ processFrame (dsd_opts * opts, dsd_state * state) } if (strcmp(new_duid, duid) != 0) { // DUID fixed by error correction - //printf("Fixing DUID %s -> %s\n", duid, new_duid); + //fprintf (stderr,"Fixing DUID %s -> %s\n", duid, new_duid); duid[0] = new_duid[0]; duid[1] = new_duid[1]; state->debug_header_errors++; } } else { // Check of NID failed and unable to recover its value - //printf("NID error\n"); + //fprintf (stderr,"NID error\n"); duid[0] = 'E'; duid[1] = 'E'; state->debug_header_critical_errors++; @@ -337,7 +337,7 @@ processFrame (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { printFrameInfo (opts, state); - printf (" HDU\n"); + fprintf (stderr," HDU\n"); } if (opts->mbe_out_dir[0] != 0) { @@ -355,7 +355,7 @@ processFrame (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { printFrameInfo (opts, state); - printf (" LDU1 "); + fprintf (stderr," LDU1 "); } if (opts->mbe_out_dir[0] != 0) { @@ -377,7 +377,7 @@ processFrame (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { printFrameInfo (opts, state); - printf (" Ignoring LDU2 not preceeded by LDU1\n"); + fprintf (stderr," Ignoring LDU2 not preceeded by LDU1\n"); } state->lastp25type = 0; sprintf (state->fsubtype, " "); @@ -387,7 +387,7 @@ processFrame (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { printFrameInfo (opts, state); - printf (" LDU2 "); + fprintf (stderr," LDU2 "); } if (opts->mbe_out_dir[0] != 0) { @@ -408,7 +408,7 @@ processFrame (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { printFrameInfo (opts, state); - printf (" TDULC\n"); + fprintf (stderr," TDULC\n"); } if (opts->mbe_out_dir[0] != 0) { @@ -434,7 +434,7 @@ processFrame (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { printFrameInfo (opts, state); - printf (" TDU\n"); + fprintf (stderr," TDU\n"); } if (opts->mbe_out_dir[0] != 0) { @@ -454,7 +454,7 @@ processFrame (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { printFrameInfo (opts, state); - printf (" TSDU\n"); + fprintf (stderr," TSDU\n"); } if (opts->resume > 0) { @@ -474,7 +474,7 @@ processFrame (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { printFrameInfo (opts, state); - printf (" PDU\n"); + fprintf (stderr," PDU\n"); } if (opts->resume > 0) { @@ -496,7 +496,7 @@ processFrame (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { printFrameInfo (opts, state); - printf ("(LDU2) "); + fprintf (stderr,"(LDU2) "); } if (opts->mbe_out_dir[0] != 0) { @@ -517,7 +517,7 @@ processFrame (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { printFrameInfo (opts, state); - printf ("(LDU1) "); + fprintf (stderr,"(LDU1) "); } if (opts->mbe_out_dir[0] != 0) { @@ -538,7 +538,7 @@ processFrame (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { printFrameInfo (opts, state); - printf (" (TSDU)\n"); + fprintf (stderr," (TSDU)\n"); } //state->lastp25type = 0; // Guess that the state is TSDU @@ -554,7 +554,7 @@ processFrame (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { printFrameInfo (opts, state); - printf (" (PDU)\n"); + fprintf (stderr," (PDU)\n"); } state->lastp25type = 0; } @@ -565,7 +565,7 @@ processFrame (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { printFrameInfo (opts, state); - printf (" duid:%s *Unknown DUID*\n", duid); + fprintf (stderr," duid:%s *Unknown DUID*\n", duid); } } } diff --git a/src/dsd_frame_sync.c b/src/dsd_frame_sync.c index e4aa0fe..5ecca52 100644 --- a/src/dsd_frame_sync.c +++ b/src/dsd_frame_sync.c @@ -94,26 +94,26 @@ printFrameSync (dsd_opts * opts, dsd_state * state, char *frametype, int offset, if (opts->verbose > 0) { //strftime (datestr, 31, "%Y-%m-%d-%H%M%S", &timep); - //printf ("Sync: %s ", frametype); - //printf ("%s %s Sync: %s ", getDate(), getTime(), frametype); - printf ("%s ", getTime()); - printf ("Sync: %s ", frametype); - //printf("%s Sync: %s ", getTime(), frametype); + //fprintf (stderr,"Sync: %s ", frametype); + //fprintf (stderr,"%s %s Sync: %s ", getDate(), getTime(), frametype); + fprintf (stderr,"%s ", getTime()); + fprintf (stderr,"Sync: %s ", frametype); + //fprintf (stderr,"%s Sync: %s ", getTime(), frametype); //printw("%s Sync: %s ", getTime(), frametype); } if (opts->verbose > 2) { - printf ("o: %4i ", offset); + fprintf (stderr,"o: %4i ", offset); //printw("o: %4i ", offset); } if (opts->verbose > 1) { - printf ("mod: %s ", modulation); + fprintf (stderr,"mod: %s ", modulation); //printw("mod: %s ", modulation); } if (opts->verbose > 2) { - printf ("g: %f ", state->aout_gain); + fprintf (stderr,"g: %f ", state->aout_gain); //printw("g: %f ", state->aout_gain); } //refresh(); @@ -179,12 +179,12 @@ getFrameSync (dsd_opts * opts, dsd_state * state) state->numflips = 0; if ((opts->symboltiming == 1) && (state->carrier == 1)) { - printf ("\nSymbol Timing:\n"); + fprintf (stderr,"\nSymbol Timing:\n"); //printw("\nSymbol Timing:\n"); } while (sync == 0) { - //printf("now=%d\n", now); //okay, so this is incrementing as expected + //fprintf (stderr,"now=%d\n", now); //okay, so this is incrementing as expected if ( opts->monitor_input_audio == 1 && (time(NULL) - now) > 1 ) //okay, still something going on, still doing the read part for some reason { //playRawAudio(opts, state); //this is on line 21 in dsd_audio.c @@ -336,36 +336,36 @@ getFrameSync (dsd_opts * opts, dsd_state * state) if (state->symbolcnt > (4800 / opts->scoperate)) { state->symbolcnt = 0; - printf ("\n"); - printf ("Demod mode: %s Nac: %4X\n", modulation, state->nac); - printf ("Frame Type: %s Talkgroup: %7i\n", state->ftype, state->lasttg); - printf ("Frame Subtype: %s Source: %12i\n", state->fsubtype, state->lastsrc); - printf ("TDMA activity: %s %s Voice errors: %s\n", state->slot0light, state->slot1light, state->err_str); - printf ("+----------------------------------------------------------------+\n"); + fprintf (stderr,"\n"); + fprintf (stderr,"Demod mode: %s Nac: %4X\n", modulation, state->nac); + fprintf (stderr,"Frame Type: %s Talkgroup: %7i\n", state->ftype, state->lasttg); + fprintf (stderr,"Frame Subtype: %s Source: %12i\n", state->fsubtype, state->lastsrc); + fprintf (stderr,"TDMA activity: %s %s Voice errors: %s\n", state->slot0light, state->slot1light, state->err_str); + fprintf (stderr,"+----------------------------------------------------------------+\n"); for (i = 0; i < 10; i++) { - printf ("|"); + fprintf (stderr,"|"); for (j = 0; j < 64; j++) { if (i == 0) { if ((j == ((state->min) + 32768) / 1024) || (j == ((state->max) + 32768) / 1024)) { - printf ("#"); + fprintf (stderr,"#"); } else if (j == (state->center + 32768) / 1024) { - printf ("!"); + fprintf (stderr,"!"); } else { if (j == 32) { - printf ("|"); + fprintf (stderr,"|"); } else { - printf (" "); + fprintf (stderr," "); } } } @@ -373,24 +373,24 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { if (spectrum[j] > 9 - i) { - printf ("*"); + fprintf (stderr,"*"); } else { if (j == 32) { - printf ("|"); + fprintf (stderr,"|"); } else { - printf (" "); + fprintf (stderr," "); } } } } - printf ("|\n"); + fprintf (stderr,"|\n"); } - printf ("+----------------------------------------------------------------+\n"); + fprintf (stderr,"+----------------------------------------------------------------+\n"); } } } @@ -934,8 +934,8 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { if ((opts->errorbars == 1) && (opts->verbose > 1) && (state->carrier == 1)) { - printf ("Sync: no sync\n"); - printf("Press CTRL + C to close.\n"); //Kindly remind user to double tap CTRL + C + fprintf (stderr,"Sync: no sync\n"); + fprintf (stderr,"Press CTRL + C to close.\n"); //Kindly remind user to double tap CTRL + C } noCarrier (opts, state); return (-1); diff --git a/src/dsd_main.c b/src/dsd_main.c index 152d67f..2705925 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -39,14 +39,14 @@ int pretty_colors() { - printf("%sred\n", KRED); - printf("%sgreen\n", KGRN); - printf("%syellow\n", KYEL); - printf("%sblue\n", KBLU); - printf("%smagenta\n", KMAG); - printf("%scyan\n", KCYN); - printf("%swhite\n", KWHT); - printf("%snormal\n", KNRM); + fprintf (stderr,"%sred\n", KRED); + fprintf (stderr,"%sgreen\n", KGRN); + fprintf (stderr,"%syellow\n", KYEL); + fprintf (stderr,"%sblue\n", KBLU); + fprintf (stderr,"%smagenta\n", KMAG); + fprintf (stderr,"%scyan\n", KCYN); + fprintf (stderr,"%swhite\n", KWHT); + fprintf (stderr,"%snormal\n", KNRM); return 0; } @@ -300,81 +300,81 @@ initState (dsd_state * state) void usage () { - printf ("\nFME build:%s", GIT_TAG); - printf ("\n"); - printf ("Usage: dsd [options] Live scanner mode\n"); - printf (" or: dsd [options] -r Read/Play saved mbe data from file(s)\n"); - printf (" or: dsd -h Show help\n"); - printf ("\n"); - printf ("Display Options:\n"); - printf (" -e Show Frame Info and errorbars (default)\n"); - printf (" -pe Show P25 encryption sync bits\n"); - printf (" -pl Show P25 link control bits\n"); - printf (" -ps Show P25 status bits and low speed data\n"); - printf (" -pt Show P25 talkgroup info\n"); - printf (" -q Don't show Frame Info/errorbars\n"); - printf (" -s Datascope (disables other display options)\n"); - printf (" -t Show symbol timing during sync\n"); - printf (" -v Frame information Verbosity\n"); - printf (" -z Frame rate for datascope\n"); - printf ("\n"); - printf ("Input/Output options:\n"); - //printf (" -i Audio input device (default is /dev/audio, - for piped stdin, rtl for rtl device)\n"); - printf (" -i Audio input device (default is pulse audio, - for piped stdin, rtl for rtl device)\n"); - //printf (" -o Audio output device (default is /dev/audio)\n"); - printf (" -o Audio output device (default is pulse audio)\n"); - printf (" -d Create mbe data files, use this directory\n"); - printf (" -r Read/Play saved mbe data from file(s)\n"); - printf (" -g Audio output gain (default = 0 = auto, disable = -1)\n"); - printf (" -n Do not send synthesized speech to audio output device\n"); - printf (" -w Output synthesized speech to a .wav file\n"); - printf (" -a Display port audio devices\n"); - printf (" -W Monitor Source Audio When No Sync Detected (WIP!)\n"); - printf ("\n"); - printf ("RTL-SDR options:\n"); - printf (" -c RTL-SDR Frequency\n"); - printf (" -P RTL-SDR PPM Error (default = 0)\n"); - printf (" -D RTL-SDR Device Index Number\n"); - printf (" -G RTL-SDR Device Gain (0-49) (default = 0 Auto Gain)\n"); - printf (" -L RTL-SDR Squelch Level (0 - Open, 25 - Little, 50 - Higher)(Just have to guess really...)\n"); - printf (" -V RTL-SDR Sample Gain Multiplier (default = 1)(1-3 recommended, still testing) \n"); - printf (" -Y RTL-SDR VFO Bandwidth kHz (default = 48)(6, 8, 12, 16, 24, 48) \n"); - printf (" -U RTL-SDR UDP Remote Port (default = 6020)\n"); - printf ("\n"); - printf ("Scanner control options:\n"); - printf (" -B Serial port baud rate (default=115200)\n"); - printf (" -C Serial port for scanner control (default=/dev/ttyUSB0)\n"); - printf (" -R Resume scan after TDULC frames or any PDU or TSDU\n"); - printf ("\n"); - printf ("Decoder options:\n"); - printf (" -fa Auto-detect frame type (default)\n"); - printf (" -f1 Decode only P25 Phase 1\n"); - printf (" -fd Decode only D-STAR\n"); - printf (" -fi Decode only NXDN48* (6.25 kHz) / IDAS*\n"); - printf (" -fn Decode only NXDN96* (12.5 kHz)\n"); - printf (" -fp Decode only ProVoice*\n"); - printf (" -fr Decode only DMR/MOTOTRBO\n"); - printf (" -fx Decode only X2-TDMA\n"); - printf (" -l Disable DMR/MOTOTRBO and NXDN input filtering\n"); - printf (" -ma Auto-select modulation optimizations (default)\n"); - printf (" -mc Use only C4FM modulation optimizations\n"); - printf (" -mg Use only GFSK modulation optimizations\n"); - printf (" -mq Use only QPSK modulation optimizations\n"); - printf (" -pu Unmute Encrypted P25\n"); - printf (" -u Unvoiced speech quality (default=3)\n"); - printf (" -xx Expect non-inverted X2-TDMA signal\n"); - printf (" -xr Expect inverted DMR/MOTOTRBO signal\n"); - printf ("\n"); - printf (" * denotes frame types that cannot be auto-detected.\n"); - printf ("\n"); - printf ("Advanced decoder options:\n"); - printf (" -A QPSK modulation auto detection threshold (default=26)\n"); - printf (" -S Symbol buffer size for QPSK decision point tracking\n"); - printf (" (default=36)\n"); - printf (" -M Min/Max buffer size for QPSK decision point tracking\n"); - printf (" (default=15)\n"); - printf ("\n"); - printf ("Report bugs to: https://github.com/lwvmobile/dsd-fme/issues \n"); + fprintf (stderr, "\nFME build:%s", GIT_TAG); + fprintf (stderr,"\n"); + fprintf (stderr,"Usage: dsd [options] Live scanner mode\n"); + fprintf (stderr," or: dsd [options] -r Read/Play saved mbe data from file(s)\n"); + fprintf (stderr," or: dsd -h Show help\n"); + fprintf (stderr,"\n"); + fprintf (stderr,"Display Options:\n"); + fprintf (stderr," -e Show Frame Info and errorbars (default)\n"); + fprintf (stderr," -pe Show P25 encryption sync bits\n"); + fprintf (stderr," -pl Show P25 link control bits\n"); + fprintf (stderr," -ps Show P25 status bits and low speed data\n"); + fprintf (stderr," -pt Show P25 talkgroup info\n"); + fprintf (stderr," -q Don't show Frame Info/errorbars\n"); + fprintf (stderr," -s Datascope (disables other display options)\n"); + fprintf (stderr," -t Show symbol timing during sync\n"); + fprintf (stderr," -v Frame information Verbosity\n"); + fprintf (stderr," -z Frame rate for datascope\n"); + fprintf (stderr,"\n"); + fprintf (stderr,"Input/Output options:\n"); + //fprintf (stderr," -i Audio input device (default is /dev/audio, - for piped stdin, rtl for rtl device)\n"); + fprintf (stderr," -i Audio input device (default is pulse audio, - for piped stdin, rtl for rtl device)\n"); + //fprintf (stderr," -o Audio output device (default is /dev/audio)\n"); + fprintf (stderr," -o Audio output device (default is pulse audio)\n"); + fprintf (stderr," -d Create mbe data files, use this directory\n"); + fprintf (stderr," -r Read/Play saved mbe data from file(s)\n"); + fprintf (stderr," -g Audio output gain (default = 0 = auto, disable = -1)\n"); + fprintf (stderr," -n Do not send synthesized speech to audio output device\n"); + fprintf (stderr," -w Output synthesized speech to a .wav file\n"); + fprintf (stderr," -a Display port audio devices\n"); + fprintf (stderr," -W Monitor Source Audio When No Sync Detected (WIP!)\n"); + fprintf (stderr,"\n"); + fprintf (stderr,"RTL-SDR options:\n"); + fprintf (stderr," -c RTL-SDR Frequency\n"); + fprintf (stderr," -P RTL-SDR PPM Error (default = 0)\n"); + fprintf (stderr," -D RTL-SDR Device Index Number\n"); + fprintf (stderr," -G RTL-SDR Device Gain (0-49) (default = 0 Auto Gain)\n"); + fprintf (stderr," -L RTL-SDR Squelch Level (0 - Open, 25 - Little, 50 - Higher)(Just have to guess really...)\n"); + fprintf (stderr," -V RTL-SDR Sample Gain Multiplier (default = 1)(1-3 recommended, still testing) \n"); + fprintf (stderr," -Y RTL-SDR VFO Bandwidth kHz (default = 48)(6, 8, 12, 16, 24, 48) \n"); + fprintf (stderr," -U RTL-SDR UDP Remote Port (default = 6020)\n"); + fprintf (stderr,"\n"); + fprintf (stderr,"Scanner control options:\n"); + fprintf (stderr," -B Serial port baud rate (default=115200)\n"); + fprintf (stderr," -C Serial port for scanner control (default=/dev/ttyUSB0)\n"); + fprintf (stderr," -R Resume scan after TDULC frames or any PDU or TSDU\n"); + fprintf (stderr,"\n"); + fprintf (stderr,"Decoder options:\n"); + fprintf (stderr," -fa Auto-detect frame type (default)\n"); + fprintf (stderr," -f1 Decode only P25 Phase 1\n"); + fprintf (stderr," -fd Decode only D-STAR\n"); + fprintf (stderr," -fi Decode only NXDN48* (6.25 kHz) / IDAS*\n"); + fprintf (stderr," -fn Decode only NXDN96* (12.5 kHz)\n"); + fprintf (stderr," -fp Decode only ProVoice*\n"); + fprintf (stderr," -fr Decode only DMR/MOTOTRBO\n"); + fprintf (stderr," -fx Decode only X2-TDMA\n"); + fprintf (stderr," -l Disable DMR/MOTOTRBO and NXDN input filtering\n"); + fprintf (stderr," -ma Auto-select modulation optimizations (default)\n"); + fprintf (stderr," -mc Use only C4FM modulation optimizations\n"); + fprintf (stderr," -mg Use only GFSK modulation optimizations\n"); + fprintf (stderr," -mq Use only QPSK modulation optimizations\n"); + fprintf (stderr," -pu Unmute Encrypted P25\n"); + fprintf (stderr," -u Unvoiced speech quality (default=3)\n"); + fprintf (stderr," -xx Expect non-inverted X2-TDMA signal\n"); + fprintf (stderr," -xr Expect inverted DMR/MOTOTRBO signal\n"); + fprintf (stderr,"\n"); + fprintf (stderr," * denotes frame types that cannot be auto-detected.\n"); + fprintf (stderr,"\n"); + fprintf (stderr,"Advanced decoder options:\n"); + fprintf (stderr," -A QPSK modulation auto detection threshold (default=26)\n"); + fprintf (stderr," -S Symbol buffer size for QPSK decision point tracking\n"); + fprintf (stderr," (default=36)\n"); + fprintf (stderr," -M Min/Max buffer size for QPSK decision point tracking\n"); + fprintf (stderr," (default=15)\n"); + fprintf (stderr,"\n"); + fprintf (stderr,"Report bugs to: https://github.com/lwvmobile/dsd-fme/issues \n"); exit (0); } @@ -388,9 +388,9 @@ liveScanner (dsd_opts * opts, dsd_state * state) PaError err = Pa_StartStream( opts->audio_in_pa_stream ); if( err != paNoError ) { - //fprintf( stderr, "An error occured while starting the portaudio input stream\n" ); - //fprintf( stderr, "Error number: %d\n", err ); - //fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + //fprintf (stderr, stderr, "An error occured while starting the portaudio input stream\n" ); + //fprintf (stderr, stderr, "Error number: %d\n", err ); + //fprintf (stderr, stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); return; } } @@ -452,16 +452,16 @@ cleanupAndExit (dsd_opts * opts, dsd_state * state) #ifdef USE_PORTAUDIO if((opts->audio_in_type == 2) || (opts->audio_out_type == 2)) { - printf("Terminating portaudio.\n"); + fprintf (stderr,"Terminating portaudio.\n"); PaError err = paNoError; if(opts->audio_in_pa_stream != NULL) { err = Pa_CloseStream( opts->audio_in_pa_stream ); if( err != paNoError ) { - //fprintf( stderr, "An error occured while closing the portaudio input stream\n" ); - //fprintf( stderr, "Error number: %d\n", err ); - //fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + //fprintf (stderr, stderr, "An error occured while closing the portaudio input stream\n" ); + //fprintf (stderr, stderr, "Error number: %d\n", err ); + //fprintf (stderr, stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); } } if(opts->audio_out_pa_stream != NULL) @@ -471,24 +471,24 @@ cleanupAndExit (dsd_opts * opts, dsd_state * state) err = Pa_StopStream( opts->audio_out_pa_stream ); if( err != paNoError ) { - //fprintf( stderr, "An error occured while closing the portaudio output stream\n" ); - //fprintf( stderr, "Error number: %d\n", err ); - //fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + //fprintf (stderr, stderr, "An error occured while closing the portaudio output stream\n" ); + //fprintf (stderr, stderr, "Error number: %d\n", err ); + //fprintf (stderr, stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); } err = Pa_CloseStream( opts->audio_out_pa_stream ); if( err != paNoError ) { - //fprintf( stderr, "An error occured while closing the portaudio output stream\n" ); - //fprintf( stderr, "Error number: %d\n", err ); - //fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + //fprintf (stderr, stderr, "An error occured while closing the portaudio output stream\n" ); + //fprintf (stderr, stderr, "Error number: %d\n", err ); + //fprintf (stderr, stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); } } err = Pa_Terminate(); if( err != paNoError ) { - //fprintf( stderr, "An error occured while terminating portaudio\n" ); - //fprintf( stderr, "Error number: %d\n", err ); - //fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + //fprintf (stderr, stderr, "An error occured while terminating portaudio\n" ); + //fprintf (stderr, stderr, "Error number: %d\n", err ); + //fprintf (stderr, stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); } } #endif @@ -501,17 +501,17 @@ cleanupAndExit (dsd_opts * opts, dsd_state * state) } #endif - printf("\n"); - printf("Total audio errors: %i\n", state->debug_audio_errors); - printf("Total header errors: %i\n", state->debug_header_errors); - printf("Total irrecoverable header errors: %i\n", state->debug_header_critical_errors); + fprintf (stderr,"\n"); + fprintf (stderr,"Total audio errors: %i\n", state->debug_audio_errors); + fprintf (stderr,"Total header errors: %i\n", state->debug_header_errors); + fprintf (stderr,"Total irrecoverable header errors: %i\n", state->debug_header_critical_errors); //debug_print_heuristics(&(state->p25_heuristics)); - printf("\n"); - printf("+P25 BER estimate: %.2f%%\n", get_P25_BER_estimate(&state->p25_heuristics)); - printf("-P25 BER estimate: %.2f%%\n", get_P25_BER_estimate(&state->inv_p25_heuristics)); - printf("\n"); + fprintf (stderr,"\n"); + fprintf (stderr,"+P25 BER estimate: %.2f%%\n", get_P25_BER_estimate(&state->p25_heuristics)); + fprintf (stderr,"-P25 BER estimate: %.2f%%\n", get_P25_BER_estimate(&state->inv_p25_heuristics)); + fprintf (stderr,"\n"); #ifdef TRACE_DSD if (state->debug_label_file != NULL) { @@ -528,7 +528,7 @@ cleanupAndExit (dsd_opts * opts, dsd_state * state) } #endif - printf ("Exiting.\n"); + fprintf (stderr,"Exiting.\n"); exit (0); } @@ -581,13 +581,13 @@ main (int argc, char **argv) for (short int i = 0; i < 7; i++) { - printf("%s%s \n", FM_banner[i], KCYN); + fprintf (stderr,"%s%s \n", FM_banner[i], KCYN); } - printf("%s", KNRM); //change back to normal + fprintf (stderr,"%s", KNRM); //change back to normal //pretty_colors(); - //printf ("Digital Speech Decoder 1.7.0-dev (build:%s)\n", GIT_TAG); - printf ("Digital Speech Decoder: Florida Man Edition\n"); - printf ("mbelib version %s\n", versionstr); + //fprintf (stderr,"Digital Speech Decoder 1.7.0-dev (build:%s)\n", GIT_TAG); + fprintf (stderr,"Digital Speech Decoder: Florida Man Edition\n"); + fprintf (stderr,"mbelib version %s\n", versionstr); initOpts (&opts); initState (&state); @@ -683,8 +683,8 @@ main (int argc, char **argv) case 'W': //monitor_input_audio if no sync opts.monitor_input_audio = 0; - //printf ("Monitor Source Audio if no sync detected (WIP!)\n"); - printf ("Monitor Source Audio Currently Disabled in Pulse Audio Builds.\n"); + //fprintf (stderr,"Monitor Source Audio if no sync detected (WIP!)\n"); + fprintf (stderr,"Monitor Source Audio Currently Disabled in Pulse Audio Builds.\n"); break; @@ -697,12 +697,12 @@ main (int argc, char **argv) opts.p25tg = 0; opts.datascope = 1; opts.symboltiming = 0; - printf ("Setting datascope frame rate to %i frame per second.\n", opts.scoperate); + fprintf (stderr,"Setting datascope frame rate to %i frame per second.\n", opts.scoperate); break; case 'i': strncpy(opts.audio_in_dev, optarg, 1023); opts.audio_in_dev[1023] = '\0'; - //printf("audio_in_dev = %s\n", opts.audio_in_dev); + //fprintf (stderr,"audio_in_dev = %s\n", opts.audio_in_dev); break; case 'o': strncpy(opts.audio_out_dev, optarg, 1023); @@ -711,37 +711,37 @@ main (int argc, char **argv) case 'd': strncpy(opts.mbe_out_dir, optarg, 1023); opts.mbe_out_dir[1023] = '\0'; - printf ("Writing mbe data files to directory %s\n", opts.mbe_out_dir); + fprintf (stderr,"Writing mbe data files to directory %s\n", opts.mbe_out_dir); break; case 'c': opts.rtlsdr_center_freq = (uint32_t)atofs(optarg); - printf("Tuning to frequency: %i Hz\n", opts.rtlsdr_center_freq); + fprintf (stderr,"Tuning to frequency: %i Hz\n", opts.rtlsdr_center_freq); break; case 'g': sscanf (optarg, "%f", &opts.audio_gain); if (opts.audio_gain < (float) 0 ) { - printf ("Disabling audio out gain setting\n"); + fprintf (stderr,"Disabling audio out gain setting\n"); } else if (opts.audio_gain == (float) 0) { opts.audio_gain = (float) 0; - printf ("Enabling audio out auto-gain\n"); + fprintf (stderr,"Enabling audio out auto-gain\n"); } else { - printf ("Setting audio out gain to %f\n", opts.audio_gain); + fprintf (stderr,"Setting audio out gain to %f\n", opts.audio_gain); state.aout_gain = opts.audio_gain; } break; case 'n': opts.audio_out = 0; - printf ("Disabling audio output to soundcard.\n"); + fprintf (stderr,"Disabling audio output to soundcard.\n"); break; case 'w': strncpy(opts.wav_out_file, optarg, 1023); opts.wav_out_file[1023] = '\0'; - printf ("Writing audio to file %s\n", opts.wav_out_file); + fprintf (stderr,"Writing audio to file %s\n", opts.wav_out_file); openWavOutFile (&opts, &state); break; case 'B': @@ -753,7 +753,7 @@ main (int argc, char **argv) break; case 'R': sscanf (optarg, "%d", &opts.resume); - printf ("Enabling scan resume after %i TDULC frames\n", opts.resume); + fprintf (stderr,"Enabling scan resume after %i TDULC frames\n", opts.resume); break; case 'f': if (optarg[0] == 'a') @@ -775,7 +775,7 @@ main (int argc, char **argv) opts.frame_nxdn96 = 0; opts.frame_dmr = 0; opts.frame_provoice = 0; - printf ("Decoding only D-STAR frames.\n"); + fprintf (stderr,"Decoding only D-STAR frames.\n"); } else if (optarg[0] == 'x') { @@ -786,7 +786,7 @@ main (int argc, char **argv) opts.frame_nxdn96 = 0; opts.frame_dmr = 0; opts.frame_provoice = 0; - printf ("Decoding only X2-TDMA frames.\n"); + fprintf (stderr,"Decoding only X2-TDMA frames.\n"); } else if (optarg[0] == 'p') { @@ -803,9 +803,9 @@ main (int argc, char **argv) opts.mod_qpsk = 0; opts.mod_gfsk = 1; state.rf_mod = 2; - printf ("Setting symbol rate to 9600 / second\n"); - printf ("Enabling only GFSK modulation optimizations.\n"); - printf ("Decoding only ProVoice frames.\n"); + fprintf (stderr,"Setting symbol rate to 9600 / second\n"); + fprintf (stderr,"Enabling only GFSK modulation optimizations.\n"); + fprintf (stderr,"Decoding only ProVoice frames.\n"); } else if (optarg[0] == '1') { @@ -816,7 +816,7 @@ main (int argc, char **argv) opts.frame_nxdn96 = 0; opts.frame_dmr = 0; opts.frame_provoice = 0; - printf ("Decoding only P25 Phase 1 frames.\n"); + fprintf (stderr,"Decoding only P25 Phase 1 frames.\n"); } else if (optarg[0] == 'i') { @@ -834,8 +834,8 @@ main (int argc, char **argv) opts.mod_gfsk = 1; //was 1 with others on zero state.rf_mod = 2; //was 2 //opts.symboltiming = 2400; //NXDN48 uses 2400 symbol rate - printf ("Setting symbol rate to 2400 / second\n"); - printf ("Decoding only NXDN 4800 baud frames.\n"); + fprintf (stderr,"Setting symbol rate to 2400 / second\n"); + fprintf (stderr,"Decoding only NXDN 4800 baud frames.\n"); } else if (optarg[0] == 'n') { @@ -850,8 +850,8 @@ main (int argc, char **argv) opts.mod_qpsk = 0; opts.mod_gfsk = 1; state.rf_mod = 2; - printf ("Enabling only GFSK modulation optimizations.\n"); - printf ("Decoding only NXDN 9600 baud frames.\n"); + fprintf (stderr,"Enabling only GFSK modulation optimizations.\n"); + fprintf (stderr,"Decoding only NXDN 9600 baud frames.\n"); } else if (optarg[0] == 'r') { @@ -862,7 +862,7 @@ main (int argc, char **argv) opts.frame_nxdn96 = 0; opts.frame_dmr = 1; opts.frame_provoice = 0; - printf ("Decoding only DMR/MOTOTRBO frames.\n"); + fprintf (stderr,"Decoding only DMR/MOTOTRBO frames.\n"); } break; case 'm': @@ -879,7 +879,7 @@ main (int argc, char **argv) opts.mod_qpsk = 0; opts.mod_gfsk = 0; state.rf_mod = 0; - printf ("Enabling only C4FM modulation optimizations.\n"); + fprintf (stderr,"Enabling only C4FM modulation optimizations.\n"); } else if (optarg[0] == 'g') { @@ -887,7 +887,7 @@ main (int argc, char **argv) opts.mod_qpsk = 0; opts.mod_gfsk = 1; state.rf_mod = 2; - printf ("Enabling only GFSK modulation optimizations.\n"); + fprintf (stderr,"Enabling only GFSK modulation optimizations.\n"); } else if (optarg[0] == 'q') { @@ -895,7 +895,7 @@ main (int argc, char **argv) opts.mod_qpsk = 1; opts.mod_gfsk = 0; state.rf_mod = 1; - printf ("Enabling only QPSK modulation optimizations.\n"); + fprintf (stderr,"Enabling only QPSK modulation optimizations.\n"); } break; case 'u': @@ -908,23 +908,23 @@ main (int argc, char **argv) { opts.uvquality = 64; } - printf ("Setting unvoice speech quality to %i waves per band.\n", opts.uvquality); + fprintf (stderr,"Setting unvoice speech quality to %i waves per band.\n", opts.uvquality); break; case 'x': if (optarg[0] == 'x') { opts.inverted_x2tdma = 0; - printf ("Expecting non-inverted X2-TDMA signals.\n"); + fprintf (stderr,"Expecting non-inverted X2-TDMA signals.\n"); } else if (optarg[0] == 'r') { opts.inverted_dmr = 1; - printf ("Expecting inverted DMR/MOTOTRBO signals.\n"); + fprintf (stderr,"Expecting inverted DMR/MOTOTRBO signals.\n"); } break; case 'A': sscanf (optarg, "%i", &opts.mod_threshold); - printf ("Setting C4FM/QPSK auto detection threshold to %i\n", opts.mod_threshold); + fprintf (stderr,"Setting C4FM/QPSK auto detection threshold to %i\n", opts.mod_threshold); break; case 'S': sscanf (optarg, "%i", &opts.ssize); @@ -936,7 +936,7 @@ main (int argc, char **argv) { opts.ssize = 1; } - printf ("Setting QPSK symbol buffer to %i\n", opts.ssize); + fprintf (stderr,"Setting QPSK symbol buffer to %i\n", opts.ssize); break; case 'M': sscanf (optarg, "%i", &opts.msize); @@ -948,7 +948,7 @@ main (int argc, char **argv) { opts.msize = 1; } - printf ("Setting QPSK Min/Max buffer to %i\n", opts.msize); + fprintf (stderr,"Setting QPSK Min/Max buffer to %i\n", opts.msize); break; case 'r': opts.playfiles = 1; @@ -985,13 +985,13 @@ main (int argc, char **argv) if((strncmp(opts.audio_in_dev, "pa:", 3) == 0) || (strncmp(opts.audio_out_dev, "pa:", 3) == 0)) { - printf("Initializing portaudio.\n"); + fprintf (stderr,"Initializing portaudio.\n"); PaError err = Pa_Initialize(); if( err != paNoError ) { - //fprintf( stderr, "An error occured while initializing portaudio\n" ); - //fprintf( stderr, "Error number: %d\n", err ); - //fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + //fprintf (stderr, stderr, "An error occured while initializing portaudio\n" ); + //fprintf (stderr, stderr, "Error number: %d\n", err ); + //fprintf (stderr, stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); exit(err); } } @@ -1044,7 +1044,7 @@ main (int argc, char **argv) attroff(COLOR_PAIR(4)); refresh(); */ - printf("Press CTRL + C twice to close.\n"); //Kindly remind user to double tap CTRL + C + fprintf (stderr,"Press CTRL + C twice to close.\n"); //Kindly remind user to double tap CTRL + C } else diff --git a/src/dsd_mbe.c b/src/dsd_mbe.c index 35c37c1..7fbd669 100644 --- a/src/dsd_mbe.c +++ b/src/dsd_mbe.c @@ -30,7 +30,7 @@ playMbeFiles (dsd_opts * opts, dsd_state * state, int argc, char **argv) sprintf (opts->mbe_in_file, "%s", argv[i]); openMbeInFile (opts, state); mbe_initMbeParms (state->cur_mp, state->prev_mp, state->prev_mp_enhanced); - printf ("playing %s\n", opts->mbe_in_file); + fprintf (stderr, "playing %s\n", opts->mbe_in_file); while (feof (opts->mbe_in_f) == 0) { if (state->mbe_file_type == 0) @@ -122,9 +122,9 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a } ambe_d_str[49] = '\0'; // print binary string - fprintf(stderr, "\n?\t?\t%s\t", ambe_d_str); + fprintf (stderr, "\n?\t?\t%s\t", ambe_d_str); // print error data - fprintf(stderr, "E1: %d; E2: %d; S: %s", state->errs, state->errs2, state->err_str); + fprintf (stderr, "E1: %d; E2: %d; S: %s", state->errs, state->errs2, state->err_str); #endif if (opts->mbe_out_f != NULL) { @@ -134,7 +134,7 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a if (opts->errorbars == 1) { - printf ("%s", state->err_str); + fprintf (stderr, "%s", state->err_str); //printw("%s", state->err_str); } diff --git a/src/dsd_serial.c b/src/dsd_serial.c index cc6a100..d970c01 100644 --- a/src/dsd_serial.c +++ b/src/dsd_serial.c @@ -8,11 +8,11 @@ openSerial (dsd_opts * opts, dsd_state * state) struct termios tty; speed_t baud; - printf ("Opening serial port %s and setting baud to %i\n", opts->serial_dev, opts->serial_baud); + fprintf (stderr, "Opening serial port %s and setting baud to %i\n", opts->serial_dev, opts->serial_baud); opts->serial_fd = open (opts->serial_dev, O_WRONLY); if (opts->serial_fd == -1) { - printf ("Error, couldn't open %s\n", opts->serial_dev); + fprintf (stderr, "Error, couldn't open %s\n", opts->serial_dev); exit (1); } diff --git a/src/dsd_symbol.c b/src/dsd_symbol.c index 1c25e1b..810506b 100644 --- a/src/dsd_symbol.c +++ b/src/dsd_symbol.c @@ -134,7 +134,7 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync) state->debug_sample_index++; #endif - // printf("res: %zd\n, offset: %lld", result, sf_seek(opts->audio_in_file, 0, SEEK_CUR)); + // printf ("res: %zd\n, offset: %lld", result, sf_seek(opts->audio_in_file, 0, SEEK_CUR)); if (opts->use_cosine_filter) { if (state->lastsynctype >= 10 && state->lastsynctype <= 13) @@ -180,14 +180,14 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync) } if ((opts->symboltiming == 1) && (have_sync == 0) && (state->lastsynctype != -1)) { - printf ("O"); + fprintf (stderr, "O"); } } else { if ((opts->symboltiming == 1) && (have_sync == 0) && (state->lastsynctype != -1)) { - printf ("+"); + fprintf (stderr, "+"); } if ((state->jitter < 0) && (state->lastsample < state->center) && (state->rf_mod != 1)) { // first transition edge @@ -213,14 +213,14 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync) } if ((opts->symboltiming == 1) && (have_sync == 0) && (state->lastsynctype != -1)) { - printf ("X"); + fprintf (stderr, "X"); } } else { if ((opts->symboltiming == 1) && (have_sync == 0) && (state->lastsynctype != -1)) { - printf ("-"); + fprintf (stderr, "-"); } if ((state->jitter < 0) && (state->lastsample > state->center) && (state->rf_mod != 1)) { // first transition edge @@ -309,11 +309,11 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync) { if (state->jitter >= 0) { - printf (" %i\n", state->jitter); + fprintf (stderr, " %i\n", state->jitter); } else { - printf ("\n"); + fprintf (stderr, "\n"); } } diff --git a/src/dstar.c b/src/dstar.c index 358baa1..9ca83e3 100644 --- a/src/dstar.c +++ b/src/dstar.c @@ -17,7 +17,7 @@ /* * Note: D-STAR support is fairly complete at this point. - * The ambe3600x2450 decoder is similar butnot compatible with D-STAR voice frames. + * The ambe3600x2450 decoder is similar butnot compatible with D-STAR voice frames. * The dstar interleave pattern is different as well. * GMSK modulation optimizations will also required to get a usable bit error */ @@ -40,11 +40,11 @@ void processDSTAR(dsd_opts * opts, dsd_state * state) { const int *w, *x; if (opts->errorbars == 1) { - printf("e:"); + fprintf (stderr, "e:"); } #ifdef DSTAR_DUMP - printf ("\n"); + fprintf (stderr, "\n"); #endif if (state->synctype == 18) { @@ -74,7 +74,7 @@ void processDSTAR(dsd_opts * opts, dsd_state * state) { } if ((bitbuffer & 0x00FFFFFF) == 0x00AAB468) { // we're slipping bits - printf("sync in voice after i=%d, restarting\n", i); + fprintf (stderr, "sync in voice after i=%d, restarting\n", i); //ugh just start over i = 0; w = dW; @@ -101,7 +101,7 @@ void processDSTAR(dsd_opts * opts, dsd_state * state) { if ((bitbuffer & 0x00FFFFFF) == 0x00AAB468) { // looking if we're slipping bits if (i != 96) { - printf("sync after i=%d\n", i); + fprintf (stderr, "sync after i=%d\n", i); i = 96; } } @@ -114,31 +114,31 @@ void processDSTAR(dsd_opts * opts, dsd_state * state) { if ((bitbuffer & 0x00FFFFFF) == 0x00AAB468) { //We got sync! - //printf("Sync on framecount = %d\n", framecount); + //fprintf (stderr, "Sync on framecount = %d\n", framecount); sync_missed = 0; } else if ((bitbuffer & 0x00FFFFFF) == 0xAAAAAA) { //End of transmission - printf("End of transmission\n"); + fprintf (stderr, "End of transmission\n"); goto end; } else if (framecount % 21 == 0) { - printf("Missed sync on framecount = %d, value = %x/%x/%x\n", + fprintf (stderr, "Missed sync on framecount = %d, value = %x/%x/%x\n", framecount, slowdata[0], slowdata[1], slowdata[2]); sync_missed++; } else if (framecount != 0 && (bitbuffer & 0x00FFFFFF) != 0x000000) { slowdata[0] ^= 0x70; slowdata[1] ^= 0x4f; slowdata[2] ^= 0x93; - //printf("unscrambled- %s",slowdata); + //fprintf (stderr, "unscrambled- %s",slowdata); } else if (framecount == 0) { - //printf("never scrambled-%s\n",slowdata); + //fprintf (stderr, "never scrambled-%s\n",slowdata); } framecount++; } end: if (opts->errorbars == 1) { - printf("\n"); + fprintf (stderr, "\n"); } } @@ -160,4 +160,3 @@ void processDSTAR_HD(dsd_opts * opts, dsd_state * state) { processDSTAR(opts, state); } - diff --git a/src/dstar_header.c b/src/dstar_header.c index 9314b9e..77ad1bd 100644 --- a/src/dstar_header.c +++ b/src/dstar_header.c @@ -49,28 +49,28 @@ void dstar_header_decode(int radioheaderbuffer[660]) { } } // print header - printf("\nDSTAR HEADER: "); - //printf("FLAG1: %02X - FLAG2: %02X - FLAG3: %02X\n", radioheader[0], + fprintf (stderr, "\nDSTAR HEADER: "); + //fprintf (stderr, "FLAG1: %02X - FLAG2: %02X - FLAG3: %02X\n", radioheader[0], // radioheader[1], radioheader[2]); - printf("RPT 2: %c%c%c%c%c%c%c%c ", radioheader[3], radioheader[4], + fprintf (stderr, "RPT 2: %c%c%c%c%c%c%c%c ", radioheader[3], radioheader[4], radioheader[5], radioheader[6], radioheader[7], radioheader[8], radioheader[9], radioheader[10]); - printf("RPT 1: %c%c%c%c%c%c%c%c ", radioheader[11], radioheader[12], + fprintf (stderr, "RPT 1: %c%c%c%c%c%c%c%c ", radioheader[11], radioheader[12], radioheader[13], radioheader[14], radioheader[15], radioheader[16], radioheader[17], radioheader[18]); - printf("YOUR: %c%c%c%c%c%c%c%c ", radioheader[19], radioheader[20], + fprintf (stderr, "YOUR: %c%c%c%c%c%c%c%c ", radioheader[19], radioheader[20], radioheader[21], radioheader[22], radioheader[23], radioheader[24], radioheader[25], radioheader[26]); - printf("MY: %c%c%c%c%c%c%c%c/%c%c%c%c\n", radioheader[27], + fprintf (stderr, "MY: %c%c%c%c%c%c%c%c/%c%c%c%c\n", radioheader[27], radioheader[28], radioheader[29], radioheader[30], radioheader[31], radioheader[32], radioheader[33], radioheader[34], radioheader[35], radioheader[36], radioheader[37], radioheader[38]); //FCSinheader = ((radioheader[39] << 8) | radioheader[40]) & 0xFFFF; //FCScalculated = calc_fcs((unsigned char*) radioheader, 39); - //printf("Check sum = %04X ", FCSinheader); + //fprintf (stderr, "Check sum = %04X ", FCSinheader); //if (FCSinheader == FCScalculated) { - // printf("(OK)\n"); + // fprintf (stderr, "(OK)\n"); //} else { - // printf("(NOT OK- Calculated FCS = %04X)\n", FCScalculated); + // fprintf (stderr, "(NOT OK- Calculated FCS = %04X)\n", FCScalculated); //}; // end else - if } diff --git a/src/nxdn96.c b/src/nxdn96.c index 4072b76..ab532e1 100644 --- a/src/nxdn96.c +++ b/src/nxdn96.c @@ -11,11 +11,11 @@ processNXDN96 (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { - printf ("VOICE e:"); + fprintf (stderr, "VOICE e:"); } #ifdef NXDN_DUMP - printf ("\n"); + fprintf (stderr, "\n"); #endif for (k = 0; k < 4; k++) @@ -24,11 +24,11 @@ processNXDN96 (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef NXDN_DUMP - printf ("%c", dibit + 48); + fprintf (stderr, "%c", dibit + 48); #endif } #ifdef NXDN_DUMP - printf (" "); + fprintf (stderr, " "); #endif if (k < 3) @@ -43,7 +43,7 @@ processNXDN96 (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef NXDN_DUMP - printf ("%c", dibit + 48); + fprintf (stderr, "%c", dibit + 48); #endif ambe_fr[*w][*x] = (1 & (dibit >> 1)); // bit 1 ambe_fr[*y][*z] = (1 & dibit); // bit 0 @@ -54,7 +54,7 @@ processNXDN96 (dsd_opts * opts, dsd_state * state) } processMbeFrame (opts, state, NULL, ambe_fr, NULL); #ifdef NXDN_DUMP - printf (" "); + fprintf (stderr, " "); #endif } } @@ -70,7 +70,7 @@ processNXDN96 (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef NXDN_DUMP - printf ("%c", dibit + 48); + fprintf (stderr, "%c", dibit + 48); #endif ambe_fr[*w][*x] = (1 & (dibit >> 1)); // bit 1 ambe_fr[*y][*z] = (1 & dibit); // bit 0 @@ -81,7 +81,7 @@ processNXDN96 (dsd_opts * opts, dsd_state * state) } processMbeFrame (opts, state, NULL, ambe_fr, NULL); #ifdef NXDN_DUMP - printf (" "); + fprintf (stderr, " "); #endif } } @@ -92,11 +92,11 @@ processNXDN96 (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef NXDN_DUMP - printf ("%c", dibit + 48); + fprintf (stderr, "%c", dibit + 48); #endif } #ifdef NXDN_DUMP - printf (" "); + fprintf (stderr, " "); #endif } @@ -106,14 +106,14 @@ processNXDN96 (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef NXDN_DUMP - printf ("%c", dibit + 48); + fprintf (stderr, "%c", dibit + 48); #endif } } } #ifdef NXDN_DUMP - printf ("\n"); + fprintf (stderr, "\n"); #endif if (opts->errorbars == 1) diff --git a/src/nxdn_data.c b/src/nxdn_data.c index 403fe7a..7eb3cbe 100644 --- a/src/nxdn_data.c +++ b/src/nxdn_data.c @@ -7,30 +7,30 @@ processNXDNData (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { - printf ("DATA "); + fprintf (stderr, "DATA "); } for (i = 0; i < 30; i++) { dibit = getDibit (opts, state); #ifdef NXDN_DUMP - printf ("%c", dibit + 48); + fprintf (stderr, "%c", dibit + 48); #endif } #ifdef NXDN_DUMP - printf (" "); + fprintf (stderr, " "); #endif for (i = 0; i < 144; i++) { dibit = getDibit (opts, state); #ifdef NXDN_DUMP - printf ("%c", dibit + 48); + fprintf (stderr, "%c", dibit + 48); #endif } if (opts->errorbars == 1) { - printf ("\n"); + fprintf (stderr, "\n"); } } diff --git a/src/nxdn_voice.c b/src/nxdn_voice.c index 2f001fc..7ef59d2 100644 --- a/src/nxdn_voice.c +++ b/src/nxdn_voice.c @@ -11,18 +11,18 @@ processNXDNVoice (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { - printf ("VOICE e:"); + fprintf (stderr,"VOICE e:"); } for (i = 0; i < 30; i++) { dibit = getDibit (opts, state); #ifdef NXDN_DUMP - printf ("%c", dibit + 48); + fprintf (stderr,"%c", dibit + 48); #endif } #ifdef NXDN_DUMP - printf (" "); + fprintf (stderr," "); #endif pr = nxdnpr; @@ -36,7 +36,7 @@ processNXDNVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef NXDN_DUMP - printf ("%c", dibit + 48); + fprintf (stderr,"%c", dibit + 48); #endif ambe_fr[*w][*x] = *pr ^ (1 & (dibit >> 1)); // bit 1 pr++; @@ -48,12 +48,12 @@ processNXDNVoice (dsd_opts * opts, dsd_state * state) } processMbeFrame (opts, state, NULL, ambe_fr, NULL); #ifdef NXDN_DUMP - printf (" "); + fprintf (stderr," "); #endif } if (opts->errorbars == 1) { - printf ("\n"); + fprintf (stderr,"\n"); } } diff --git a/src/p25_lcw.c b/src/p25_lcw.c index 392d11e..43601b3 100644 --- a/src/p25_lcw.c +++ b/src/p25_lcw.c @@ -12,10 +12,10 @@ processP25lcw (dsd_opts * opts, dsd_state * state, char *lcformat, char *mfid, c if (opts->p25lc == 1) { - printf ("lcformat: %s mfid: %s lcinfo: %s ", lcformat, mfid, lcinfo); + fprintf (stderr, "lcformat: %s mfid: %s lcinfo: %s ", lcformat, mfid, lcinfo); if (opts->p25tg == 0) { - printf ("\n"); + fprintf (stderr, "\n"); } } @@ -46,12 +46,12 @@ processP25lcw (dsd_opts * opts, dsd_state * state, char *lcformat, char *mfid, c } if (opts->p25tg == 1) { - printf ("tg: %li ", talkgroup); + fprintf (stderr, "tg: %li ", talkgroup); } if (opts->p25tg == 1) { - printf ("tg: %li ", talkgroup); + fprintf (stderr, "tg: %li ", talkgroup); // the remaining 3 appear to be other active tg's on the system j = 0; @@ -66,7 +66,7 @@ processP25lcw (dsd_opts * opts, dsd_state * state, char *lcformat, char *mfid, c tmpstr[15] = 48; tmpstr[16] = 0; talkgroup = strtol (tmpstr, NULL, 2); - printf ("%li ", talkgroup); + fprintf (stderr, "%li ", talkgroup); j = 0; for (i = 16; i < 28; i++) { @@ -79,7 +79,7 @@ processP25lcw (dsd_opts * opts, dsd_state * state, char *lcformat, char *mfid, c tmpstr[15] = 48; tmpstr[16] = 0; talkgroup = strtol (tmpstr, NULL, 2); - printf ("%li ", talkgroup); + fprintf (stderr, "%li ", talkgroup); j = 0; for (i = 4; i < 16; i++) { @@ -92,7 +92,7 @@ processP25lcw (dsd_opts * opts, dsd_state * state, char *lcformat, char *mfid, c tmpstr[15] = 48; tmpstr[16] = 0; talkgroup = strtol (tmpstr, NULL, 2); - printf ("%li\n", talkgroup); + fprintf (stderr, "%li\n", talkgroup); } } @@ -136,7 +136,7 @@ processP25lcw (dsd_opts * opts, dsd_state * state, char *lcformat, char *mfid, c } if (opts->p25tg == 1) { - printf ("tg: %li ", talkgroup); + fprintf (stderr, "tg: %li ", talkgroup); } j = 0; @@ -150,11 +150,11 @@ processP25lcw (dsd_opts * opts, dsd_state * state, char *lcformat, char *mfid, c state->lastsrc = source; if (opts->p25tg == 1) { - printf ("src: %li emr: %c\n", source, lcinfo[0]); + fprintf (stderr, "src: %li emr: %c\n", source, lcinfo[0]); } } else if ((opts->p25tg == 1) && (opts->p25lc == 1)) { - printf ("\n"); + fprintf (stderr, "\n"); } } diff --git a/src/p25p1_check_hdu.cpp b/src/p25p1_check_hdu.cpp index cf81289..2b71976 100644 --- a/src/p25p1_check_hdu.cpp +++ b/src/p25p1_check_hdu.cpp @@ -16,31 +16,31 @@ static DSDReedSolomon_36_20_17 reed_solomon_36_20_17; int check_and_fix_golay_24_6(char* hex, char* parity, int* fixed_errors) { #ifdef CHECK_HDU_DEBUG - printf("["); + fprintf (stderr, "["); for(unsigned int i=0; i<6; i++) { - printf("%c", (hex[i] != 0)? 'X': ' '); + fprintf (stderr, "%c", (hex[i] != 0)? 'X': ' '); } - printf("] ["); + fprintf (stderr, "] ["); for(unsigned int i=12; i<24; i++) { - printf("%c", (parity[i-12] != 0)? 'X': ' '); + fprintf (stderr, "%c", (parity[i-12] != 0)? 'X': ' '); } - printf("]"); + fprintf (stderr, "]"); #endif int irrecoverable_errors = golay24.decode_6(hex, parity, fixed_errors); #ifdef CHECK_HDU_DEBUG - printf(" -> ["); + fprintf (stderr, " -> ["); for(unsigned int i=0; i<6; i++) { - printf("%c", (hex[i] != 0)? 'X': ' '); + fprintf (stderr, "%c", (hex[i] != 0)? 'X': ' '); } - printf("]"); + fprintf (stderr, "]"); if (irrecoverable_errors) { - printf(" Errors: >4"); + fprintf (stderr, " Errors: >4"); } else { - printf(" Errors: %i", *fixed_errors); + fprintf (stderr, " Errors: %i", *fixed_errors); } - printf("\n"); + fprintf (stderr, "\n"); #endif return irrecoverable_errors; @@ -49,31 +49,31 @@ int check_and_fix_golay_24_6(char* hex, char* parity, int* fixed_errors) int check_and_fix_golay_24_12(char* dodeca, char* parity, int* fixed_errors) { #ifdef CHECK_HDU_DEBUG - printf("["); + fprintf (stderr, "["); for(unsigned int i=0; i<12; i++) { - printf("%c", (dodeca[i] != 0)? 'X': ' '); + fprintf (stderr, "%c", (dodeca[i] != 0)? 'X': ' '); } - printf("] ["); + fprintf (stderr, "] ["); for(unsigned int i=12; i<24; i++) { - printf("%c", (parity[i-12] != 0)? 'X': ' '); + fprintf (stderr, "%c", (parity[i-12] != 0)? 'X': ' '); } - printf("]"); + fprintf (stderr, "]"); #endif int irrecoverable_errors = golay24.decode_12(dodeca, parity, fixed_errors); #ifdef CHECK_HDU_DEBUG - printf(" -> ["); + fprintf (stderr, " -> ["); for(unsigned int i=0; i<12; i++) { - printf("%c", (dodeca[i] != 0)? 'X': ' '); + fprintf (stderr, "%c", (dodeca[i] != 0)? 'X': ' '); } - printf("]"); + fprintf (stderr, "]"); if (irrecoverable_errors) { - printf(" Errors: >4"); + fprintf (stderr, " Errors: >4"); } else { - printf(" Errors: %i", *fixed_errors); + fprintf (stderr, " Errors: %i", *fixed_errors); } - printf("\n"); + fprintf (stderr, "\n"); #endif return irrecoverable_errors; @@ -104,32 +104,32 @@ int check_and_fix_redsolomon_36_20_17(char* data, char* parity) int irrecoverable_errors = reed_solomon_36_20_17.decode(data, parity); #ifdef CHECK_HDU_DEBUG - printf("Results for Reed-Solomon code (36,20,17)\n\n"); + fprintf (stderr, "Results for Reed-Solomon code (36,20,17)\n\n"); if (irrecoverable_errors == 0) { - printf(" i original fixed\n"); + fprintf (stderr, " i original fixed\n"); for (int i = 0; i < 20; i++) { - printf("%3d [", i); + fprintf (stderr, "%3d [", i); for (int j = 0; j < 6; j++) { - printf("%c", (original[i][j] == 1)? 'X' : ' '); + fprintf (stderr, "%c", (original[i][j] == 1)? 'X' : ' '); } - printf("] ["); + fprintf (stderr, "] ["); for (int j = 0; j < 6; j++) { - printf("%c", (data[i*6+j] == 1)? 'X' : ' '); + fprintf (stderr, "%c", (data[i*6+j] == 1)? 'X' : ' '); } - printf("]\n"); + fprintf (stderr, "]\n"); } } else { - printf("Irrecoverable errors found\n"); - printf(" i original fixed\n"); + fprintf (stderr, "Irrecoverable errors found\n"); + fprintf (stderr, " i original fixed\n"); for (int i = 0; i < 20; i++) { - printf("%3d [", i); + fprintf (stderr, "%3d [", i); for (int j = 0; j < 6; j++) { - printf("%c", (original[i][j] == 1)? 'X' : ' '); + fprintf (stderr, "%c", (original[i][j] == 1)? 'X' : ' '); } - printf("]\n"); + fprintf (stderr, "]\n"); } } - printf("\n"); + fprintf (stderr, "\n"); #endif return irrecoverable_errors; @@ -139,4 +139,3 @@ void encode_reedsolomon_36_20_17(char* hex_data, char* fixed_parity) { reed_solomon_36_20_17.encode(hex_data, fixed_parity); } - diff --git a/src/p25p1_check_ldu.cpp b/src/p25p1_check_ldu.cpp index 15efdd3..cb198a9 100644 --- a/src/p25p1_check_ldu.cpp +++ b/src/p25p1_check_ldu.cpp @@ -38,32 +38,32 @@ int check_and_fix_reedsolomon_24_12_13(char* data, char* parity) int irrecoverable_error = reed_solomon_24_12_13.decode(data, parity); #ifdef CHECK_LDU_DEBUG - printf("Results for Reed-Solomon code (24,12,13)\n\n"); + fprintf (stderr, "Results for Reed-Solomon code (24,12,13)\n\n"); if (irrecoverable_error == 0) { - printf(" i original fixed\n"); + fprintf (stderr, " i original fixed\n"); for (int i = 0; i < 12; i++) { - printf("%3d [", i); + fprintf (stderr, "%3d [", i); for (int j = 0; j < 6; j++) { - printf("%c", (original[i][j] == 1)? 'X' : ' '); + fprintf (stderr, "%c", (original[i][j] == 1)? 'X' : ' '); } - printf("] ["); + fprintf (stderr, "] ["); for (int j = 0; j < 6; j++) { - printf("%c", (data[i*6+j] == 1)? 'X' : ' '); + fprintf (stderr, "%c", (data[i*6+j] == 1)? 'X' : ' '); } - printf("]\n"); + fprintf (stderr, "]\n"); } } else { - printf("Irrecoverable errors found\n"); - printf(" i original fixed\n"); + fprintf (stderr, "Irrecoverable errors found\n"); + fprintf (stderr, " i original fixed\n"); for (int i = 0; i < 12; i++) { - printf("%3d [", i); + fprintf (stderr, "%3d [", i); for (int j = 0; j < 6; j++) { - printf("%c", (original[i][j] == 1)? 'X' : ' '); + fprintf (stderr, "%c", (original[i][j] == 1)? 'X' : ' '); } - printf("]\n"); + fprintf (stderr, "]\n"); } } - printf("\n"); + fprintf (stderr, "\n"); #endif return irrecoverable_error; @@ -88,32 +88,32 @@ int check_and_fix_reedsolomon_24_16_9(char* data, char* parity) int irrecoverable_error = reed_solomon_24_16_9.decode(data, parity); #ifdef CHECK_LDU_DEBUG - printf("Results for Reed-Solomon code (24,16,9)\n\n"); + fprintf (stderr, "Results for Reed-Solomon code (24,16,9)\n\n"); if (irrecoverable_error == 0) { - printf(" i original fixed\n"); + fprintf (stderr, " i original fixed\n"); for (int i = 0; i < 16; i++) { - printf("%3d [", i); + fprintf (stderr, "%3d [", i); for (int j = 0; j < 6; j++) { - printf("%c", (original[i][j] == 1)? 'X' : ' '); + fprintf (stderr, "%c", (original[i][j] == 1)? 'X' : ' '); } - printf("] ["); + fprintf (stderr, "] ["); for (int j = 0; j < 6; j++) { - printf("%c", (data[i*6+j] == 1)? 'X' : ' '); + fprintf (stderr, "%c", (data[i*6+j] == 1)? 'X' : ' '); } - printf("]\n"); + fprintf (stderr, "]\n"); } } else { - printf("Irrecoverable errors found\n"); - printf(" i original fixed\n"); + fprintf (stderr, "Irrecoverable errors found\n"); + fprintf (stderr, " i original fixed\n"); for (int i = 0; i < 16; i++) { - printf("%3d [", i); + fprintf (stderr, "%3d [", i); for (int j = 0; j < 6; j++) { - printf("%c", (original[i][j] == 1)? 'X' : ' '); + fprintf (stderr, "%c", (original[i][j] == 1)? 'X' : ' '); } - printf("]\n"); + fprintf (stderr, "]\n"); } } - printf("\n"); + fprintf (stderr, "\n"); #endif return irrecoverable_error; diff --git a/src/p25p1_check_nid.cpp b/src/p25p1_check_nid.cpp index 668471d..33b01cc 100644 --- a/src/p25p1_check_nid.cpp +++ b/src/p25p1_check_nid.cpp @@ -83,7 +83,7 @@ int check_NID(char* bch_code, int* new_nac, char* new_duid, unsigned char parity if (expected_parity != parity) { // Ignore, not sure what to do - //printf("Error in parity detected?"); + //fprintf (stderr, "Error in parity detected?"); } result = 1; diff --git a/src/p25p1_hdu.c b/src/p25p1_hdu.c index bf0135e..bf2d9e2 100644 --- a/src/p25p1_hdu.c +++ b/src/p25p1_hdu.c @@ -177,7 +177,7 @@ correct_golay_dibits_6(char* corrected_hex_data, int hex_count, AnalogSignal* an #ifdef HEURISTICS_DEBUG if (analog_signal_array[analog_signal_index].dibit != dibit) { - printf("HDU data word corrected from %i to %i, analog value %i\n", + fprintf (stderr, "HDU data word corrected from %i to %i, analog value %i\n", analog_signal_array[analog_signal_index].dibit, dibit, analog_signal_array[analog_signal_index].value); } #endif @@ -199,7 +199,7 @@ correct_golay_dibits_6(char* corrected_hex_data, int hex_count, AnalogSignal* an #ifdef HEURISTICS_DEBUG if (analog_signal_array[analog_signal_index].dibit != dibit) { - printf("HDU parity corrected from %i to %i, analog value %i\n", + fprintf (stderr, "HDU parity corrected from %i to %i, analog value %i\n", analog_signal_array[analog_signal_index].dibit, dibit, analog_signal_array[analog_signal_index].value); } #endif @@ -457,14 +457,14 @@ processHDU(dsd_opts* opts, dsd_state* state) { algidhex = strtol (algid, NULL, 2); kidhex = strtol (kid, NULL, 2); - printf ("mi: %s algid: $%x kid: $%x\n", mi, algidhex, kidhex); + fprintf (stderr, "mi: %s algid: $%x kid: $%x\n", mi, algidhex, kidhex); } if (opts->p25lc == 1) { - printf ("mfid: %s tgid: %s ", mfid, tgid); + fprintf (stderr, "mfid: %s tgid: %s ", mfid, tgid); if (opts->p25tg == 0) { - printf ("\n"); + fprintf (stderr, "\n"); } } @@ -506,6 +506,6 @@ processHDU(dsd_opts* opts, dsd_state* state) } if (opts->p25tg == 1) { - printf ("tg: %li\n", talkgroup); + fprintf (stderr, "tg: %li\n", talkgroup); } } diff --git a/src/p25p1_heuristics.c b/src/p25p1_heuristics.c index 88c4e3d..688c196 100644 --- a/src/p25p1_heuristics.c +++ b/src/p25p1_heuristics.c @@ -249,7 +249,7 @@ static void debug_log_pdf(P25Heuristics* heuristics, int previous_dibit, int ana pdfs[i] = evaluate_pdf(&(heuristics->symbols[previous_dibit][i]), analog_value); } - printf("v: %i, (%e, %e, %e, %e)\n", analog_value, pdfs[0], pdfs[1], pdfs[2], pdfs[3]); + fprintf (stderr, "v: %i, (%e, %e, %e, %e)\n", analog_value, pdfs[0], pdfs[1], pdfs[2], pdfs[3]); } int estimate_symbol(int rf_mod, P25Heuristics* heuristics, int previous_dibit, int analog_value, int* dibit) @@ -329,20 +329,20 @@ static void debug_print_symbol_heuristics(int previous_dibit, int dibit, SymbolH mean = sh->sum/n; sd = sqrtf(sh->var_sum / ((float) n)); } - printf("%i%i: count: %2i mean: % 10.2f sd: % 10.2f", previous_dibit, dibit, sh->count, mean, sd); + fprintf (stderr, "%i%i: count: %2i mean: % 10.2f sd: % 10.2f", previous_dibit, dibit, sh->count, mean, sd); /* - printf("("); + fprintf (stderr, "("); for (k=0; kvalues[k]); + fprintf (stderr, "%i", sh->values[k]); } - printf(")"); + fprintf (stderr, ")"); */ - printf("\n"); + fprintf (stderr, "\n"); } @@ -350,7 +350,7 @@ void debug_print_heuristics(P25Heuristics* heuristics) { int i,j; - printf("\n"); + fprintf (stderr, "\n"); for(i=0; i<4; i++) { diff --git a/src/p25p1_ldu.c b/src/p25p1_ldu.c index c7dc85b..4c83b38 100644 --- a/src/p25p1_ldu.c +++ b/src/p25p1_ldu.c @@ -28,37 +28,37 @@ static void debug_log_imbe(char imbe_fr[8][23]) { int i, j; - printf(" "); + fprintf (stderr, " "); for (j=0; j<4; j++) { - printf("{"); + fprintf (stderr, "{"); for (i=0; i<23; i++) { if (i>0) { - printf(", "); + fprintf (stderr, ", "); } - printf("%c", (imbe_fr[j][i] + '0')); + fprintf (stderr, "%c", (imbe_fr[j][i] + '0')); } - printf("}; "); + fprintf (stderr, "}; "); } for (j=4; j<7; j++) { - printf("{"); + fprintf (stderr, "{"); for (i=0; i<15; i++) { if (i>0) { - printf(", "); + fprintf (stderr, ", "); } - printf("%c", (imbe_fr[j][i] + '0')); + fprintf (stderr, "%c", (imbe_fr[j][i] + '0')); } - printf("}; "); + fprintf (stderr, "}; "); } - printf("\n"); + fprintf (stderr, "\n"); } void @@ -137,7 +137,7 @@ process_IMBE (dsd_opts* opts, dsd_state* state, int* status_count) if (match) { // Skip this particular value. If we let it pass it will be signaled as an erroneus IMBE - printf("(Non-standard IMBE c0 detected, skipped)"); + fprintf (stderr, "(Non-standard IMBE c0 detected, skipped)"); } else { processMbeFrame (opts, state, imbe_fr, NULL, NULL); } @@ -161,17 +161,17 @@ read_and_correct_hex_word (dsd_opts* opts, dsd_state* state, char* hex, int* sta read_hamm_parity (opts, state, parity, status_count, analog_signal_array, analog_signal_index); #ifdef LDU_DEBUG - printf("["); + fprintf (stderr, "["); for (i = 0; i < 6; i++) { - printf("%c", (hex[i] == 1)? 'X' : ' '); + fprintf (stderr, "%c", (hex[i] == 1)? 'X' : ' '); } - printf("-"); + fprintf (stderr, "-"); for (i = 0; i < 4; i++) { - printf("%c", (parity[i] == 1)? 'X' : ' '); + fprintf (stderr, "%c", (parity[i] == 1)? 'X' : ' '); } - printf("]"); + fprintf (stderr, "]"); #endif // Use Hamming to error correct the hex word @@ -187,21 +187,21 @@ read_and_correct_hex_word (dsd_opts* opts, dsd_state* state, char* hex, int* sta } #ifdef LDU_DEBUG - printf(" -> ["); + fprintf (stderr, " -> ["); for (i = 0; i < 6; i++) { - printf("%c", (hex[i] == 1)? 'X' : ' '); + fprintf (stderr, "%c", (hex[i] == 1)? 'X' : ' '); } - printf("]"); + fprintf (stderr, "]"); if (error_count == 1) { - printf(" fixed!"); + fprintf (stderr, " fixed!"); } else if (error_count ==2) { - printf(" IRRECOVERABLE"); + fprintf (stderr, " IRRECOVERABLE"); } - printf("\n"); + fprintf (stderr, "\n"); #endif } @@ -226,7 +226,7 @@ correct_hamming_dibits(char* data, int count, AnalogSignal* analog_signal_array) #ifdef HEURISTICS_DEBUG if (analog_signal_array[analog_signal_index].dibit != dibit) { - printf("LDU word corrected from %i to %i, analog value %i\n", + fprintf (stderr, "LDU word corrected from %i to %i, analog value %i\n", analog_signal_array[analog_signal_index].dibit, dibit, analog_signal_array[analog_signal_index].value); } #endif @@ -246,7 +246,7 @@ correct_hamming_dibits(char* data, int count, AnalogSignal* analog_signal_array) #ifdef HEURISTICS_DEBUG if (analog_signal_array[analog_signal_index].dibit != dibit) { - printf("LDU-HM parity corrected from %i to %i, analog value %i\n", + fprintf (stderr, "LDU-HM parity corrected from %i to %i, analog value %i\n", analog_signal_array[analog_signal_index].dibit, dibit, analog_signal_array[analog_signal_index].value); } #endif @@ -261,9 +261,8 @@ debug_ldu_header(dsd_state* state) { #ifdef TRACE_DSD float s = state->debug_sample_index / 48000.0F; - printf("Start of LDU at sample %f\n", s); + fprintf (stderr, "Start of LDU at sample %f\n", s); #endif debug_print_heuristics(&state->p25_heuristics); } - diff --git a/src/p25p1_ldu1.c b/src/p25p1_ldu1.c index fcafbfd..afe15eb 100644 --- a/src/p25p1_ldu1.c +++ b/src/p25p1_ldu1.c @@ -51,7 +51,7 @@ processLDU1 (dsd_opts* opts, dsd_state* state) if (opts->errorbars == 1) { - printf ("e:"); + fprintf (stderr, "e:"); } // IMBE 1 @@ -187,12 +187,12 @@ processLDU1 (dsd_opts* opts, dsd_state* state) if (opts->errorbars == 1) { - printf ("\n"); + fprintf (stderr, "\n"); } if (opts->p25status == 1) { - printf ("lsd1: %s lsd2: %s\n", lsd1, lsd2); + fprintf (stderr, "lsd1: %s lsd2: %s\n", lsd1, lsd2); } // trailing status symbol @@ -234,7 +234,7 @@ processLDU1 (dsd_opts* opts, dsd_state* state) } #ifdef HEURISTICS_DEBUG - printf("(audio errors, header errors, critical header errors) (%i,%i,%i)\n", + fprintf (stderr, "(audio errors, header errors, critical header errors) (%i,%i,%i)\n", state->debug_audio_errors, state->debug_header_errors, state->debug_header_critical_errors); #endif diff --git a/src/p25p1_ldu2.c b/src/p25p1_ldu2.c index 238993f..ee631dd 100644 --- a/src/p25p1_ldu2.c +++ b/src/p25p1_ldu2.c @@ -52,7 +52,7 @@ processLDU2 (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { - printf ("e:"); + fprintf (stderr, "e:"); } // IMBE 1 @@ -188,12 +188,12 @@ processLDU2 (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { - printf ("\n"); + fprintf (stderr, "\n"); } if (opts->p25status == 1) { - printf ("lsd1: %s lsd2: %s\n", lsd1, lsd2); + fprintf (stderr, "lsd1: %s lsd2: %s\n", lsd1, lsd2); } // trailing status symbol @@ -236,7 +236,7 @@ processLDU2 (dsd_opts * opts, dsd_state * state) #ifdef HEURISTICS_DEBUG - printf("(audio errors, header errors, critical header errors) (%i,%i,%i)\n", + fprintf (stderr, "(audio errors, header errors, critical header errors) (%i,%i,%i)\n", state->debug_audio_errors, state->debug_header_errors, state->debug_header_critical_errors); #endif @@ -365,6 +365,6 @@ processLDU2 (dsd_opts * opts, dsd_state * state) { algidhex = strtol (algid, NULL, 2); kidhex = strtol (kid, NULL, 2); - printf ("mi: %s algid: $%x kid: $%x\n", mi, algidhex, kidhex); + fprintf (stderr, "mi: %s algid: $%x kid: $%x\n", mi, algidhex, kidhex); } } diff --git a/src/p25p1_tdu.c b/src/p25p1_tdu.c index 2401910..4f4e501 100644 --- a/src/p25p1_tdu.c +++ b/src/p25p1_tdu.c @@ -22,7 +22,7 @@ processTDU (dsd_opts* opts, dsd_state* state) // Next we should find an status dibit if (status_count != 35) { - printf("*** SYNC ERROR\n"); + fprintf (stderr, "*** SYNC ERROR\n"); } // trailing status symbol diff --git a/src/p25p1_tdulc.c b/src/p25p1_tdulc.c index 74b4fdc..181f6b3 100644 --- a/src/p25p1_tdulc.c +++ b/src/p25p1_tdulc.c @@ -76,17 +76,17 @@ read_and_correct_dodeca_word (dsd_opts* opts, dsd_state* state, char* dodeca, in read_golay24_parity (opts, state, parity, status_count, analog_signal_array, analog_signal_index); #ifdef TDULC_DEBUG - printf("["); + fprintf (stderr, "["); for (i = 0; i < 12; i++) { - printf("%c", (dodeca[i] == 1)? 'X' : ' '); + fprintf (stderr, "%c", (dodeca[i] == 1)? 'X' : ' '); } - printf("-"); + fprintf (stderr, "-"); for (i = 0; i < 12; i++) { - printf("%c", (parity[i] == 1)? 'X' : ' '); + fprintf (stderr, "%c", (parity[i] == 1)? 'X' : ' '); } - printf("]"); + fprintf (stderr, "]"); #endif // Use extended golay to error correct the dodeca word @@ -99,24 +99,24 @@ read_and_correct_dodeca_word (dsd_opts* opts, dsd_state* state, char* dodeca, in } #ifdef TDULC_DEBUG - printf(" -> ["); + fprintf (stderr, " -> ["); for (i = 0; i < 12; i++) { - printf("%c", (dodeca[i] == 1)? 'X' : ' '); + fprintf (stderr, "%c", (dodeca[i] == 1)? 'X' : ' '); } - printf("]"); + fprintf (stderr, "]"); if (irrecoverable_errors == 0) { if (fixed_errors > 0) { - printf(" fixed!"); + fprintf (stderr, " fixed!"); } } else { - printf(" IRRECOVERABLE"); + fprintf (stderr, " IRRECOVERABLE"); } - printf("\n"); + fprintf (stderr, "\n"); #endif } @@ -148,7 +148,7 @@ correct_golay_dibits_12(char* data, int count, AnalogSignal* analog_signal_array #ifdef HEURISTICS_DEBUG if (analog_signal_array[analog_signal_index].dibit != dibit) { - printf("TDULC data word corrected from %i to %i, analog value %i\n", + fprintf (stderr, "TDULC data word corrected from %i to %i, analog value %i\n", analog_signal_array[analog_signal_index].dibit, dibit, analog_signal_array[analog_signal_index].value); } #endif @@ -167,7 +167,7 @@ correct_golay_dibits_12(char* data, int count, AnalogSignal* analog_signal_array #ifdef HEURISTICS_DEBUG if (analog_signal_array[analog_signal_index].dibit != dibit) { - printf("TDULC parity corrected from %i to %i, analog value %i\n", + fprintf (stderr, "TDULC parity corrected from %i to %i, analog value %i\n", analog_signal_array[analog_signal_index].dibit, dibit, analog_signal_array[analog_signal_index].value); } #endif @@ -200,7 +200,7 @@ read_zeros(dsd_opts* opts, dsd_state* state, AnalogSignal* analog_signal_array, #ifdef HEURISTICS_DEBUG if (analog_signal_array[i].corrected_dibit != analog_signal_array[i].dibit) { - printf("TDULC ending zeros corrected from %i to %i, analog value %i\n", + fprintf (stderr, "TDULC ending zeros corrected from %i to %i, analog value %i\n", analog_signal_array[i].dibit, 0, analog_signal_array[i].value); } #endif @@ -293,7 +293,7 @@ processTDULC (dsd_opts* opts, dsd_state* state) // Next we should find an status dibit if (status_count != 35) { - printf("*** SYNC ERROR\n"); + fprintf (stderr, "*** SYNC ERROR\n"); } // trailing status symbol diff --git a/src/pa_devs.c b/src/pa_devs.c index f627c41..ca504cc 100644 --- a/src/pa_devs.c +++ b/src/pa_devs.c @@ -17,54 +17,54 @@ void printPortAudioDevices() Pa_Initialize(); - printf( "\nPortAudio version number = %d\nPortAudio version text = '%s'\n", + fprintf (stderr, "\nPortAudio version number = %d\nPortAudio version text = '%s'\n", Pa_GetVersion(), Pa_GetVersionText() ); numDevices = Pa_GetDeviceCount(); if( numDevices < 0 ) { - printf( "ERROR: Pa_GetDeviceCount returned 0x%x\n", numDevices ); + fprintf (stderr, "ERROR: Pa_GetDeviceCount returned 0x%x\n", numDevices ); err = numDevices; goto error; } - printf( "Number of devices = %d\n", numDevices ); + fprintf (stderr, "Number of devices = %d\n", numDevices ); for( i=0; ihostApi )->defaultInputDevice ) { const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo( deviceInfo->hostApi ); - printf( "[ Default %s Input", hostInfo->name ); + fprintf (stderr, "[ Default %s Input", hostInfo->name ); defaultDisplayed = 1; } if( i == Pa_GetDefaultOutputDevice() ) { - printf( (defaultDisplayed ? "," : "[") ); - printf( " Default Output" ); + fprintf (stderr, (defaultDisplayed ? "," : "[") ); + fprintf (stderr, " Default Output" ); defaultDisplayed = 1; } else if( i == Pa_GetHostApiInfo( deviceInfo->hostApi )->defaultOutputDevice ) { const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo( deviceInfo->hostApi ); - printf( (defaultDisplayed ? "," : "[") ); - printf( " Default %s Output", hostInfo->name ); + fprintf (stderr, (defaultDisplayed ? "," : "[") ); + fprintf (stderr, " Default %s Output", hostInfo->name ); defaultDisplayed = 1; } if( defaultDisplayed ) - printf( " ]\n" ); + fprintf (stderr, " ]\n" ); /* print device info fields */ #ifdef WIN32 @@ -74,17 +74,17 @@ void printPortAudioDevices() wprintf( L"Name = %s\n", wideName ); } #else - printf( "Name = %s\n", deviceInfo->name ); + fprintf (stderr, "Name = %s\n", deviceInfo->name ); #endif - printf( "Host API = %s\n", Pa_GetHostApiInfo( deviceInfo->hostApi )->name ); - printf( "Max inputs = %d", deviceInfo->maxInputChannels ); - printf( ", Max outputs = %d\n", deviceInfo->maxOutputChannels ); - printf( "Default sample rate = %8.2f\n", deviceInfo->defaultSampleRate ); + fprintf (stderr, "Host API = %s\n", Pa_GetHostApiInfo( deviceInfo->hostApi )->name ); + fprintf (stderr, "Max inputs = %d", deviceInfo->maxInputChannels ); + fprintf (stderr, ", Max outputs = %d\n", deviceInfo->maxOutputChannels ); + fprintf (stderr, "Default sample rate = %8.2f\n", deviceInfo->defaultSampleRate ); } Pa_Terminate(); - printf("----------------------------------------------\n"); + fprintf (stderr,"----------------------------------------------\n"); return; error: @@ -98,7 +98,7 @@ error: void printPortAudioDevices() { - printf("PortAudio not supported in this build of dsd\n"); + fprintf (stderr,"PortAudio not supported in this build of dsd\n"); } #endif diff --git a/src/provoice.c b/src/provoice.c index c114197..4c26850 100644 --- a/src/provoice.c +++ b/src/provoice.c @@ -14,19 +14,19 @@ processProVoice (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { //strftime (datestr, 31, "%Y-%m-%d-%H%M%S", &timep); - //printf ("%s VOICE e:", datestr); - printf ("VOICE e:"); + //fprintf (stderr,"%s VOICE e:", datestr); + fprintf (stderr,"VOICE e:"); } for (i = 0; i < 64; i++) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif } #ifdef PROVOICE_DUMP - printf (" "); + fprintf (stderr," "); #endif // lid @@ -34,22 +34,22 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif } #ifdef PROVOICE_DUMP - printf (" "); + fprintf (stderr," "); #endif for (i = 0; i < 64; i++) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif } #ifdef PROVOICE_DUMP - printf (" "); + fprintf (stderr," "); #endif // imbe frames 1,2 first half @@ -62,14 +62,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - //printf ("%i", dibit); + //fprintf (stderr,"%i", dibit); #endif imbe7100_fr1[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - //printf ("_"); + //fprintf (stderr,"_"); #endif w -= 6; x -= 6; @@ -77,14 +77,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif imbe7100_fr2[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - printf ("_"); + fprintf (stderr,"_"); #endif } @@ -92,14 +92,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif imbe7100_fr1[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - printf ("_"); + fprintf (stderr,"_"); #endif w -= 6; x -= 6; @@ -107,25 +107,25 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif imbe7100_fr2[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - printf (" "); + fprintf (stderr," "); #endif // spacer bits dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); - printf (" "); + fprintf (stderr,"%i", dibit); + fprintf (stderr," "); #endif // imbe frames 1,2 second half @@ -134,14 +134,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif imbe7100_fr2[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - printf ("_"); + fprintf (stderr,"_"); #endif for (i = 0; i < 3; i++) @@ -150,14 +150,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif imbe7100_fr1[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - printf ("_"); + fprintf (stderr,"_"); #endif w -= 6; x -= 6; @@ -165,14 +165,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif imbe7100_fr2[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - printf ("_"); + fprintf (stderr,"_"); #endif } @@ -180,14 +180,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif imbe7100_fr1[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - printf ("_"); + fprintf (stderr,"_"); #endif w -= 5; x -= 5; @@ -195,14 +195,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif imbe7100_fr2[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - printf ("_"); + fprintf (stderr,"_"); #endif for (i = 0; i < 7; i++) @@ -211,14 +211,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - //printf ("%i", dibit); + //fprintf (stderr,"%i", dibit); #endif imbe7100_fr1[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - printf ("_"); + fprintf (stderr,"_"); #endif w -= 6; x -= 6; @@ -226,14 +226,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif imbe7100_fr2[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - printf ("_"); + fprintf (stderr,"_"); #endif } @@ -241,14 +241,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif imbe7100_fr1[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - printf ("_"); + fprintf (stderr,"_"); #endif w -= 5; x -= 5; @@ -256,14 +256,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif imbe7100_fr2[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - printf (" "); + fprintf (stderr," "); #endif processMbeFrame (opts, state, NULL, NULL, imbe7100_fr1); @@ -272,23 +272,23 @@ processProVoice (dsd_opts * opts, dsd_state * state) // spacer bits dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); - printf (" "); + fprintf (stderr,"%i", dibit); + fprintf (stderr," "); #endif for (i = 0; i < 16; i++) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif } #ifdef PROVOICE_DUMP - printf (" "); + fprintf (stderr," "); #endif // imbe frames 3,4 first half @@ -300,14 +300,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif imbe7100_fr1[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - printf ("_"); + fprintf (stderr,"_"); #endif w -= 6; x -= 6; @@ -315,28 +315,28 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif imbe7100_fr2[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - printf ("_"); + fprintf (stderr,"_"); #endif } for (j = 0; j < 6; j++) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif imbe7100_fr1[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - printf ("_"); + fprintf (stderr,"_"); #endif w -= 6; x -= 6; @@ -344,25 +344,25 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - printf ("%i", dibit); + fprintf (stderr,"%i", dibit); #endif imbe7100_fr2[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - printf (" "); + fprintf (stderr," "); #endif // spacer bits dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - //printf ("%i", dibit); + //fprintf (stderr,"%i", dibit); #endif dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - //printf ("%i", dibit); - //printf ("_"); + //fprintf (stderr,"%i", dibit); + //fprintf (stderr,"_"); #endif // imbe frames 3,4 second half @@ -370,14 +370,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - //printf ("%i", dibit); + //fprintf (stderr,"%i", dibit); #endif imbe7100_fr2[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - //printf ("_"); + //fprintf (stderr,"_"); #endif for (i = 0; i < 3; i++) { @@ -385,14 +385,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - //printf ("%i", dibit); + //fprintf (stderr,"%i", dibit); #endif imbe7100_fr1[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - //printf ("_"); + //fprintf (stderr,"_"); #endif w -= 6; x -= 6; @@ -400,14 +400,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - //printf ("%i", dibit); + //fprintf (stderr,"%i", dibit); #endif imbe7100_fr2[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - //printf ("_"); + //fprintf (stderr,"_"); #endif } @@ -415,14 +415,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - //printf ("%i", dibit); + //fprintf (stderr,"%i", dibit); #endif imbe7100_fr1[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - //printf ("_"); + //fprintf (stderr,"_"); #endif w -= 5; x -= 5; @@ -430,14 +430,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - //printf ("%i", dibit); + //fprintf (stderr,"%i", dibit); #endif imbe7100_fr2[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - //printf (" "); + //fprintf (stderr," "); #endif for (i = 0; i < 7; i++) @@ -446,14 +446,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - //printf ("%i", dibit); + //fprintf (stderr,"%i", dibit); #endif imbe7100_fr1[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - //printf ("_"); + //fprintf (stderr,"_"); #endif w -= 6; x -= 6; @@ -461,14 +461,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - //printf ("%i", dibit); + //fprintf (stderr,"%i", dibit); #endif imbe7100_fr2[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - //printf ("_"); + //fprintf (stderr,"_"); #endif } @@ -476,14 +476,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - //printf ("%i", dibit); + //fprintf (stderr,"%i", dibit); #endif imbe7100_fr1[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - //printf ("_"); + //fprintf (stderr,"_"); #endif w -= 5; x -= 5; @@ -491,14 +491,14 @@ processProVoice (dsd_opts * opts, dsd_state * state) { dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - //printf ("%i", dibit); + //fprintf (stderr,"%i", dibit); #endif imbe7100_fr2[*w][*x] = dibit; w++; x++; } #ifdef PROVOICE_DUMP - //printf (" "); + //fprintf (stderr," "); #endif processMbeFrame (opts, state, NULL, NULL, imbe7100_fr1); @@ -507,16 +507,16 @@ processProVoice (dsd_opts * opts, dsd_state * state) // spacer bits dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - //printf ("%i", dibit); + //fprintf (stderr,"%i", dibit); #endif dibit = getDibit (opts, state); #ifdef PROVOICE_DUMP - //printf ("%i", dibit); - //printf (" "); + //fprintf (stderr,"%i", dibit); + //fprintf (stderr," "); #endif if (opts->errorbars == 1) { - printf ("\n"); + fprintf (stderr,"\n"); } } diff --git a/src/rtl_sdr_fm.cpp b/src/rtl_sdr_fm.cpp index f90c809..a5989f4 100644 --- a/src/rtl_sdr_fm.cpp +++ b/src/rtl_sdr_fm.cpp @@ -602,7 +602,7 @@ int nearest_gain(rtlsdr_dev_t *dev, int target_gain) int* gains; r = rtlsdr_set_tuner_gain_mode(dev, 1); if (r < 0) { - fprintf(stderr, "WARNING: Failed to enable manual gain.\n"); + fprintf (stderr, "WARNING: Failed to enable manual gain.\n"); return r; } count = rtlsdr_get_tuner_gains(dev, NULL); @@ -628,10 +628,10 @@ int verbose_set_frequency(rtlsdr_dev_t *dev, uint32_t frequency) int r; r = rtlsdr_set_center_freq(dev, frequency); if (r < 0) { - fprintf(stderr, "WARNING: Failed to set center freq.\n"); + fprintf (stderr, "WARNING: Failed to set center freq.\n"); } else { - //fprintf(stderr, "Tuned to %u Hz.\n", frequency); - fprintf(stderr, "Tuned to center frequency %u Hz.\n", frequency); + //fprintf (stderr, "Tuned to %u Hz.\n", frequency); + fprintf (stderr, "Tuned to center frequency %u Hz.\n", frequency); } return r; } @@ -641,9 +641,9 @@ int verbose_set_sample_rate(rtlsdr_dev_t *dev, uint32_t samp_rate) int r; r = rtlsdr_set_sample_rate(dev, samp_rate); if (r < 0) { - fprintf(stderr, "WARNING: Failed to set sample rate.\n"); + fprintf (stderr, "WARNING: Failed to set sample rate.\n"); } else { - fprintf(stderr, "Sampling at %u S/s.\n", samp_rate); + fprintf (stderr, "Sampling at %u S/s.\n", samp_rate); } return r; } @@ -653,15 +653,15 @@ int verbose_direct_sampling(rtlsdr_dev_t *dev, int on) int r; r = rtlsdr_set_direct_sampling(dev, on); if (r != 0) { - fprintf(stderr, "WARNING: Failed to set direct sampling mode.\n"); + fprintf (stderr, "WARNING: Failed to set direct sampling mode.\n"); return r; } if (on == 0) { - fprintf(stderr, "Direct sampling mode disabled.\n");} + fprintf (stderr, "Direct sampling mode disabled.\n");} if (on == 1) { - fprintf(stderr, "Enabled direct sampling mode, input 1/I.\n");} + fprintf (stderr, "Enabled direct sampling mode, input 1/I.\n");} if (on == 2) { - fprintf(stderr, "Enabled direct sampling mode, input 2/Q.\n");} + fprintf (stderr, "Enabled direct sampling mode, input 2/Q.\n");} return r; } @@ -670,9 +670,9 @@ int verbose_offset_tuning(rtlsdr_dev_t *dev) int r; r = rtlsdr_set_offset_tuning(dev, 1); if (r != 0) { - fprintf(stderr, "WARNING: Failed to set offset tuning.\n"); + fprintf (stderr, "WARNING: Failed to set offset tuning.\n"); } else { - fprintf(stderr, "Offset tuning mode enabled.\n"); + fprintf (stderr, "Offset tuning mode enabled.\n"); } return r; } @@ -683,9 +683,9 @@ int verbose_auto_gain(rtlsdr_dev_t *dev) int r; r = rtlsdr_set_tuner_gain_mode(dev, 0); if (r != 0) { - fprintf(stderr, "WARNING: Failed to set tuner gain.\n"); + fprintf (stderr, "WARNING: Failed to set tuner gain.\n"); } else { - fprintf(stderr, "Tuner gain set to automatic.\n"); + fprintf (stderr, "Tuner gain set to automatic.\n"); } return r; } @@ -696,14 +696,14 @@ int verbose_gain_set(rtlsdr_dev_t *dev, int gain) int r; r = rtlsdr_set_tuner_gain_mode(dev, 1); if (r < 0) { - fprintf(stderr, "WARNING: Failed to enable manual gain.\n"); + fprintf (stderr, "WARNING: Failed to enable manual gain.\n"); return r; } r = rtlsdr_set_tuner_gain(dev, gain); if (r != 0) { - fprintf(stderr, "WARNING: Failed to set tuner gain.\n"); + fprintf (stderr, "WARNING: Failed to set tuner gain.\n"); } else { - fprintf(stderr, "Tuner gain set to %0.2f dB.\n", gain/10.0); + fprintf (stderr, "Tuner gain set to %0.2f dB.\n", gain/10.0); } return r; } @@ -716,9 +716,9 @@ int verbose_ppm_set(rtlsdr_dev_t *dev, int ppm_error) return 0;} r = rtlsdr_set_freq_correction(dev, ppm_error); if (r < 0) { - fprintf(stderr, "WARNING: Failed to set ppm error.\n"); + fprintf (stderr, "WARNING: Failed to set ppm error.\n"); } else { - fprintf(stderr, "Tuner error set to %i ppm.\n", ppm_error); + fprintf (stderr, "Tuner error set to %i ppm.\n", ppm_error); } return r; } @@ -728,7 +728,7 @@ int verbose_reset_buffer(rtlsdr_dev_t *dev) int r; r = rtlsdr_reset_buffer(dev); if (r < 0) { - fprintf(stderr, "WARNING: Failed to reset buffers.\n");} + fprintf (stderr, "WARNING: Failed to reset buffers.\n");} return r; } @@ -782,15 +782,15 @@ static void *controller_thread_fn(void *arg) /* Set the frequency */ verbose_set_frequency(dongle.dev, dongle.freq); - fprintf(stderr, "Oversampling input by: %ix.\n", demod.downsample); - fprintf(stderr, "Oversampling output by: %ix.\n", demod.post_downsample); - fprintf(stderr, "Buffer size: %0.2fms\n", + fprintf (stderr, "Oversampling input by: %ix.\n", demod.downsample); + fprintf (stderr, "Oversampling output by: %ix.\n", demod.post_downsample); + fprintf (stderr, "Buffer size: %0.2fms\n", 1000 * 0.5 * (float)ACTUAL_BUF_LENGTH / (float)dongle.rate); /* Set the sample rate */ verbose_set_sample_rate(dongle.dev, dongle.rate); - fprintf(stderr, "Output at %u Hz.\n", demod.rate_in/demod.post_downsample); - fprintf(stderr, "Press CTRL + C to close.\n"); //Kindly remind user to double tap CTRL + C + fprintf (stderr, "Output at %u Hz.\n", demod.rate_in/demod.post_downsample); + fprintf (stderr, "Press CTRL + C to close.\n"); //Kindly remind user to double tap CTRL + C while (!exitflag) { safe_cond_wait(&s->hop, &s->hop_m); @@ -889,17 +889,17 @@ void controller_cleanup(struct controller_state *s) void sanity_checks(void) { if (controller.freq_len == 0) { - fprintf(stderr, "Please specify a frequency.\n"); + fprintf (stderr, "Please specify a frequency.\n"); exit(1); } if (controller.freq_len >= FREQUENCIES_LIMIT) { - fprintf(stderr, "Too many channels, maximum %i.\n", FREQUENCIES_LIMIT); + fprintf (stderr, "Too many channels, maximum %i.\n", FREQUENCIES_LIMIT); exit(1); } if (controller.freq_len > 1 && demod.squelch_level == 0) { - fprintf(stderr, "Please specify a squelch level. Required for scanning multiple frequencies.\n"); + fprintf (stderr, "Please specify a squelch level. Required for scanning multiple frequencies.\n"); exit(1); } @@ -1013,11 +1013,11 @@ static void *socket_thread_fn(void *arg) { } if (r != 0) { - fprintf(stderr, "WARNING: Failed to set tuner gain.\n"); + fprintf (stderr, "WARNING: Failed to set tuner gain.\n"); } else if (new_gain == AUTO_GAIN) { - fprintf(stderr, "Tuner gain set to automatic.\n"); + fprintf (stderr, "Tuner gain set to automatic.\n"); } else { - fprintf(stderr, "Tuner gain set to %0.2f dB.\n", new_gain/10.0); + fprintf (stderr, "Tuner gain set to %0.2f dB.\n", new_gain/10.0); } } */ @@ -1025,10 +1025,10 @@ static void *socket_thread_fn(void *arg) { if (buffer[0] == 8) { agc_mode = chars_to_int(buffer); if (agc_mode == 0 || agc_mode == 1) { - fprintf(stderr, "Setting AGC to %d\n", agc_mode); + fprintf (stderr, "Setting AGC to %d\n", agc_mode); rtlsdr_set_agc_mode(dev, agc_mode); } else { - fprintf(stderr, "Failed to set AGC to %d\n", agc_mode); + fprintf (stderr, "Failed to set AGC to %d\n", agc_mode); } } */ @@ -1041,8 +1041,8 @@ static void *socket_thread_fn(void *arg) { void rtlsdr_sighandler() { - fprintf(stderr, "Signal caught, exiting!\n"); - fprintf(stderr, "Press CTRL + C again to close. Thanks. \n"); //Kindly remind user to double tap CTRL + C + fprintf (stderr, "Signal caught, exiting!\n"); + fprintf (stderr, "Press CTRL + C again to close. Thanks. \n"); //Kindly remind user to double tap CTRL + C rtlsdr_cancel_async(dongle.dev); //cleanup_rtlsdr_stream(); //thank the wraith for this one...if it works...didn't work //_Exit(1); @@ -1077,9 +1077,9 @@ void open_rtlsdr_stream(dsd_opts *opts) //bandwidth_multiplier = rtl_bandwidth / bandwidth_divisor; //find multiple with no remainder if oddball number entered //bandwidth_multiplier = 1; demod.squelch_level = opts->rtl_squelch_level; //adding user definable squelch level to prevent false positives on account of noise in NXDN etc - fprintf(stderr, "Setting RTL VFO Bandwidth to %d Hz\n", rtl_bandwidth); - fprintf(stderr, "Setting RTL Sample Multiplier to %d\n", bandwidth_multiplier); - fprintf(stderr, "Setting RTL Squelch Level to %d\n", demod.squelch_level); + fprintf (stderr, "Setting RTL VFO Bandwidth to %d Hz\n", rtl_bandwidth); + fprintf (stderr, "Setting RTL Sample Multiplier to %d\n", bandwidth_multiplier); + fprintf (stderr, "Setting RTL Squelch Level to %d\n", demod.squelch_level); port = opts->rtl_udp_port; } @@ -1087,7 +1087,7 @@ void open_rtlsdr_stream(dsd_opts *opts) dongle.gain = opts->rtl_gain_value * 10; //multiple by ten to make it consitent with the way rtl_fm really works } volume_multiplier = opts->rtl_volume_multiplier; - fprintf(stderr, "Setting RTL Volume Multiplier to %d\n", volume_multiplier); + fprintf (stderr, "Setting RTL Volume Multiplier to %d\n", volume_multiplier); /* quadruple sample_rate to limit to Δθ to ±π/2 */ demod.rate_in *= demod.post_downsample; @@ -1102,10 +1102,10 @@ void open_rtlsdr_stream(dsd_opts *opts) if (r < 0) { - fprintf(stderr, "Failed to open rtlsdr device %d.\n", dongle.dev_index); + fprintf (stderr, "Failed to open rtlsdr device %d.\n", dongle.dev_index); exit(1); } else { - fprintf(stderr, "Using RTLSDR Device Index: %d. \n", dongle.dev_index); //Kindly tell us which device we are using + fprintf (stderr, "Using RTLSDR Device Index: %d. \n", dongle.dev_index); //Kindly tell us which device we are using } // sigact.sa_handler = sighandler; @@ -1142,7 +1142,7 @@ void open_rtlsdr_stream(dsd_opts *opts) void cleanup_rtlsdr_stream() { - printf("cleaning up...\n"); + fprintf (stderr, "cleaning up...\n"); rtlsdr_cancel_async(dongle.dev); pthread_join(dongle.thread, NULL); safe_cond_signal(&demod.ready, &demod.ready_m); diff --git a/src/x2tdma_data.c b/src/x2tdma_data.c index 3829270..eb60476 100644 --- a/src/x2tdma_data.c +++ b/src/x2tdma_data.c @@ -83,7 +83,7 @@ processX2TDMAdata (dsd_opts * opts, dsd_state * state) k++; } cachbits[24] = 0; - printf ("%s ", cachbits); + fprintf (stderr,"%s ", cachbits); #endif // current slot @@ -204,7 +204,7 @@ processX2TDMAdata (dsd_opts * opts, dsd_state * state) k++; } syncbits[48] = 0; - printf ("%s ", syncbits); + fprintf (stderr,"%s ", syncbits); #endif if ((strcmp (sync, X2TDMA_BS_DATA_SYNC) == 0) || (strcmp (sync, X2TDMA_BS_DATA_SYNC) == 0)) @@ -221,7 +221,7 @@ processX2TDMAdata (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { - printf ("%s %s ", state->slot0light, state->slot1light); + fprintf (stderr,"%s %s ", state->slot0light, state->slot1light); } // current slot second half, cach, next slot 1st half @@ -231,11 +231,11 @@ processX2TDMAdata (dsd_opts * opts, dsd_state * state) { if (strcmp (state->fsubtype, " ") == 0) { - printf (" Unknown burst type: %s\n", bursttype); + fprintf (stderr," Unknown burst type: %s\n", bursttype); } else { - printf ("%s\n", state->fsubtype); + fprintf (stderr,"%s\n", state->fsubtype); } } } diff --git a/src/x2tdma_voice.c b/src/x2tdma_voice.c index 4fd6d21..4d68b71 100644 --- a/src/x2tdma_voice.c +++ b/src/x2tdma_voice.c @@ -127,7 +127,7 @@ processX2TDMAvoice (dsd_opts * opts, dsd_state * state) k++; } cachbits[24] = 0; - printf ("%s ", cachbits); + fprintf (stderr,"%s ", cachbits); #endif // current slot frame 1 @@ -240,7 +240,7 @@ processX2TDMAvoice (dsd_opts * opts, dsd_state * state) if ((j == 0) && (opts->errorbars == 1)) { - printf ("%s %s VOICE e:", state->slot0light, state->slot1light); + fprintf (stderr,"%s %s VOICE e:", state->slot0light, state->slot1light); } #ifdef X2TDMA_DUMP @@ -254,7 +254,7 @@ processX2TDMAvoice (dsd_opts * opts, dsd_state * state) k++; } syncbits[48] = 0; - printf ("%s ", syncbits); + fprintf (stderr,"%s ", syncbits); #endif if (j == 1) @@ -554,7 +554,7 @@ processX2TDMAvoice (dsd_opts * opts, dsd_state * state) k++; } cachbits[24] = 0; - printf ("%s ", cachbits); + fprintf (stderr,"%s ", cachbits); #endif @@ -605,7 +605,7 @@ processX2TDMAvoice (dsd_opts * opts, dsd_state * state) k++; } syncbits[48] = 0; - printf ("%s ", syncbits); + fprintf (stderr,"%s ", syncbits); #endif if (j == 5) @@ -623,7 +623,7 @@ processX2TDMAvoice (dsd_opts * opts, dsd_state * state) if (opts->errorbars == 1) { - printf ("\n"); + fprintf (stderr,"\n"); } if (mutecurrentslot == 0) @@ -636,7 +636,7 @@ processX2TDMAvoice (dsd_opts * opts, dsd_state * state) { algidhex = strtol (state->algid, NULL, 2); kidhex = strtol (state->keyid, NULL, 2); - printf ("mi: %s algid: $%x kid: $%x\n", mi, algidhex, kidhex); + fprintf (stderr,"mi: %s algid: $%x kid: $%x\n", mi, algidhex, kidhex); } } } From 325bff80d072bc3fa5065721e84668c6378e34c3 Mon Sep 17 00:00:00 2001 From: lwvmobile <59371473+lwvmobile@users.noreply.github.com> Date: Thu, 10 Feb 2022 17:04:47 -0500 Subject: [PATCH 2/2] Print to STDERR Print to STDERR Take 3 --- src/dsd_audio.c | 12 ++++++------ src/dsd_main.c | 36 ++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/dsd_audio.c b/src/dsd_audio.c index b64381f..60043b2 100644 --- a/src/dsd_audio.c +++ b/src/dsd_audio.c @@ -391,9 +391,9 @@ playSynthesizedVoice (dsd_opts * opts, dsd_state * state) if( err != paNoError ) { - fprintf (stderr, stderr, "An error occured while using the portaudio output stream\n" ); - fprintf (stderr, stderr, "Error number: %d\n", err ); - fprintf (stderr, stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + fprintf (stderr, "An error occured while using the portaudio output stream\n" ); + fprintf (stderr, "Error number: %d\n", err ); + fprintf (stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); } #endif @@ -484,9 +484,9 @@ int getPADevice(char* dev, int input, PaStream** stream) return 0; error: - fprintf (stderr, stderr, "An error occured while initializing a portaudio stream\n" ); - fprintf (stderr, stderr, "Error number: %d\n", err ); - fprintf (stderr, stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + fprintf (stderr, "An error occured while initializing a portaudio stream\n" ); + fprintf (stderr, "Error number: %d\n", err ); + fprintf (stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); return err; } #endif diff --git a/src/dsd_main.c b/src/dsd_main.c index 2705925..6c03f25 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -388,9 +388,9 @@ liveScanner (dsd_opts * opts, dsd_state * state) PaError err = Pa_StartStream( opts->audio_in_pa_stream ); if( err != paNoError ) { - //fprintf (stderr, stderr, "An error occured while starting the portaudio input stream\n" ); - //fprintf (stderr, stderr, "Error number: %d\n", err ); - //fprintf (stderr, stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + //fprintf (stderr, "An error occured while starting the portaudio input stream\n" ); + //fprintf (stderr, "Error number: %d\n", err ); + //fprintf (stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); return; } } @@ -459,9 +459,9 @@ cleanupAndExit (dsd_opts * opts, dsd_state * state) err = Pa_CloseStream( opts->audio_in_pa_stream ); if( err != paNoError ) { - //fprintf (stderr, stderr, "An error occured while closing the portaudio input stream\n" ); - //fprintf (stderr, stderr, "Error number: %d\n", err ); - //fprintf (stderr, stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + //fprintf (stderr, "An error occured while closing the portaudio input stream\n" ); + //fprintf (stderr, "Error number: %d\n", err ); + //fprintf (stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); } } if(opts->audio_out_pa_stream != NULL) @@ -471,24 +471,24 @@ cleanupAndExit (dsd_opts * opts, dsd_state * state) err = Pa_StopStream( opts->audio_out_pa_stream ); if( err != paNoError ) { - //fprintf (stderr, stderr, "An error occured while closing the portaudio output stream\n" ); - //fprintf (stderr, stderr, "Error number: %d\n", err ); - //fprintf (stderr, stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + //fprintf (stderr, "An error occured while closing the portaudio output stream\n" ); + //fprintf (stderr, "Error number: %d\n", err ); + //fprintf (stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); } err = Pa_CloseStream( opts->audio_out_pa_stream ); if( err != paNoError ) { - //fprintf (stderr, stderr, "An error occured while closing the portaudio output stream\n" ); - //fprintf (stderr, stderr, "Error number: %d\n", err ); - //fprintf (stderr, stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + //fprintf (stderr, "An error occured while closing the portaudio output stream\n" ); + //fprintf (stderr, "Error number: %d\n", err ); + //fprintf (stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); } } err = Pa_Terminate(); if( err != paNoError ) { - //fprintf (stderr, stderr, "An error occured while terminating portaudio\n" ); - //fprintf (stderr, stderr, "Error number: %d\n", err ); - //fprintf (stderr, stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + //fprintf (stderr, "An error occured while terminating portaudio\n" ); + //fprintf (stderr, "Error number: %d\n", err ); + //fprintf (stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); } } #endif @@ -989,9 +989,9 @@ main (int argc, char **argv) PaError err = Pa_Initialize(); if( err != paNoError ) { - //fprintf (stderr, stderr, "An error occured while initializing portaudio\n" ); - //fprintf (stderr, stderr, "Error number: %d\n", err ); - //fprintf (stderr, stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + //fprintf (stderr, "An error occured while initializing portaudio\n" ); + //fprintf (stderr, "Error number: %d\n", err ); + //fprintf (stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); exit(err); } }