mirror of
https://github.com/jfdelnero/rf-tools.git
synced 2026-07-07 03:13:15 -04:00
command line parameter help
This commit is contained in:
+10
-4
@@ -28,16 +28,16 @@ EXEC=broadcast_tv broadcast_fm rf_jammer pocsag
|
||||
|
||||
all: $(EXEC)
|
||||
|
||||
broadcast_fm: broadcast_fm.o rds.o rds_stream_dump.o wave.o modulator.o FIR_Audio_Filter_Filter.o FM_Baseband_Filter.o AudioPreemphasis_Filter.o FIR_RDS_Passband_Filter.o hxcmod.o rand_gen.o std_crc32.o
|
||||
broadcast_fm: broadcast_fm.o rds.o rds_stream_dump.o wave.o modulator.o FIR_Audio_Filter_Filter.o FM_Baseband_Filter.o AudioPreemphasis_Filter.o FIR_RDS_Passband_Filter.o hxcmod.o rand_gen.o std_crc32.o cmd_param.o
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
broadcast_tv: broadcast_tv.o composite.o wave.o modulator.o bmp_file.o std_crc32.o
|
||||
broadcast_tv: broadcast_tv.o composite.o wave.o modulator.o bmp_file.o std_crc32.o cmd_param.o
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
rf_jammer: rf_jammer.o wave.o modulator.o rand_gen.o composite.o std_crc32.o
|
||||
rf_jammer: rf_jammer.o wave.o modulator.o rand_gen.o composite.o std_crc32.o cmd_param.o
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
pocsag: pocsag.o wave.o modulator.o serial.o std_crc32.o utils.o
|
||||
pocsag: pocsag.o wave.o modulator.o serial.o std_crc32.o utils.o cmd_param.o
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
broadcast_fm.o: ../src/broadcast_fm/broadcast_fm.c
|
||||
@@ -91,12 +91,18 @@ bmp_file.o: ../src/common/bmp_file.c
|
||||
rand_gen.o: ../src/common/rand_gen.c
|
||||
$(CC) -o $@ -c $< $(CFLAGS)
|
||||
|
||||
bmp_file.o: ../src/common/bmp_file.c
|
||||
$(CC) -o $@ -c $< $(CFLAGS)
|
||||
|
||||
composite.o: ../src/broadcast_tv/composite.c
|
||||
$(CC) -o $@ -c $< $(CFLAGS)
|
||||
|
||||
broadcast_tv.o: ../src/broadcast_tv/broadcast_tv.c
|
||||
$(CC) -o $@ -c $< $(CFLAGS)
|
||||
|
||||
cmd_param.o: ../src/common/cmd_param.c
|
||||
$(CC) -o $@ -c $< $(CFLAGS)
|
||||
|
||||
clean:
|
||||
rm -rf *.o
|
||||
rm -rf *.so
|
||||
|
||||
@@ -134,6 +134,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cmd_param.h"
|
||||
|
||||
#include "wave.h"
|
||||
|
||||
#include "modulator.h"
|
||||
@@ -166,65 +168,6 @@
|
||||
|
||||
int stdoutmode;
|
||||
|
||||
int isOption(int argc, char* argv[],char * paramtosearch,char * argtoparam)
|
||||
{
|
||||
int param=1;
|
||||
int i,j;
|
||||
|
||||
char option[512];
|
||||
|
||||
memset(option,0,512);
|
||||
while(param<=argc)
|
||||
{
|
||||
if(argv[param])
|
||||
{
|
||||
if(argv[param][0]=='-')
|
||||
{
|
||||
memset(option,0,512);
|
||||
|
||||
j=0;
|
||||
i=1;
|
||||
while( argv[param][i] && argv[param][i]!=':')
|
||||
{
|
||||
option[j]=argv[param][i];
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
|
||||
if( !strcmp(option,paramtosearch) )
|
||||
{
|
||||
if(argtoparam)
|
||||
{
|
||||
if(argv[param][i]==':')
|
||||
{
|
||||
i++;
|
||||
j=0;
|
||||
while( argv[param][i] )
|
||||
{
|
||||
argtoparam[j]=argv[param][i];
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
argtoparam[j]=0;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
param++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void printhelp(char* argv[])
|
||||
{
|
||||
@@ -298,7 +241,7 @@ int main(int argc, char* argv[])
|
||||
no_rds = 0;
|
||||
silence = 0;
|
||||
|
||||
if(isOption(argc,argv,"stdout",NULL)>0)
|
||||
if(isOption(argc,argv,"stdout",NULL,NULL)>0)
|
||||
{
|
||||
stdoutmode = 1;
|
||||
}
|
||||
@@ -313,34 +256,34 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
// help option...
|
||||
if(isOption(argc,argv,"help",0)>0)
|
||||
if(isOption(argc,argv,"help",0,NULL)>0)
|
||||
{
|
||||
printhelp(argv);
|
||||
}
|
||||
|
||||
memset(filename,0,sizeof(filename));
|
||||
// Input file name option
|
||||
if(isOption(argc,argv,"mod_file",(char*)&filename)>0)
|
||||
if(isOption(argc,argv,"mod_file",(char*)&filename,NULL)>0)
|
||||
{
|
||||
printf("Input file : %s\n",filename);
|
||||
}
|
||||
|
||||
if(isOption(argc,argv,"mono",NULL)>0)
|
||||
if(isOption(argc,argv,"mono",NULL,NULL)>0)
|
||||
{
|
||||
monomode = 1;
|
||||
}
|
||||
|
||||
if(isOption(argc,argv,"no_rds",NULL)>0)
|
||||
if(isOption(argc,argv,"no_rds",NULL,NULL)>0)
|
||||
{
|
||||
no_rds = 1;
|
||||
}
|
||||
|
||||
if(isOption(argc,argv,"silence",NULL)>0)
|
||||
if(isOption(argc,argv,"silence",NULL,NULL)>0)
|
||||
{
|
||||
silence = 1;
|
||||
}
|
||||
|
||||
if(isOption(argc,argv,"generate",0)>0)
|
||||
if(isOption(argc,argv,"generate",0,NULL)>0)
|
||||
{
|
||||
// Init the .mod player and load the mod file.
|
||||
hxcmod_init(&modctx);
|
||||
@@ -421,7 +364,7 @@ int main(int argc, char* argv[])
|
||||
rds_carrier_57KHz_gen.sample_rate = SUBCARRIERS_SAMPLE_RATE;
|
||||
|
||||
init_rds_encoder(&rdsstat,SUBCARRIERS_SAMPLE_RATE);
|
||||
if(isOption(argc,argv,"rdstxt",(char*)&rdstxt)>0)
|
||||
if(isOption(argc,argv,"rdstxt",(char*)&rdstxt,NULL)>0)
|
||||
{
|
||||
set_rds_text(&rdsstat,rdstxt);
|
||||
}
|
||||
@@ -609,8 +552,8 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if( (isOption(argc,argv,"help",0)<=0) &&
|
||||
(isOption(argc,argv,"generate",0)<=0)
|
||||
if( (isOption(argc,argv,"help",0,NULL)<=0) &&
|
||||
(isOption(argc,argv,"generate",0,NULL)<=0)
|
||||
)
|
||||
{
|
||||
printhelp(argv);
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cmd_param.h"
|
||||
|
||||
#include "wave.h"
|
||||
|
||||
#include "modulator.h"
|
||||
@@ -71,66 +73,6 @@
|
||||
|
||||
int stdoutmode;
|
||||
|
||||
int isOption(int argc, char* argv[],char * paramtosearch,char * argtoparam)
|
||||
{
|
||||
int param=1;
|
||||
int i,j;
|
||||
|
||||
char option[512];
|
||||
|
||||
memset(option,0,512);
|
||||
while(param<=argc)
|
||||
{
|
||||
if(argv[param])
|
||||
{
|
||||
if(argv[param][0]=='-')
|
||||
{
|
||||
memset(option,0,512);
|
||||
|
||||
j=0;
|
||||
i=1;
|
||||
while( argv[param][i] && argv[param][i]!=':')
|
||||
{
|
||||
option[j]=argv[param][i];
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
|
||||
if( !strcmp(option,paramtosearch) )
|
||||
{
|
||||
if(argtoparam)
|
||||
{
|
||||
if(argv[param][i]==':')
|
||||
{
|
||||
i++;
|
||||
j=0;
|
||||
while( argv[param][i] )
|
||||
{
|
||||
argtoparam[j]=argv[param][i];
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
argtoparam[j]=0;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
param++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void printhelp(char* argv[])
|
||||
{
|
||||
printf("Options:\n");
|
||||
@@ -161,7 +103,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
stdoutmode = 0;
|
||||
|
||||
if(isOption(argc,argv,"stdout",NULL)>0)
|
||||
if(isOption(argc,argv,"stdout",NULL,NULL)>0)
|
||||
{
|
||||
stdoutmode = 1;
|
||||
}
|
||||
@@ -176,14 +118,14 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
// help option...
|
||||
if(isOption(argc,argv,"help",0)>0)
|
||||
if(isOption(argc,argv,"help",0,NULL)>0)
|
||||
{
|
||||
printhelp(argv);
|
||||
}
|
||||
|
||||
memset(filename,0,sizeof(filename));
|
||||
|
||||
if(isOption(argc,argv,"bmp_file",(char*)&filename)>0)
|
||||
if(isOption(argc,argv,"bmp_file",(char*)&filename,NULL)>0)
|
||||
{
|
||||
printf("Input file : %s\n",filename);
|
||||
}
|
||||
@@ -202,7 +144,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if(isOption(argc,argv,"generate",0)>0)
|
||||
if(isOption(argc,argv,"generate",0,NULL)>0)
|
||||
{
|
||||
// IQ Modulator
|
||||
iqgen.phase = 0;
|
||||
@@ -210,7 +152,7 @@ int main(int argc, char* argv[])
|
||||
iqgen.Amplitude = 127;
|
||||
iqgen.sample_rate = IQ_SAMPLE_RATE;
|
||||
|
||||
init_composite(&vid_stat, 16000000, 768, 576,bmp_data.data);
|
||||
init_composite(&vid_stat, IQ_SAMPLE_RATE, 768, 576,bmp_data.data);
|
||||
|
||||
if(stdoutmode)
|
||||
{
|
||||
@@ -222,7 +164,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
// file mode : create iq + wav files
|
||||
wave1 = create_wave("broadcast_tv.iq",iqgen.sample_rate,WAVE_FILE_FORMAT_RAW_8BITS_IQ);
|
||||
wave2 = create_wave("broadcast_tv.wav",16000000,WAVE_FILE_FORMAT_WAV_16BITS_MONO);
|
||||
wave2 = create_wave("broadcast_tv.wav",IQ_SAMPLE_RATE,WAVE_FILE_FORMAT_WAV_16BITS_MONO);
|
||||
}
|
||||
|
||||
for(i=0;i<1024*16*2 || stdoutmode;i++)
|
||||
@@ -244,8 +186,8 @@ int main(int argc, char* argv[])
|
||||
close_wave(wave2);
|
||||
}
|
||||
|
||||
if( (isOption(argc,argv,"help",0)<=0) &&
|
||||
(isOption(argc,argv,"generate",0)<=0)
|
||||
if( (isOption(argc,argv,"help",0,NULL)<=0) &&
|
||||
(isOption(argc,argv,"generate",0,NULL)<=0)
|
||||
)
|
||||
{
|
||||
printhelp(argv);
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
//
|
||||
// Command line helper
|
||||
//
|
||||
// Copyright (C) Jean-François DEL NERO
|
||||
//
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int isOption(int argc, char* argv[],char * paramtosearch,char * argtoparam, int * param_start_index)
|
||||
{
|
||||
int param;
|
||||
int i,j;
|
||||
|
||||
char option[512];
|
||||
|
||||
memset(option,0,sizeof(option));
|
||||
|
||||
param = 1;
|
||||
|
||||
if( param_start_index )
|
||||
{
|
||||
param = *param_start_index;
|
||||
}
|
||||
|
||||
if(param < 1)
|
||||
{
|
||||
param = 1;
|
||||
}
|
||||
|
||||
while(param<=argc)
|
||||
{
|
||||
if(argv[param])
|
||||
{
|
||||
if(argv[param][0]=='-')
|
||||
{
|
||||
memset(option,0,sizeof(option));
|
||||
|
||||
j=0;
|
||||
i=1;
|
||||
while( argv[param][i] && argv[param][i]!=':' && ( j < (sizeof(option) - 1)) )
|
||||
{
|
||||
option[j]=argv[param][i];
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
|
||||
if( !strcmp(option,paramtosearch) )
|
||||
{
|
||||
if(argtoparam)
|
||||
{
|
||||
argtoparam[0] = 0;
|
||||
|
||||
if(argv[param][i]==':')
|
||||
{
|
||||
i++;
|
||||
j=0;
|
||||
while( argv[param][i] && j < (512 - 1) )
|
||||
{
|
||||
argtoparam[j]=argv[param][i];
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
argtoparam[j]=0;
|
||||
|
||||
if(param_start_index)
|
||||
*param_start_index = param;
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(param_start_index)
|
||||
*param_start_index = param;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
param++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
//
|
||||
// Command line helper
|
||||
//
|
||||
// Copyright (C) Jean-François DEL NERO
|
||||
//
|
||||
*/
|
||||
|
||||
int isOption(int argc, char* argv[],char * paramtosearch,char * argtoparam, int * param_start_index);
|
||||
|
||||
|
||||
+20
-81
@@ -91,6 +91,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cmd_param.h"
|
||||
|
||||
#include "wave.h"
|
||||
#include "modulator.h"
|
||||
#include "serial.h"
|
||||
@@ -127,69 +129,6 @@ typedef struct _poc
|
||||
int frm_end;
|
||||
}poc;
|
||||
|
||||
int isOption(int argc, char* argv[],char * paramtosearch,char * argtoparam)
|
||||
{
|
||||
int param=1;
|
||||
int i,j;
|
||||
|
||||
char option[512];
|
||||
|
||||
memset(option,0,sizeof(option));
|
||||
|
||||
while(param<=argc)
|
||||
{
|
||||
if(argv[param])
|
||||
{
|
||||
if(argv[param][0]=='-')
|
||||
{
|
||||
memset(option,0,sizeof(option));
|
||||
|
||||
j=0;
|
||||
i=1;
|
||||
while( argv[param][i] && argv[param][i]!=':' && ( j < (sizeof(option) - 1)) )
|
||||
{
|
||||
option[j]=argv[param][i];
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
|
||||
if( !strcmp(option,paramtosearch) )
|
||||
{
|
||||
if(argtoparam)
|
||||
{
|
||||
argtoparam[0] = 0;
|
||||
|
||||
if(argv[param][i]==':')
|
||||
{
|
||||
i++;
|
||||
j=0;
|
||||
while( argv[param][i] && j < (512 - 1) )
|
||||
{
|
||||
argtoparam[j]=argv[param][i];
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
argtoparam[j]=0;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
param++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void printhelp(char* argv[])
|
||||
{
|
||||
printf("Options:\n");
|
||||
@@ -557,43 +496,43 @@ int main(int argc, char* argv[])
|
||||
memset(&pocctx,0,sizeof(pocctx));
|
||||
|
||||
stdoutmode = 0;
|
||||
if(isOption(argc,argv,"stdout",NULL)>0)
|
||||
if(isOption(argc,argv,"stdout",NULL,NULL)>0)
|
||||
{
|
||||
stdoutmode = 1;
|
||||
}
|
||||
|
||||
baud = 1200;
|
||||
if(isOption(argc,argv,"baud",(char*)&temp_str)>0)
|
||||
if(isOption(argc,argv,"baud",(char*)&temp_str,NULL)>0)
|
||||
{
|
||||
baud = atoi(temp_str);
|
||||
}
|
||||
|
||||
ric = 8;
|
||||
if(isOption(argc,argv,"ric",(char*)&temp_str)>0)
|
||||
if(isOption(argc,argv,"ric",(char*)&temp_str,NULL)>0)
|
||||
{
|
||||
ric = atoi(temp_str);
|
||||
}
|
||||
|
||||
func = 0;
|
||||
if(isOption(argc,argv,"func",(char*)&temp_str)>0)
|
||||
if(isOption(argc,argv,"func",(char*)&temp_str,NULL)>0)
|
||||
{
|
||||
func = atoi(temp_str);
|
||||
}
|
||||
|
||||
freqshift = 4500;
|
||||
if(isOption(argc,argv,"freqshift",(char*)&temp_str)>0)
|
||||
if(isOption(argc,argv,"freqshift",(char*)&temp_str,NULL)>0)
|
||||
{
|
||||
freqshift = atoi(temp_str);
|
||||
}
|
||||
|
||||
message[0] = 0;
|
||||
if(isOption(argc,argv,"message",(char*)&message)>0)
|
||||
if(isOption(argc,argv,"message",(char*)&message,NULL)>0)
|
||||
{
|
||||
message_size = strlen(message);
|
||||
}
|
||||
|
||||
temp_str[0] = 0;
|
||||
if(isOption(argc,argv,"fmessage",(char*)&temp_str)>0)
|
||||
if(isOption(argc,argv,"fmessage",(char*)&temp_str,NULL)>0)
|
||||
{
|
||||
if(strlen(temp_str))
|
||||
{
|
||||
@@ -633,31 +572,31 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
alpha = 0;
|
||||
if(isOption(argc,argv,"alpha",NULL)>0)
|
||||
if(isOption(argc,argv,"alpha",NULL,NULL)>0)
|
||||
{
|
||||
alpha = 1;
|
||||
}
|
||||
|
||||
smprate = IQ_SAMPLE_RATE;
|
||||
if(isOption(argc,argv,"smprate",(char*)&temp_str)>0)
|
||||
if(isOption(argc,argv,"smprate",(char*)&temp_str,NULL)>0)
|
||||
{
|
||||
smprate = atoi(temp_str);
|
||||
}
|
||||
|
||||
batchbruteforce = 0;
|
||||
if(isOption(argc,argv,"batch",NULL)>0)
|
||||
if(isOption(argc,argv,"batch",NULL,NULL)>0)
|
||||
{
|
||||
batchbruteforce = 1;
|
||||
}
|
||||
|
||||
wavout = 0;
|
||||
if(isOption(argc,argv,"wav",NULL)>0)
|
||||
if(isOption(argc,argv,"wav",NULL,NULL)>0)
|
||||
{
|
||||
wavout = 1;
|
||||
}
|
||||
|
||||
settle_time = 20;
|
||||
if(isOption(argc,argv,"settle_time",(char*)&temp_str)>0)
|
||||
if(isOption(argc,argv,"settle_time",(char*)&temp_str,NULL)>0)
|
||||
{
|
||||
settle_time = atoi(temp_str);
|
||||
if( settle_time < 0 )
|
||||
@@ -668,7 +607,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
level = 126;
|
||||
if(isOption(argc,argv,"level",(char*)&temp_str)>0)
|
||||
if(isOption(argc,argv,"level",(char*)&temp_str,NULL)>0)
|
||||
{
|
||||
level = atoi(temp_str);
|
||||
if( level < 0 )
|
||||
@@ -679,7 +618,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
verbose = 0;
|
||||
if(isOption(argc,argv,"verbose",NULL)>0)
|
||||
if(isOption(argc,argv,"verbose",NULL,NULL)>0)
|
||||
{
|
||||
verbose = 1;
|
||||
}
|
||||
@@ -694,7 +633,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
// help option...
|
||||
if(isOption(argc,argv,"help",0)>0)
|
||||
if(isOption(argc,argv,"help",0,NULL)>0)
|
||||
{
|
||||
printhelp(argv);
|
||||
}
|
||||
@@ -704,7 +643,7 @@ int main(int argc, char* argv[])
|
||||
settle_size = 2;
|
||||
|
||||
|
||||
if(isOption(argc,argv,"generate",0)>0)
|
||||
if(isOption(argc,argv,"generate",0,NULL)>0)
|
||||
{
|
||||
fprintf(stderr,"\nBaud:%d, RIC: %d, Function:%d, Alpha:%d, Message:%s\n", baud, ric, func, alpha, message );
|
||||
|
||||
@@ -920,8 +859,8 @@ int main(int argc, char* argv[])
|
||||
free(settle_buf);
|
||||
}
|
||||
|
||||
if( (isOption(argc,argv,"help",0)<=0) &&
|
||||
(isOption(argc,argv,"generate",0)<=0)
|
||||
if( (isOption(argc,argv,"help",0,NULL)<=0) &&
|
||||
(isOption(argc,argv,"generate",0,NULL)<=0)
|
||||
)
|
||||
{
|
||||
printhelp(argv);
|
||||
|
||||
Reference in New Issue
Block a user