Commit 14bb7b0a authored by Jenda's avatar Jenda

server command line parameters

parent 8781eafa
......@@ -14,7 +14,8 @@ freq="$(( 100 * 1000 * 1000 ))"
[ ! -p "$sdr" ] && mkfifo "$sdr"
[ ! -p "$tune" ] && mkfifo "$tune"
./server -s 2048000 -p "$ppm" -f "$freq" -i "$tune" -o "$sdr" -f "$freq" -g "$gain" -s "$2" -w 1024 &
# set -b :: for ipv4 and ipv6 all interfaces
./server -s 2048000 -p "$ppm" -f "$freq" -i "$tune" -o "$sdr" -f "$freq" -g "$gain" -a -s "$2" -b 127.0.0.1 -t 4444 -w 1024 &
spid=$!
echo "Server PID $spid, use 'gdb ./server $spid -ex c' to debug"
......
......@@ -72,7 +72,7 @@ FILE * sdr_pipe;
int32_t samplerate = -1;
int64_t frequency = 100e6;
int32_t ppm = INT32_MIN;
int32_t ppm = 0;
int32_t fftw = FFTSIZE;
struct current_gain_t gain;
......@@ -400,7 +400,10 @@ static void create_read_write_threads() {
}
static void usage(char * me) {
printf("usage: %s -s samplerate -p ppm -f frequency -i cmdpipe -o sdrpipe\n", me);
printf(
"usage: %s [parameters]\n"
" mandatory: -s samplerate -f frequency -i cmdpipe -o sdrpipe\n"
" optional: -p ppm -a (autogain) -g gain -b host -t port -w fft_width\n", me);
exit(1);
}
......@@ -411,7 +414,7 @@ int main(int argc, char **argv) {
/* Command line opts */
int opt;
while ((opt = getopt(argc, argv, "s:f:p:g:i:o:h:t:w:")) != -1) {
while ((opt = getopt(argc, argv, "s:f:p:ag:i:o:b:t:w:")) != -1) {
switch (opt) {
case 's':
samplerate = atoi(optarg);
......@@ -422,8 +425,10 @@ int main(int argc, char **argv) {
case 'p':
ppm = atoi(optarg);
break;
case 'g':
case 'a':
gain.autogain = 1;
break;
case 'g':
gain.global_gain = atoi(optarg);
gain.if_gain = atoi(optarg);
gain.bb_gain = atoi(optarg);
......@@ -440,7 +445,7 @@ int main(int argc, char **argv) {
case 'w':
fftw = atoi(optarg);
break;
case 'h':
case 'b':
host = optarg;
break;
default:
......@@ -448,8 +453,7 @@ int main(int argc, char **argv) {
}
}
if(frequency < 0 || samplerate <= 0 || ppm == INT32_MIN ||
sdr_pipe_file == NULL || sdr_cmd_file == NULL) {
if(frequency < 0 || samplerate <= 0 || sdr_pipe_file == NULL || sdr_cmd_file == NULL) {
usage(argv[0]);
}
......
......@@ -176,7 +176,7 @@ void network_listener(char * host, char * port) {
sdr_cmd = fopen(sdr_cmd_file, "w");
int sockfd = bind_me(port, host, true);
int sockfd = bind_me(port, host, false);
listen(sockfd, 4);
int newsockfd;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment