dsctl-devel Mailing List for Dsctl - Digital scanner control program (Page 3)
Status: Alpha
Brought to you by:
roger-linux
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(59) |
Jul
(76) |
Aug
(1) |
Sep
|
Oct
|
Nov
(5) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: <rog...@us...> - 2007-07-12 06:36:33
|
Revision: 94 http://dsctl.svn.sourceforge.net/dsctl/?rev=94&view=rev Author: roger-linux Date: 2007-07-11 23:36:31 -0700 (Wed, 11 Jul 2007) Log Message: ----------- human_commands.c: Adds something I'm experimenting with just printing the output of STS command to console. (-e or --test undocumented option). main.c: This also fixes command line bug where switches would only work after the command specified. main.h & main.c: Removed an not needed function for these BCD models. Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/human_commands.c src/main.c src/main.h src/usage.c Modified: src/human_commands.c =================================================================== --- src/human_commands.c 2007-07-12 04:24:28 UTC (rev 93) +++ src/human_commands.c 2007-07-12 06:36:31 UTC (rev 94) @@ -159,6 +159,7 @@ get_current_tgid_status(fd); } + /* Give the user a daemon mode */ else if (daemon_mode == 1) { while (daemon_mode != 0) @@ -172,6 +173,15 @@ sleep(1); } } + /* User just wants a console display in deamon mode*/ + else if (daemon_mode == 2) + { + while (daemon_mode != 0) + { + get_current_status(fd); + sleep(1); + } + } } /*********************************************************************** Modified: src/main.c =================================================================== --- src/main.c 2007-07-12 04:24:28 UTC (rev 93) +++ src/main.c 2007-07-12 06:36:31 UTC (rev 94) @@ -57,8 +57,6 @@ FILE *configfile; char errorstr[100]; - signal(SIGINT, sighandler); - bzero(serial_port, 20); cmd_loc = 1; @@ -150,6 +148,7 @@ { bzero(serial_port, 20); strncat(serial_port, argv[++i], 20); + cmd_loc += 2; cmd_arg_loc += 2; } @@ -157,16 +156,35 @@ else if (strcmp(argv[i], "-b") == 0 || strcmp(argv[i], "--baud") == 0) /* baud rate */ { baud_rate = atoi(argv[++i]); + cmd_loc += 2; cmd_arg_loc += 2; } else if (strcmp(argv[i], "-d") == 0 || strcmp(argv[i], "--daemon") == 0) /* daemon mode */ + { daemon_mode = 1; + cmd_loc += 1; + cmd_arg_loc += 1; + } + + else if (strcmp(argv[i], "-e") == 0 || strcmp(argv[i], "--test") == 0) /* daemon mode */ + { + daemon_mode = 2; + + cmd_loc += 1; + cmd_arg_loc += 1; + } + else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) /* help */ + { usage(C_NONE); + cmd_loc += 1; + cmd_arg_loc += 1; + } + else if (strcmp(argv[i], "-m") == 0 || strcmp(argv[i], "--model") == 0) /* model */ { char mdl[9], *p; @@ -180,13 +198,19 @@ scannermodel = BCD396T; else scannermodel = MODELUNKNOWN; /* error will be caught below */ - + cmd_loc += 2; cmd_arg_loc += 2; } else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) /* debug */ + { debug = 1; + + + cmd_loc += 1; + cmd_arg_loc += 1; + } } /* now set our variables that can be passed in to human functions */ @@ -276,44 +300,3 @@ return (-1); } -/*********************************************************************** - * a signal handler to reset the scanner's mode, useful mostly for - id_report() at this point. - ***********************************************************************/ -void sighandler(int sig) -{ - char answer[100]; - int exitcode; - - signal(sig, SIG_IGN); - - bzero(answer, 100); - do_command(fd, "IDF", answer); - - if (strncmp(answer, "OK", 2) == 0) - { - puts("ID report mode disabled\n"); - - exitcode = 0; - } - else - { - puts("Unable to disable ID report mode\n"); - exitcode = 1; - } - - bzero(answer, 100); - do_command(fd, "QUF", answer); - - if (strncmp(answer, "OK", 2) == 0) - { - puts("Scan report mode disabled\n"); - } - else - { - puts("Unable to disable scan report mode\n"); - exitcode = 1; - } - - exit(exitcode); -} Modified: src/main.h =================================================================== --- src/main.h 2007-07-12 04:24:28 UTC (rev 93) +++ src/main.h 2007-07-12 06:36:31 UTC (rev 94) @@ -50,6 +50,5 @@ ***********************************************************************/ int get_cmd(char *cmd); -void sighandler(int sig); #endif /* _MAIN_H_ */ Modified: src/usage.c =================================================================== --- src/usage.c 2007-07-12 04:24:28 UTC (rev 93) +++ src/usage.c 2007-07-12 06:36:31 UTC (rev 94) @@ -61,7 +61,7 @@ default: fprintf(stderr, - "\n Usage: dsctl [-p port] [-b baud rate] [-m scannermodel] command options\n\n"); + "\n Usage: dsctl [-p port] [-b baud rate] [-m scannermodel] command\n\n"); fprintf(stderr, " (It's important a space is used between the command letter and it's argument.)\n\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-12 04:24:37
|
Revision: 93 http://dsctl.svn.sourceforge.net/dsctl/?rev=93&view=rev Author: roger-linux Date: 2007-07-11 21:24:28 -0700 (Wed, 11 Jul 2007) Log Message: ----------- commands.c Modification to daemon mode so display only displays raw output from scanner. This looks good for a log mode. But I still want to modify this further to diplay a time for each scanner call and including this features as a "log feature" instead of daemon mode feature. (Daemon mode should only monitor for specified scanner activity and then log specified activity along with record audio.) Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.c src/commands.h Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-11 06:34:36 UTC (rev 92) +++ src/commands.c 2007-07-12 04:24:28 UTC (rev 93) @@ -49,9 +49,10 @@ do_command(fd, "GID", answer); /*printf ("%s\n(%i)\n", answer, strlen (answer)); */ parse_fields(answer, field); + + if (daemon_mode == 0) + printf("\nTalkgroup ID Status:\n"); - printf("Talkgroup ID Status:\n"); - /* We have 6 parsed fields to print for this command */ for (i = 0; i <= 5; i++) { @@ -59,7 +60,7 @@ printf(","); printf("%s", field[i]); } - printf("\n\n"); + printf("\n"); } /*********************************************************************** @@ -128,6 +129,8 @@ strncmp(second_half, "SCAN", 4) == 0) strncpy(field[6], "SCANNING\0", 17); + if (daemon_mode == 0) + { printf("Display Status:\n"); /* Note: Screen changes entirely when in Menu Mode */ printf(" %s\n %s\n %s\n %s\n", field[6], field[8], field[10], field[12]); @@ -159,9 +162,10 @@ printf(" Alert LED: ON\n"); printf(" Signal Level: %i\n\n", atoi(field[20]) ); + } /* We have 23 parsed fields to print for this command */ - if (debug > 0) + if (debug > 0 || daemon_mode > 0) { for (i = 0; i <= 22; i++) { @@ -169,7 +173,7 @@ printf(","); printf("%s", field[i]); } - printf("\n\n"); + printf("\n"); } } @@ -189,7 +193,8 @@ /*printf ("%s\n(%i)\n", answer, strlen (answer)); */ parse_fields(answer, field); - printf("Reception Status:\n"); + if (daemon_mode == 0) + printf("Reception Status:\n"); /* We have 10 parsed fields to print for this command */ for (i = 0; i <= 9; i++) @@ -198,7 +203,7 @@ printf(","); printf("%s", field[i]); } - printf("\n\n"); + printf("\n"); } /*********************************************************************** Modified: src/commands.h =================================================================== --- src/commands.h 2007-07-11 06:34:36 UTC (rev 92) +++ src/commands.h 2007-07-12 04:24:28 UTC (rev 93) @@ -22,6 +22,7 @@ #define _COMMANDS_H_ extern int scannermodel; +extern int daemon_mode; extern int debug; /*********************************************************************** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-11 06:34:38
|
Revision: 92 http://dsctl.svn.sourceforge.net/dsctl/?rev=92&view=rev Author: roger-linux Date: 2007-07-10 23:34:36 -0700 (Tue, 10 Jul 2007) Log Message: ----------- commands.c Daemon Mode -- Experimental. But I think it's really calling for an ncurses interface for the console/terminal. (In theory, think daemon mode should also provide a facility for constantly monitoring so users can perform timed recording or activated recording based on scanner activity.) Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/human_commands.c src/human_commands.h src/main.c src/usage.c Modified: src/human_commands.c =================================================================== --- src/human_commands.c 2007-07-10 22:59:00 UTC (rev 91) +++ src/human_commands.c 2007-07-11 06:34:36 UTC (rev 92) @@ -25,6 +25,7 @@ #include <string.h> #include <ctype.h> #include <stdlib.h> +#include <signal.h> #include "human_commands.h" #include "commands.h" @@ -150,13 +151,27 @@ ***********************************************************************/ void human_do_status(int fd, int argc, char **args) { + if (daemon_mode == 0) + { + get_current_status(fd); - get_current_status(fd); + get_reception_status(fd); + + get_current_tgid_status(fd); + } + else if (daemon_mode == 1) + { + while (daemon_mode != 0) + { + get_current_status(fd); - get_reception_status(fd); + get_reception_status(fd); - get_current_tgid_status(fd); - + get_current_tgid_status(fd); + + sleep(1); + } + } } /*********************************************************************** Modified: src/human_commands.h =================================================================== --- src/human_commands.h 2007-07-10 22:59:00 UTC (rev 91) +++ src/human_commands.h 2007-07-11 06:34:36 UTC (rev 92) @@ -25,6 +25,7 @@ #define _HUMAN_COMMANDS_H_ extern int debug; +extern int daemon_mode; /*********************************************************************** * Keycodes for the Key Push command Modified: src/main.c =================================================================== --- src/main.c 2007-07-10 22:59:00 UTC (rev 91) +++ src/main.c 2007-07-11 06:34:36 UTC (rev 92) @@ -40,6 +40,7 @@ int fd; /* because we need to have the fd available for the signal handler */ int scannermodel = DEFAULT_MODEL; /* scanner model id... used throughout the program to * determine how certain commands are given to the scanner */ +int daemon_mode = 0; /* this should get us a daemon mode */ int debug = DEBUG; /* debug flag for extra output */ /*********************************************************************** @@ -152,12 +153,17 @@ cmd_loc += 2; cmd_arg_loc += 2; } + else if (strcmp(argv[i], "-b") == 0 || strcmp(argv[i], "--baud") == 0) /* baud rate */ { baud_rate = atoi(argv[++i]); cmd_loc += 2; cmd_arg_loc += 2; } + + else if (strcmp(argv[i], "-d") == 0 || strcmp(argv[i], "--daemon") == 0) /* daemon mode */ + daemon_mode = 1; + else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) /* help */ usage(C_NONE); @@ -178,6 +184,7 @@ cmd_loc += 2; cmd_arg_loc += 2; } + else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) /* debug */ debug = 1; } Modified: src/usage.c =================================================================== --- src/usage.c 2007-07-10 22:59:00 UTC (rev 91) +++ src/usage.c 2007-07-11 06:34:36 UTC (rev 92) @@ -71,6 +71,9 @@ fprintf(stderr, " 4800, 9600, 19200, 38400, 57600, 115200\n\n"); + fprintf(stderr, + " -d --daemon Daemon mode. (Experimental)\n"); + fprintf(stderr, " -h --help This help text.\n\n"); fprintf(stderr, " -m --model Supported scanner models are:\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-10 22:59:04
|
Revision: 91 http://dsctl.svn.sourceforge.net/dsctl/?rev=91&view=rev Author: roger-linux Date: 2007-07-10 15:59:00 -0700 (Tue, 10 Jul 2007) Log Message: ----------- commands.c: Modified status command output to including a more detailed explanation of SAME code alert. (Trivial) Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.c Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-10 22:51:26 UTC (rev 90) +++ src/commands.c 2007-07-10 22:59:00 UTC (rev 91) @@ -145,7 +145,7 @@ if (atoi(field[17]) == 0) printf(" Weather Alert: None\n"); else - printf(" Weather Alert: ON SAME CODE %s", field[17] ); + printf(" Weather Alert: ON for SAME CODE - %s", field[17] ); if (atoi(field[18]) == 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-10 22:51:27
|
Revision: 90 http://dsctl.svn.sourceforge.net/dsctl/?rev=90&view=rev Author: roger-linux Date: 2007-07-10 15:51:26 -0700 (Tue, 10 Jul 2007) Log Message: ----------- serial.c: Fixed printf to include newline (Trivial) Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/serial.c Modified: src/serial.c =================================================================== --- src/serial.c 2007-07-10 22:41:15 UTC (rev 89) +++ src/serial.c 2007-07-10 22:51:26 UTC (rev 90) @@ -188,7 +188,7 @@ { errno = ETIME; perror("read serial: returned error code"); - printf("read serial: Wrong port or baud rate?"); + printf("read serial: Wrong port or baud rate?\n"); exit(EXIT_FAILURE); } else if (select_err == -1) @@ -309,7 +309,7 @@ { errno = ETIME; perror("write_serial: returned error code"); - printf("write_serial: Wrong port or baud rate?"); + printf("write_serial: Wrong port or baud rate?\n"); exit(EXIT_FAILURE); } else if (select_err == -1) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-10 22:41:19
|
Revision: 89 http://dsctl.svn.sourceforge.net/dsctl/?rev=89&view=rev Author: roger-linux Date: 2007-07-10 15:41:15 -0700 (Tue, 10 Jul 2007) Log Message: ----------- usage.c: Augmented -v/--verbose for specifying verbosity instead of the unimplemented "-v just output version" switch. Modified Paths: -------------- src/usage.c Modified: src/usage.c =================================================================== --- src/usage.c 2007-07-10 22:31:43 UTC (rev 88) +++ src/usage.c 2007-07-10 22:41:15 UTC (rev 89) @@ -82,7 +82,7 @@ " -p --port ie. \"-p /dev/ttyS0\" or \"-p /dev/ttyUSB0\"\n\n"); fprintf(stderr, - " -v --version Just this program's version.\n\n"); + " -v --verbose Verbose output.\n\n"); fprintf(stderr, " Currently supported commands for BCD models are:\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-10 22:31:44
|
Revision: 88 http://dsctl.svn.sourceforge.net/dsctl/?rev=88&view=rev Author: roger-linux Date: 2007-07-10 15:31:43 -0700 (Tue, 10 Jul 2007) Log Message: ----------- main.c: New verbose option. (Gets initial value of defined DEBUG - zero - in config.h.). Still have to uncomment existing printfs, but status command now uses the -v switch. commands.c: Modified output of command status. Raw output is now only available via debug/verbose switch. (I'll probably add a "really raw output" for status commands later for gui or other reasons.) commands.c: FIXED: bug in get_lcd_contrast settings. Variable array to small & would segfault on dump. (TRIVIAL). Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.c src/commands.h src/human_commands.h src/main.c src/utils.c src/utils.h Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-10 07:00:44 UTC (rev 87) +++ src/commands.c 2007-07-10 22:31:43 UTC (rev 88) @@ -114,6 +114,9 @@ replace_chars(field[8], field[8]); /*printf("Test replace_chars: %s, %i\n\n\n", field[8], strlen(field[8]); */ + + //replace_chars(field[10], field[10]); /* replace_chars is omitting Sytems Scan status line, so comment out for now */ + /*printf("Test replace_chars: %s, %i\n\n\n", field[8], strlen(field[8]); */ /* The following is used for stopping the effect of the 6th field SCAN */ char first_half[20]; @@ -125,33 +128,49 @@ strncmp(second_half, "SCAN", 4) == 0) strncpy(field[6], "SCANNING\0", 17); - printf("Status:\n"); + printf("Display Status:\n"); + /* Note: Screen changes entirely when in Menu Mode */ + printf(" %s\n %s\n %s\n %s\n", field[6], field[8], field[10], field[12]); - /* Because the scanners lines change so frequently with multiple types of - * data, I can only think of using just the scrolling scan from the display - * for indicating the scanners status of actively scanning. Other then - * this, probably just best to actually pipe the actual output as is? - * - * Status: (L/O, HOLD, SIGNAL, CC?) - * System/Group Name: - * Channel Name: - * Channel Data: || Channel Frequency || Trunk Activity Indicators - * Systems: || P25 Status: - * Groups: || P25 : - * - * *Screen changes entirely when in Menu Mode - * - */ + if (atoi(field[14]) == 0) + printf(" Squelch Status: Closed\n"); + else + printf(" Squelch Status: Open\n"); + if (atoi(field[15]) == 0) + printf(" Mute Status: Off\n"); + else + printf(" Mute Status: ON\n"); + + if (atoi(field[17]) == 0) + printf(" Weather Alert: None\n"); + else + printf(" Weather Alert: ON SAME CODE %s", field[17] ); + + + if (atoi(field[18]) == 0) + printf(" Close Call LED: Off\n"); + else + printf(" Close Call LED: ON\n"); + + if (atoi(field[19]) == 0) + printf(" Alert LED: Off\n"); + else + printf(" Alert LED: ON\n"); + + printf(" Signal Level: %i\n\n", atoi(field[20]) ); + /* We have 23 parsed fields to print for this command */ - - for (i = 0; i <= 22; i++) + if (debug > 0) { - if (i != 0) - printf(","); - printf("%s", field[i]); + for (i = 0; i <= 22; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n\n"); } - printf("\n\n"); } /*********************************************************************** @@ -159,9 +178,7 @@ ***********************************************************************/ void get_reception_status(int fd) { - /* GLG - Reception Status - * See GID comment */ - + /* GLG - Reception Status */ char answer[500]; char *field[100]; int i; @@ -1935,12 +1952,11 @@ ***********************************************************************/ int get_lcd_contrast_settings(int fd) { - - char answer[100], command[100]; + char answer[500], command[100]; char *field[100]; int i; - memset(answer, 0, 100); + memset(answer, 0, 500); memset(command, 0, 100); memset(*field, 0, 100); @@ -2245,9 +2261,9 @@ get_weather_settings(fd); get_same_group_settings(fd); - + get_tone_out_settings(fd); - + get_lcd_contrast_settings(fd); get_lcd_upside_down_settings(fd); Modified: src/commands.h =================================================================== --- src/commands.h 2007-07-10 07:00:44 UTC (rev 87) +++ src/commands.h 2007-07-10 22:31:43 UTC (rev 88) @@ -22,6 +22,7 @@ #define _COMMANDS_H_ extern int scannermodel; +extern int debug; /*********************************************************************** * Function Declarations Modified: src/human_commands.h =================================================================== --- src/human_commands.h 2007-07-10 07:00:44 UTC (rev 87) +++ src/human_commands.h 2007-07-10 22:31:43 UTC (rev 88) @@ -24,6 +24,8 @@ #ifndef _HUMAN_COMMANDS_H_ #define _HUMAN_COMMANDS_H_ +extern int debug; + /*********************************************************************** * Keycodes for the Key Push command TODO: human_commands.c - use switch instead of if ?) Modified: src/main.c =================================================================== --- src/main.c 2007-07-10 07:00:44 UTC (rev 87) +++ src/main.c 2007-07-10 22:31:43 UTC (rev 88) @@ -40,6 +40,7 @@ int fd; /* because we need to have the fd available for the signal handler */ int scannermodel = DEFAULT_MODEL; /* scanner model id... used throughout the program to * determine how certain commands are given to the scanner */ +int debug = DEBUG; /* debug flag for extra output */ /*********************************************************************** * the main function. ain't it grand? @@ -177,6 +178,8 @@ cmd_loc += 2; cmd_arg_loc += 2; } + else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) /* debug */ + debug = 1; } /* now set our variables that can be passed in to human functions */ Modified: src/utils.c =================================================================== --- src/utils.c 2007-07-10 07:00:44 UTC (rev 87) +++ src/utils.c 2007-07-10 22:31:43 UTC (rev 88) @@ -397,55 +397,80 @@ if (strstr(bcd_chars, "\200") != 0) strncat(tmp_line, "[FULL DOT] ", 11); + if (strstr(bcd_chars, "\201") != 0) strncat(tmp_line, "[>>>] ", 6); + if (strstr(bcd_chars, "\202") != 0) strncat(tmp_line, "[<<<] ", 6); + if (strstr(bcd_chars, "\213") != 0) strncat(tmp_line, "[FUNCTION KEY] ", 15); + if (strstr(bcd_chars, "\215\216\217\220") != 0) strncat(tmp_line, "[HOLD] ", 7); + if (strstr(bcd_chars, "\225\226\227") != 0) strncat(tmp_line, "[LOCKOUT] ", 10); + if (strstr(bcd_chars, "\221\222\223\224") != 0) strncat(tmp_line, "[DATA SKIP] ", 12); + if (strstr(bcd_chars, "\214") != 0) strncat(tmp_line, "[PRI CHANNEL] ", 14); + if (strstr(bcd_chars, "\230\231\232") != 0) strncat(tmp_line, "[AM] ", 5); + if (strstr(bcd_chars, "\233\234\232") != 0) strncat(tmp_line, "[FM] ", 5); + if (strstr(bcd_chars, "\235\236\234\232") != 0) strncat(tmp_line, "[NFM] ", 6); + if (strstr(bcd_chars, "\237\240\234\232") != 0) strncat(tmp_line, "[WFM] ", 6); + if (strstr(bcd_chars, "\233\234\271\272") != 0) strncat(tmp_line, "[FMB] ", 6); + if (strstr(bcd_chars, "\243\244\245") != 0) strncat(tmp_line, "[ATT] ", 6); + if (strstr(bcd_chars, "\252\253 ") != 0) strncat(tmp_line, "[SIGNAL LEVEL 4] ", 17); + if (strstr(bcd_chars, "\254\255") != 0) strncat(tmp_line, "[SIGNAL LEVEL 5] ", 17); + if (strstr(bcd_chars, "\246") != 0) strncat(tmp_line, "[SIGNAL LEVEL 1] ", 17); + if (strstr(bcd_chars, "\247") != 0) strncat(tmp_line, "[SIGNAL LEVEL 2] ", 17); + if (strstr(bcd_chars, "\256") != 0) strncat(tmp_line, "[ACTIVE INDICATOR 1] ", 21); + if (strstr(bcd_chars, "\257") != 0) strncat(tmp_line, "[ACTIVE INDICATOR 2] ", 21); + if (strstr(bcd_chars, "\260") != 0) strncat(tmp_line, "[ACTIVE INDICATOR 3] ", 21); + if (strstr(bcd_chars, "\264") != 0) strncat(tmp_line, "[ACTIVE INDICATOR 4] ", 21); + if (strstr(bcd_chars, "\207\210") != 0) strncat(tmp_line, "[CC PRI TOP] ", 13); - if (strstr(bcd_chars, "\211\212") != 0) + + if (strstr(bcd_chars, " \211\212") != 0) strncat(tmp_line, "[CC PRI BOTTOM] ", 16); + if (strstr(bcd_chars, "\265\266") != 0) strncat(tmp_line, "[CC DND TOP] ", 13); - if (strstr(bcd_chars, "\267\270") != 0) + + if (strstr(bcd_chars, "\267\270") != NULL) strncat(tmp_line, "[CC DND BOTTOM] ", 16); strncpy(common_chars, tmp_line, 100); Modified: src/utils.h =================================================================== --- src/utils.h 2007-07-10 07:00:44 UTC (rev 87) +++ src/utils.h 2007-07-10 22:31:43 UTC (rev 88) @@ -25,6 +25,7 @@ #define _UTILS_H_ extern int scannermodel; +extern int debug; /* * Uniden's customized Ascii Characters This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-10 07:00:46
|
Revision: 87 http://dsctl.svn.sourceforge.net/dsctl/?rev=87&view=rev Author: roger-linux Date: 2007-07-10 00:00:44 -0700 (Tue, 10 Jul 2007) Log Message: ----------- commands.c: Variable renaming and Comments trivial adjustments. Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.c Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-09 19:29:29 UTC (rev 86) +++ src/commands.c 2007-07-10 07:00:44 UTC (rev 87) @@ -52,7 +52,7 @@ printf("Talkgroup ID Status:\n"); - /* We have 6 parsed fields to print for GLG command */ + /* We have 6 parsed fields to print for this command */ for (i = 0; i <= 5; i++) { if (i != 0) @@ -143,7 +143,7 @@ * */ - /* We have 23 parsed fields to print for STS command */ + /* We have 23 parsed fields to print for this command */ for (i = 0; i <= 22; i++) { @@ -174,7 +174,7 @@ printf("Reception Status:\n"); - /* We have 10 parsed fields to print for GLG command */ + /* We have 10 parsed fields to print for this command */ for (i = 0; i <= 9; i++) { if (i != 0) @@ -209,7 +209,7 @@ /*printf("%s\n(%i)\n", answer, strlen(answer)); */ parse_fields(answer, field); - /* We have 2 parsed fields to print for MDL command */ + /* We have 2 parsed fields to print for this command */ for (i = 0; i <= 1; i++) { if (i != 0) @@ -237,7 +237,7 @@ /*printf("%s\n(%i)\n", answer, strlen(answer)); */ parse_fields(answer, field); - /* We have 2 parsed fields to print for VER command */ + /* We have 2 parsed fields to print for this command */ for (i = 0; i <= 1; i++) { if (i != 0) @@ -316,7 +316,7 @@ /*printf("%s\n(%i)\n", answer, strlen(answer)); */ parse_fields(answer, field); - /* We have 2 parsed fields to print for BKL command */ + /* We have 2 parsed fields to print for this command */ for (i = 0; i <= 1; i++) { if (i != 0) @@ -355,7 +355,7 @@ /*printf("%s\n(%i)\n", answer, strlen(answer)); */ parse_fields(answer, field); - /* We have 2 parsed fields to print for KBP command */ + /* We have 2 parsed fields to print for this command */ for (i = 0; i <= 1; i++) { if (i != 0) @@ -387,7 +387,7 @@ /*printf("%s\n(%i)\n", answer, strlen(answer)); */ parse_fields(answer, field); - /* We have 5 parsed fields to print for OMS command */ + /* We have 5 parsed fields to print for this command */ for (i = 0; i <= 4; i++) { if (i != 0) @@ -418,7 +418,7 @@ /*printf("%s\n(%i)\n", answer, strlen(answer)); */ parse_fields(answer, field); - /* We have 2 parsed fields to print for PRI command */ + /* We have 2 parsed fields to print for this command */ for (i = 0; i <= 1; i++) { if (i != 0) @@ -449,7 +449,7 @@ /*printf("%s\n(%i)\n", answer, strlen(answer)); */ parse_fields(answer, field); - /* We have 3 parsed fields to print for AGV command */ + /* We have 3 parsed fields to print for this command */ for (i = 0; i <= 2; i++) { if (i != 0) @@ -480,7 +480,7 @@ /*printf("%s\n(%i)\n", answer, strlen(answer)); */ parse_fields(answer, field); - /* We have 2 parsed fields to print for SCT command */ + /* We have 2 parsed fields to print for this command */ for (i = 0; i <= 1; i++) { if (i != 0) @@ -544,7 +544,7 @@ /*printf("%s\n(%i)\n", answer, strlen(answer)); */ parse_fields(answer, field); - /* We have 2 parsed fields to print for SIT command */ + /* We have 2 parsed fields to print for this command */ for (i = 0; i <= 1; i++) { if (i != 0) @@ -577,7 +577,7 @@ /*printf("%s\n(%i)\n", answer, strlen(answer)); */ parse_fields(answer, field); - /* We have 11 parsed fields to print for QSL command */ + /* We have 11 parsed fields to print for this command */ for (i = 0; i <= 10; i++) { if (i != 0) @@ -608,7 +608,7 @@ /*printf("%s\n(%i)\n", answer, strlen(answer)); */ parse_fields(answer, field); - /* We have 2 parsed fields to print for QGL command */ + /* We have 2 parsed fields to print for this command */ for (i = 0; i <= 1; i++) { if (i != 0) @@ -677,9 +677,10 @@ /*********************************************************************** * Get System ***********************************************************************/ -int get_system_info(int fd, int system_index, char *system_type, char *channel_group_head) +int get_system_info(int fd, int system_index, char *system_type, + char *channel_group_head) { - //get_group_quick_lockout(fd, sys_index); /* This might break things */ + //get_group_quick_lockout(fd, sys_index); /* This might break things */ char answer[500], command[100]; char *field[100]; @@ -696,7 +697,7 @@ /*printf ("\n%s\n(%i)\n", answer, strlen (answer)); */ parse_fields(answer, field); - /* We have 23 parsed fields to print for SIN command */ + /* We have 23 parsed fields to print for this command */ for (i = 0; i <= 22; i++) { if (i != 0) @@ -915,7 +916,7 @@ /*printf("%s\n(%i)\n", answer, strlen(answer)); */ parse_fields(answer, field); - /* We have 11 parsed fields to print for GIN command */ + /* We have 11 parsed fields to print for this command */ for (i = 0; i <= 10; i++) { if (i != 0) @@ -1327,7 +1328,7 @@ /*printf("%s\n(%i)\n", answer, strlen(answer)); */ parse_fields(answer, field); - /* We have 9 parsed fields to print for ABP command */ + /* We have 9 parsed fields to print for this command */ for (i = 0; i <= 9; i++) { if (i != 0) @@ -1447,7 +1448,7 @@ /*printf("%s\n(%i)\n", answer, strlen(answer)); */ parse_fields(answer, field); - /* We have 2 parsed fields to print for RMB command */ + /* We have 2 parsed fields to print for this command */ for (i = 0; i <= 1; i++) { if (i != 0) @@ -1478,7 +1479,7 @@ /*printf("%s\n(%i)\n", answer, strlen(answer)); */ parse_fields(answer, field); - /* We have 6 parsed fields to print for MEM command */ + /* We have 6 parsed fields to print for this command */ for (i = 0; i <= 5; i++) { if (i != 0) @@ -1848,7 +1849,7 @@ /*printf("%s\n(%i)\n", answer, strlen(answer)); */ parse_fields(answer, field); - /* We have 4 parsed fields to print for WXS command */ + /* We have 4 parsed fields to print for this command */ for (i = 0; i <= 3; i++) { if (i != 0) @@ -1881,7 +1882,7 @@ /*printf("%s\n(%i)\n", answer, strlen(answer)); */ parse_fields(answer, field); - /* We have 10 parsed fields to print for SGP command */ + /* We have 10 parsed fields to print for this command */ for (i = 0; i <= 9; i++) { if (i != 0) @@ -1916,7 +1917,7 @@ /*printf("%s\n(%i)\n", answer, strlen(answer)); */ parse_fields(answer, field); - /* We have 15 parsed fields to print for TON command */ + /* We have 15 parsed fields to print for this command */ for (i = 0; i <= 14; i++) { if (i != 0) @@ -1936,25 +1937,25 @@ { char answer[100], command[100]; - char *lcdcontrast_field[100]; + char *field[100]; int i; memset(answer, 0, 100); memset(command, 0, 100); - memset(lcdcontrast_field, 0, 100); + memset(*field, 0, 100); snprintf(command, 100, "CNT"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, lcdcontrast_field); + parse_fields(answer, field); - /* We have 2 parsed fields to print for CNT command */ + /* We have 2 parsed fields to print for this command */ for (i = 0; i <= 1; i++) { if (i != 0) printf(","); - printf("%s", lcdcontrast_field[i]); + printf("%s", field[i]); } printf("\n"); @@ -1967,25 +1968,25 @@ int get_lcd_upside_down_settings(int fd) { char answer[100], command[100]; - char *lcdupsidedown_field[100]; + char *field[100]; int i; memset(answer, 0, 100); memset(command, 0, 100); - memset(lcdupsidedown_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "DUD"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, lcdupsidedown_field); + parse_fields(answer, field); - /* We have 2 parsed fields to print for DUD command */ + /* We have 2 parsed fields to print for this command */ for (i = 0; i <= 1; i++) { if (i != 0) printf(","); - printf("%s", lcdupsidedown_field[i]); + printf("%s", field[i]); } printf("\n"); @@ -1998,25 +1999,25 @@ int get_scanner_option_settings(int fd) { char answer[500], command[100]; - char *scanneropts_field[100]; + char *field[100]; int i; memset(answer, 0, 500); memset(command, 0, 100); - memset(scanneropts_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "SCN"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, scanneropts_field); + parse_fields(answer, field); - /* We have 20 parsed fields to print for SCN command */ + /* We have 20 parsed fields to print for this command */ for (i = 0; i <= 19; i++) { if (i != 0) printf(","); - printf("%s", scanneropts_field[i]); + printf("%s", field[i]); } printf("\n"); @@ -2029,25 +2030,25 @@ int get_apco_settings(int fd) { char answer[500], command[100]; - char *apcodata_field[100]; + char *field[100]; int i; memset(answer, 0, 500); memset(command, 0, 100); - memset(apcodata_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "P25"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, apcodata_field); + parse_fields(answer, field); - /* We have 4 parsed fields to print for SCN command */ + /* We have 4 parsed fields to print for this command */ for (i = 0; i <= 3; i++) { if (i != 0) printf(","); - printf("%s", apcodata_field[i]); + printf("%s", field[i]); } printf("\n"); @@ -2060,25 +2061,25 @@ int get_gps_display_option(int fd) { char answer[500], command[100]; - char *gpsformat_field[100]; + char *field[100]; int i; memset(answer, 0, 500); memset(command, 0, 100); - memset(gpsformat_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "GDO"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, gpsformat_field); + parse_fields(answer, field); - /* We have 5 parsed fields to print for GDO command */ + /* We have 5 parsed fields to print for this command */ for (i = 0; i <= 4; i++) { if (i != 0) printf(","); - printf("%s", gpsformat_field[i]); + printf("%s", field[i]); } printf("\n"); @@ -2091,25 +2092,25 @@ int get_gps_gga_data(int fd) { char answer[100], command[100]; - char *ggadata_field[100]; + char *field[100]; int i; memset(answer, 0, 100); memset(command, 0, 100); - memset(ggadata_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "GGA"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, ggadata_field); + parse_fields(answer, field); - /* We have 2 parsed fields to print for GDO command */ + /* We have 2 parsed fields to print for this command */ for (i = 0; i <= 1; i++) { if (i != 0) printf(","); - printf("%s", ggadata_field[i]); + printf("%s", field[i]); } printf("\n"); @@ -2122,25 +2123,25 @@ int get_gps_rmc_data(int fd) { char answer[100], command[100]; - char *rmcdata_field[100]; + char *field[100]; int i; memset(answer, 0, 100); memset(command, 0, 100); - memset(rmcdata_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "RMC"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, rmcdata_field); + parse_fields(answer, field); - /* We have 2 parsed fields to print for RMC command */ + /* We have 2 parsed fields to print for this command */ for (i = 0; i <= 1; i++) { if (i != 0) printf(","); - printf("%s", rmcdata_field[i]); + printf("%s", field[i]); } printf("\n"); @@ -2153,25 +2154,25 @@ int get_window_voltage(int fd) { char answer[100], command[100]; - char *winvolt_field[100]; + char *field[100]; int i; memset(answer, 0, 100); memset(command, 0, 100); - memset(winvolt_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "WIN"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, winvolt_field); + parse_fields(answer, field); - /* We have 2 parsed fields to print for WIN command */ + /* We have 2 parsed fields to print for this command */ for (i = 0; i <= 1; i++) { if (i != 0) printf(","); - printf("%s", winvolt_field[i]); + printf("%s", field[i]); } printf("\n"); @@ -2180,21 +2181,14 @@ /*********************************************************************** * Download BCD memory contents -* TODO: Break This int low-level scanner command functions. -* (Reason I initially just gobbed this, had no idea how Uniden's memory -* tree worked.) +* TODO: All done. Just need to make things look nice. ***********************************************************************/ - - /* TODO: All done. Just need to make things look nice. - * TODO: We can start to see repeated code & how we - * might possibly put this code into functions. */ - int dump(int fd, FILE * outfile) { int i = 0; char sys_type[5], site_type[5]; - + int sys_index, grpinfo_index, chaninfo_index, trunkinfo_index, siteinfo_index, motbandplan_index, apcobandplan_index, trunkfreq_index, tgidinfo_index; @@ -2282,14 +2276,15 @@ { /* Get Group Quick Lockouts now along with System Info */ get_group_quick_lockout(fd, sys_index); - + /* Continue getting System Info */ char channel_group_head[10]; int next_system_index = 0; memset(channel_group_head, 0, 10); - next_system_index = get_system_info(fd, sys_index, sys_type, channel_group_head); + next_system_index = + get_system_info(fd, sys_index, sys_type, channel_group_head); /* Set our starting Group and Site index addresses from SIN info */ //siteinfo_index = atoi(sys_field[14]);*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-09 19:29:31
|
Revision: 86 http://dsctl.svn.sourceforge.net/dsctl/?rev=86&view=rev Author: roger-linux Date: 2007-07-09 12:29:29 -0700 (Mon, 09 Jul 2007) Log Message: ----------- commands.c Trivial comments. Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.c Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-09 07:18:19 UTC (rev 85) +++ src/commands.c 2007-07-09 19:29:29 UTC (rev 86) @@ -2264,15 +2264,14 @@ get_gps_display_option(fd); - /************************************************ - * Get Scan Settings - ************************************************/ + /* Get Scan Settings */ - /* SIN */ - /* While we have System Indexes, then print them. + /* SIN + * While we have System Indexes, then print them. * using the above System Head and System Tail * And once we find the first system, find the next system using - * forward system index field */ + * forward system index field. + * TODO: When we get SIN, create a new out-file named for each SIN name */ sys_index = get_system_index_head(fd); @@ -2293,8 +2292,7 @@ next_system_index = get_system_info(fd, sys_index, sys_type, channel_group_head); /* Set our starting Group and Site index addresses from SIN info */ - /* Pointers are returned from parse_fields, use strncpy for strings. */ - //siteinfo_index = atoi(sys_field[14]); + //siteinfo_index = atoi(sys_field[14]);*/ siteinfo_index = atoi(channel_group_head); trunkinfo_index = sys_index; //grpinfo_index = atoi(sys_field[14]); @@ -2389,7 +2387,7 @@ } /* SIF */ - /* While System has Sites, then print them. + /* While System has Sites, print them. * We only get Site Info (aka Site Settings), as well as TFQ, * if the System is not Conv Type * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-09 07:18:21
|
Revision: 85 http://dsctl.svn.sourceforge.net/dsctl/?rev=85&view=rev Author: roger-linux Date: 2007-07-09 00:18:19 -0700 (Mon, 09 Jul 2007) Log Message: ----------- commands.c: Variable renaming (Trivial) Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.c Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-09 06:58:42 UTC (rev 84) +++ src/commands.c 2007-07-09 07:18:19 UTC (rev 85) @@ -196,25 +196,25 @@ printf("Scanner Sysinfo: %s\n", answer); */ char answer[100], command[100]; - char *model_field[100]; + char *field[100]; int i; memset(answer, 0, 100); memset(command, 0, 100); - memset(model_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "MDL"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, model_field); + parse_fields(answer, field); /* We have 2 parsed fields to print for MDL command */ for (i = 0; i <= 1; i++) { if (i != 0) printf(","); - printf("%s", model_field[i]); + printf("%s", field[i]); } printf("\n"); } @@ -225,24 +225,24 @@ void get_firmware_version(fd) { char answer[100], command[100]; - char *firmvers_field[100]; + char *field[100]; int i; memset(answer, 0, 100); memset(command, 0, 100); - bzero(firmvers_field, 100); + bzero(field, 100); snprintf(command, 100, "VER"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, firmvers_field); + parse_fields(answer, field); /* We have 2 parsed fields to print for VER command */ for (i = 0; i <= 1; i++) { if (i != 0) printf(","); - printf("%s", firmvers_field[i]); + printf("%s", field[i]); } printf("\n"); @@ -304,24 +304,24 @@ int get_backlight(int fd) { char answer[100], command[100]; - char *backlight_field[100]; + char *field[100]; int i; memset(answer, 0, 100); memset(command, 0, 100); - memset(backlight_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "BKL"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, backlight_field); + parse_fields(answer, field); /* We have 2 parsed fields to print for BKL command */ for (i = 0; i <= 1; i++) { if (i != 0) printf(","); - printf("%s", backlight_field[i]); + printf("%s", field[i]); } printf("\n"); @@ -342,25 +342,25 @@ int get_key_beep(int fd) { char answer[100], command[100]; - char *key_beep_field[100]; + char *field[100]; int i; memset(answer, 0, 100); memset(command, 0, 100); - memset(key_beep_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "KBP"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, key_beep_field); + parse_fields(answer, field); /* We have 2 parsed fields to print for KBP command */ for (i = 0; i <= 1; i++) { if (i != 0) printf(","); - printf("%s", key_beep_field[i]); + printf("%s", field[i]); } printf("\n"); @@ -374,25 +374,25 @@ { char answer[500], command[100]; - char *openingmsg_field[500]; + char *field[500]; int i; memset(answer, 0, 500); memset(command, 0, 100); - memset(openingmsg_field, 0, 500); + memset(field, 0, 500); snprintf(command, 100, "OMS"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, openingmsg_field); + parse_fields(answer, field); /* We have 5 parsed fields to print for OMS command */ for (i = 0; i <= 4; i++) { if (i != 0) printf(","); - printf("%s", openingmsg_field[i]); + printf("%s", field[i]); } printf("\n"); @@ -405,25 +405,25 @@ int get_priority_mode(int fd) { char answer[100], command[100]; - char *primode_field[100]; + char *field[100]; int i; memset(answer, 0, 100); memset(command, 0, 100); - memset(primode_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "PRI"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, primode_field); + parse_fields(answer, field); /* We have 2 parsed fields to print for PRI command */ for (i = 0; i <= 1; i++) { if (i != 0) printf(","); - printf("%s", primode_field[i]); + printf("%s", field[i]); } printf("\n"); @@ -436,25 +436,25 @@ int get_auto_gain_control(int fd) { char answer[100], command[100]; - char *autogainctrl_field[100]; + char *field[100]; int i; memset(answer, 0, 100); memset(command, 0, 100); - memset(autogainctrl_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "AGV"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, autogainctrl_field); + parse_fields(answer, field); /* We have 3 parsed fields to print for AGV command */ for (i = 0; i <= 2; i++) { if (i != 0) printf(","); - printf("%s", autogainctrl_field[i]); + printf("%s", field[i]); } printf("\n"); @@ -467,25 +467,25 @@ int get_system_count(int fd) { char answer[100], command[100]; - char *syscount_field[100]; + char *field[100]; int i; memset(answer, 0, 100); memset(command, 0, 100); - memset(syscount_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "SCT"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, syscount_field); + parse_fields(answer, field); /* We have 2 parsed fields to print for SCT command */ for (i = 0; i <= 1; i++) { if (i != 0) printf(","); - printf("%s", syscount_field[i]); + printf("%s", field[i]); } printf("\n"); @@ -498,31 +498,31 @@ int get_system_index_head(int fd) { char answer[100], command[100]; - char *sysindexhead_field[100]; - int i; + char *field[100]; + int i, system_index_head; memset(answer, 0, 100); memset(command, 0, 100); - memset(sysindexhead_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "SIH"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, sysindexhead_field); + parse_fields(answer, field); - /* We have 2 parsed fields to print for SIH command */ - /*for (i = 0; i <= 1; i++) - { - if (i != 0) - printf(","); - printf("%s", sysindexhead_field[i]); - } - printf("\n"); */ + /* We have 2 parsed fields to print for this command */ + for (i = 0; i <= 1; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); - i = atoi(sysindexhead_field[1]); + system_index_head = atoi(field[1]); - return (i); + return (system_index_head); } /*********************************************************************** @@ -531,31 +531,31 @@ int get_system_index_tail(int fd) { char answer[100], command[100]; - char *sysindextail_field[100]; - int i; + char *field[100]; + int i, system_index_tail; memset(answer, 0, 100); memset(command, 0, 100); - memset(sysindextail_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "SIT"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, sysindextail_field); + parse_fields(answer, field); /* We have 2 parsed fields to print for SIT command */ - /*for (i = 0; i <= 1; i++) - { - if (i != 0) - printf(","); - printf("%s", sysindextail_field[i]); - } - printf("\n"); */ + for (i = 0; i <= 1; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); - i = atoi(sysindextail_field[1]); + system_index_tail = atoi(field[1]); - return (i); + return (system_index_tail); } /*********************************************************************** @@ -1435,24 +1435,24 @@ int get_remains_memory_block(int fd) { char answer[100], command[100]; - char *memblocks_field[100]; + char *field[100]; int i; memset(answer, 0, 100); memset(command, 0, 100); - memset(memblocks_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "RMB"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, memblocks_field); + parse_fields(answer, field); /* We have 2 parsed fields to print for RMB command */ for (i = 0; i <= 1; i++) { if (i != 0) printf(","); - printf("%s", memblocks_field[i]); + printf("%s", field[i]); } printf("\n"); @@ -1465,25 +1465,25 @@ int get_memory_used(int fd) { char answer[100], command[100]; - char *memused_field[100]; + char *field[100]; int i; memset(answer, 0, 100); memset(command, 0, 100); - memset(memused_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "MEM"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, memused_field); + parse_fields(answer, field); /* We have 6 parsed fields to print for MEM command */ for (i = 0; i <= 5; i++) { if (i != 0) printf(","); - printf("%s", memused_field[i]); + printf("%s", field[i]); } printf("\n"); @@ -1835,25 +1835,25 @@ int get_weather_settings(int fd) { char answer[100], command[100]; - char *wxsettings_field[100]; + char *field[100]; int i; memset(answer, 0, 100); memset(command, 0, 100); - memset(wxsettings_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "WXS"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, wxsettings_field); + parse_fields(answer, field); /* We have 4 parsed fields to print for WXS command */ for (i = 0; i <= 3; i++) { if (i != 0) printf(","); - printf("%s", wxsettings_field[i]); + printf("%s", field[i]); } printf("\n"); @@ -1866,27 +1866,27 @@ int get_same_group_settings(int fd) { char answer[500], command[100]; - char *samegrp_field[100]; + char *field[100]; int cmd_index, i; for (cmd_index = 1; cmd_index <= 5; cmd_index++) { memset(answer, 0, 500); memset(command, 0, 100); - memset(samegrp_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "SGP,%i", cmd_index); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, samegrp_field); + parse_fields(answer, field); /* We have 10 parsed fields to print for SGP command */ for (i = 0; i <= 9; i++) { if (i != 0) printf(","); - printf("%s", samegrp_field[i]); + printf("%s", field[i]); } printf("\n"); } @@ -1900,7 +1900,7 @@ int get_tone_out_settings(int fd) { char answer[500], command[100]; - char *toneout_field[100]; + char *field[100]; int cmd_index, i; int renum[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; @@ -1908,20 +1908,20 @@ { memset(answer, 0, 500); memset(command, 0, 100); - memset(toneout_field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "TON,%i", renum[cmd_index]); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, toneout_field); + parse_fields(answer, field); /* We have 15 parsed fields to print for TON command */ for (i = 0; i <= 14; i++) { if (i != 0) printf(","); - printf("%s", toneout_field[i]); + printf("%s", field[i]); } printf("\n"); } @@ -2191,16 +2191,13 @@ int dump(int fd, FILE * outfile) { - char answer[500], command[100]; - int i = 0; char sys_type[5], site_type[5]; - + int sys_index, grpinfo_index, chaninfo_index, trunkinfo_index, siteinfo_index, motbandplan_index, apcobandplan_index, trunkfreq_index, tgidinfo_index; - char *sys_field[100], *trunkinfo_field[100]; /* File Version Format */ printf("dsctl version %s\n\n", FFVERSION); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-09 06:58:44
|
Revision: 84 http://dsctl.svn.sourceforge.net/dsctl/?rev=84&view=rev Author: roger-linux Date: 2007-07-08 23:58:42 -0700 (Sun, 08 Jul 2007) Log Message: ----------- commands.c: Last function to move to the low-level scanner commands at the top. Now, just to go back through the dump function and change variable names for consistancy. Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.c src/commands.h Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-09 06:30:54 UTC (rev 83) +++ src/commands.c 2007-07-09 06:58:42 UTC (rev 84) @@ -677,10 +677,52 @@ /*********************************************************************** * Get System ***********************************************************************/ -int get_system_info(int fd, int system_index) +int get_system_info(int fd, int system_index, char *system_type, char *channel_group_head) { + //get_group_quick_lockout(fd, sys_index); /* This might break things */ - return (0); + char answer[500], command[100]; + char *field[100]; + int i; + int next_system_index = 0; + + memset(answer, 0, 500); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "SIN,%i", system_index); + /*printf("Command == %s\n", command); */ + do_command(fd, command, answer); + /*printf ("\n%s\n(%i)\n", answer, strlen (answer)); */ + parse_fields(answer, field); + + /* We have 23 parsed fields to print for SIN command */ + for (i = 0; i <= 22; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); + + /* Set our starting Group and Site index addresses from SIN info */ + /* Pointers are returned from parse_fields, use strncpy for strings. */ + //siteinfo_index = atoi(sys_field[14]); + //trunkinfo_index = sys_index; + //grpinfo_index = atoi(sys_field[14]); + //strncpy(sys_type, sys_field[1], 5); + strncpy(system_type, field[1], 5); + strncpy(channel_group_head, field[14], 10); + + /*sys_type = sys_field[1]; */ + /*printf("systype = %s\n", sys_type); */ + /*printf("trunkinfo_index = %i\n", trunkinfo_index); */ + + /* We're using the Forward System Index field for getting the + * next System Info address. Set this after we set the above variables. */ + next_system_index = atoi(field[13]); + + return (next_system_index); } /*********************************************************************** @@ -2234,38 +2276,33 @@ * using the above System Head and System Tail * And once we find the first system, find the next system using * forward system index field */ + sys_index = get_system_index_head(fd); + /* Get System Quick Lockouts now */ get_system_quick_lockout(fd); while (sys_index != -1) { - get_group_quick_lockout(fd, sys_index); /* This might break things */ + /* Get Group Quick Lockouts now along with System Info */ + get_group_quick_lockout(fd, sys_index); + + /* Continue getting System Info */ + char channel_group_head[10]; + int next_system_index = 0; - bzero(answer, 500); - bzero(command, 100); - bzero(sys_field, 100); - snprintf(command, 100, "SIN,%i", sys_index); - /*printf("Command == %s\n", command); */ - do_command(fd, command, answer); - /*printf ("\n%s\n(%i)\n", answer, strlen (answer)); */ - parse_fields(answer, sys_field); + memset(channel_group_head, 0, 10); - /* We have 23 parsed fields to print for SIN command */ - for (i = 0; i <= 22; i++) - { - if (i != 0) - printf(","); - printf("%s", sys_field[i]); - } - printf("\n"); + next_system_index = get_system_info(fd, sys_index, sys_type, channel_group_head); /* Set our starting Group and Site index addresses from SIN info */ /* Pointers are returned from parse_fields, use strncpy for strings. */ - siteinfo_index = atoi(sys_field[14]); + //siteinfo_index = atoi(sys_field[14]); + siteinfo_index = atoi(channel_group_head); trunkinfo_index = sys_index; - grpinfo_index = atoi(sys_field[14]); - strncpy(sys_type, sys_field[1], 5); + //grpinfo_index = atoi(sys_field[14]); + grpinfo_index = atoi(channel_group_head); + //strncpy(sys_type, sys_field[1], 5); /*sys_type = sys_field[1]; */ /*printf("systype = %s\n", sys_type); */ @@ -2273,21 +2310,18 @@ /* We're using the Forward System Index field for getting the * next System Info address. Set this after we set the above variables. */ - sys_index = atoi(sys_field[13]); + //sys_index = atoi(sys_field[13]); + sys_index = next_system_index; /* TRN */ /* While System has Trunked Systems, then print them. * - * Site Info shares the first Group's address for some - * odd/undocumented reason - memory layout? - * Use the SIN address (TRN,13320) - * * Set our grpinfo variable before getting site info because * these are pointers and site info will overwrite it's - * variable! + * variable. * - * We only get Site Info (aka Site Settings), as well as TFQ, - * if the System is not Conv Type */ + * We only get Site Info, as well as trunked frequencies, + * if the system is not conv type */ /*printf("systype = %s trunkinfo_index = %i\n", sys_type, trunkinfo_index); */ /*TODO: trunkinfo_index -- used orig name. Might want to rename it. */ Modified: src/commands.h =================================================================== --- src/commands.h 2007-07-09 06:30:54 UTC (rev 83) +++ src/commands.h 2007-07-09 06:58:42 UTC (rev 84) @@ -60,7 +60,7 @@ /*int set_group_quick_lockout(int fd, char **parsed_line);*/ int create_system(int fd, char *system_type); /*int delete_system(int fd);*/ -int get_system_info(int fd, int system_index); +int get_system_info(int fd, int system_index, char *system_type, char *channel_group_head); int set_system_info(int fd, int system_index, char **parsed_line); int get_trunk_info(int fd, int system_index); int set_trunk_info(int fd, int system_index, char **parsed_line); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-09 06:30:55
|
Revision: 83 http://dsctl.svn.sourceforge.net/dsctl/?rev=83&view=rev Author: roger-linux Date: 2007-07-08 23:30:54 -0700 (Sun, 08 Jul 2007) Log Message: ----------- commands.c: Moved TRN into low-level scanner command function. (One left to go.) Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.c src/commands.h Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-09 05:40:12 UTC (rev 82) +++ src/commands.c 2007-07-09 06:30:54 UTC (rev 83) @@ -675,6 +675,15 @@ } /*********************************************************************** +* Get System +***********************************************************************/ +int get_system_info(int fd, int system_index) +{ + + return (0); +} + +/*********************************************************************** * Set System ***********************************************************************/ int set_system_info(int fd, int system_index, char **parsed_line) @@ -708,6 +717,50 @@ } /*********************************************************************** +* Get Trunk +***********************************************************************/ +int get_trunk_info(int fd, int system_index) +{ + char answer[500], command[100]; + char *field[100]; + int i; + int group_info_index = 0; + + memset(answer, 0, 500); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "TRN,%i", system_index); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, field); + + /* We have 22 parsed fields to print for this command */ + for (i = 0; i <= 21; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); + + /* We're using the Forward Site Info Index field for + * getting the next Site Info address. + * There is no forward index for this group. Uses sys_field[14]. */ + /*trunkinfo_index = atoi (trunkinfoinfo_field[12]); */ + + /* Reset starting GIN address since we're a Trunked System + * instead of using the SIN address values for starting GIN + * + * We have no map of the internal memory. Linking starting TRN/GIN/TIN addresses + * is guess work because of the poorly proof-read Uniden documentation. */ + group_info_index = atoi(field[21]); + + return (group_info_index); +} + +/*********************************************************************** * Set Trunk ***********************************************************************/ int set_trunk_info(int fd, int system_index, char **parsed_line) @@ -991,9 +1044,9 @@ } /*********************************************************************** -* Set TGID Information +* Get TGID Information ***********************************************************************/ -int get_trunk_info(int fd, int system_index) +int get_tgid_info(int fd, int tgid_index) { char answer[500], command[100]; char *field[100]; @@ -1004,7 +1057,7 @@ memset(command, 0, 100); memset(field, 0, 100); - snprintf(command, 100, "TIN,%i", system_index); + snprintf(command, 100, "TIN,%i", tgid_index); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf ("%s\n(%i)\n", answer, strlen (answer)); */ @@ -1498,7 +1551,6 @@ int cmd_index, i; int renum[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; - for (cmd_index = 0; cmd_index <= 9; cmd_index++) { memset(answer, 0, 500); @@ -2084,7 +2136,6 @@ return (0); } - /*********************************************************************** * Download BCD memory contents * TODO: Break This int low-level scanner command functions. @@ -2235,43 +2286,15 @@ * these are pointers and site info will overwrite it's * variable! * - * We only get Site Info (aka Site Settings), as well as TFQ, if the System is not Conv Type */ + * We only get Site Info (aka Site Settings), as well as TFQ, + * if the System is not Conv Type */ /*printf("systype = %s trunkinfo_index = %i\n", sys_type, trunkinfo_index); */ + /*TODO: trunkinfo_index -- used orig name. Might want to rename it. */ if (trunkinfo_index != -1 && strncmp(sys_type, "CNV", 3) != 0 && strncmp(sys_type, "LTR", 3) != 0) - { - bzero(answer, 500); - bzero(command, 100); - bzero(trunkinfo_field, 100); - snprintf(command, 100, "TRN,%i", trunkinfo_index); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, trunkinfo_field); + grpinfo_index = get_trunk_info(fd, trunkinfo_index); - /* We have 22 parsed fields to print for TRN command */ - for (i = 0; i <= 21; i++) - { - if (i != 0) - printf(","); - printf("%s", trunkinfo_field[i]); - } - printf("\n"); - - /* We're using the Forward Site Info Index field for - * getting the next Site Info address. - * There is no forward index for this group. Uses sys_field[14]. */ - /*trunkinfo_index = atoi (trunkinfoinfo_field[12]); */ - - /* Reset starting GIN address since we're a Trunked System - * instead of using the SIN address values for starting GIN - * - * We have no map of the internal memory. Linking starting TRN/GIN/TIN addresses - * is guess work because of the poorly proof-read Uniden documentation. */ - grpinfo_index = atoi(trunkinfo_field[21]); - } - /* GIN */ /* While System has Groups, then print them. * @@ -2280,10 +2303,11 @@ /*printf(" (Group Starting Location: %s Group Ending Location: %s)\n", sys_field[14], sys_field[15]); */ int next_group_index = 0; char channel_index[10]; - + while (grpinfo_index != -1) { - next_group_index = get_group_info(fd, grpinfo_index, channel_index); + next_group_index = + get_group_info(fd, grpinfo_index, channel_index); /* We're using the Forward Group Index field for getting * the next Group Info address. */ @@ -2293,7 +2317,6 @@ chaninfo_index = atoi(channel_index); tgidinfo_index = atoi(channel_index); - /* CIN */ /* While Group has Channels, and System Type is Conventional, then print them. * Else they're treated like Trunk Group ID's. */ @@ -2325,7 +2348,7 @@ && strncmp(sys_type, "LTR", 3) != 0) { /*printf("systype = %s\n", sys_type); */ - next_tgidinfo_index = get_trunk_info(fd, tgidinfo_index); + next_tgidinfo_index = get_tgid_info(fd, tgidinfo_index); /* We're using the Forward Trunk Group ID Info Index field for getting * the next Trunk Group ID info address. */ @@ -2556,7 +2579,7 @@ exit_prg_mode(fd); fclose(infile); /* note this can close stdin if they didn' t - specify a filename, but at this point we don 't care */ + specify a filename, but at this point we don 't care */ return (0); } @@ -2583,4 +2606,3 @@ return (1); } - Modified: src/commands.h =================================================================== --- src/commands.h 2007-07-09 05:40:12 UTC (rev 82) +++ src/commands.h 2007-07-09 06:30:54 UTC (rev 83) @@ -59,8 +59,8 @@ int get_group_quick_lockout(int fd, int system_index); /*int set_group_quick_lockout(int fd, char **parsed_line);*/ int create_system(int fd, char *system_type); -/*int delete_system(int fd); -int get_system_info(int fd, int system_index);*/ +/*int delete_system(int fd);*/ +int get_system_info(int fd, int system_index); int set_system_info(int fd, int system_index, char **parsed_line); int get_trunk_info(int fd, int system_index); int set_trunk_info(int fd, int system_index, char **parsed_line); @@ -74,7 +74,7 @@ /*int delete_channel(int fd, channel_index);*/ int get_channel_info(int fd, int channel_index); int set_channel_info(int fd, int channel_index, char **parsed_line); -/*int get_tgid_info(int fd, int tgid_index, int fwd_tgid_index);*/ +int get_tgid_info(int fd, int tgid_index); int set_tgid_info(int fd, int channel_index, char **parsed_line); int append_site(int fd, int system_index, char *system_type); int get_site_info(int fd, int site_index, char *site_type, char *trunk_freq_index); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-09 05:40:14
|
Revision: 82 http://dsctl.svn.sourceforge.net/dsctl/?rev=82&view=rev Author: roger-linux Date: 2007-07-08 22:40:12 -0700 (Sun, 08 Jul 2007) Log Message: ----------- commands.c More functions moved Modified Paths: -------------- src/commands.c src/commands.h Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-09 01:48:06 UTC (rev 81) +++ src/commands.c 2007-07-09 05:40:12 UTC (rev 82) @@ -800,6 +800,46 @@ } /*********************************************************************** +* Get Group Information +***********************************************************************/ +int get_group_info(int fd, int group_index, char *channel_index) +{ + char answer[500], command[100]; + char *field[100]; + int i; + int next_group_index = 0; + + memset(answer, 0, 500); + memset(command, 0, 100); + memset(field, 0, 100); + memset(channel_index, 0, 10); + + snprintf(command, 100, "GIN,%i", group_index); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, field); + + /* We have 11 parsed fields to print for GIN command */ + for (i = 0; i <= 10; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); + + /* We're using the Forward Group Index field for getting + * the next Group Info address. */ + next_group_index = atoi(field[6]); + + /* Set our starting channel address index from GIN info */ + strncpy(channel_index, field[8], 10); + + return (next_group_index); +} + +/*********************************************************************** * Set Group Information ***********************************************************************/ int set_group_info(int fd, int group_index, char **parsed_line) @@ -2067,8 +2107,7 @@ int sys_index, grpinfo_index, chaninfo_index, trunkinfo_index, siteinfo_index, motbandplan_index, apcobandplan_index, trunkfreq_index, tgidinfo_index; - char *sys_field[100], *grp_field[100], - *trunkinfo_field[100]; + char *sys_field[100], *trunkinfo_field[100]; /* File Version Format */ printf("dsctl version %s\n\n", FFVERSION); @@ -2238,36 +2277,23 @@ * * grpinfo_index was set prior to getting Site Info because * we're returning pointers from parse_fields */ - /*grpinfo_index = atoi (sys_field[14]); */ /*printf(" (Group Starting Location: %s Group Ending Location: %s)\n", sys_field[14], sys_field[15]); */ + int next_group_index = 0; + char channel_index[10]; + while (grpinfo_index != -1) { - bzero(answer, 500); - bzero(command, 100); - bzero(grp_field, 100); - snprintf(command, 100, "GIN,%i", grpinfo_index); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, grp_field); + next_group_index = get_group_info(fd, grpinfo_index, channel_index); - /* We have 11 parsed fields to print for GIN command */ - for (i = 0; i <= 10; i++) - { - if (i != 0) - printf(","); - printf("%s", grp_field[i]); - } - printf("\n"); - /* We're using the Forward Group Index field for getting * the next Group Info address. */ - grpinfo_index = atoi(grp_field[6]); + grpinfo_index = next_group_index; /* Set our starting channel address index from GIN info */ - chaninfo_index = atoi(grp_field[8]); - tgidinfo_index = atoi(grp_field[8]); + chaninfo_index = atoi(channel_index); + tgidinfo_index = atoi(channel_index); + /* CIN */ /* While Group has Channels, and System Type is Conventional, then print them. * Else they're treated like Trunk Group ID's. */ @@ -2310,7 +2336,8 @@ /* SIF */ /* While System has Sites, then print them. - * We only get Site Info (aka Site Settings), as well as TFQ, if the System is not Conv Type + * We only get Site Info (aka Site Settings), as well as TFQ, + * if the System is not Conv Type * * (Site Info shares the first Group's address for some * odd/undocumented reason - memory layout?) @@ -2339,18 +2366,19 @@ siteinfo_index = next_site_index; /* MBP - * Only if it's a trunked MU2 or MV2 site, and get this info before trunk freqs. */ + *Only if it's a trunked MU2 or MV2 site, + * and get this info before trunk freqs. */ if (strncmp(site_type, "MU2", 3) == 0 || strncmp(site_type, "MV2", 3) == 0) get_motorola_band_plan(fd, motbandplan_index); - /* ABP + /* APB * If trunked MP25 site, get this info. */ if (strncmp(site_type, "MP25", 4) == 0) get_apco25_band_plan(fd, apcobandplan_index); - /* TFQ */ - /* While Sites has Trunk Frequencies, then print them. */ + /* TFQ + * While Sites has Trunk Frequencies, then print them. */ while (trunkfreq_index != -1) trunkfreq_index = get_trunk_freq_info(fd, trunkfreq_index); } @@ -2527,8 +2555,8 @@ exit_prg_mode(fd); - fclose(infile); /* note this can close stdin if they didn't specify a - filename, but at this point we don't care */ + fclose(infile); /* note this can close stdin if they didn' t + specify a filename, but at this point we don 't care */ return (0); } @@ -2555,3 +2583,4 @@ return (1); } + Modified: src/commands.h =================================================================== --- src/commands.h 2007-07-09 01:48:06 UTC (rev 81) +++ src/commands.h 2007-07-09 05:40:12 UTC (rev 82) @@ -67,7 +67,7 @@ int append_channel_group(int fd, int system_index); int append_tgid_group(int fd, int system_index); /*int delete_group(int fd, group_index);*/ /* Use same function for delete_site */ -/*int get_group_info(int fd, int group_index);*/ +int get_group_info(int fd, int group_index, char *channel_index); int set_group_info(int fd, int group_index, char **parsed_line); int append_channel_freq(int fd, int group_index); /* Use same function for append_trunk_freq */ int append_tgid(int fd, int group_index); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-09 01:48:12
|
Revision: 81 http://dsctl.svn.sourceforge.net/dsctl/?rev=81&view=rev Author: roger-linux Date: 2007-07-08 18:48:06 -0700 (Sun, 08 Jul 2007) Log Message: ----------- commands.c: More stuff from the dump command moved into lower-level functions. (Only three scanner commands left to move into low-level functions.) Modified Paths: -------------- src/commands.c src/commands.h Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-08 21:46:21 UTC (rev 80) +++ src/commands.c 2007-07-09 01:48:06 UTC (rev 81) @@ -39,11 +39,11 @@ * of active TGID info. After the first display, repeated reissues of * these commands will return null until a different TGID becomes active. * Save last info and recall it as "Last GID/GID Active:"? */ - + char answer[500]; char *field[100]; int i; - + memset(answer, 0, 500); memset(field, 0, 100); do_command(fd, "GID", answer); @@ -87,7 +87,7 @@ ***********************************************************************/ int quick_search_hold_mode(int fd, char **parsed_line) { - return(0); + return (0); } /*********************************************************************** @@ -161,11 +161,11 @@ { /* GLG - Reception Status * See GID comment */ - + char answer[500]; char *field[100]; int i; - + memset(answer, 0, 500); memset(field, 0, 100); do_command(fd, "GLG", answer); @@ -190,11 +190,11 @@ void get_model_info(int fd) { /*char answer[100]; - memset(answer, 0, 100); - - do_command(fd, "MDL", answer); - printf("Scanner Sysinfo: %s\n", answer);*/ + memset(answer, 0, 100); + do_command(fd, "MDL", answer); + printf("Scanner Sysinfo: %s\n", answer); */ + char answer[100], command[100]; char *model_field[100]; int i; @@ -227,7 +227,7 @@ char answer[100], command[100]; char *firmvers_field[100]; int i; - + memset(answer, 0, 100); memset(command, 0, 100); bzero(firmvers_field, 100); @@ -306,7 +306,7 @@ char answer[100], command[100]; char *backlight_field[100]; int i; - + memset(answer, 0, 100); memset(command, 0, 100); memset(backlight_field, 0, 100); @@ -324,8 +324,8 @@ printf("%s", backlight_field[i]); } printf("\n"); - - return(0); + + return (0); } /*********************************************************************** @@ -344,11 +344,11 @@ char answer[100], command[100]; char *key_beep_field[100]; int i; - + memset(answer, 0, 100); memset(command, 0, 100); memset(key_beep_field, 0, 100); - + snprintf(command, 100, "KBP"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); @@ -363,8 +363,8 @@ printf("%s", key_beep_field[i]); } printf("\n"); - - return(0); + + return (0); } /*********************************************************************** @@ -372,7 +372,7 @@ ***********************************************************************/ int get_opening_message(int fd) { - + char answer[500], command[100]; char *openingmsg_field[500]; int i; @@ -403,7 +403,7 @@ * Get Priority Mode ***********************************************************************/ int get_priority_mode(int fd) -{ +{ char answer[100], command[100]; char *primode_field[100]; int i; @@ -442,7 +442,7 @@ memset(answer, 0, 100); memset(command, 0, 100); memset(autogainctrl_field, 0, 100); - + snprintf(command, 100, "AGV"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); @@ -473,7 +473,7 @@ memset(answer, 0, 100); memset(command, 0, 100); memset(syscount_field, 0, 100); - + snprintf(command, 100, "SCT"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); @@ -504,7 +504,7 @@ memset(answer, 0, 100); memset(command, 0, 100); memset(sysindexhead_field, 0, 100); - + snprintf(command, 100, "SIH"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); @@ -513,12 +513,12 @@ /* We have 2 parsed fields to print for SIH command */ /*for (i = 0; i <= 1; i++) - { - if (i != 0) - printf(","); - printf("%s", sysindexhead_field[i]); - } - printf("\n");*/ + { + if (i != 0) + printf(","); + printf("%s", sysindexhead_field[i]); + } + printf("\n"); */ i = atoi(sysindexhead_field[1]); @@ -537,7 +537,7 @@ memset(answer, 0, 100); memset(command, 0, 100); memset(sysindextail_field, 0, 100); - + snprintf(command, 100, "SIT"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); @@ -546,12 +546,12 @@ /* We have 2 parsed fields to print for SIT command */ /*for (i = 0; i <= 1; i++) - { - if (i != 0) - printf(","); - printf("%s", sysindextail_field[i]); - } - printf("\n");*/ + { + if (i != 0) + printf(","); + printf("%s", sysindextail_field[i]); + } + printf("\n"); */ i = atoi(sysindextail_field[1]); @@ -570,7 +570,7 @@ memset(answer, 0, 500); memset(command, 0, 100); memset(field, 0, 100); - + snprintf(command, 100, "QSL"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); @@ -601,7 +601,7 @@ memset(answer, 0, 100); memset(command, 0, 100); memset(field, 0, 100); - + snprintf(command, 100, "QGL,%i", system_index); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); @@ -885,6 +885,42 @@ } /*********************************************************************** +* Get Channel Information +***********************************************************************/ +int get_channel_info(int fd, int channel_index) +{ + char answer[500], command[100]; + char *field[100]; + int i; + int next_channel_index = 0; + + memset(answer, 0, 500); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "CIN,%i", channel_index); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf ("%s\n(%i)\n", answer, strlen (answer)); */ + parse_fields(answer, field); + + /* We have 17 parsed fields to print for this command */ + for (i = 0; i <= 16; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); + + /* We're using the Forward Channel Index field for getting + * the next Channel Info address. */ + next_channel_index = atoi(field[12]); + + return (next_channel_index); +} + +/*********************************************************************** * Set Channel Information ***********************************************************************/ int set_channel_info(int fd, int channel_index, char **parsed_line) @@ -917,6 +953,42 @@ /*********************************************************************** * Set TGID Information ***********************************************************************/ +int get_trunk_info(int fd, int system_index) +{ + char answer[500], command[100]; + char *field[100]; + int i; + int next_tgidinfo_index = 0; + + memset(answer, 0, 500); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "TIN,%i", system_index); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf ("%s\n(%i)\n", answer, strlen (answer)); */ + parse_fields(answer, field); + + /* We have 12 parsed fields to print for this command */ + for (i = 0; i <= 11; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); + + /* We're using the Forward Trunk Group ID Info Index field for getting + * the next Trunk Group ID info address. */ + next_tgidinfo_index = atoi(field[8]); + + return (next_tgidinfo_index); +} + +/*********************************************************************** +* Set TGID Information +***********************************************************************/ int set_tgid_info(int fd, int channel_index, char **parsed_line) { char answer[100], command[500]; @@ -973,6 +1045,43 @@ } /*********************************************************************** +* Get Site Information +***********************************************************************/ +int get_site_info(int fd, int site_index, char *site_type, + char *trunk_freq_index) +{ + char answer[500], command[100]; + char *field[100]; + int i; + int next_siteinfo_index = 0; + + memset(answer, 0, 500); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "SIF,%i", site_index); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, field); + + /* We have 22 parsed fields to print for this command */ + for (i = 0; i <= 21; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); + + strncpy(site_type, field[1], 5); + strncpy(trunk_freq_index, field[14], 10); + next_siteinfo_index = atoi(field[12]); + + return (next_siteinfo_index); +} + +/*********************************************************************** * Set Site Information ***********************************************************************/ int set_site_info(int fd, int site_index, char **parsed_line) @@ -1005,6 +1114,37 @@ } /*********************************************************************** +* Get Motorola Band Plan Information +***********************************************************************/ +int get_motorola_band_plan(int fd, int site_index) +{ + char answer[500], command[100]; + char *field[100]; + int i; + + memset(answer, 0, 500); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "MBP,%i", site_index); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, field); + + /* We have 9 parsed fields to print for this command */ + for (i = 0; i <= 9; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); + + return (0); +} + +/*********************************************************************** * Set Motorola Band Plan Information ***********************************************************************/ int set_motorola_band_plan(int fd, int site_index, char **parsed_line) @@ -1034,6 +1174,37 @@ } /*********************************************************************** +* Get APCO-25 Band Plan Information +***********************************************************************/ +int get_apco25_band_plan(int fd, int site_index) +{ + char answer[500], command[100]; + char *field[100]; + int i; + + memset(answer, 0, 500); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "ABP,%i", site_index); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, field); + + /* We have 9 parsed fields to print for ABP command */ + for (i = 0; i <= 9; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); + + return (0); +} + +/*********************************************************************** * Set APCO-25 Band Plan Information ***********************************************************************/ int set_apco25_band_plan(int fd, int site_index, char **parsed_line) @@ -1062,6 +1233,41 @@ } /*********************************************************************** +* Get Trunk Frequency Information +***********************************************************************/ +int get_trunk_freq_info(int fd, int channel_index) +{ + char answer[500], command[100]; + char *field[100]; + int i; + + memset(answer, 0, 500); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "TFQ,%i", channel_index); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, field); + + /* We have 8 parsed fields to print for this command */ + for (i = 0; i <= 7; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); + + /* We're using the Forward Trunk Frequency Index field for + * getting the next Trunk Frequency address. */ + channel_index = atoi(field[5]); + + return (channel_index); +} + +/*********************************************************************** * Set Trunk Frequency Information ***********************************************************************/ int set_trunk_freq_info(int fd, int channel_index, char **parsed_line) @@ -1115,7 +1321,7 @@ } printf("\n"); - return(0); + return (0); } /*********************************************************************** @@ -1146,7 +1352,7 @@ } printf("\n"); - return(0); + return (0); } /*********************************************************************** @@ -1160,8 +1366,8 @@ memset(answer, 0, 100); memset(command, 0, 100); - memset(field, 0, 100); - + memset(field, 0, 100); + snprintf(command, 100, "LIH,%s", loc_alert_system_type); /*printf("Command == %s\n", command); */ do_command(fd, command, answer); @@ -1186,7 +1392,7 @@ memset(answer, 0, 100); memset(command, 0, 100); - memset(field, 0, 100); + memset(field, 0, 100); snprintf(command, 100, "LIN,%i", loc_alert_system_index); /*printf("Command == %s\n", command); */ @@ -1199,7 +1405,7 @@ { if (i != 0) printf(","); - printf("%s", field[i]); + printf("%s", field[i]); } printf("\n"); @@ -1239,7 +1445,7 @@ } printf("\n"); - return(0); + return (0); } /*********************************************************************** @@ -1249,7 +1455,7 @@ { char answer[500], command[100]; char *field[100]; - int cmd_index,i; + int cmd_index, i; int renum[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; @@ -1305,7 +1511,7 @@ printf("%s", field[i]); } printf("\n"); - + return (0); } @@ -1363,7 +1569,7 @@ memset(answer, 0, 500); memset(command, 0, 100); memset(field, 0, 100); - + snprintf(command, 100, "CLC"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); @@ -1400,8 +1606,8 @@ memset(answer, 0, 500); memset(command, 0, 100); - memset(field, 0, 100); - + memset(field, 0, 100); + snprintf(command, 100, "SSP,%i", cmd_index); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); @@ -1432,8 +1638,8 @@ memset(answer, 0, 500); memset(command, 0, 100); - memset(field, 0, 100); - + memset(field, 0, 100); + snprintf(command, 100, "CSG"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); @@ -1471,9 +1677,9 @@ memset(field, 0, 100); snprintf(command, 100, "CSP,%i", renum[cmd_index]); - /*printf("\nCommand == %s\n", command);*/ + /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer));*/ + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ parse_fields(answer, field); /* We have 16 parsed fields to print for this command */ @@ -1497,7 +1703,7 @@ char answer[100], command[100]; char *wxsettings_field[100]; int i; - + memset(answer, 0, 100); memset(command, 0, 100); memset(wxsettings_field, 0, 100); @@ -1528,7 +1734,7 @@ char answer[500], command[100]; char *samegrp_field[100]; int cmd_index, i; - + for (cmd_index = 1; cmd_index <= 5; cmd_index++) { memset(answer, 0, 500); @@ -1553,6 +1759,7 @@ return (0); } + /*********************************************************************** * Get Tone-Out Settings ***********************************************************************/ @@ -1562,7 +1769,7 @@ char *toneout_field[100]; int cmd_index, i; int renum[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; - + for (cmd_index = 0; cmd_index <= 9; cmd_index++) { memset(answer, 0, 500); @@ -1593,7 +1800,7 @@ ***********************************************************************/ int get_lcd_contrast_settings(int fd) { - + char answer[100], command[100]; char *lcdcontrast_field[100]; int i; @@ -1601,7 +1808,7 @@ memset(answer, 0, 100); memset(command, 0, 100); memset(lcdcontrast_field, 0, 100); - + snprintf(command, 100, "CNT"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); @@ -1628,7 +1835,7 @@ char answer[100], command[100]; char *lcdupsidedown_field[100]; int i; - + memset(answer, 0, 100); memset(command, 0, 100); memset(lcdupsidedown_field, 0, 100); @@ -1659,7 +1866,7 @@ char answer[500], command[100]; char *scanneropts_field[100]; int i; - + memset(answer, 0, 500); memset(command, 0, 100); memset(scanneropts_field, 0, 100); @@ -1690,7 +1897,7 @@ char answer[500], command[100]; char *apcodata_field[100]; int i; - + memset(answer, 0, 500); memset(command, 0, 100); memset(apcodata_field, 0, 100); @@ -1721,7 +1928,7 @@ char answer[500], command[100]; char *gpsformat_field[100]; int i; - + memset(answer, 0, 500); memset(command, 0, 100); memset(gpsformat_field, 0, 100); @@ -1752,7 +1959,7 @@ char answer[100], command[100]; char *ggadata_field[100]; int i; - + memset(answer, 0, 100); memset(command, 0, 100); memset(ggadata_field, 0, 100); @@ -1783,7 +1990,7 @@ char answer[100], command[100]; char *rmcdata_field[100]; int i; - + memset(answer, 0, 100); memset(command, 0, 100); memset(rmcdata_field, 0, 100); @@ -1814,7 +2021,7 @@ char answer[100], command[100]; char *winvolt_field[100]; int i; - + memset(answer, 0, 100); memset(command, 0, 100); memset(winvolt_field, 0, 100); @@ -1859,40 +2066,39 @@ int sys_index, grpinfo_index, chaninfo_index, trunkinfo_index, siteinfo_index, motbandplan_index, apcobandplan_index, - trunkfreq_index, tgidinfo_index, loc_index; - char *sys_field[100], *grp_field[100], *chan_field[100], - *trunkinfo_field[100], *siteinfo_field[100], *motinfo_field[100], - *apcoinfo_field[100], *trunkfreq_field[100], *tgid_field[100]; + trunkfreq_index, tgidinfo_index; + char *sys_field[100], *grp_field[100], + *trunkinfo_field[100]; /* File Version Format */ printf("dsctl version %s\n\n", FFVERSION); /* Make sure unit is in Scan Mode and not Menu Mode, else we get NG */ - push_key(fd,'S','P'); - + push_key(fd, 'S', 'P'); + /* Enter Program Mode */ enter_prg_mode(fd); /* Get System Information */ get_model_info(fd); - + get_firmware_version(fd); - + get_opening_message(fd); get_remains_memory_block(fd); - + get_memory_used(fd); /* Get System Settings */ get_backlight(fd); - + get_key_beep(fd); get_opening_message(fd); get_priority_mode(fd); - + get_auto_gain_control(fd); get_system_count(fd); @@ -1904,13 +2110,13 @@ get_search_key_settings(fd); get_global_lockout_freq(fd); - + get_close_call_settings(fd); get_service_search_settings(fd); - + get_custom_search_group(fd); - + get_custom_search_settings(fd); get_weather_settings(fd); @@ -1922,7 +2128,7 @@ get_lcd_contrast_settings(fd); get_lcd_upside_down_settings(fd); - + get_scanner_option_settings(fd); get_apco_settings(fd); @@ -1944,7 +2150,7 @@ while (sys_index != -1) { - get_group_quick_lockout(fd, sys_index); /* This might break things */ + get_group_quick_lockout(fd, sys_index); /* This might break things */ bzero(answer, 500); bzero(command, 100); @@ -1963,7 +2169,7 @@ printf("%s", sys_field[i]); } printf("\n"); - + /* Set our starting Group and Site index addresses from SIN info */ /* Pointers are returned from parse_fields, use strncpy for strings. */ siteinfo_index = atoi(sys_field[14]); @@ -2067,63 +2273,38 @@ * Else they're treated like Trunk Group ID's. */ /*printf(" (Channel Starting Location: %s Channel Ending Location: %s)\n", grp_field[8], grp_field[9]; */ /*chaninfo_index = atoi (grp_field[8]); */ + int next_channel_index = 0; + while (chaninfo_index != -1 && (strncmp(sys_type, "CNV", 3) == 0 || strncmp(sys_type, "LTR", 3) == 0)) { /*printf("systype = %s\n", sys_type); */ - bzero(answer, 500); - bzero(command, 100); - bzero(chan_field, 100); - snprintf(command, 100, "CIN,%i", chaninfo_index); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf ("%s\n(%i)\n", answer, strlen (answer)); */ - parse_fields(answer, chan_field); - /* We have 17 parsed fields to print for CIN command */ - for (i = 0; i <= 16; i++) - { - if (i != 0) - printf(","); - printf("%s", chan_field[i]); - } - printf("\n"); + next_channel_index = get_channel_info(fd, chaninfo_index); /* We're using the Forward Channel Index field for getting * the next Channel Info address. */ - chaninfo_index = atoi(chan_field[12]); + //chaninfo_index = atoi(chan_field[12]); + chaninfo_index = next_channel_index; } /* TIN */ /* While system is not convention, then get Trunk Group ID info. */ /*printf(" (TGID Starting Location: %s TGID Ending Location: %s)\n", tgid_field[8], tgid_field[9]; */ /*printf("systype = %s\n", sys_type); */ + int next_tgidinfo_index = 0; + while (tgidinfo_index != -1 && strncmp(sys_type, "CNV", 3) != 0 && strncmp(sys_type, "LTR", 3) != 0) { /*printf("systype = %s\n", sys_type); */ - bzero(answer, 500); - bzero(command, 100); - bzero(tgid_field, 100); - snprintf(command, 100, "TIN,%i", tgidinfo_index); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf ("%s\n(%i)\n", answer, strlen (answer)); */ - parse_fields(answer, tgid_field); + next_tgidinfo_index = get_trunk_info(fd, tgidinfo_index); - /* We have 12 parsed fields to print for TIN command */ - for (i = 0; i <= 11; i++) - { - if (i != 0) - printf(","); - printf("%s", tgid_field[i]); - } - printf("\n"); - /* We're using the Forward Trunk Group ID Info Index field for getting * the next Trunk Group ID info address. */ - tgidinfo_index = atoi(tgid_field[8]); + //tgidinfo_index = atoi(tgid_field[8]); + tgidinfo_index = next_tgidinfo_index; } } @@ -2136,114 +2317,49 @@ * * Set our grpinfo variable before getting site info because * these are pointers and Site Info will overwrite it's variable! */ + char trunk_freq_index[10]; + int next_site_index = 0; + + memset(trunk_freq_index, 0, 10); + while (siteinfo_index != -1 && strncmp(sys_type, "CNV", 3) != 0 && strncmp(sys_type, "LTR", 3) != 0) { - bzero(answer, 500); - bzero(command, 100); - bzero(siteinfo_field, 100); - snprintf(command, 100, "SIF,%i", siteinfo_index); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, siteinfo_field); + next_site_index = + get_site_info(fd, siteinfo_index, site_type, + trunk_freq_index); - /* We have 22 parsed fields to print for GIN command */ - for (i = 0; i <= 21; i++) - { - if (i != 0) - printf(","); - printf("%s", siteinfo_field[i]); - } - printf("\n"); - - /* Set other variables for subcommands */ - trunkfreq_index = atoi(siteinfo_field[14]); - strncpy(site_type, siteinfo_field[1], 5); + /* Set other variables for sub-commands */ + trunkfreq_index = atoi(trunk_freq_index); motbandplan_index = siteinfo_index; apcobandplan_index = siteinfo_index; /* We're using the Forward Site Info Index field for * getting the next Site Info address. */ - siteinfo_index = atoi(siteinfo_field[12]); + siteinfo_index = next_site_index; /* MBP * Only if it's a trunked MU2 or MV2 site, and get this info before trunk freqs. */ if (strncmp(site_type, "MU2", 3) == 0 || strncmp(site_type, "MV2", 3) == 0) - { - bzero(answer, 500); - bzero(command, 100); - bzero(motinfo_field, 100); - snprintf(command, 100, "MBP,%i", motbandplan_index); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, motinfo_field); + get_motorola_band_plan(fd, motbandplan_index); - /* We have 9 parsed fields to print for MBP command */ - for (i = 0; i <= 9; i++) - { - if (i != 0) - printf(","); - printf("%s", motinfo_field[i]); - } - printf("\n"); - } - /* ABP * If trunked MP25 site, get this info. */ if (strncmp(site_type, "MP25", 4) == 0) - { - bzero(answer, 500); - bzero(command, 100); - bzero(apcoinfo_field, 100); - snprintf(command, 100, "ABP,%i", apcobandplan_index); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, apcoinfo_field); + get_apco25_band_plan(fd, apcobandplan_index); - /* We have 9 parsed fields to print for ABP command */ - for (i = 0; i <= 9; i++) - { - if (i != 0) - printf(","); - printf("%s", apcoinfo_field[i]); - } - printf("\n"); - } - /* TFQ */ /* While Sites has Trunk Frequencies, then print them. */ while (trunkfreq_index != -1) - { - bzero(answer, 500); - bzero(command, 100); - bzero(trunkfreq_field, 100); - snprintf(command, 100, "TFQ,%i", trunkfreq_index); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, trunkfreq_field); - - /* We have 8 parsed fields to print for TRN command */ - for (i = 0; i <= 7; i++) - { - if (i != 0) - printf(","); - printf("%s", trunkfreq_field[i]); - } - printf("\n"); - - /* We're using the Forward Trunk Frequency Index field for - * getting the next Trunk Frequency address. */ - trunkfreq_index = atoi(trunkfreq_field[5]); - } + trunkfreq_index = get_trunk_freq_info(fd, trunkfreq_index); } } - /* Get Location Alert Settings */ + /* Get Location Alert Settings + * We need to get the index of each Location Alert type (POI, DROAD, DXING) + * and then send the type to return each Location Alert System Info. */ + int loc_index = 0; char loc_alert_system_type[3][10] = { "POI", "DROAD", "DXING" }; for (i = 0; i <= 2; i++) @@ -2323,8 +2439,8 @@ scanner_command); /* TODO: Break the following into sections for allowing - upload of only Configuration Settings, Systems Data only or - Location Alert Settings only. */ + upload of only Configuration Settings, Systems Data only or + Location Alert Settings only. */ if (strncmp(scanner_command, "SIN", 3) == 0) { /*printf("DEBUG %s\n", scanner_command); */ @@ -2432,7 +2548,7 @@ printf ("For more information on these matters, see the file named LICENSE.\n\n"); - /*printf("Scanner Model (Internal): %d\n", scannermodel);*/ + /*printf("Scanner Model (Internal): %d\n", scannermodel); */ get_model_info(fd); get_firmware_version(fd); Modified: src/commands.h =================================================================== --- src/commands.h 2007-07-08 21:46:21 UTC (rev 80) +++ src/commands.h 2007-07-09 01:48:06 UTC (rev 81) @@ -62,7 +62,7 @@ /*int delete_system(int fd); int get_system_info(int fd, int system_index);*/ int set_system_info(int fd, int system_index, char **parsed_line); -/*int get_trunk_info(int fd, int system_index);*/ +int get_trunk_info(int fd, int system_index); int set_trunk_info(int fd, int system_index, char **parsed_line); int append_channel_group(int fd, int system_index); int append_tgid_group(int fd, int system_index); @@ -72,18 +72,18 @@ int append_channel_freq(int fd, int group_index); /* Use same function for append_trunk_freq */ int append_tgid(int fd, int group_index); /*int delete_channel(int fd, channel_index);*/ -/*int get_channel_info(int fd, int channel_index, int channel_fwd_index);*/ +int get_channel_info(int fd, int channel_index); int set_channel_info(int fd, int channel_index, char **parsed_line); /*int get_tgid_info(int fd, int tgid_index, int fwd_tgid_index);*/ int set_tgid_info(int fd, int channel_index, char **parsed_line); int append_site(int fd, int system_index, char *system_type); -/*int get_site_info(int fd, int site_index);*/ +int get_site_info(int fd, int site_index, char *site_type, char *trunk_freq_index); int set_site_info(int fd, int site_index, char **parsed_line); -/*int get_motorola_band_plan(int fd, int site_index);*/ +int get_motorola_band_plan(int fd, int site_index); int set_motorola_band_plan(int fd, int site_index, char **parsed_line); -/*int get_apco25_band_plan(int fd, int site_index);*/ +int get_apco25_band_plan(int fd, int site_index); int set_apco25_band_plan(int fd, int site_index, char **parsed_line); -/*int get_trunk_freq_info(int fd, int channel_index);*/ +int get_trunk_freq_info(int fd, int channel_index); int set_trunk_freq_info(int fd, int channel_index, char **parsed_line); /* End Scan Settings Commands */ @@ -95,12 +95,12 @@ int forward_index(int fd, int index);*/ int get_remains_memory_block(int fd); int get_memory_used(int fd); -/*int loc_alert_system_index_head(int fd, char *loc_alert_system_type); -int get_loc_alert_system_index_tail(int fd, char *loc_alert_system_type); +int loc_alert_system_index_head(int fd, char *loc_alert_system_type); +/*int get_loc_alert_system_index_tail(int fd, char *loc_alert_system_type); int create_loc_alert_system(int fd, char *loc_alert_system_type); -int delete_loc_alert_system(int loc_alert_system_index); +int delete_loc_alert_system(int loc_alert_system_index);*/ int get_loc_alert_system_info(int fd, int loc_alert_system_index); -int set_loc_alert_system_info(int fd, int loc_alert_system_index, char**parsed_line);*/ +/*int set_loc_alert_system_info(int fd, int loc_alert_system_index, char**parsed_line);*/ int get_srch_cc_settings(int fd); /*int set_srch_cc_settings(int fd, char **parsed_line);*/ int get_bcast_screen_band_settings(int fd); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-08 21:46:23
|
Revision: 80 http://dsctl.svn.sourceforge.net/dsctl/?rev=80&view=rev Author: roger-linux Date: 2007-07-08 14:46:21 -0700 (Sun, 08 Jul 2007) Log Message: ----------- commands.c: Converted Location Alert Systems Settings part of command dump into lower-level functions. (I think this looks good and more readable.) Now moving onto breaking-down dump command Scan Settings. (Last grouping for converting to lower-level scanner command functions.) Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.c Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-08 18:49:25 UTC (rev 79) +++ src/commands.c 2007-07-08 21:46:21 UTC (rev 80) @@ -1150,6 +1150,68 @@ } /*********************************************************************** +* Get Location Alert System Index Head +***********************************************************************/ +int loc_alert_system_index_head(int fd, char *loc_alert_system_type) +{ + char answer[100], command[100]; + char *field[100]; + int loc_indexhead = 0; + + memset(answer, 0, 100); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "LIH,%s", loc_alert_system_type); + /*printf("Command == %s\n", command); */ + do_command(fd, command, answer); + /*printf("\n%s\n(%i)\n", answer, strlen(answer)); */ + sscanf(answer, "LIH,%i", &loc_indexhead); + + /* While we have Location Alert Systems, then print them. + * And once we find the first system, find the next one using + * forward system index field */ + + return (loc_indexhead); +} + +/*********************************************************************** +* Get Location Alert System System Info +***********************************************************************/ +int get_loc_alert_system_info(int fd, int loc_alert_system_index) +{ + char answer[500], command[100]; + char *field[100]; + int i; + + memset(answer, 0, 100); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "LIN,%i", loc_alert_system_index); + /*printf("Command == %s\n", command); */ + do_command(fd, command, answer); + /*printf ("\n%s\n(%i)\n", answer, strlen (answer)); */ + parse_fields(answer, field); + + /* We have 13 parsed fields to print for this command */ + for (i = 0; i <= 12; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); + + /* We're using the Forward System Index field for getting the + * next Location Alert System Info address. + * Set this after we set the above variables. */ + loc_alert_system_index = atoi(field[7]); + + return (loc_alert_system_index); +} + +/*********************************************************************** * Get Search/Close Call Settings ***********************************************************************/ int get_srch_cc_settings(int fd) @@ -1795,14 +1857,12 @@ char sys_type[5], site_type[5]; - int loc_indexhead; int sys_index, grpinfo_index, chaninfo_index, trunkinfo_index, siteinfo_index, motbandplan_index, apcobandplan_index, trunkfreq_index, tgidinfo_index, loc_index; char *sys_field[100], *grp_field[100], *chan_field[100], *trunkinfo_field[100], *siteinfo_field[100], *motinfo_field[100], *apcoinfo_field[100], *trunkfreq_field[100], *tgid_field[100]; - char *loc_field[100]; /* File Version Format */ printf("dsctl version %s\n\n", FFVERSION); @@ -1873,12 +1933,6 @@ * Get Scan Settings ************************************************/ - /* Get System Index Head */ - //bzero(answer, 100); - //do_command(fd, "SIH", answer); - /*printf(" Starting Systems Location: %s", answer); */ - //sscanf(answer, "SIH,%i", &sys_indexhead); - /* SIN */ /* While we have System Indexes, then print them. * using the above System Head and System Tail @@ -2189,53 +2243,24 @@ } } - /************************************************ - * Get Location Alert Settings - ************************************************/ + /* Get Location Alert Settings */ + char loc_alert_system_type[3][10] = { "POI", "DROAD", "DXING" }; - /* Get Location Alert System Index Head - * TODO: This needs testing. */ - int parameter; - char locationalert_type[3][10] = { "POI", "DROAD", "DXING" }; - for (parameter = 0; parameter <= 2; parameter++) + for (i = 0; i <= 2; i++) { - bzero(answer, 500); - snprintf(command, 100, "LIH,%s", locationalert_type[parameter]); - /*printf("Command == %s\n", command); */ - do_command(fd, command, answer); - /*printf("\n%s\n(%i)\n", answer, strlen(answer)); */ - sscanf(answer, "LIH,%i", &loc_indexhead); + loc_index = loc_alert_system_index_head(fd, loc_alert_system_type[i]); /* While we have Location Alert Systems, then print them. * And once we find the first system, find the next one using * forward system index field */ - loc_index = loc_indexhead; while (loc_index != -1) { - bzero(answer, 500); - bzero(command, 100); - bzero(loc_field, 100); - snprintf(command, 100, "LIN,%i", loc_index); - /*printf("Command == %s\n", command); */ - do_command(fd, command, answer); - /*printf ("\n%s\n(%i)\n", answer, strlen (answer)); */ - parse_fields(answer, loc_field); - - /* We have 13 parsed fields to print for LIN command */ - for (i = 0; i <= 12; i++) - { - if (i != 0) - printf(","); - printf("%s", loc_field[i]); - } - printf("\n"); - - /* We're using the Forward System Index field for getting the - * next Location Alert System Info address. Set this after we set the above variables. */ - loc_index = atoi(loc_field[7]); + loc_index = get_loc_alert_system_info(fd, loc_index); } } + /* Exit from Programming Mode */ + exit_prg_mode(fd); return (0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-08 18:49:27
|
Revision: 79 http://dsctl.svn.sourceforge.net/dsctl/?rev=79&view=rev Author: roger-linux Date: 2007-07-08 11:49:25 -0700 (Sun, 08 Jul 2007) Log Message: ----------- commands.c: More moving of dump command functions into low-level commands to the top of the file. Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.c src/commands.h Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-08 07:10:09 UTC (rev 78) +++ src/commands.c 2007-07-08 18:49:25 UTC (rev 79) @@ -1217,7 +1217,7 @@ } /*********************************************************************** -* Get Broadcast Screen Band Settings +* Get Search Key Settings ***********************************************************************/ int get_search_key_settings(int fd) { @@ -1247,8 +1247,187 @@ return (0); } +/*********************************************************************** +* Get Global Lockout Frequency +***********************************************************************/ +int get_global_lockout_freq(int fd) +{ + char answer[100], command[100]; + char *field[100]; + int i, cmd_index = 0; + memset(answer, 0, 100); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "GLF"); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, field); + + cmd_index = atoi(field[1]); + + /* While we have locked out frequencies, get them. */ + while (cmd_index != -1) + { + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, field); + + /* We have 2 parsed fields to print for this command */ + for (i = 0; i <= 1; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); + cmd_index = atoi(field[1]); + } + + return (0); +} + /*********************************************************************** +* Get Close Call Settings +***********************************************************************/ +int get_close_call_settings(int fd) +{ + char answer[500], command[100]; + char *field[100]; + int i; + + memset(answer, 0, 500); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "CLC"); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, field); + + /* We have 10 parsed fields to print for this command */ + for (i = 0; i <= 9; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); + + return (0); +} + +/*********************************************************************** +* Get Service Search Settings +***********************************************************************/ +int get_service_search_settings(int fd) +{ + char answer[500], command[100]; + char *field[100]; + int cmd_index, i; + + /* Needs an index 1-15 */ + for (cmd_index = 1; cmd_index <= 15; cmd_index++) + { + /* Skip 13 & 14 addresses because Uniden has them set to null */ + if (cmd_index == 13) + cmd_index = 15; + + memset(answer, 0, 500); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "SSP,%i", cmd_index); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, field); + + /* We have 8 parsed fields to print for this command */ + for (i = 0; i <= 7; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); + } + + return (0); +} + +/*********************************************************************** +* Get Custom Search Group +***********************************************************************/ +int get_custom_search_group(int fd) +{ + char answer[500], command[100]; + char *field[100]; + int i; + + memset(answer, 0, 500); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "CSG"); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, field); + + /* We have 2 parsed fields to print for this command */ + for (i = 0; i <= 1; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); + + return (0); +} + +/*********************************************************************** +* Get Custom Search Settings +***********************************************************************/ +int get_custom_search_settings(int fd) +{ + char answer[500], command[100]; + char *field[100]; + int cmd_index, i; + int renum[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; + + /* Get Custom Search Settings + * Needs an index 1-0 (0 = 10) */ + for (cmd_index = 0; cmd_index <= 9; cmd_index++) + { + memset(answer, 0, 500); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "CSP,%i", renum[cmd_index]); + /*printf("\nCommand == %s\n", command);*/ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer));*/ + parse_fields(answer, field); + + /* We have 16 parsed fields to print for this command */ + for (i = 0; i <= 15; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); + } + + return (0); +} + +/*********************************************************************** * Get Weather Settings ***********************************************************************/ int get_weather_settings(int fd) @@ -1612,17 +1791,10 @@ { char answer[500], command[100]; - int i = 0, cmd_index; - int renum[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; + int i = 0; char sys_type[5], site_type[5]; - char *globallockoutfreq_field[100], - *closecall_field[100]; - - char *svcsearch_field[100], - *customsearchgrp_field[100], *customsearch_field[100]; - int loc_indexhead; int sys_index, grpinfo_index, chaninfo_index, trunkinfo_index, siteinfo_index, motbandplan_index, apcobandplan_index, @@ -1665,131 +1837,22 @@ get_system_count(fd); - /*********************************************************************** - * Get Search / Close Call Settings - ***********************************************************************/ - get_srch_cc_settings(fd); get_bcast_screen_band_settings(fd); get_search_key_settings(fd); - /* Get Global Lockout Frequencies */ - bzero(answer, 500); - bzero(command, 100); - bzero(globallockoutfreq_field, 100); - cmd_index = 0; - snprintf(command, 100, "GLF"); - /*printf("\nCommand == %s\n", command); */ - /* While we have locked out frequencies, get them. */ - while (cmd_index != -1) - { - do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, globallockoutfreq_field); + get_global_lockout_freq(fd); + + get_close_call_settings(fd); - /* We have 2 parsed fields to print for GLF command */ - /* For now, we print the first "-1" field returned, - * showing we're getting GLF fields even though there - * might be none. */ - for (i = 0; i <= 1; i++) - { - if (i != 0) - printf(","); - printf("%s", globallockoutfreq_field[i]); - } - printf("\n"); - cmd_index = atoi(globallockoutfreq_field[1]); - } + get_service_search_settings(fd); + + get_custom_search_group(fd); + + get_custom_search_settings(fd); - /* Get Close Call Settings */ - bzero(answer, 500); - bzero(command, 100); - bzero(closecall_field, 100); - snprintf(command, 100, "CLC"); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, closecall_field); - - /* We have 10 parsed fields to print for CLC command */ - for (i = 0; i <= 9; i++) - { - if (i != 0) - printf(","); - printf("%s", closecall_field[i]); - } - printf("\n"); - - /* Get Service Search Settings - * Needs an index 1-15 */ - for (cmd_index = 1; cmd_index <= 15; cmd_index++) - { - /* Skip 13 & 14 addresses because Uniden has them set to null */ - if (cmd_index == 13) - cmd_index = 15; - bzero(answer, 500); - bzero(command, 100); - bzero(svcsearch_field, 100); - snprintf(command, 100, "SSP,%i", cmd_index); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, svcsearch_field); - - /* We have 8 parsed fields to print for SSP command */ - for (i = 0; i <= 7; i++) - { - if (i != 0) - printf(","); - printf("%s", svcsearch_field[i]); - } - printf("\n"); - } - - /* Get Custom Search Group */ - bzero(answer, 500); - bzero(command, 100); - bzero(customsearchgrp_field, 100); - snprintf(command, 100, "CSG"); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, customsearchgrp_field); - - /* We have 2 parsed fields to print for CSG command */ - for (i = 0; i <= 1; i++) - { - if (i != 0) - printf(","); - printf("%s", customsearchgrp_field[i]); - } - printf("\n"); - - /* Get Custom Search Settings - * Needs an index 1-0 (0 = 10) */ - for (cmd_index = 0; cmd_index <= 9; cmd_index++) - { - bzero(answer, 500); - bzero(command, 100); - bzero(customsearch_field, 100); - snprintf(command, 100, "CSP,%i", renum[cmd_index]); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, customsearch_field); - - /* We have 16 parsed fields to print for CSP command */ - for (i = 0; i <= 15; i++) - { - if (i != 0) - printf(","); - printf("%s", customsearch_field[i]); - } - printf("\n"); - } - get_weather_settings(fd); get_same_group_settings(fd); Modified: src/commands.h =================================================================== --- src/commands.h 2007-07-08 07:10:09 UTC (rev 78) +++ src/commands.h 2007-07-08 18:49:25 UTC (rev 79) @@ -106,18 +106,18 @@ int get_bcast_screen_band_settings(int fd); /*int set_bcast_screen_band_settings(int fd, int bcast_screen_band_settings_index, char **parsed_line);*/ int get_search_key_settings(int fd); -/*int set_search_key_settings(int fd, char **parsed_line); +/*int set_search_key_settings(int fd, char **parsed_line); */ int get_global_lockout_freq(int fd); -int unlock_global_lockout_freq(int fd, double global_lockout_freq); -int lock_out_freq(int fd, double frequency); +/* int unlock_global_lockout_freq(int fd, double global_lockout_freq); +int lock_out_freq(int fd, double frequency);*/ int get_close_call_settings(int fd); -int set_close_call_settings(int fd, char **parsed_line); -int get_service_search_settings(int fd, int search_index); -int set_service_search_settings(int fd, int search_index, char **parsed_line); +/*int set_close_call_settings(int fd, char **parsed_line);*/ +int get_service_search_settings(int fd); +/*int set_service_search_settings(int fd, int search_index, char **parsed_line);*/ int get_custom_search_group(int fd); -int set_custom_search_group(int fd, char **parsed_line); -int get_custom_search_settings(int fd, int search_index); -int set_custom_search_settings(int fd, int search_index, char **parsed_line);*/ +/*int set_custom_search_group(int fd, char **parsed_line);*/ +int get_custom_search_settings(int fd); +/*int set_custom_search_settings(int fd, int search_index, char **parsed_line);*/ int get_weather_settings(int fd); /*int set_weather_setting(int fd, char **parsed_line);*/ int get_same_group_settings(int fd); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-08 07:10:21
|
Revision: 78 http://dsctl.svn.sourceforge.net/dsctl/?rev=78&view=rev Author: roger-linux Date: 2007-07-08 00:10:09 -0700 (Sun, 08 Jul 2007) Log Message: ----------- commands.c: Splitting the one big mess for the dump command into smaller functions and moving them into some type of order at the top of the file. Got about half of them done. Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.c src/commands.h src/human_commands.c src/human_commands.h Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-08 00:01:40 UTC (rev 77) +++ src/commands.c 2007-07-08 07:10:09 UTC (rev 78) @@ -42,7 +42,7 @@ char answer[500]; char *field[100]; - int i = 0; + int i; memset(answer, 0, 500); memset(field, 0, 100); @@ -65,28 +65,39 @@ /*********************************************************************** * Push Key ***********************************************************************/ -int push_key(int fd, char *key) +int push_key(int fd, char key_code, char key_mode) { - char answer[100]; + char answer[100], command[100]; memset(answer, 0, 100); - - do_command(fd, key, answer); + memset(command, 0, 100); + snprintf(command, 100, "KEY,%c,%c", key_code, key_mode); + + do_command(fd, command, answer); + if (strncmp(answer, "KEY,OK", 6) != 0) - u_err(key, answer); + u_err(command, answer); return (1); } /*********************************************************************** + * Go to Quick Search Hold Mode + ***********************************************************************/ +int quick_search_hold_mode(int fd, char **parsed_line) +{ + return(0); +} + +/*********************************************************************** * Get Current Status ***********************************************************************/ void get_current_status(int fd) { char answer[500]; char *field[100]; - int i = 0; + int i; /* STS - Current Status * For this particular command, as it returns actual display output, @@ -153,7 +164,7 @@ char answer[500]; char *field[100]; - int i = 0; + int i; memset(answer, 0, 500); memset(field, 0, 100); @@ -176,15 +187,36 @@ /*********************************************************************** * Get Model Info ***********************************************************************/ -void get_model_info(fd) +void get_model_info(int fd) { - char answer[100]; + /*char answer[100]; + memset(answer, 0, 100); - memset(answer, 0, 100); - - do_command(fd, "MDL", answer); - printf("Scanner Sysinfo: %s\n", answer); + do_command(fd, "MDL", answer); + printf("Scanner Sysinfo: %s\n", answer);*/ + char answer[100], command[100]; + char *model_field[100]; + int i; + + memset(answer, 0, 100); + memset(command, 0, 100); + memset(model_field, 0, 100); + + snprintf(command, 100, "MDL"); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, model_field); + + /* We have 2 parsed fields to print for MDL command */ + for (i = 0; i <= 1; i++) + { + if (i != 0) + printf(","); + printf("%s", model_field[i]); + } + printf("\n"); } /*********************************************************************** @@ -192,12 +224,28 @@ ***********************************************************************/ void get_firmware_version(fd) { - char answer[100]; + char answer[100], command[100]; + char *firmvers_field[100]; + int i; + + memset(answer, 0, 100); + memset(command, 0, 100); + bzero(firmvers_field, 100); + snprintf(command, 100, "VER"); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, firmvers_field); - memset(answer, 0, 100); - - do_command(fd, "VER", answer); - printf("Scanner Firmware: %s\n", answer); + /* We have 2 parsed fields to print for VER command */ + for (i = 0; i <= 1; i++) + { + if (i != 0) + printf(","); + printf("%s", firmvers_field[i]); + } + printf("\n"); + } /*********************************************************************** @@ -251,6 +299,328 @@ } /*********************************************************************** +* Get Backlight +***********************************************************************/ +int get_backlight(int fd) +{ + char answer[100], command[100]; + char *backlight_field[100]; + int i; + + memset(answer, 0, 100); + memset(command, 0, 100); + memset(backlight_field, 0, 100); + snprintf(command, 100, "BKL"); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, backlight_field); + + /* We have 2 parsed fields to print for BKL command */ + for (i = 0; i <= 1; i++) + { + if (i != 0) + printf(","); + printf("%s", backlight_field[i]); + } + printf("\n"); + + return(0); +} + +/*********************************************************************** +* Set Backlight +***********************************************************************/ +/*int set_backlight(int fd, char **parsed_line) +{ + return(0); +}*/ + +/*********************************************************************** +* Get Key Beep +***********************************************************************/ +int get_key_beep(int fd) +{ + char answer[100], command[100]; + char *key_beep_field[100]; + int i; + + memset(answer, 0, 100); + memset(command, 0, 100); + memset(key_beep_field, 0, 100); + + snprintf(command, 100, "KBP"); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, key_beep_field); + + /* We have 2 parsed fields to print for KBP command */ + for (i = 0; i <= 1; i++) + { + if (i != 0) + printf(","); + printf("%s", key_beep_field[i]); + } + printf("\n"); + + return(0); +} + +/*********************************************************************** +* Get Opening Message +***********************************************************************/ +int get_opening_message(int fd) +{ + + char answer[500], command[100]; + char *openingmsg_field[500]; + int i; + + memset(answer, 0, 500); + memset(command, 0, 100); + memset(openingmsg_field, 0, 500); + + snprintf(command, 100, "OMS"); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, openingmsg_field); + + /* We have 5 parsed fields to print for OMS command */ + for (i = 0; i <= 4; i++) + { + if (i != 0) + printf(","); + printf("%s", openingmsg_field[i]); + } + printf("\n"); + + return (0); +} + +/*********************************************************************** +* Get Priority Mode +***********************************************************************/ +int get_priority_mode(int fd) +{ + char answer[100], command[100]; + char *primode_field[100]; + int i; + + memset(answer, 0, 100); + memset(command, 0, 100); + memset(primode_field, 0, 100); + + snprintf(command, 100, "PRI"); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, primode_field); + + /* We have 2 parsed fields to print for PRI command */ + for (i = 0; i <= 1; i++) + { + if (i != 0) + printf(","); + printf("%s", primode_field[i]); + } + printf("\n"); + + return (0); +} + +/*********************************************************************** +* Get Auto Gain Control +***********************************************************************/ +int get_auto_gain_control(int fd) +{ + char answer[100], command[100]; + char *autogainctrl_field[100]; + int i; + + memset(answer, 0, 100); + memset(command, 0, 100); + memset(autogainctrl_field, 0, 100); + + snprintf(command, 100, "AGV"); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, autogainctrl_field); + + /* We have 3 parsed fields to print for AGV command */ + for (i = 0; i <= 2; i++) + { + if (i != 0) + printf(","); + printf("%s", autogainctrl_field[i]); + } + printf("\n"); + + return (0); +} + +/*********************************************************************** +* Get System Count +***********************************************************************/ +int get_system_count(int fd) +{ + char answer[100], command[100]; + char *syscount_field[100]; + int i; + + memset(answer, 0, 100); + memset(command, 0, 100); + memset(syscount_field, 0, 100); + + snprintf(command, 100, "SCT"); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, syscount_field); + + /* We have 2 parsed fields to print for SCT command */ + for (i = 0; i <= 1; i++) + { + if (i != 0) + printf(","); + printf("%s", syscount_field[i]); + } + printf("\n"); + + return (0); +} + +/*********************************************************************** +* Get System Index Head +***********************************************************************/ +int get_system_index_head(int fd) +{ + char answer[100], command[100]; + char *sysindexhead_field[100]; + int i; + + memset(answer, 0, 100); + memset(command, 0, 100); + memset(sysindexhead_field, 0, 100); + + snprintf(command, 100, "SIH"); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, sysindexhead_field); + + /* We have 2 parsed fields to print for SIH command */ + /*for (i = 0; i <= 1; i++) + { + if (i != 0) + printf(","); + printf("%s", sysindexhead_field[i]); + } + printf("\n");*/ + + i = atoi(sysindexhead_field[1]); + + return (i); +} + +/*********************************************************************** +* Get System Index Tail +***********************************************************************/ +int get_system_index_tail(int fd) +{ + char answer[100], command[100]; + char *sysindextail_field[100]; + int i; + + memset(answer, 0, 100); + memset(command, 0, 100); + memset(sysindextail_field, 0, 100); + + snprintf(command, 100, "SIT"); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, sysindextail_field); + + /* We have 2 parsed fields to print for SIT command */ + /*for (i = 0; i <= 1; i++) + { + if (i != 0) + printf(","); + printf("%s", sysindextail_field[i]); + } + printf("\n");*/ + + i = atoi(sysindextail_field[1]); + + return (i); +} + +/*********************************************************************** +* Get System/Site Quick Lockout +***********************************************************************/ +int get_system_quick_lockout(int fd) +{ + char answer[500], command[100]; + char *field[100]; + int i; + + memset(answer, 0, 500); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "QSL"); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, field); + + /* We have 11 parsed fields to print for QSL command */ + for (i = 0; i <= 10; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); + + return (0); +} + +/*********************************************************************** +* Get Group Quick Lockout +***********************************************************************/ +int get_group_quick_lockout(int fd, int system_index) +{ + char answer[100], command[100]; + char *field[100]; + int i; + + memset(answer, 0, 100); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "QGL,%i", system_index); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, field); + + /* We have 2 parsed fields to print for QGL command */ + for (i = 0; i <= 1; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); + + return (0); +} + +/*********************************************************************** * Clear All Memory ***********************************************************************/ int clear_memory(int fd) @@ -719,352 +1089,592 @@ } /*********************************************************************** -* Download BCD memory contents -* TODO: Break This Into Functions. See above lower level SET functions -* and elongated functions at the bottom integrating the above SET -* functions for uploading. When this is complete, the below will be -* separated into lower level GET functions with elongated functions for -* implementation. (Reason I initially just gobbed this, had no idea how -* Uniden's memory tree worked.) +* Get Remains of Memory ***********************************************************************/ - - /* TODO: All done. Just need to make things look nice. - * TODO: We can start to see repeated code & how we - * might possibly put this code into functions. */ - -int dump(int fd, FILE * outfile) +int get_remains_memory_block(int fd) { - char answer[500], command[100]; + char answer[100], command[100]; + char *memblocks_field[100]; + int i; - int i = 0, cmd_index; - int renum[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; - - char *model_field[100], *firmver_field[100]; - char *memblocks_field[100], *memused_field[100]; - - char *backlight_field[100], *keybeep_field[100], *openingmsg_field[100], - *primode_field[100], *autogainctrl_field[100], *syscount_field[100]; - char sys_type[5], site_type[5]; - - char *searchcc_field[100], *broadcastscreen_field[100], - *searchkey_field[100], *globallockoutfreq_field[100], - *closecall_field[100]; - - char *svcsearch_field[100], - *customsearchgrp_field[100], *customsearch_field[100], - *wxsettings_field[100], *samegrp_field[100], *toneout_field[100], - *lcdcontrast_field[100], *lcdupsidedown_field[100], - *scanneropts_field[100], *gpsformat_field[100]; - - int sys_indexhead, loc_indexhead; - int sys_index, grpinfo_index, chaninfo_index, trunkinfo_index, - siteinfo_index, motbandplan_index, apcobandplan_index, - trunkfreq_index, tgidinfo_index, loc_index; - char *sys_field[100], *grp_field[100], *chan_field[100], - *trunkinfo_field[100], *siteinfo_field[100], *motinfo_field[100], - *apcoinfo_field[100], *trunkfreq_field[100], *tgid_field[100]; - char *loc_field[100]; - - /* Put BCD into Program Mode - * First, make sure BCD is in scan mode, else we get NG */ - - /* I Tried this but get a double beep if in Scan Mode already, plus - * QUF was returned as ERR. So just hoping the user - * in Scan Mode and not Menu Mode! - memset(answer, 0, 100); - do_command(fd, "KEY,S,L", answer); - if (strncmp(answer, "KEY,OK", 6) != 0) - { - u_err("KEY", answer); - return (1); - }*/ - - printf("dsctl version %s\n\n", FFVERSION); - - enter_prg_mode(fd); - - /*********************************************************************** - * Get System Information - ***********************************************************************/ - - /* Get Model Info */ - bzero(answer, 500); - bzero(command, 100); - bzero(model_field, 100); - snprintf(command, 100, "MDL"); + memset(answer, 0, 100); + memset(command, 0, 100); + memset(memblocks_field, 0, 100); + snprintf(command, 100, "RMB"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, model_field); + parse_fields(answer, memblocks_field); - /* We have 2 parsed fields to print for MDL command */ + /* We have 2 parsed fields to print for RMB command */ for (i = 0; i <= 1; i++) { if (i != 0) printf(","); - printf("%s", model_field[i]); + printf("%s", memblocks_field[i]); } printf("\n"); - /* Get Firmware Version */ - bzero(answer, 500); - bzero(command, 100); - bzero(firmver_field, 100); - snprintf(command, 100, "VER"); + return(0); +} + +/*********************************************************************** +* Get Memory Used +***********************************************************************/ +int get_memory_used(int fd) +{ + char answer[100], command[100]; + char *memused_field[100]; + int i; + + memset(answer, 0, 100); + memset(command, 0, 100); + memset(memused_field, 0, 100); + + snprintf(command, 100, "MEM"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, firmver_field); + parse_fields(answer, memused_field); - /* We have 2 parsed fields to print for VER command */ - for (i = 0; i <= 1; i++) + /* We have 6 parsed fields to print for MEM command */ + for (i = 0; i <= 5; i++) { if (i != 0) printf(","); - printf("%s", firmver_field[i]); + printf("%s", memused_field[i]); } printf("\n"); - /* Get Remains of Memory Block (Free Memory Blocks) */ - bzero(answer, 500); - bzero(command, 100); - bzero(memblocks_field, 100); - snprintf(command, 100, "RMB"); + return(0); +} + +/*********************************************************************** +* Get Search/Close Call Settings +***********************************************************************/ +int get_srch_cc_settings(int fd) +{ + char answer[500], command[100]; + char *field[100]; + int i; + + memset(answer, 0, 500); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "SCO"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, memblocks_field); + parse_fields(answer, field); - /* We have 2 parsed fields to print for RMB command */ - for (i = 0; i <= 1; i++) + /* We have 13 parsed fields to print for this command */ + for (i = 0; i <= 12; i++) { if (i != 0) printf(","); - printf("%s", memblocks_field[i]); + printf("%s", field[i]); } printf("\n"); - /* Get Memory Used */ - bzero(answer, 500); - bzero(command, 100); - bzero(memused_field, 100); - snprintf(command, 100, "MEM"); + return(0); +} + +/*********************************************************************** +* Get Broadcast Screen Band Settings +***********************************************************************/ +int get_bcast_screen_band_settings(int fd) +{ + char answer[500], command[100]; + char *field[100]; + int cmd_index,i; + int renum[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; + + + for (cmd_index = 0; cmd_index <= 9; cmd_index++) + { + memset(answer, 0, 500); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "BBS,%i", renum[cmd_index]); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, field); + + /* We have 3 parsed fields to print for this command */ + for (i = 0; i <= 2; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n"); + } + + return (0); +} + +/*********************************************************************** +* Get Broadcast Screen Band Settings +***********************************************************************/ +int get_search_key_settings(int fd) +{ + char answer[500], command[100]; + char *field[100]; + int i; + + memset(answer, 0, 500); + memset(command, 0, 100); + memset(field, 0, 100); + + snprintf(command, 100, "SHK"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, memused_field); + parse_fields(answer, field); - /* We have 6 parsed fields to print for MEM command */ + /* We have 6 parsed fields to print for this command */ for (i = 0; i <= 5; i++) { if (i != 0) printf(","); - printf("%s", memused_field[i]); + printf("%s", field[i]); } printf("\n"); + + return (0); +} - /*********************************************************************** - * Get System Settings - ***********************************************************************/ - /* Get Backlight */ - bzero(answer, 500); - bzero(command, 100); - bzero(backlight_field, 100); - snprintf(command, 100, "BKL"); +/*********************************************************************** +* Get Weather Settings +***********************************************************************/ +int get_weather_settings(int fd) +{ + char answer[100], command[100]; + char *wxsettings_field[100]; + int i; + + memset(answer, 0, 100); + memset(command, 0, 100); + memset(wxsettings_field, 0, 100); + + snprintf(command, 100, "WXS"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, backlight_field); + parse_fields(answer, wxsettings_field); - /* We have 2 parsed fields to print for BKL command */ - for (i = 0; i <= 1; i++) + /* We have 4 parsed fields to print for WXS command */ + for (i = 0; i <= 3; i++) { if (i != 0) printf(","); - printf("%s", backlight_field[i]); + printf("%s", wxsettings_field[i]); } printf("\n"); - /* Get Key Beep */ - bzero(answer, 500); - bzero(command, 100); - bzero(keybeep_field, 100); - snprintf(command, 100, "KBP"); + return (0); +} + +/*********************************************************************** +* Get Same Group Settings +***********************************************************************/ +int get_same_group_settings(int fd) +{ + char answer[500], command[100]; + char *samegrp_field[100]; + int cmd_index, i; + + for (cmd_index = 1; cmd_index <= 5; cmd_index++) + { + memset(answer, 0, 500); + memset(command, 0, 100); + memset(samegrp_field, 0, 100); + + snprintf(command, 100, "SGP,%i", cmd_index); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, samegrp_field); + + /* We have 10 parsed fields to print for SGP command */ + for (i = 0; i <= 9; i++) + { + if (i != 0) + printf(","); + printf("%s", samegrp_field[i]); + } + printf("\n"); + } + + return (0); +} +/*********************************************************************** +* Get Tone-Out Settings +***********************************************************************/ +int get_tone_out_settings(int fd) +{ + char answer[500], command[100]; + char *toneout_field[100]; + int cmd_index, i; + int renum[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; + + for (cmd_index = 0; cmd_index <= 9; cmd_index++) + { + memset(answer, 0, 500); + memset(command, 0, 100); + memset(toneout_field, 0, 100); + + snprintf(command, 100, "TON,%i", renum[cmd_index]); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, toneout_field); + + /* We have 15 parsed fields to print for TON command */ + for (i = 0; i <= 14; i++) + { + if (i != 0) + printf(","); + printf("%s", toneout_field[i]); + } + printf("\n"); + } + + return (0); +} + +/*********************************************************************** +* Get LCD Contrast Settings +***********************************************************************/ +int get_lcd_contrast_settings(int fd) +{ + + char answer[100], command[100]; + char *lcdcontrast_field[100]; + int i; + + memset(answer, 0, 100); + memset(command, 0, 100); + memset(lcdcontrast_field, 0, 100); + + snprintf(command, 100, "CNT"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, keybeep_field); + parse_fields(answer, lcdcontrast_field); - /* We have 2 parsed fields to print for KBP command */ + /* We have 2 parsed fields to print for CNT command */ for (i = 0; i <= 1; i++) { if (i != 0) printf(","); - printf("%s", keybeep_field[i]); + printf("%s", lcdcontrast_field[i]); } printf("\n"); - /* Get Opening Message */ - bzero(answer, 500); - bzero(command, 100); - bzero(openingmsg_field, 100); - snprintf(command, 100, "OMS"); + return (0); +} + +/*********************************************************************** +* Get LCD Upside Down Settings +***********************************************************************/ +int get_lcd_upside_down_settings(int fd) +{ + char answer[100], command[100]; + char *lcdupsidedown_field[100]; + int i; + + memset(answer, 0, 100); + memset(command, 0, 100); + memset(lcdupsidedown_field, 0, 100); + + snprintf(command, 100, "DUD"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, openingmsg_field); + parse_fields(answer, lcdupsidedown_field); - /* We have 5 parsed fields to print for OMS command */ - for (i = 0; i <= 4; i++) + /* We have 2 parsed fields to print for DUD command */ + for (i = 0; i <= 1; i++) { if (i != 0) printf(","); - printf("%s", openingmsg_field[i]); + printf("%s", lcdupsidedown_field[i]); } printf("\n"); - /* Get Priority Mode */ - bzero(answer, 500); - bzero(command, 100); - bzero(primode_field, 100); - snprintf(command, 100, "PRI"); + return (0); +} + +/*********************************************************************** +* Get Scanner Option Settings +***********************************************************************/ +int get_scanner_option_settings(int fd) +{ + char answer[500], command[100]; + char *scanneropts_field[100]; + int i; + + memset(answer, 0, 500); + memset(command, 0, 100); + memset(scanneropts_field, 0, 100); + + snprintf(command, 100, "SCN"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, primode_field); + parse_fields(answer, scanneropts_field); - /* We have 2 parsed fields to print for PRI command */ - for (i = 0; i <= 1; i++) + /* We have 20 parsed fields to print for SCN command */ + for (i = 0; i <= 19; i++) { if (i != 0) printf(","); - printf("%s", primode_field[i]); + printf("%s", scanneropts_field[i]); } printf("\n"); - /* Get Auto Gain Control */ - bzero(answer, 500); - bzero(command, 100); - bzero(autogainctrl_field, 100); - snprintf(command, 100, "AGV"); + return (0); +} + +/*********************************************************************** +* Get APCO Data Settings +***********************************************************************/ +int get_apco_settings(int fd) +{ + char answer[500], command[100]; + char *apcodata_field[100]; + int i; + + memset(answer, 0, 500); + memset(command, 0, 100); + memset(apcodata_field, 0, 100); + + snprintf(command, 100, "P25"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, autogainctrl_field); + parse_fields(answer, apcodata_field); - /* We have 3 parsed fields to print for AGV command */ - for (i = 0; i <= 2; i++) + /* We have 4 parsed fields to print for SCN command */ + for (i = 0; i <= 3; i++) { if (i != 0) printf(","); - printf("%s", autogainctrl_field[i]); + printf("%s", apcodata_field[i]); } printf("\n"); - /* Get System Count */ - bzero(answer, 500); - bzero(command, 100); - bzero(syscount_field, 100); - snprintf(command, 100, "SCT"); + return (0); +} + +/*********************************************************************** +* Get GPS Display Option +***********************************************************************/ +int get_gps_display_option(int fd) +{ + char answer[500], command[100]; + char *gpsformat_field[100]; + int i; + + memset(answer, 0, 500); + memset(command, 0, 100); + memset(gpsformat_field, 0, 100); + + snprintf(command, 100, "GDO"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, syscount_field); + parse_fields(answer, gpsformat_field); - /* We have 2 parsed fields to print for SCT command */ - for (i = 0; i <= 1; i++) + /* We have 5 parsed fields to print for GDO command */ + for (i = 0; i <= 4; i++) { if (i != 0) printf(","); - printf("%s", syscount_field[i]); + printf("%s", gpsformat_field[i]); } printf("\n"); - /* Get Remains of Memory Block (Free Memory Blocks) */ - bzero(answer, 500); - bzero(command, 100); - bzero(memblocks_field, 100); - snprintf(command, 100, "RMB"); + return (0); +} + +/*********************************************************************** +* Get GGA Data from GPS +***********************************************************************/ +int get_gps_gga_data(int fd) +{ + char answer[100], command[100]; + char *ggadata_field[100]; + int i; + + memset(answer, 0, 100); + memset(command, 0, 100); + memset(ggadata_field, 0, 100); + + snprintf(command, 100, "GGA"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, memblocks_field); + parse_fields(answer, ggadata_field); - /* We have 2 parsed fields to print for RMB command */ + /* We have 2 parsed fields to print for GDO command */ for (i = 0; i <= 1; i++) { if (i != 0) printf(","); - printf("%s", memblocks_field[i]); + printf("%s", ggadata_field[i]); } printf("\n"); - /*********************************************************************** - * Get Search / Close Call Settings - ***********************************************************************/ + return (0); +} - /* TODO: This needs testing! */ - bzero(answer, 500); - bzero(command, 100); - bzero(searchcc_field, 100); - snprintf(command, 100, "SCO"); +/*********************************************************************** +* Get RMC Data from GPS +***********************************************************************/ +int get_gps_rmc_data(int fd) +{ + char answer[100], command[100]; + char *rmcdata_field[100]; + int i; + + memset(answer, 0, 100); + memset(command, 0, 100); + memset(rmcdata_field, 0, 100); + + snprintf(command, 100, "RMC"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, searchcc_field); + parse_fields(answer, rmcdata_field); - /* We have 12 parsed fields to print for SCO command */ - for (i = 0; i <= 11; i++) + /* We have 2 parsed fields to print for RMC command */ + for (i = 0; i <= 1; i++) { if (i != 0) printf(","); - printf("%s", searchcc_field[i]); + printf("%s", rmcdata_field[i]); } printf("\n"); - /* Get Broadcast Screen Band Settings - * Needs an index 1-0 (0 = 10) */ - for (cmd_index = 0; cmd_index <= 9; cmd_index++) - { - bzero(answer, 500); - bzero(command, 100); - bzero(broadcastscreen_field, 100); - snprintf(command, 100, "BBS,%i", renum[cmd_index]); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, broadcastscreen_field); + return (0); +} - /* We have 3 parsed fields to print for BBS command */ - for (i = 0; i <= 2; i++) - { - if (i != 0) - printf(","); - printf("%s", broadcastscreen_field[i]); - } - printf("\n"); - } +/*********************************************************************** +* Get Window Voltage +***********************************************************************/ +int get_window_voltage(int fd) +{ + char answer[100], command[100]; + char *winvolt_field[100]; + int i; + + memset(answer, 0, 100); + memset(command, 0, 100); + memset(winvolt_field, 0, 100); - /* Get Search Key Settings */ - bzero(answer, 500); - bzero(command, 100); - bzero(searchkey_field, 100); - snprintf(command, 100, "SHK"); + snprintf(command, 100, "WIN"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, searchkey_field); + parse_fields(answer, winvolt_field); - /* We have 6 parsed fields to print for SHK command */ - for (i = 0; i <= 5; i++) + /* We have 2 parsed fields to print for WIN command */ + for (i = 0; i <= 1; i++) { if (i != 0) printf(","); - printf("%s", searchkey_field[i]); + printf("%s", winvolt_field[i]); } printf("\n"); + return (0); +} + + +/*********************************************************************** +* Download BCD memory contents +* TODO: Break This int low-level scanner command functions. +* (Reason I initially just gobbed this, had no idea how Uniden's memory +* tree worked.) +***********************************************************************/ + + /* TODO: All done. Just need to make things look nice. + * TODO: We can start to see repeated code & how we + * might possibly put this code into functions. */ + +int dump(int fd, FILE * outfile) +{ + char answer[500], command[100]; + + int i = 0, cmd_index; + int renum[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; + + char sys_type[5], site_type[5]; + + char *globallockoutfreq_field[100], + *closecall_field[100]; + + char *svcsearch_field[100], + *customsearchgrp_field[100], *customsearch_field[100]; + + int loc_indexhead; + int sys_index, grpinfo_index, chaninfo_index, trunkinfo_index, + siteinfo_index, motbandplan_index, apcobandplan_index, + trunkfreq_index, tgidinfo_index, loc_index; + char *sys_field[100], *grp_field[100], *chan_field[100], + *trunkinfo_field[100], *siteinfo_field[100], *motinfo_field[100], + *apcoinfo_field[100], *trunkfreq_field[100], *tgid_field[100]; + char *loc_field[100]; + + /* File Version Format */ + printf("dsctl version %s\n\n", FFVERSION); + + /* Make sure unit is in Scan Mode and not Menu Mode, else we get NG */ + push_key(fd,'S','P'); + + /* Enter Program Mode */ + enter_prg_mode(fd); + + /* Get System Information */ + get_model_info(fd); + + get_firmware_version(fd); + + get_opening_message(fd); + + get_remains_memory_block(fd); + + get_memory_used(fd); + + /* Get System Settings */ + get_backlight(fd); + + get_key_beep(fd); + + get_opening_message(fd); + + get_priority_mode(fd); + + get_auto_gain_control(fd); + + get_system_count(fd); + + /*********************************************************************** + * Get Search / Close Call Settings + ***********************************************************************/ + + get_srch_cc_settings(fd); + + get_bcast_screen_band_settings(fd); + + get_search_key_settings(fd); + /* Get Global Lockout Frequencies */ bzero(answer, 500); bzero(command, 100); @@ -1180,163 +1790,45 @@ printf("\n"); } - /* Weather Settings */ - bzero(answer, 500); - bzero(command, 100); - bzero(wxsettings_field, 100); - snprintf(command, 100, "WXS"); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, wxsettings_field); + get_weather_settings(fd); - /* We have 4 parsed fields to print for WXS command */ - for (i = 0; i <= 3; i++) - { - if (i != 0) - printf(","); - printf("%s", wxsettings_field[i]); - } - printf("\n"); + get_same_group_settings(fd); - /* SAME Group Settings */ - for (cmd_index = 1; cmd_index <= 5; cmd_index++) - { - bzero(answer, 500); - bzero(command, 100); - bzero(samegrp_field, 100); - snprintf(command, 100, "SGP,%i", cmd_index); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, samegrp_field); + get_tone_out_settings(fd); - /* We have 10 parsed fields to print for SGP command */ - for (i = 0; i <= 9; i++) - { - if (i != 0) - printf(","); - printf("%s", samegrp_field[i]); - } - printf("\n"); - } + get_lcd_contrast_settings(fd); - /* Tone-Out Settings */ - for (cmd_index = 0; cmd_index <= 9; cmd_index++) - { - bzero(answer, 500); - bzero(command, 100); - bzero(toneout_field, 100); - snprintf(command, 100, "TON,%i", renum[cmd_index]); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, toneout_field); + get_lcd_upside_down_settings(fd); + + get_scanner_option_settings(fd); - /* We have 15 parsed fields to print for TON command */ - for (i = 0; i <= 14; i++) - { - if (i != 0) - printf(","); - printf("%s", toneout_field[i]); - } - printf("\n"); - } + get_apco_settings(fd); - /* Get LCD Contrast Settings */ - bzero(answer, 500); - bzero(command, 100); - bzero(lcdcontrast_field, 100); - snprintf(command, 100, "CNT"); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, lcdcontrast_field); + get_gps_display_option(fd); - /* We have 2 parsed fields to print for CNT command */ - for (i = 0; i <= 1; i++) - { - if (i != 0) - printf(","); - printf("%s", lcdcontrast_field[i]); - } - printf("\n"); - - /* Get LCD Upside-down Settings */ - bzero(answer, 500); - bzero(command, 100); - bzero(lcdupsidedown_field, 100); - snprintf(command, 100, "DUD"); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, lcdupsidedown_field); - - /* We have 2 parsed fields to print for DUD command */ - for (i = 0; i <= 1; i++) - { - if (i != 0) - printf(","); - printf("%s", lcdupsidedown_field[i]); - } - printf("\n"); - - /* Get Scanner Option Settings */ - bzero(answer, 500); - bzero(command, 100); - bzero(scanneropts_field, 100); - snprintf(command, 100, "SCN"); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, scanneropts_field); - - /* We have 20 parsed fields to print for SCN command */ - for (i = 0; i <= 19; i++) - { - if (i != 0) - printf(","); - printf("%s", scanneropts_field[i]); - } - printf("\n"); - - /* Get GPS Format Settings */ - bzero(answer, 500); - bzero(command, 100); - bzero(gpsformat_field, 100); - snprintf(command, 100, "GDO"); - /*printf("\nCommand == %s\n", command); */ - do_command(fd, command, answer); - /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, gpsformat_field); - - /* We have 5 parsed fields to print for GDO command */ - for (i = 0; i <= 4; i++) - { - if (i != 0) - printf(","); - printf("%s", gpsformat_field[i]); - } - printf("\n"); - /************************************************ * Get Scan Settings ************************************************/ /* Get System Index Head */ - bzero(answer, 100); - do_command(fd, "SIH", answer); + //bzero(answer, 100); + //do_command(fd, "SIH", answer); /*printf(" Starting Systems Location: %s", answer); */ - sscanf(answer, "SIH,%i", &sys_indexhead); + //sscanf(answer, "SIH,%i", &sys_indexhead); /* SIN */ /* While we have System Indexes, then print them. * using the above System Head and System Tail * And once we find the first system, find the next system using * forward system index field */ - sys_index = sys_indexhead; + sys_index = get_system_index_head(fd); + + get_system_quick_lockout(fd); + while (sys_index != -1) { + get_group_quick_lockout(fd, sys_index); /* This might break things */ + bzero(answer, 500); bzero(command, 100); bzero(sys_field, 100); @@ -1354,13 +1846,14 @@ printf("%s", sys_field[i]); } printf("\n"); - + /* Set our starting Group and Site index addresses from SIN info */ /* Pointers are returned from parse_fields, use strncpy for strings. */ siteinfo_index = atoi(sys_field[14]); trunkinfo_index = sys_index; grpinfo_index = atoi(sys_field[14]); strncpy(sys_type, sys_field[1], 5); + /*sys_type = sys_field[1]; */ /*printf("systype = %s\n", sys_type); */ /*printf("trunkinfo_index = %i\n", trunkinfo_index); */ @@ -1688,6 +2181,9 @@ /*********************************************************************** * Load BCD memory from file ***********************************************************************/ +/* TODO: Break the following into sections for allowing upload of + *only Configuration Settings, Systems Data only or Location Alert + *Settings only.*/ int load(int fd, FILE * infile) { char answer[500], command[500], line[500], *parsed_line[100], @@ -1738,8 +2234,9 @@ printf("scanner_command (parsed_line[0]) == %s\n", scanner_command); - /* TODO: Link the following functions and verify they're proper usage - * with compiling & upload tests of a dsctl dumped contents file. */ + /* TODO: Break the following into sections for allowing + upload of only Configuration Settings, Systems Data only or + Location Alert Settings only. */ if (strncmp(scanner_command, "SIN", 3) == 0) { /*printf("DEBUG %s\n", scanner_command); */ @@ -1847,7 +2344,7 @@ printf ("For more information on these matters, see the file named LICENSE.\n\n"); - printf("Scanner Model: %d\n", scannermodel); + /*printf("Scanner Model (Internal): %d\n", scannermodel);*/ get_model_info(fd); get_firmware_version(fd); Modified: src/commands.h =================================================================== --- src/commands.h 2007-07-08 00:01:40 UTC (rev 77) +++ src/commands.h 2007-07-08 07:10:09 UTC (rev 78) @@ -24,47 +24,13 @@ extern int scannermodel; /*********************************************************************** - * Keycodes for the KEY PRESS command -TODO: These should go into human_commands.h (and use switch instead of if ?) - ***********************************************************************/ -#define K_PRI "P" /* Priority */ -#define K_WX "W" /* Weather */ -#define K_GPS "G" /* GPS */ -#define K_MENU "M" /* Menu */ -#define K_FUNC_PUSH "F" /* VFO Push - Function */ -#define K_HOLD "H" /* Hold */ -#define K_SCAN "S" /* Scan /Search */ -#define K_LO "L" /* Lock Out */ -#define K_0 "0" /* numeric keypad key 0 */ -#define K_1 "1" /* numeric keypad key 1 */ -#define K_2 "2" /* numeric keypad key 2 */ -#define K_3 "3" /* numeric keypad key 3 */ -#define K_4 "4" /* numeric keypad key 4 */ -#define K_5 "5" /* numeric keypad key 5 */ -#define K_6 "6" /* numeric keypad key 6 */ -#define K_7 "7" /* numeric keypad key 7 */ -#define K_8 "8" /* numeric keypad key 8 */ -#define K_9 "9" /* numeric keypad key 9 */ -#define K_DOT "." /* Decimal Point and ATT (Attenuator) */ -#define K_ENTER "E" /* Enter and Yes */ -#define K_SQL_PUSH "Q" /* Squelch Push */ -#define K_VOL_PUSH "V" /* Volume Push */ -#define K_VFO_RIGHT ">" /* VFO Right, Use with Key Mode Press */ -#define K_VFO_LEFT "<" /* VFO Left, Use with Key Mode Press */ - -#define K_MODE_PRESS "P" /* Press Key */ -#define K_MODE_HOLD "H" /* Press and Hold Key until Release is - recieved */ -#define K_MODE_RELEASE "R" /* Release and Cancel Hold Key state */ - -/*********************************************************************** * Function Declarations ***********************************************************************/ /* TODO: Copy code from commands.c or implement uncoded functions */ void get_current_tgid_status(int fd); -int push_key(int fd, char *key); -/*int quick_search_hold_mode(int fd, char **parsed_line);*/ +int push_key(int fd, char key_code, char key_mode); +int quick_search_hold_mode(int fd, char **parsed_line); void get_current_status(int fd); void get_reception_status(int fd); void get_model_info(int fd); @@ -72,26 +38,26 @@ int enter_prg_mode(int fd); int exit_prg_mode(int fd); -/*int get_backlight(int fd); -int set_backlight(int fd, char **parsed_line);*/ +int get_backlight(int fd); +/*int set_backlight(int fd, char **parsed_line);*/ int clear_memory(int fd); -/*int get_key_beep(int fd); -int set_key_beep(int fd, char **parsed_line); +int get_key_beep(int fd); +/*int set_key_beep(int fd, char **parsed_line);*/ int get_opening_message(int fd); -int set_opening_message(int fd, char **parsed_line); +/*int set_opening_message(int fd, char **parsed_line);*/ int get_priority_mode(int fd); -int set_priority_mode(int fd, char **parsed_line); +/*int set_priority_mode(int fd, char **parsed_line);*/ int get_auto_gain_control(int fd); -int set_auto_gain_control(int fd, char **parsed_line);*/ +/*int set_auto_gain_control(int fd, char **parsed_line);*/ /* Scan Settings - Goes in order we get/set - Calls Group Index only once instead of twice */ -/*int get_system_count(int fd); +int get_system_count(int fd); int get_system_index_head(int fd); int get_system_index_tail(int fd); int get_system_quick_lockout(int fd); -int set_system_quick_lockout(int fd, char **parsed_line); -int get_group_quick_lockout(int fd); -int set_group_quick_lockout(int fd, char **parsed_line);*/ +/*int set_system_quick_lockout(int fd, char **parsed_line);*/ +int get_group_quick_lockout(int fd, int system_index); +/*int set_group_quick_lockout(int fd, char **parsed_line);*/ int create_system(int fd, char *system_type); /*int delete_system(int fd); int get_system_info(int fd, int system_index);*/ @@ -121,26 +87,26 @@ int set_trunk_freq_info(int fd, int channel_index, char **parsed_line); /* End Scan Settings Commands */ -/*int get_lockout_tgid(int fd, int system_index); -int get_search_lockout_tgid(int fd, int system_index); -int unlock_tgid(int fd, int system_index); +/*int get_lockout_tgid(int fd, int system_index);*/ +/*int get_search_lockout_tgid(int fd, int system_index);*/ +/*int unlock_tgid(int fd, int system_index); int lockout_tgid(int fd, int system_index); int reverse_index(int fd, int index); -int forward_index(int fd, int index); +int forward_index(int fd, int index);*/ int get_remains_memory_block(int fd); int get_memory_used(int fd); -int loc_alert_system_index_head(int fd, char *loc_alert_system_type); +/*int loc_alert_system_index_head(int fd, char *loc_alert_system_type); int get_loc_alert_system_index_tail(int fd, char *loc_alert_system_type); int create_loc_alert_system(int fd, char *loc_alert_system_type); int delete_loc_alert_system(int loc_alert_system_index); int get_loc_alert_system_info(int fd, int loc_alert_system_index); -int set_loc_alert_system_info(int fd, int loc_alert_system_index, char**parsed_line); +int set_loc_alert_system_info(int fd, int loc_alert_system_index, char**parsed_line);*/ int get_srch_cc_settings(int fd); -int set_srch_cc_settings(int fd, char **parsed_line); -int get_bcast_screen_band_settings(int fd, int bcast_screen_band_settings_index); -int set_bcast_screen_band_settings(int fd, int bcast_screen_band_settings_index, char **parsed_line); +/*int set_srch_cc_settings(int fd, char **parsed_line);*/ +int get_bcast_screen_band_settings(int fd); +/*int set_bcast_screen_band_settings(int fd, int bcast_screen_band_settings_index, char **parsed_line);*/ int get_search_key_settings(int fd); -int set_search_key_settings(int fd, char **parsed_line); +/*int set_search_key_settings(int fd, char **parsed_line); int get_global_lockout_freq(int fd); int unlock_global_lockout_freq(int fd, double global_lockout_freq); int lock_out_freq(int fd, double frequency); @@ -151,33 +117,34 @@ int get_custom_search_group(int fd); int set_custom_search_group(int fd, char **parsed_line); int get_custom_search_settings(int fd, int search_index); -int set_custom_search_settings(int fd, int search_index, char **parsed_line); +int set_custom_search_settings(int fd, int search_index, char **parsed_line);*/ int get_weather_settings(int fd); -int set_weather_setting(int fd, char **parsed_line); -int get_same_group_settings(int fd, int same_index); -int set_same_group_settings(int fd, int same_index, char **parsed_line); -int get_tone_out_settings(int fd, int tone_out_index); -int set_tone_out_settings(int fd, int tone_out_index, char **parsed_line); +/*int set_weather_setting(int fd, char **parsed_line);*/ +int get_same_group_settings(int fd); +/*int set_same_group_settings(int fd, int same_index, char **parsed_line);*/ +int get_tone_out_settings(int fd); +/*int set_tone_out_settings(int fd, int tone_out_index, char **parsed_line);*/ int get_lcd_contrast_settings(int fd); -int set_lcd_contrast_settings(int fd, char **parsed_line); +/*int set_lcd_contrast_settings(int fd, char **parsed_line);*/ int get_lcd_upside_down_settings(int fd); -int set_lcd_upside_down_settings(int fd, char **parsed_line); +/*int set_lcd_upside_down_settings(int fd, char **parsed_line);*/ int get_scanner_option_settings(int fd); -int set_scanner_option_settings(int fd, char **parsed_line); +/*int set_scanner_option_settings(int fd, char **parsed_line); int get_volume_level_settings(int fd); int set_volume_level_settings(int fd, int volume_level); int get_squelch_level_settings(int fd); -int set_squelch_level_settings(int fd, int squelch_level); +int set_squelch_level_settings(int fd, int squelch_level);*/ int get_apco_settings(int fd); -int set_apco_settings(int fd, char **parsed_line);*/ -/* GPS Related -- I don't have one for this scanner */ -/*int get_gps_display_option(int fd); -int set_gps_display_option(int fd, char **parsed_line); -int get_gps_gga_data(int fd); -int get_gps_rmc_data(int fd); -int get_window_voltage(int fd);*/ +/*int set_apco_settings(int fd, char **parsed_line);*/ -/* Elongated Functions - Using above lower-level functions */ +/* GPS Related -- I don't have a GPS for this scanner */ +int get_gps_display_option(int fd); +/*int set_gps_display_option(int fd, char **parsed_line);*/ +int get_gps_gga_data(int fd); /* TODO: Untested! */ +int get_gps_rmc_data(int fd); /* TODO: Untested! */ +int get_window_voltage(int fd); + +/* Elongated Functions - Using above lower-level scanner command functions */ int dump(int fd, FILE * outfile); int load(int fd, FILE * infile); int version(int fd); Modified: src/human_commands.c =================================================================== --- src/human_commands.c 2007-07-08 00:01:40 UTC (rev 77) +++ src/human_commands.c 2007-07-08 07:10:09 UTC (rev 78) @@ -116,8 +116,8 @@ else usage(C_KEY); - snprintf(command, 100, "KEY,%c,%c", key_code, key_mode); - push_key(fd, command); + //snprintf(command, 100, "KEY,%c,%c", key_code, key_mode); + push_key(fd, key_code, key_mode); } Modified: src/human_commands.h =================================================================== --- src/human_commands.h 2007-07-08 00:01:40 UTC (rev 77) +++ src/human_commands.h 2007-07-08 07:10:09 UTC (rev 78) @@ -24,6 +24,40 @@ #ifndef _HUMAN_COMMANDS_H_ #define _HUMAN_COMMANDS_H_ +/*********************************************************************** + * Keycodes for the Key Push command +TODO: human_commands.c - use switch instead of if ?) + ***********************************************************************/ +#define K_PRI "P" /* Priority */ +#define K_WX "W" /* Weather */ +#define K_GPS "G" /* GPS */ +#define K_MENU "M" /* Menu */ +#define K_FUNC_PUSH "F" /* VFO Push - Function */ +#define K_HOLD "H" /* Hold */ +#define K_SCAN "S" /* Scan /Search */ +#define K_LO "L" /* Lock Out */ +#define K_0 "0" /* numeric keypad key 0 */ +#define K_1 "1" /* numeric keypad key 1 */ +#define K_2 "2" /* numeric keypad key 2 */ +#define K_3 "3" /* numeric keypad key 3 */ +#define K_4 "4" /* numeric keypad key 4 */ +#define K_5 "5" /* numeric keypad key 5 */ +#define K_6 "6" /* numeric keypad key 6 */ +#define K_7 "7" /* numeric keypad key 7 */ +#define K_8 "8" /* numeric keypad key 8 */ +#define K_9 "9" /* numeric keypad key 9 */ +#define K_DOT "." /* Decimal Point and ATT (Attenuator) */ +#define K_ENTER "E" /* Enter and Yes */ +#define K_SQL_PUSH "Q" /* Squelch Push */ +#define K_VOL_PUSH "V" /* Volume Push */ +#define K_VFO_RIGHT ">" /* VFO Right, Use with Key Mode Press */ +#define K_VFO_LEFT "<" /* VFO Left, Use with Key Mode Press */ + +#define K_MODE_PRESS "P" /* Press Key */ +#define K_MODE_HOLD "H" /* Press and Hold Key until Release is + recieved */ +#define K_MODE_RELEASE "R" /* Release and Cancel Hold Key state */ + void human_do_dump(int fd, int argc, char **args); void human_do_key(int fd, int argc, char **args); void human_do_load(int fd, int argc, char **args); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-08 00:01:45
|
Revision: 77 http://dsctl.svn.sourceforge.net/dsctl/?rev=77&view=rev Author: roger-linux Date: 2007-07-07 17:01:40 -0700 (Sat, 07 Jul 2007) Log Message: ----------- commands.c: Moved pasts of version command code into the proper scanner command functions (ie. scanner command model "MDL" & firmware version "VER". Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.c src/commands.h src/human_commands.c Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-07 23:34:58 UTC (rev 76) +++ src/commands.c 2007-07-08 00:01:40 UTC (rev 77) @@ -63,6 +63,23 @@ } /*********************************************************************** + * Push Key + ***********************************************************************/ +int push_key(int fd, char *key) +{ + char answer[100]; + + memset(answer, 0, 100); + + do_command(fd, key, answer); + + if (strncmp(answer, "KEY,OK", 6) != 0) + u_err(key, answer); + + return (1); +} + +/*********************************************************************** * Get Current Status ***********************************************************************/ void get_current_status(int fd) @@ -157,6 +174,33 @@ } /*********************************************************************** +* Get Model Info +***********************************************************************/ +void get_model_info(fd) +{ + char answer[100]; + + memset(answer, 0, 100); + + do_command(fd, "MDL", answer); + printf("Scanner Sysinfo: %s\n", answer); + +} + +/*********************************************************************** +* Get Firmware Version +***********************************************************************/ +void get_firmware_version(fd) +{ + char answer[100]; + + memset(answer, 0, 100); + + do_command(fd, "VER", answer); + printf("Scanner Firmware: %s\n", answer); +} + +/*********************************************************************** * Enter Program Mode ***********************************************************************/ int enter_prg_mode(int fd) @@ -1789,29 +1833,12 @@ } /*********************************************************************** - * Press Key - ***********************************************************************/ -int press_key(int fd, char *key) -{ - char answer[100]; - - memset(answer, 0, 100); - do_command(fd, key, answer); - - if (strncmp(answer, "KEY,OK", 6) != 0) - u_err(key, answer); - - return (1); -} - -/*********************************************************************** * Get Scanner Model & Scanner Firmware Version ***********************************************************************/ int version(int fd) { - char answer[100]; - printf("Dsctl %s\n", VERSION); + printf("Sctl\n"); printf("Copyright (c) 2001\n"); printf ("Dsctl comes with NO WARRANTY, to the extent permitted by law. You may\n"); @@ -1822,14 +1849,8 @@ printf("Scanner Model: %d\n", scannermodel); - { - do_command(fd, "MDL", answer); - printf("Scanner Sysinfo: %s\n", answer); + get_model_info(fd); + get_firmware_version(fd); - memset(answer, 0, 100); - do_command(fd, "VER", answer); - printf("Scanner Firmware: %s\n", answer); - } - return (1); } Modified: src/commands.h =================================================================== --- src/commands.h 2007-07-07 23:34:58 UTC (rev 76) +++ src/commands.h 2007-07-08 00:01:40 UTC (rev 77) @@ -63,13 +63,13 @@ /* TODO: Copy code from commands.c or implement uncoded functions */ void get_current_tgid_status(int fd); +int push_key(int fd, char *key); /*int quick_search_hold_mode(int fd, char **parsed_line);*/ void get_current_status(int fd); void get_reception_status(int fd); +void get_model_info(int fd); +void get_firmware_version(int fd); -/*void get_model_info(fd); -void get_firmware_version(fd);*/ - int enter_prg_mode(int fd); int exit_prg_mode(int fd); /*int get_backlight(int fd); @@ -180,7 +180,6 @@ /* Elongated Functions - Using above lower-level functions */ int dump(int fd, FILE * outfile); int load(int fd, FILE * infile); -int press_key(int fd, char *key); int version(int fd); #endif /* _COMMANDS_H_ */ Modified: src/human_commands.c =================================================================== --- src/human_commands.c 2007-07-07 23:34:58 UTC (rev 76) +++ src/human_commands.c 2007-07-08 00:01:40 UTC (rev 77) @@ -117,7 +117,7 @@ usage(C_KEY); snprintf(command, 100, "KEY,%c,%c", key_code, key_mode); - press_key(fd, command); + push_key(fd, command); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-07 23:35:00
|
Revision: 76 http://dsctl.svn.sourceforge.net/dsctl/?rev=76&view=rev Author: roger-linux Date: 2007-07-07 16:34:58 -0700 (Sat, 07 Jul 2007) Log Message: ----------- commands.c: Moved status command code from human_commands.c into commands.c functions. Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.c src/commands.h src/human_commands.c src/utils.h Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-07 23:06:36 UTC (rev 75) +++ src/commands.c 2007-07-07 23:34:58 UTC (rev 76) @@ -30,6 +30,133 @@ #include "utils.h" /*********************************************************************** +* Get Current TGID Status +***********************************************************************/ +void get_current_tgid_status(int fd) +{ + /* GID - Current TGID Status + * Uniden's GID & GLG commands only prints out the first unique occurance + * of active TGID info. After the first display, repeated reissues of + * these commands will return null until a different TGID becomes active. + * Save last info and recall it as "Last GID/GID Active:"? */ + + char answer[500]; + char *field[100]; + int i = 0; + + memset(answer, 0, 500); + memset(field, 0, 100); + do_command(fd, "GID", answer); + /*printf ("%s\n(%i)\n", answer, strlen (answer)); */ + parse_fields(answer, field); + + printf("Talkgroup ID Status:\n"); + + /* We have 6 parsed fields to print for GLG command */ + for (i = 0; i <= 5; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n\n"); +} + +/*********************************************************************** +* Get Current Status +***********************************************************************/ +void get_current_status(int fd) +{ + char answer[500]; + char *field[100]; + int i = 0; + + /* STS - Current Status + * For this particular command, as it returns actual display output, + * customized ascii characters will bork the command line if not caught! */ + memset(answer, 0, 500); + memset(field, 0, 100); + + do_command(fd, "STS", answer); + /*printf ("%s\n(%i)\n", answer, strlen(answer)); */ + parse_fields(answer, field); + + replace_chars(field[2], field[2]); + /*printf("Test replace_chars: %s, %i\n", field[2], strlen(field[2]); */ + + replace_chars(field[8], field[8]); + /*printf("Test replace_chars: %s, %i\n\n\n", field[8], strlen(field[8]); */ + + /* The following is used for stopping the effect of the 6th field SCAN */ + char first_half[20]; + char second_half[20]; + + sscanf(field[6], "%s %s", first_half, second_half); + strcat(second_half, first_half); + if (strncmp(first_half, "SCAN", 4) == 0 || + strncmp(second_half, "SCAN", 4) == 0) + strncpy(field[6], "SCANNING\0", 17); + + printf("Status:\n"); + + /* Because the scanners lines change so frequently with multiple types of + * data, I can only think of using just the scrolling scan from the display + * for indicating the scanners status of actively scanning. Other then + * this, probably just best to actually pipe the actual output as is? + * + * Status: (L/O, HOLD, SIGNAL, CC?) + * System/Group Name: + * Channel Name: + * Channel Data: || Channel Frequency || Trunk Activity Indicators + * Systems: || P25 Status: + * Groups: || P25 : + * + * *Screen changes entirely when in Menu Mode + * + */ + + /* We have 23 parsed fields to print for STS command */ + + for (i = 0; i <= 22; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n\n"); +} + +/*********************************************************************** +* Get Reception Status +***********************************************************************/ +void get_reception_status(int fd) +{ + /* GLG - Reception Status + * See GID comment */ + + char answer[500]; + char *field[100]; + int i = 0; + + memset(answer, 0, 500); + memset(field, 0, 100); + do_command(fd, "GLG", answer); + /*printf ("%s\n(%i)\n", answer, strlen (answer)); */ + parse_fields(answer, field); + + printf("Reception Status:\n"); + + /* We have 10 parsed fields to print for GLG command */ + for (i = 0; i <= 9; i++) + { + if (i != 0) + printf(","); + printf("%s", field[i]); + } + printf("\n\n"); +} + +/*********************************************************************** * Enter Program Mode ***********************************************************************/ int enter_prg_mode(int fd) Modified: src/commands.h =================================================================== --- src/commands.h 2007-07-07 23:06:36 UTC (rev 75) +++ src/commands.h 2007-07-07 23:34:58 UTC (rev 76) @@ -61,11 +61,13 @@ * Function Declarations ***********************************************************************/ /* TODO: Copy code from commands.c or implement uncoded functions */ -/*int get_current_status(int fd); -int quick_search_hold_mode(int fd, char **parsed_line); + +void get_current_tgid_status(int fd); +/*int quick_search_hold_mode(int fd, char **parsed_line);*/ void get_current_status(int fd); void get_reception_status(int fd); -void get_model_info(fd); + +/*void get_model_info(fd); void get_firmware_version(fd);*/ int enter_prg_mode(int fd); Modified: src/human_commands.c =================================================================== --- src/human_commands.c 2007-07-07 23:06:36 UTC (rev 75) +++ src/human_commands.c 2007-07-07 23:34:58 UTC (rev 76) @@ -150,104 +150,13 @@ ***********************************************************************/ void human_do_status(int fd, int argc, char **args) { - char answer[500]; - char *field[100]; - - /* STS - Current Status - * For this particular command, as it returns actual display output, - * customized ascii characters will bork the command line if not caught! */ - memset(answer, 0, 500); - memset(field, 0, 100); - - do_command(fd, "STS", answer); - /*printf ("%s\n(%i)\n", answer, strlen(answer)); */ - parse_fields(answer, field); - - replace_chars(field[2], field[2]); - /*printf("Test replace_chars: %s, %i\n", field[2], strlen(field[2]); */ - - replace_chars(field[8], field[8]); - /*printf("Test replace_chars: %s, %i\n\n\n", field[8], strlen(field[8]); */ - - /* The following is used for stopping the effect of the 6th field SCAN */ - char first_half[20]; - char second_half[20]; - - sscanf(field[6], "%s %s", first_half, second_half); - strcat(second_half, first_half); - if (strncmp(first_half, "SCAN", 4) == 0 || - strncmp(second_half, "SCAN", 4) == 0) - strncpy(field[6], "SCANNING\0", 17); - - printf("Status:\n"); - - /* Because the scanners lines change so frequently with multiple types of - * data, I can only think of using just the scrolling scan from the display - * for indicating the scanners status of actively scanning. Other then - * this, probably just best to actually pipe the actual output as is? - * - * Status: (L/O, HOLD, SIGNAL, CC?) - * System/Group Name: - * Channel Name: - * Channel Data: || Channel Frequency || Trunk Activity Indicators - * Systems: || P25 Status: - * Groups: || P25 : - * - * *Screen changes entirely when in Menu Mode - * - */ - - /* We have 23 parsed fields to print for STS command */ - int i = 0; - - for (i = 0; i <= 22; i++) - { - if (i != 0) - printf(","); - printf("%s", field[i]); - } - printf("\n\n"); - - /* GID - Current TGID Status - * Uniden's GID & GLG commands only prints out the first unique occurance - * of active TGID info. After the first display, repeated reissues of - * these commands will return null until a different TGID becomes active. - * Save last info and recall it as "Last GID/GID Active:"? */ - memset(answer, 0, 500); - memset(field, 0, 100); - do_command(fd, "GID", answer); - /*printf ("%s\n(%i)\n", answer, strlen (answer)); */ - parse_fields(answer, field); - - printf("Talkgroup ID Status:\n"); - - /* We have 6 parsed fields to print for GLG command */ - for (i = 0; i <= 5; i++) - { - if (i != 0) - printf(","); - printf("%s", field[i]); - } - printf("\n\n"); - - /* GLG - Reception Status - * See GID comment */ - memset(answer, 0, 500); - memset(field, 0, 100); - do_command(fd, "GLG", answer); - /*printf ("%s\n(%i)\n", answer, strlen (answer)); */ - parse_fields(answer, field); - - printf("Reception Status:\n"); - - /* We have 10 parsed fields to print for GLG command */ - for (i = 0; i <= 9; i++) - { - if (i != 0) - printf(","); - printf("%s", field[i]); - } - printf("\n\n"); + + get_current_status(fd); + + get_reception_status(fd); + + get_current_tgid_status(fd); + } /*********************************************************************** Modified: src/utils.h =================================================================== --- src/utils.h 2007-07-07 23:06:36 UTC (rev 75) +++ src/utils.h 2007-07-07 23:34:58 UTC (rev 76) @@ -104,7 +104,7 @@ int get_first_channel(char bank); int withinlimits(double freq); void print_s_meter(char *slchar); -int do_parse(char *unparsed, char **parsed); +//int do_parse(char *unparsed, char **parsed); int parse_fields(char *unparsed, char **parsed); int replace_chars(char *bcd_chars, char *common_chars); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-07 23:06:38
|
Revision: 75 http://dsctl.svn.sourceforge.net/dsctl/?rev=75&view=rev Author: roger-linux Date: 2007-07-07 16:06:36 -0700 (Sat, 07 Jul 2007) Log Message: ----------- commands.h: Add the remaining scanner commands (funtion definitions). Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.h Modified: src/commands.h =================================================================== --- src/commands.h 2007-07-07 07:36:09 UTC (rev 74) +++ src/commands.h 2007-07-07 23:06:36 UTC (rev 75) @@ -60,7 +60,7 @@ /*********************************************************************** * Function Declarations ***********************************************************************/ -/* TODO: Copy code or implement uncoded functions */ +/* TODO: Copy code from commands.c or implement uncoded functions */ /*int get_current_status(int fd); int quick_search_hold_mode(int fd, char **parsed_line); void get_current_status(int fd); @@ -80,15 +80,16 @@ int get_priority_mode(int fd); int set_priority_mode(int fd, char **parsed_line); int get_auto_gain_control(int fd); -int set_auto_gain_control(int fd, char **parsed_line); -int get_system_count(int fd); +int set_auto_gain_control(int fd, char **parsed_line);*/ + +/* Scan Settings - Goes in order we get/set - Calls Group Index only once instead of twice */ +/*int get_system_count(int fd); int get_system_index_head(int fd); int get_system_index_tail(int fd); int get_system_quick_lockout(int fd); int set_system_quick_lockout(int fd, char **parsed_line); int get_group_quick_lockout(int fd); int set_group_quick_lockout(int fd, char **parsed_line);*/ - int create_system(int fd, char *system_type); /*int delete_system(int fd); int get_system_info(int fd, int system_index);*/ @@ -107,18 +108,6 @@ int set_channel_info(int fd, int channel_index, char **parsed_line); /*int get_tgid_info(int fd, int tgid_index, int fwd_tgid_index);*/ int set_tgid_info(int fd, int channel_index, char **parsed_line); -/*int get_lockout_tgid(int fd, int system_index); -int get_search_lockout_tgid(int fd, int system_index); -int unlock_tgid(int fd, int system_index); -int lockout_tgid(int fd, int system_index); -int reverse_index(int fd, int index); -int forward_index(int fd, int index); -int get_remains_memory_block(int fd); -int get_memory_used(int fd);*/ - -/* TODO: Left off here associating the scanner commands with function names -Continue with Location Alert LIH and continue to Window Voltage WIN */ - int append_site(int fd, int system_index, char *system_type); /*int get_site_info(int fd, int site_index);*/ int set_site_info(int fd, int site_index, char **parsed_line); @@ -128,7 +117,65 @@ int set_apco25_band_plan(int fd, int site_index, char **parsed_line); /*int get_trunk_freq_info(int fd, int channel_index);*/ int set_trunk_freq_info(int fd, int channel_index, char **parsed_line); +/* End Scan Settings Commands */ +/*int get_lockout_tgid(int fd, int system_index); +int get_search_lockout_tgid(int fd, int system_index); +int unlock_tgid(int fd, int system_index); +int lockout_tgid(int fd, int system_index); +int reverse_index(int fd, int index); +int forward_index(int fd, int index); +int get_remains_memory_block(int fd); +int get_memory_used(int fd); +int loc_alert_system_index_head(int fd, char *loc_alert_system_type); +int get_loc_alert_system_index_tail(int fd, char *loc_alert_system_type); +int create_loc_alert_system(int fd, char *loc_alert_system_type); +int delete_loc_alert_system(int loc_alert_system_index); +int get_loc_alert_system_info(int fd, int loc_alert_system_index); +int set_loc_alert_system_info(int fd, int loc_alert_system_index, char**parsed_line); +int get_srch_cc_settings(int fd); +int set_srch_cc_settings(int fd, char **parsed_line); +int get_bcast_screen_band_settings(int fd, int bcast_screen_band_settings_index); +int set_bcast_screen_band_settings(int fd, int bcast_screen_band_settings_index, char **parsed_line); +int get_search_key_settings(int fd); +int set_search_key_settings(int fd, char **parsed_line); +int get_global_lockout_freq(int fd); +int unlock_global_lockout_freq(int fd, double global_lockout_freq); +int lock_out_freq(int fd, double frequency); +int get_close_call_settings(int fd); +int set_close_call_settings(int fd, char **parsed_line); +int get_service_search_settings(int fd, int search_index); +int set_service_search_settings(int fd, int search_index, char **parsed_line); +int get_custom_search_group(int fd); +int set_custom_search_group(int fd, char **parsed_line); +int get_custom_search_settings(int fd, int search_index); +int set_custom_search_settings(int fd, int search_index, char **parsed_line); +int get_weather_settings(int fd); +int set_weather_setting(int fd, char **parsed_line); +int get_same_group_settings(int fd, int same_index); +int set_same_group_settings(int fd, int same_index, char **parsed_line); +int get_tone_out_settings(int fd, int tone_out_index); +int set_tone_out_settings(int fd, int tone_out_index, char **parsed_line); +int get_lcd_contrast_settings(int fd); +int set_lcd_contrast_settings(int fd, char **parsed_line); +int get_lcd_upside_down_settings(int fd); +int set_lcd_upside_down_settings(int fd, char **parsed_line); +int get_scanner_option_settings(int fd); +int set_scanner_option_settings(int fd, char **parsed_line); +int get_volume_level_settings(int fd); +int set_volume_level_settings(int fd, int volume_level); +int get_squelch_level_settings(int fd); +int set_squelch_level_settings(int fd, int squelch_level); +int get_apco_settings(int fd); +int set_apco_settings(int fd, char **parsed_line);*/ +/* GPS Related -- I don't have one for this scanner */ +/*int get_gps_display_option(int fd); +int set_gps_display_option(int fd, char **parsed_line); +int get_gps_gga_data(int fd); +int get_gps_rmc_data(int fd); +int get_window_voltage(int fd);*/ + +/* Elongated Functions - Using above lower-level functions */ int dump(int fd, FILE * outfile); int load(int fd, FILE * infile); int press_key(int fd, char *key); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-07 07:36:11
|
Revision: 74 http://dsctl.svn.sourceforge.net/dsctl/?rev=74&view=rev Author: roger-linux Date: 2007-07-07 00:36:09 -0700 (Sat, 07 Jul 2007) Log Message: ----------- commands.h: Listing the rest of the scanner commands and associating them with function names. (Left off at Location Alert LIH) (Trivial) commands.h: Renamed a few existing function names I did today. (Trivial) human_commands.c: Made a TODO note concerning key command code should use switch instead of if statments(?) If so, move key defines to human_commands.h. * This svn commit I'm doing tonight is not tested yet to ensure dsctl commands are still working. Since the changes on this commit tonight are trivial, everything should just still work as they did with the previous svn version. ** Again, use caution and save your existing scanner's memory contents using another program as "dsctl load" still lacks all loading all location alerts, quicklocks, gps and misc settings. Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.c src/commands.h src/human_commands.c Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-07 01:24:29 UTC (rev 73) +++ src/commands.c 2007-07-07 07:36:09 UTC (rev 74) @@ -346,7 +346,7 @@ /*********************************************************************** * Set Channel Information ***********************************************************************/ -int channel_info(int fd, int channel_index, char **parsed_line) +int set_channel_info(int fd, int channel_index, char **parsed_line) { char answer[100], command[500]; @@ -466,7 +466,7 @@ /*********************************************************************** * Set Motorola Band Plan Information ***********************************************************************/ -int set_motband_info(int fd, int site_index, char **parsed_line) +int set_motorola_band_plan(int fd, int site_index, char **parsed_line) { char answer[100], command[500]; @@ -495,7 +495,7 @@ /*********************************************************************** * Set APCO-25 Band Plan Information ***********************************************************************/ -int set_apco_info(int fd, int site_index, char **parsed_line) +int set_apco25_band_plan(int fd, int site_index, char **parsed_line) { char answer[100], command[500]; @@ -523,7 +523,7 @@ /*********************************************************************** * Set Trunk Frequency Information ***********************************************************************/ -int trunk_freq_info(int fd, int channel_index, char **parsed_line) +int set_trunk_freq_info(int fd, int channel_index, char **parsed_line) { char answer[100], command[500]; @@ -1609,7 +1609,7 @@ /* For Conv Systems. Send group_index, Returns channel_index or trunk_freq_index. */ channel_index = append_channel_freq(fd, group_index); /* Set Conv frequency info. Send channel_index & string info; Returns OK. */ - channel_info(fd, channel_index, parsed_line); + set_channel_info(fd, channel_index, parsed_line); } else if (strncmp(scanner_command, "TIN", 3) == 0) @@ -1634,13 +1634,13 @@ else if (strncmp(scanner_command, "MBP", 3) == 0) { /* If Mot Band Plan, set info. Send site_index & string info; Returns OK. */ - set_motband_info(fd, site_index, parsed_line); + set_motorola_band_plan(fd, site_index, parsed_line); } else if (strncmp(scanner_command, "ABP", 3) == 0) { /* If APCO-25 Band Plan, set info. Send site_index & string info; Returns OK. */ - set_apco_info(fd, site_index, parsed_line); + set_apco25_band_plan(fd, site_index, parsed_line); } else if (strncmp(scanner_command, "TFQ", 3) == 0) @@ -1648,7 +1648,7 @@ /* Append Trunk Frequency. Send group_index; Returns trunk_freq_index. Func for both Conv & Trunk */ trunk_freq_index = append_channel_freq(fd, group_index); /* Set Trunk Frequency info. Send channel_index & string info; Returns OK. */ - trunk_freq_info(fd, channel_index, parsed_line); + set_trunk_freq_info(fd, channel_index, parsed_line); } } } Modified: src/commands.h =================================================================== --- src/commands.h 2007-07-07 01:24:29 UTC (rev 73) +++ src/commands.h 2007-07-07 07:36:09 UTC (rev 74) @@ -25,6 +25,7 @@ /*********************************************************************** * Keycodes for the KEY PRESS command +TODO: These should go into human_commands.h (and use switch instead of if ?) ***********************************************************************/ #define K_PRI "P" /* Priority */ #define K_WX "W" /* Weather */ @@ -59,26 +60,74 @@ /*********************************************************************** * Function Declarations ***********************************************************************/ +/* TODO: Copy code or implement uncoded functions */ +/*int get_current_status(int fd); +int quick_search_hold_mode(int fd, char **parsed_line); +void get_current_status(int fd); +void get_reception_status(int fd); +void get_model_info(fd); +void get_firmware_version(fd);*/ int enter_prg_mode(int fd); int exit_prg_mode(int fd); +/*int get_backlight(int fd); +int set_backlight(int fd, char **parsed_line);*/ int clear_memory(int fd); +/*int get_key_beep(int fd); +int set_key_beep(int fd, char **parsed_line); +int get_opening_message(int fd); +int set_opening_message(int fd, char **parsed_line); +int get_priority_mode(int fd); +int set_priority_mode(int fd, char **parsed_line); +int get_auto_gain_control(int fd); +int set_auto_gain_control(int fd, char **parsed_line); +int get_system_count(int fd); +int get_system_index_head(int fd); +int get_system_index_tail(int fd); +int get_system_quick_lockout(int fd); +int set_system_quick_lockout(int fd, char **parsed_line); +int get_group_quick_lockout(int fd); +int set_group_quick_lockout(int fd, char **parsed_line);*/ -int create_create(int fd, char *system_type); +int create_system(int fd, char *system_type); +/*int delete_system(int fd); +int get_system_info(int fd, int system_index);*/ int set_system_info(int fd, int system_index, char **parsed_line); +/*int get_trunk_info(int fd, int system_index);*/ int set_trunk_info(int fd, int system_index, char **parsed_line); int append_channel_group(int fd, int system_index); int append_tgid_group(int fd, int system_index); +/*int delete_group(int fd, group_index);*/ /* Use same function for delete_site */ +/*int get_group_info(int fd, int group_index);*/ int set_group_info(int fd, int group_index, char **parsed_line); -int append_channel_freq(int fd, int group_index); +int append_channel_freq(int fd, int group_index); /* Use same function for append_trunk_freq */ int append_tgid(int fd, int group_index); -int channel_info(int fd, int channel_index, char **parsed_line); +/*int delete_channel(int fd, channel_index);*/ +/*int get_channel_info(int fd, int channel_index, int channel_fwd_index);*/ +int set_channel_info(int fd, int channel_index, char **parsed_line); +/*int get_tgid_info(int fd, int tgid_index, int fwd_tgid_index);*/ int set_tgid_info(int fd, int channel_index, char **parsed_line); +/*int get_lockout_tgid(int fd, int system_index); +int get_search_lockout_tgid(int fd, int system_index); +int unlock_tgid(int fd, int system_index); +int lockout_tgid(int fd, int system_index); +int reverse_index(int fd, int index); +int forward_index(int fd, int index); +int get_remains_memory_block(int fd); +int get_memory_used(int fd);*/ + +/* TODO: Left off here associating the scanner commands with function names +Continue with Location Alert LIH and continue to Window Voltage WIN */ + int append_site(int fd, int system_index, char *system_type); +/*int get_site_info(int fd, int site_index);*/ int set_site_info(int fd, int site_index, char **parsed_line); -int set_motband_info(int fd, int site_index, char **parsed_line); -int set_apco_info(int fd, int site_index, char **parsed_line); -int trunk_freq_info(int fd, int channel_index, char **parsed_line); +/*int get_motorola_band_plan(int fd, int site_index);*/ +int set_motorola_band_plan(int fd, int site_index, char **parsed_line); +/*int get_apco25_band_plan(int fd, int site_index);*/ +int set_apco25_band_plan(int fd, int site_index, char **parsed_line); +/*int get_trunk_freq_info(int fd, int channel_index);*/ +int set_trunk_freq_info(int fd, int channel_index, char **parsed_line); int dump(int fd, FILE * outfile); int load(int fd, FILE * infile); Modified: src/human_commands.c =================================================================== --- src/human_commands.c 2007-07-07 01:24:29 UTC (rev 73) +++ src/human_commands.c 2007-07-07 07:36:09 UTC (rev 74) @@ -50,6 +50,7 @@ /*********************************************************************** * key command + * TODO: Use switch instead of if statements? Move over key defines to here. ***********************************************************************/ void human_do_key(int fd, int argc, char **args) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-07 01:24:32
|
Revision: 73 http://dsctl.svn.sourceforge.net/dsctl/?rev=73&view=rev Author: roger-linux Date: 2007-07-06 18:24:29 -0700 (Fri, 06 Jul 2007) Log Message: ----------- commands.c load: Completed coding of basic loading of system data. (Want to also get quick_key data completed too today.) TODO: loading of other misc settings including Location settings. TODO: when a command borks, we should exit_prg_mode before exiting. Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.c src/commands.h src/config.h src/human_commands.c src/human_commands.h src/main.h src/serial.c src/serial.h src/usage.c src/usage.h src/utils.c src/utils.h Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-06 03:11:14 UTC (rev 72) +++ src/commands.c 2007-07-07 01:24:29 UTC (rev 73) @@ -43,9 +43,13 @@ do_command(fd, command, answer); check_err(command, answer); - + + /* TODO: We only check for "OK" and not the "," when a 16 char name remains unchanged */ if (strncmp(answer, "PRG,OK", 6) != 0) + { + exit_prg_mode(fd); u_err(command, answer); + } return (0); } @@ -59,15 +63,18 @@ memset(answer, 0, 100); memset(command, 0, 100); - + snprintf(command, 100, "EPG"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); check_err(command, answer); - + if (strncmp(answer, "EPG,OK", 6) != 0) + { + exit_prg_mode(fd); u_err(command, answer); + } return (0); } @@ -81,15 +88,18 @@ memset(answer, 0, 100); memset(command, 0, 100); - + snprintf(command, 100, "CLR"); - /*printf("\nCommand == %s\n", command); */ + printf("\nCommand == %s\n", command); do_command(fd, command, answer); check_err(command, answer); - + if (strncmp(answer, "CLR,OK", 6) != 0) + { + exit_prg_mode(fd); u_err(command, answer); + } return (0); } @@ -104,16 +114,19 @@ memset(answer, 0, 100); memset(command, 0, 100); - + snprintf(command, 100, "CSY,%s", system_type); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ check_err(command, answer); - + if (strncmp(answer, "CSY,-1", 6) == 0) + { + exit_prg_mode(fd); u_err(command, answer); + } sscanf(answer, "CSY,%d", &system_index); @@ -123,55 +136,66 @@ /*********************************************************************** * Set System ***********************************************************************/ -int set_system(int fd, int system_index , char **parsed_line) +int set_system_info(int fd, int system_index, char **parsed_line) { char answer[100], command[500]; - + memset(answer, 0, 100); memset(command, 0, 500); - - snprintf(command, 500, "SIN,%i,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", system_index, - parsed_line[2], parsed_line[3], parsed_line[4], parsed_line[5], - parsed_line[6], parsed_line[7], parsed_line[8], parsed_line[9], - parsed_line[10], parsed_line[11], parsed_line[17], parsed_line[18], - parsed_line[19], parsed_line[20], parsed_line[21], parsed_line[22], - parsed_line[23] ); + + snprintf(command, 500, + "SIN,%i,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", + system_index, parsed_line[2], parsed_line[3], parsed_line[4], + parsed_line[5], parsed_line[6], parsed_line[7], parsed_line[8], + parsed_line[9], parsed_line[10], parsed_line[11], + parsed_line[17], parsed_line[18], parsed_line[19], + parsed_line[20], parsed_line[21], parsed_line[22], + parsed_line[23]); printf("\nCommand == %s\n", command); do_command(fd, command, answer); printf("%s\n(%i)\n", answer, strlen(answer)); - + check_err(command, answer); - + if (strncmp(answer, "SIN,OK", 6) != 0) + { + exit_prg_mode(fd); u_err(command, answer); - + } + return (0); } /*********************************************************************** * Set Trunk ***********************************************************************/ -int set_trunk(int fd, int system_index , char **parsed_line) +int set_trunk_info(int fd, int system_index, char **parsed_line) { char answer[100], command[500]; - + memset(answer, 0, 100); memset(command, 0, 500); - - snprintf(command, 500, "TRN,%i,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", system_index, - parsed_line[2], parsed_line[3], parsed_line[4], parsed_line[5], - parsed_line[6], parsed_line[7], parsed_line[8], parsed_line[9], - parsed_line[10], parsed_line[11], parsed_line[12], parsed_line[13], - parsed_line[14], parsed_line[15], parsed_line[16], parsed_line[17], - parsed_line[18], parsed_line[19], parsed_line[20], parsed_line[21] ); + + snprintf(command, 500, + "TRN,%i,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", + system_index, parsed_line[2], parsed_line[3], parsed_line[4], + parsed_line[5], parsed_line[6], parsed_line[7], parsed_line[8], + parsed_line[9], parsed_line[10], parsed_line[11], + parsed_line[12], parsed_line[13], parsed_line[14], + parsed_line[15], parsed_line[16], parsed_line[17], + parsed_line[18], parsed_line[19], parsed_line[20], + parsed_line[21]); printf("\nCommand == %s\n", command); do_command(fd, command, answer); printf("%s\n(%i)\n", answer, strlen(answer)); - + check_err(command, answer); - + if (strncmp(answer, "TRN,OK", 6) != 0) + { + exit_prg_mode(fd); u_err(command, answer); + } return (0); } @@ -182,46 +206,81 @@ int append_channel_group(int fd, int system_index) { char answer[100], command[100]; - int group_index=0; - + int group_index = 0; + memset(answer, 0, 100); memset(command, 0, 100); - + snprintf(command, 100, "AGC,%i", system_index); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - + check_err(command, answer); - if (strncmp(answer, "AGC,OK", 6) != 0) + if (strncmp(answer, "AGC,-1", 6) == 0) + { + exit_prg_mode(fd); u_err("AGC", answer); - - sscanf(answer, "AGC,%d", &group_index); - + } + + sscanf(answer, "AGC,%d", &group_index); + return (group_index); } /*********************************************************************** +* Append TGID Group +***********************************************************************/ +int append_tgid_group(int fd, int system_index) +{ + char answer[100], command[100]; + int group_index = 0; + + memset(answer, 0, 100); + memset(command, 0, 100); + + snprintf(command, 100, "AGT,%i", system_index); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + + check_err(command, answer); + + if (strncmp(answer, "AGT,-1", 6) == 0) + { + exit_prg_mode(fd); + u_err("AGC", answer); + } + + sscanf(answer, "AGT,%d", &group_index); + + return (group_index); +} + +/*********************************************************************** * Set Group Information ***********************************************************************/ -int set_group_info(int fd, int group_index , char **parsed_line) +int set_group_info(int fd, int group_index, char **parsed_line) { char answer[100], command[500]; - + memset(answer, 0, 100); memset(command, 0, 500); - - snprintf(command, 500, "GIN,%i,%s,%s,%s,%s", group_index, - parsed_line[2], parsed_line[3], parsed_line[4], parsed_line[5]); + + snprintf(command, 500, "GIN,%i,%s,%s,%s", group_index, + parsed_line[2], parsed_line[3], parsed_line[4]); printf("\nCommand == %s\n", command); do_command(fd, command, answer); printf("%s\n(%i)\n", answer, strlen(answer)); - + check_err(command, answer); - + if (strncmp(answer, "GIN,OK", 6) != 0) + { + exit_prg_mode(fd); u_err(command, answer); + } return (0); } @@ -232,48 +291,84 @@ int append_channel_freq(int fd, int group_index) { char answer[100], command[100]; - int channel_index=0; - + int channel_index = 0; + memset(answer, 0, 100); memset(command, 0, 100); - + snprintf(command, 100, "ACC,%i", group_index); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ - + check_err(command, answer); - if (strncmp(answer, "ACC,OK", 6) != 0) + if (strncmp(answer, "ACC,-1", 6) == 0) + { + exit_prg_mode(fd); u_err(command, answer); - - sscanf(answer, "ACC,%d", &group_index); - + } + + sscanf(answer, "ACC,%d", &channel_index); + return (channel_index); } /*********************************************************************** +* Append TGID +***********************************************************************/ +int append_tgid(int fd, int group_index) +{ + char answer[100], command[100]; + int channel_index = 0; + + memset(answer, 0, 100); + memset(command, 0, 100); + + snprintf(command, 100, "ACT,%i", group_index); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + + check_err(command, answer); + + if (strncmp(answer, "ACT,-1", 6) == 0) + { + exit_prg_mode(fd); + u_err(command, answer); + } + + sscanf(answer, "ACT,%d", &channel_index); + + return (channel_index); +} + +/*********************************************************************** * Set Channel Information ***********************************************************************/ -int channel_info(int fd, int channel_index , char **parsed_line) +int channel_info(int fd, int channel_index, char **parsed_line) { char answer[100], command[500]; - + memset(answer, 0, 100); memset(command, 0, 500); - - snprintf(command, 500, "CIN,%i,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", channel_index, - parsed_line[1], parsed_line[2], parsed_line[3], parsed_line[4], - parsed_line[5], parsed_line[6], parsed_line[7], parsed_line[8], - parsed_line[9], parsed_line[10], parsed_line[15], parsed_line[16]); + + snprintf(command, 500, "CIN,%i,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", + channel_index, parsed_line[1], parsed_line[2], parsed_line[3], + parsed_line[4], parsed_line[5], parsed_line[6], parsed_line[7], + parsed_line[8], parsed_line[9], parsed_line[10], parsed_line[15], + parsed_line[16]); printf("\nCommand == %s\n", command); do_command(fd, command, answer); printf("%s\n(%i)\n", answer, strlen(answer)); - + check_err(command, answer); - + if (strncmp(answer, "CIN,OK", 6) != 0) + { + exit_prg_mode(fd); u_err(command, answer); + } return (0); } @@ -281,24 +376,28 @@ /*********************************************************************** * Set TGID Information ***********************************************************************/ -int set_tgid(int fd, int channel_index , char **parsed_line) +int set_tgid_info(int fd, int channel_index, char **parsed_line) { char answer[100], command[500]; - + memset(answer, 0, 100); memset(command, 0, 500); - + snprintf(command, 500, "TIN,%i,%s,%s,%s,%s,%s,%s,%s,%s", channel_index, parsed_line[1], parsed_line[2], parsed_line[3], parsed_line[4], - parsed_line[5], parsed_line[6], parsed_line[11], parsed_line[12]); + parsed_line[5], parsed_line[6], parsed_line[11], + parsed_line[12]); printf("\nCommand == %s\n", command); do_command(fd, command, answer); printf("%s\n(%i)\n", answer, strlen(answer)); - + check_err(command, answer); - + if (strncmp(answer, "TIN,OK", 6) != 0) + { + exit_prg_mode(fd); u_err(command, answer); + } return (0); } @@ -313,16 +412,19 @@ memset(answer, 0, 100); memset(command, 0, 100); - - snprintf(command, 100, "AST,%i,%s", system_index , system_type); + + snprintf(command, 100, "AST,%i,%s", system_index, system_type); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ check_err(command, answer); - - if (strncmp(answer, "AST,OK", 6) != 0) + + if (strncmp(answer, "AST,-1", 6) == 0) + { + exit_prg_mode(fd); u_err(command, answer); + } sscanf(answer, "AST,%d", &site_index); @@ -332,26 +434,31 @@ /*********************************************************************** * Set Site Information ***********************************************************************/ -int set_site_info(int fd, int site_index , char **parsed_line) +int set_site_info(int fd, int site_index, char **parsed_line) { char answer[100], command[500]; - + memset(answer, 0, 100); memset(command, 0, 500); - - snprintf(command, 500, "SIF,%i,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", site_index, - parsed_line[2], parsed_line[3], parsed_line[4], parsed_line[5], - parsed_line[6], parsed_line[7], parsed_line[8], parsed_line[9], - parsed_line[10], parsed_line[17], parsed_line[18], parsed_line[19], - parsed_line[20], parsed_line[21], parsed_line[22]); + + snprintf(command, 500, + "SIF,%i,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", + site_index, parsed_line[2], parsed_line[3], parsed_line[4], + parsed_line[5], parsed_line[6], parsed_line[7], parsed_line[8], + parsed_line[9], parsed_line[10], parsed_line[17], + parsed_line[18], parsed_line[19], parsed_line[20], + parsed_line[21], parsed_line[22]); printf("\nCommand == %s\n", command); do_command(fd, command, answer); printf("%s\n(%i)\n", answer, strlen(answer)); - + check_err(command, answer); - + if (strncmp(answer, "SIF,OK", 6) != 0) + { + exit_prg_mode(fd); u_err(command, answer); + } return (0); } @@ -359,13 +466,13 @@ /*********************************************************************** * Set Motorola Band Plan Information ***********************************************************************/ -int set_motband_info(int fd, int site_index , char **parsed_line) +int set_motband_info(int fd, int site_index, char **parsed_line) { char answer[100], command[500]; - + memset(answer, 0, 100); memset(command, 0, 500); - + snprintf(command, 500, "MBP,%i,%s,%s,%s,%s,%s,%s,%s,%s,%s", site_index, parsed_line[1], parsed_line[2], parsed_line[3], parsed_line[4], parsed_line[5], parsed_line[6], parsed_line[7], parsed_line[8], @@ -373,11 +480,14 @@ printf("\nCommand == %s\n", command); do_command(fd, command, answer); printf("%s\n(%i)\n", answer, strlen(answer)); - + check_err(command, answer); - + if (strncmp(answer, "MBP,OK", 6) != 0) + { + exit_prg_mode(fd); u_err(command, answer); + } return (0); } @@ -385,24 +495,27 @@ /*********************************************************************** * Set APCO-25 Band Plan Information ***********************************************************************/ -int set_apco_info(int fd, int site_index , char **parsed_line) +int set_apco_info(int fd, int site_index, char **parsed_line) { char answer[100], command[500]; - + memset(answer, 0, 100); memset(command, 0, 500); - + snprintf(command, 500, "ABP,%i,%s,%s,%s,%s,%s,%s,%s,%s", site_index, parsed_line[2], parsed_line[3], parsed_line[4], parsed_line[5], parsed_line[6], parsed_line[7], parsed_line[8], parsed_line[9]); printf("\nCommand == %s\n", command); do_command(fd, command, answer); printf("%s\n(%i)\n", answer, strlen(answer)); - + check_err(command, answer); - + if (strncmp(answer, "ABP,OK", 6) != 0) + { + exit_prg_mode(fd); u_err(command, answer); + } return (0); } @@ -410,23 +523,26 @@ /*********************************************************************** * Set Trunk Frequency Information ***********************************************************************/ -int trunk_freq_info(int fd, int channel_index , char **parsed_line) +int trunk_freq_info(int fd, int channel_index, char **parsed_line) { char answer[100], command[500]; - + memset(answer, 0, 100); memset(command, 0, 500); - + snprintf(command, 500, "TFQ,%i,%s,%s,%s,%s", channel_index, parsed_line[1], parsed_line[2], parsed_line[3], parsed_line[8]); printf("\nCommand == %s\n", command); do_command(fd, command, answer); printf("%s\n(%i)\n", answer, strlen(answer)); - + check_err(command, answer); - + if (strncmp(answer, "TFQ,OK", 6) != 0) + { + exit_prg_mode(fd); u_err(command, answer); + } return (0); } @@ -491,9 +607,9 @@ u_err("KEY", answer); return (1); }*/ - + printf("dsctl version %s\n\n", FFVERSION); - + enter_prg_mode(fd); /*********************************************************************** @@ -1405,8 +1521,11 @@ { char answer[500], command[500], line[500], *parsed_line[100], errstring[100]; + char scanner_command[5], system_type[5], site_type[5]; - int ffversion = 0, system_index = 0; + int ffversion = 0; + int system_index = 0, group_index = 0, channel_index = 0; + int tgid_index = 0, site_index = 0, trunk_freq_index = 0; memset(answer, 0, 500); memset(command, 0, 500); @@ -1414,6 +1533,10 @@ memset(parsed_line, 0, 100); memset(errstring, 0, 500); + memset(scanner_command, 0, 5); + memset(system_type, 0, 5); + memset(site_type, 0, 5); + fscanf(infile, "dsctl version %d", &ffversion); if (ffversion != 1) { @@ -1426,39 +1549,108 @@ enter_prg_mode(fd); - /* TODO: Verify if user wants to Clear the Memory. - * If No Memory Clearing, Also check for free memory? - * If No Clear, advise the systems will be added to existing memory contents. */ + /* Verify the user wants to Clear Memory + * TODO: Move this to human_commands.c for using -f args? */ + printf("\nClear All Memory? (Y/n):"); + if (getchar() == 'Y') + clear_memory(fd); - /* clear_memory(fd); */ - + /* Get line from file and upload accordingly */ while (fgets(line, MAXLINELEN, infile) != NULL) { - /*printf("line == %s\n", line);*/ + printf("Line From File == %s\n", line); parse_fields(line, parsed_line); - /*printf("parsed_line[0] == %s\n", parsed_line[0]);*/ if (parsed_line[0] != NULL) - if (strncmp(parsed_line[0], "SIN", 3) == 0) + { + strncpy(scanner_command, parsed_line[0], 3); + printf("scanner_command (parsed_line[0]) == %s\n", + scanner_command); + + /* TODO: Link the following functions and verify they're proper usage + * with compiling & upload tests of a dsctl dumped contents file. */ + if (strncmp(scanner_command, "SIN", 3) == 0) { - /*printf("DEBUG %s\n", parsed_line[0]);*/ - system_index = create_system(fd, parsed_line[1]); - /*printf("DEBUG %i\n", system_index);*/ - set_system(fd, system_index, parsed_line); - /*TODO: Link the following functions and verify they're proper usage - * with compiling & upload tests of a dsctl dumped contents file. */ - //int set_trunk(int fd, int system_index , char **parsed_line); - //int append_channel_group(int fd, int system_index); - //int set_group_info(int fd, int group_index , char **parsed_line); - //int append_channel_freq(int fd, int group_index); - //int channel_info(int fd, int channel_index , char **parsed_line); - //int set_tgid(int fd, int channel_index , char **parsed_line); - //int append_site(int fd, int system_index, char *system_type); - //int set_site_info(int fd, int site_index , char **parsed_line); - //int set_motband_info(int fd, int site_index , char **parsed_line); - //int set_apco_info(int fd, int site_index , char **parsed_line); - //int trunk_freq_info(int fd, int channel_index , char **parsed_line); + /*printf("DEBUG %s\n", scanner_command); */ + strncpy(system_type, parsed_line[1], 5); + + /* Send create_system system_type; Returns system_index */ + system_index = create_system(fd, system_type); + + /* Send system_index and system string info; Returns OK. */ + /*printf("DEBUG %i\n", system_index); */ + set_system_info(fd, system_index, parsed_line); } + + else if (strncmp(scanner_command, "TRN", 3) == 0) + { + /* While TRN Trunked System, Send system_index & trunking information; Returns OK. */ + set_trunk_info(fd, system_index, parsed_line); + } + + else if (strncmp(scanner_command, "GIN", 3) == 0) + { + /* For Conv Systems. Send system_index; Returns group_index. */ + if (strncmp(system_type, "CNV", 3) == 0 + || strncmp(system_type, "LTR", 3) == 0) + group_index = append_channel_group(fd, system_index); + /* For Trunked Systems. Send system_index; Returns group_index. */ + else if (strncmp(system_type, "MOT1", 4) == 0 + || strncmp(system_type, "MOT2", 4) == 0 + || strncmp(system_type, "EDC", 3) == 0 + || strncmp(system_type, "EDS", 3) == 0) + group_index = append_tgid_group(fd, system_index); + /* For Conv & Trunked Systems. Send group_index, string info; Returns OK. */ + set_group_info(fd, group_index, parsed_line); + } + + else if (strncmp(scanner_command, "CIN", 3) == 0) + { + /* For Conv Systems. Send group_index, Returns channel_index or trunk_freq_index. */ + channel_index = append_channel_freq(fd, group_index); + /* Set Conv frequency info. Send channel_index & string info; Returns OK. */ + channel_info(fd, channel_index, parsed_line); + } + + else if (strncmp(scanner_command, "TIN", 3) == 0) + { + /* For Trunked Systems. Send group_index, Returns channel_index or trunk_freq_index. */ + trunk_freq_index = append_channel_freq(fd, group_index); + /* For Trunked Systems. Send group_index, Returns tgid_index. */ + tgid_index = append_tgid(fd, group_index); + /* If Trunked, set info. Send tgid_index & string info; Returns OK. */ + set_tgid_info(fd, tgid_index, parsed_line); + } + + else if (strncmp(scanner_command, "SIF", 3) == 0) + { + strncpy(site_type, parsed_line[1], 5); + /* While Trunked System, append Site Info. Send system_index, system_type; Returns site_index. */ + site_index = append_site(fd, system_index, site_type); + /* While Site, set Site Info. Send site_index, string info; Returns OK. */ + set_site_info(fd, site_index, parsed_line); + } + + else if (strncmp(scanner_command, "MBP", 3) == 0) + { + /* If Mot Band Plan, set info. Send site_index & string info; Returns OK. */ + set_motband_info(fd, site_index, parsed_line); + } + + else if (strncmp(scanner_command, "ABP", 3) == 0) + { + /* If APCO-25 Band Plan, set info. Send site_index & string info; Returns OK. */ + set_apco_info(fd, site_index, parsed_line); + } + + else if (strncmp(scanner_command, "TFQ", 3) == 0) + { + /* Append Trunk Frequency. Send group_index; Returns trunk_freq_index. Func for both Conv & Trunk */ + trunk_freq_index = append_channel_freq(fd, group_index); + /* Set Trunk Frequency info. Send channel_index & string info; Returns OK. */ + trunk_freq_info(fd, channel_index, parsed_line); + } + } } exit_prg_mode(fd); Modified: src/commands.h =================================================================== --- src/commands.h 2007-07-06 03:11:14 UTC (rev 72) +++ src/commands.h 2007-07-07 01:24:29 UTC (rev 73) @@ -26,7 +26,6 @@ /*********************************************************************** * Keycodes for the KEY PRESS command ***********************************************************************/ - #define K_PRI "P" /* Priority */ #define K_WX "W" /* Weather */ #define K_GPS "G" /* GPS */ @@ -66,22 +65,24 @@ int clear_memory(int fd); int create_create(int fd, char *system_type); -int set_system(int fd, int system_index, char **parsed_line); -int set_trunk(int fd, int system_index , char **parsed_line); +int set_system_info(int fd, int system_index, char **parsed_line); +int set_trunk_info(int fd, int system_index, char **parsed_line); int append_channel_group(int fd, int system_index); -int set_group_info(int fd, int group_index , char **parsed_line); +int append_tgid_group(int fd, int system_index); +int set_group_info(int fd, int group_index, char **parsed_line); int append_channel_freq(int fd, int group_index); -int channel_info(int fd, int channel_index , char **parsed_line); -int set_tgid(int fd, int channel_index , char **parsed_line); +int append_tgid(int fd, int group_index); +int channel_info(int fd, int channel_index, char **parsed_line); +int set_tgid_info(int fd, int channel_index, char **parsed_line); int append_site(int fd, int system_index, char *system_type); -int set_site_info(int fd, int site_index , char **parsed_line); -int set_motband_info(int fd, int site_index , char **parsed_line); -int set_apco_info(int fd, int site_index , char **parsed_line); -int trunk_freq_info(int fd, int channel_index , char **parsed_line); +int set_site_info(int fd, int site_index, char **parsed_line); +int set_motband_info(int fd, int site_index, char **parsed_line); +int set_apco_info(int fd, int site_index, char **parsed_line); +int trunk_freq_info(int fd, int channel_index, char **parsed_line); int dump(int fd, FILE * outfile); int load(int fd, FILE * infile); int press_key(int fd, char *key); int version(int fd); -#endif /* _COMMANDS_H_ */ +#endif /* _COMMANDS_H_ */ Modified: src/config.h =================================================================== --- src/config.h 2007-07-06 03:11:14 UTC (rev 72) +++ src/config.h 2007-07-07 01:24:29 UTC (rev 73) @@ -36,16 +36,16 @@ /* the models we know about */ #define MODELUNKNOWN -1 -//#define BC895XLT 0 -//#define BC245XLT 1 -//#define BC780XLT 2 -//#define PRO2052 3 +//#define BC895XLT 0 +//#define BC245XLT 1 +//#define BC780XLT 2 +//#define PRO2052 3 #define BCD396T 0 #define BCD996T 1 /* these are constants based on the BC895XLT and BC245XLT specs */ -//#define MAXMEM 300 -//#define BANKS 10 +//#define MAXMEM 300 +//#define BANKS 10 /* scanner model specific s-meter levels as reported by sctl status */ #define S_895_MIN 14 @@ -66,4 +66,4 @@ /* make the program talk a lot */ #define DEBUG 0 -#endif /* _CONFIG_H_ */ +#endif /* _CONFIG_H_ */ Modified: src/human_commands.c =================================================================== --- src/human_commands.c 2007-07-06 03:11:14 UTC (rev 72) +++ src/human_commands.c 2007-07-07 01:24:29 UTC (rev 73) @@ -269,6 +269,8 @@ usage(C_DUMP); else if (strncmp(args[0], "k", 1) == 0) usage(C_KEY); + else if (strncmp(args[0], "l", 1) == 0) + usage(C_LOAD); else if (strncmp(args[0], "h", 1) == 0) usage(C_HELP); else if (strncmp(args[0], "st", 2) == 0) Modified: src/human_commands.h =================================================================== --- src/human_commands.h 2007-07-06 03:11:14 UTC (rev 72) +++ src/human_commands.h 2007-07-07 01:24:29 UTC (rev 73) @@ -31,4 +31,4 @@ void human_do_version(int fd, int argc, char **args); void human_help(int fd, int argc, char **args); -#endif /* _HUMAN_COMMANDS_H_ */ +#endif /* _HUMAN_COMMANDS_H_ */ Modified: src/main.h =================================================================== --- src/main.h 2007-07-06 03:11:14 UTC (rev 72) +++ src/main.h 2007-07-07 01:24:29 UTC (rev 73) @@ -52,4 +52,4 @@ int get_cmd(char *cmd); void sighandler(int sig); -#endif /* _MAIN_H_ */ +#endif /* _MAIN_H_ */ Modified: src/serial.c =================================================================== --- src/serial.c 2007-07-06 03:11:14 UTC (rev 72) +++ src/serial.c 2007-07-07 01:24:29 UTC (rev 73) @@ -298,18 +298,23 @@ timeout.tv_sec = 3; timeout.tv_usec = 0; + /* Set 20 second timeout for CLR command. + * Usually takes approx. 15 seconds. */ + if (strncmp(string, "CLR", 3) == 0) + timeout.tv_sec = 20; + /* Check the port for usability. Timeout after 3 seconds. */ select_err = (select(FD_SETSIZE, &set, NULL, NULL, &timeout)); if (select_err == 0) { errno = ETIME; - perror("read serial: returned error code"); - printf("read serial: Wrong port or baud rate?"); + perror("write_serial: returned error code"); + printf("write_serial: Wrong port or baud rate?"); exit(EXIT_FAILURE); } else if (select_err == -1) { - perror("read serial: returned error code"); + perror("write_serial: returned error code"); exit(EXIT_FAILURE); } Modified: src/serial.h =================================================================== --- src/serial.h 2007-07-06 03:11:14 UTC (rev 72) +++ src/serial.h 2007-07-07 01:24:29 UTC (rev 73) @@ -34,4 +34,4 @@ int setup_port(int fd, int baud_rate); int write_serial(int fd, char *string); -#endif /* _SERIAL_H_ */ +#endif /* _SERIAL_H_ */ Modified: src/usage.c =================================================================== --- src/usage.c 2007-07-06 03:11:14 UTC (rev 72) +++ src/usage.c 2007-07-07 01:24:29 UTC (rev 73) @@ -47,6 +47,10 @@ usage_key(); break; + case C_LOAD: + usage_load(); + break; + case C_STATUS: usage_status(); break; @@ -83,12 +87,14 @@ fprintf(stderr, " Currently supported commands for BCD models are:\n"); fprintf(stderr, - " dump - downloads a all memory from the scanner\n"); + " dump - downloads a all memory from the scanner to stdout\n"); fprintf(stderr, " help - displays a help message for a command\n"); fprintf(stderr, " key - press a key along with the optional type of press.\n"); fprintf(stderr, + " load - loads data from a dsctl dump file. (Experimental)\n"); + fprintf(stderr, " status - shows the current status of the scanner\n"); fprintf(stderr, " version - displays version and licensing information\n\n"); @@ -154,6 +160,19 @@ /*********************************************************************** ***********************************************************************/ +void usage_load(void) +{ + fprintf(stderr, "\nUsage: dsctl load [filename]\n\n"); + fprintf(stderr, "This command loads a dsctl dump file into the scanners memory.\n\n"); + fprintf(stderr, + "[filename] - A file created from the stdout of dsctl dump.\n\n"); + fprintf(stderr, + " This command is incompletely & experimental!\n\n"); + fprintf(stderr, " Be sure you have saved all data with another utility!\n\n"); +} + +/*********************************************************************** + ***********************************************************************/ void usage_status(void) { fprintf(stderr, "\nUsage: dsctl status\n\n"); Modified: src/usage.h =================================================================== --- src/usage.h 2007-07-06 03:11:14 UTC (rev 72) +++ src/usage.h 2007-07-07 01:24:29 UTC (rev 73) @@ -28,8 +28,9 @@ void usage_dump(void); void usage_help(void); void usage_key(void); +void usage_load(void); void usage_status(void); void usage_version(void); void usage_versiono(void); -#endif /* _USAGE_H_ */ +#endif /* _USAGE_H_ */ Modified: src/utils.c =================================================================== --- src/utils.c 2007-07-06 03:11:14 UTC (rev 72) +++ src/utils.c 2007-07-07 01:24:29 UTC (rev 73) @@ -132,6 +132,18 @@ complain(errorstr); exit(EXIT_FAILURE); } + else if (strncmp("-1", answer, 2) == 0) + { + snprintf(errorstr, 512, + "The command failed because a \"No Resource\" condition was returned.\n" + "Command: %s\n" + "Reply: %s\n" + "This error usually occurs when memory lacks resources.\n" + "(Free memory either by clearing memory or renaming systems.)", + command, answer); + complain(errorstr); + exit(EXIT_FAILURE); + } } /*********************************************************************** @@ -260,7 +272,7 @@ int slevel, i; double step, units; - if (scannermodel == BCD996T) /* Just inserting BCD here for template */ + if (scannermodel == BCD996T) /* Just inserting BCD here for template */ { step = ((float) S_895_MAX - (float) S_895_MIN) / (float) MAX_S_SCALE; slevel = atoi(slchar); Modified: src/utils.h =================================================================== --- src/utils.h 2007-07-06 03:11:14 UTC (rev 72) +++ src/utils.h 2007-07-07 01:24:29 UTC (rev 73) @@ -108,4 +108,4 @@ int parse_fields(char *unparsed, char **parsed); int replace_chars(char *bcd_chars, char *common_chars); -#endif /* _UTILS_H_ */ +#endif /* _UTILS_H_ */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-06 03:11:44
|
Revision: 72 http://dsctl.svn.sourceforge.net/dsctl/?rev=72&view=rev Author: roger-linux Date: 2007-07-05 20:11:14 -0700 (Thu, 05 Jul 2007) Log Message: ----------- commands.c load: Added low level commands to commands.h and also added them to the "load" command/function section of commands.c (towards the bottom of the source code). Advised within the TODO comment, mearily linking them together should prove sucess with uploading system's data. Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.c src/commands.h Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-06 02:54:57 UTC (rev 71) +++ src/commands.c 2007-07-06 03:11:14 UTC (rev 72) @@ -1427,7 +1427,8 @@ enter_prg_mode(fd); /* TODO: Verify if user wants to Clear the Memory. - * Also check for free memory? */ + * If No Memory Clearing, Also check for free memory? + * If No Clear, advise the systems will be added to existing memory contents. */ /* clear_memory(fd); */ @@ -1444,6 +1445,19 @@ system_index = create_system(fd, parsed_line[1]); /*printf("DEBUG %i\n", system_index);*/ set_system(fd, system_index, parsed_line); + /*TODO: Link the following functions and verify they're proper usage + * with compiling & upload tests of a dsctl dumped contents file. */ + //int set_trunk(int fd, int system_index , char **parsed_line); + //int append_channel_group(int fd, int system_index); + //int set_group_info(int fd, int group_index , char **parsed_line); + //int append_channel_freq(int fd, int group_index); + //int channel_info(int fd, int channel_index , char **parsed_line); + //int set_tgid(int fd, int channel_index , char **parsed_line); + //int append_site(int fd, int system_index, char *system_type); + //int set_site_info(int fd, int site_index , char **parsed_line); + //int set_motband_info(int fd, int site_index , char **parsed_line); + //int set_apco_info(int fd, int site_index , char **parsed_line); + //int trunk_freq_info(int fd, int channel_index , char **parsed_line); } } Modified: src/commands.h =================================================================== --- src/commands.h 2007-07-06 02:54:57 UTC (rev 71) +++ src/commands.h 2007-07-06 03:11:14 UTC (rev 72) @@ -67,6 +67,17 @@ int create_create(int fd, char *system_type); int set_system(int fd, int system_index, char **parsed_line); +int set_trunk(int fd, int system_index , char **parsed_line); +int append_channel_group(int fd, int system_index); +int set_group_info(int fd, int group_index , char **parsed_line); +int append_channel_freq(int fd, int group_index); +int channel_info(int fd, int channel_index , char **parsed_line); +int set_tgid(int fd, int channel_index , char **parsed_line); +int append_site(int fd, int system_index, char *system_type); +int set_site_info(int fd, int site_index , char **parsed_line); +int set_motband_info(int fd, int site_index , char **parsed_line); +int set_apco_info(int fd, int site_index , char **parsed_line); +int trunk_freq_info(int fd, int channel_index , char **parsed_line); int dump(int fd, FILE * outfile); int load(int fd, FILE * infile); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-06 02:55:02
|
Revision: 71 http://dsctl.svn.sourceforge.net/dsctl/?rev=71&view=rev Author: roger-linux Date: 2007-07-05 19:54:57 -0700 (Thu, 05 Jul 2007) Log Message: ----------- commands.c "dsctl load" This adds the remaining load library functions for uploading scanner systems & it's system's data. I just need to link these lower level scanner command functions together within the elongated function at the bottom of commands.c for upload testing of complete systems. TODO: commands.c The remaining trivial upload data functions such as uploading Locations and uploading scanner settings will be quick & easy. TODO: commands.c - Recode the "dump" section into functions. (Similer to the "upload" section of commands.c -- this is for readability and for code reuse!) Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.c Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-06 02:09:37 UTC (rev 70) +++ src/commands.c 2007-07-06 02:54:57 UTC (rev 71) @@ -203,7 +203,7 @@ } /*********************************************************************** -* Set Group Infomation +* Set Group Information ***********************************************************************/ int set_group_info(int fd, int group_index , char **parsed_line) { @@ -253,7 +253,7 @@ } /*********************************************************************** -* Set Channel Infomation +* Set Channel Information ***********************************************************************/ int channel_info(int fd, int channel_index , char **parsed_line) { @@ -279,9 +279,9 @@ } /*********************************************************************** -* Set TGID Infomation +* Set TGID Information ***********************************************************************/ -int chan_info(int fd, int channel_index , char **parsed_line) +int set_tgid(int fd, int channel_index , char **parsed_line) { char answer[100], command[500]; @@ -303,13 +303,135 @@ return (0); } -// AST - append site (recieves sys_index, sys_type, outputs site_index) -// SIF - set site info (recieves site_index, parsed_line string, outputs ok) -// MBP - set mot band plan (recieves site_index, parsed_string, outputs ok) -// ABP - set apco band plan (recieves site_index, parsed_string, outputs ok) -// TFQ - set trunk freq (receives channel_index, parsed_string, outputs ok) +/*********************************************************************** +* Append Site +***********************************************************************/ +int append_site(int fd, int system_index, char *system_type) +{ + char answer[100], command[100]; + int site_index = 0; + memset(answer, 0, 100); + memset(command, 0, 100); + + snprintf(command, 100, "AST,%i,%s", system_index , system_type); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + + check_err(command, answer); + + if (strncmp(answer, "AST,OK", 6) != 0) + u_err(command, answer); + + sscanf(answer, "AST,%d", &site_index); + + return (site_index); +} + /*********************************************************************** +* Set Site Information +***********************************************************************/ +int set_site_info(int fd, int site_index , char **parsed_line) +{ + char answer[100], command[500]; + + memset(answer, 0, 100); + memset(command, 0, 500); + + snprintf(command, 500, "SIF,%i,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", site_index, + parsed_line[2], parsed_line[3], parsed_line[4], parsed_line[5], + parsed_line[6], parsed_line[7], parsed_line[8], parsed_line[9], + parsed_line[10], parsed_line[17], parsed_line[18], parsed_line[19], + parsed_line[20], parsed_line[21], parsed_line[22]); + printf("\nCommand == %s\n", command); + do_command(fd, command, answer); + printf("%s\n(%i)\n", answer, strlen(answer)); + + check_err(command, answer); + + if (strncmp(answer, "SIF,OK", 6) != 0) + u_err(command, answer); + + return (0); +} + +/*********************************************************************** +* Set Motorola Band Plan Information +***********************************************************************/ +int set_motband_info(int fd, int site_index , char **parsed_line) +{ + char answer[100], command[500]; + + memset(answer, 0, 100); + memset(command, 0, 500); + + snprintf(command, 500, "MBP,%i,%s,%s,%s,%s,%s,%s,%s,%s,%s", site_index, + parsed_line[1], parsed_line[2], parsed_line[3], parsed_line[4], + parsed_line[5], parsed_line[6], parsed_line[7], parsed_line[8], + parsed_line[9]); + printf("\nCommand == %s\n", command); + do_command(fd, command, answer); + printf("%s\n(%i)\n", answer, strlen(answer)); + + check_err(command, answer); + + if (strncmp(answer, "MBP,OK", 6) != 0) + u_err(command, answer); + + return (0); +} + +/*********************************************************************** +* Set APCO-25 Band Plan Information +***********************************************************************/ +int set_apco_info(int fd, int site_index , char **parsed_line) +{ + char answer[100], command[500]; + + memset(answer, 0, 100); + memset(command, 0, 500); + + snprintf(command, 500, "ABP,%i,%s,%s,%s,%s,%s,%s,%s,%s", site_index, + parsed_line[2], parsed_line[3], parsed_line[4], parsed_line[5], + parsed_line[6], parsed_line[7], parsed_line[8], parsed_line[9]); + printf("\nCommand == %s\n", command); + do_command(fd, command, answer); + printf("%s\n(%i)\n", answer, strlen(answer)); + + check_err(command, answer); + + if (strncmp(answer, "ABP,OK", 6) != 0) + u_err(command, answer); + + return (0); +} + +/*********************************************************************** +* Set Trunk Frequency Information +***********************************************************************/ +int trunk_freq_info(int fd, int channel_index , char **parsed_line) +{ + char answer[100], command[500]; + + memset(answer, 0, 100); + memset(command, 0, 500); + + snprintf(command, 500, "TFQ,%i,%s,%s,%s,%s", channel_index, + parsed_line[1], parsed_line[2], parsed_line[3], parsed_line[8]); + printf("\nCommand == %s\n", command); + do_command(fd, command, answer); + printf("%s\n(%i)\n", answer, strlen(answer)); + + check_err(command, answer); + + if (strncmp(answer, "TFQ,OK", 6) != 0) + u_err(command, answer); + + return (0); +} + +/*********************************************************************** * Download BCD memory contents * TODO: Break This Into Functions. See above lower level SET functions * and elongated functions at the bottom integrating the above SET This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rog...@us...> - 2007-07-06 02:09:39
|
Revision: 70 http://dsctl.svn.sourceforge.net/dsctl/?rev=70&view=rev Author: roger-linux Date: 2007-07-05 19:09:37 -0700 (Thu, 05 Jul 2007) Log Message: ----------- commands.c: Added more upload library functions. dsct load command works as far as creating a system and setting system info. commands.c file might look messy, but the "dump" section wasn't broken into functions initially because I wasn't sure what it took to get each data type info from the scanner. Now that I do understand the tree more, breaking the "dump" section into functions and will look more like what the "upload" library functions looks now. So, "dump section" of commands.c looks rough but works, "upload" section looks more like what we want things to look like -- broken into functions. Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.c src/utils.c Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-05 21:42:50 UTC (rev 69) +++ src/commands.c 2007-07-06 02:09:37 UTC (rev 70) @@ -34,19 +34,18 @@ ***********************************************************************/ int enter_prg_mode(int fd) { - char answer[500], command[100]; + char answer[100], command[100]; - memset(answer, 0, 500); + memset(answer, 0, 100); memset(command, 0, 100); snprintf(command, 100, "PRG"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); + check_err(command, answer); + if (strncmp(answer, "PRG,OK", 6) != 0) - { - u_err("CSY", answer); - return (1); - } + u_err(command, answer); return (0); } @@ -56,19 +55,19 @@ ***********************************************************************/ int exit_prg_mode(int fd) { - char answer[500], command[100]; + char answer[100], command[100]; - memset(answer, 0, 500); + memset(answer, 0, 100); memset(command, 0, 100); + snprintf(command, 100, "EPG"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); + check_err(command, answer); + if (strncmp(answer, "EPG,OK", 6) != 0) - { - u_err("CSY", answer); - return (1); - } + u_err(command, answer); return (0); } @@ -78,19 +77,19 @@ ***********************************************************************/ int clear_memory(int fd) { - char answer[500], command[100]; + char answer[100], command[100]; - memset(answer, 0, 500); + memset(answer, 0, 100); memset(command, 0, 100); + snprintf(command, 100, "CLR"); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); + check_err(command, answer); + if (strncmp(answer, "CLR,OK", 6) != 0) - { - u_err("CSY", answer); - return (1); - } + u_err(command, answer); return (0); } @@ -100,27 +99,25 @@ ***********************************************************************/ int create_system(int fd, char *system_type) { + char answer[100], command[100]; int system_index = 0; - char answer[100], command[100]; memset(answer, 0, 100); memset(command, 0, 100); + snprintf(command, 100, "CSY,%s", system_type); /*printf("\nCommand == %s\n", command); */ do_command(fd, command, answer); /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + check_err(command, answer); + if (strncmp(answer, "CSY,-1", 6) == 0) - { - u_err("CSY", answer); - return (-1); - } - else - { - sscanf(answer, "CSY,%d", &system_index); - return (system_index); - } - return (0); + u_err(command, answer); + + sscanf(answer, "CSY,%d", &system_index); + + return (system_index); } /*********************************************************************** @@ -132,20 +129,194 @@ memset(answer, 0, 100); memset(command, 0, 500); - snprintf(command, 100, "%s,%i,%s", parsed_line[0], system_index, parsed_line[2]); + + snprintf(command, 500, "SIN,%i,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", system_index, + parsed_line[2], parsed_line[3], parsed_line[4], parsed_line[5], + parsed_line[6], parsed_line[7], parsed_line[8], parsed_line[9], + parsed_line[10], parsed_line[11], parsed_line[17], parsed_line[18], + parsed_line[19], parsed_line[20], parsed_line[21], parsed_line[22], + parsed_line[23] ); printf("\nCommand == %s\n", command); do_command(fd, command, answer); printf("%s\n(%i)\n", answer, strlen(answer)); - // input parsed_line into command[500] and send to the scanner - // via SIN command. + check_err(command, answer); - // return ok else error. + if (strncmp(answer, "SIN,OK", 6) != 0) + u_err(command, answer); + return (0); } /*********************************************************************** +* Set Trunk +***********************************************************************/ +int set_trunk(int fd, int system_index , char **parsed_line) +{ + char answer[100], command[500]; + + memset(answer, 0, 100); + memset(command, 0, 500); + + snprintf(command, 500, "TRN,%i,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", system_index, + parsed_line[2], parsed_line[3], parsed_line[4], parsed_line[5], + parsed_line[6], parsed_line[7], parsed_line[8], parsed_line[9], + parsed_line[10], parsed_line[11], parsed_line[12], parsed_line[13], + parsed_line[14], parsed_line[15], parsed_line[16], parsed_line[17], + parsed_line[18], parsed_line[19], parsed_line[20], parsed_line[21] ); + printf("\nCommand == %s\n", command); + do_command(fd, command, answer); + printf("%s\n(%i)\n", answer, strlen(answer)); + + check_err(command, answer); + + if (strncmp(answer, "TRN,OK", 6) != 0) + u_err(command, answer); + + return (0); +} + +/*********************************************************************** +* Append Channel Group +***********************************************************************/ +int append_channel_group(int fd, int system_index) +{ + char answer[100], command[100]; + int group_index=0; + + memset(answer, 0, 100); + memset(command, 0, 100); + + snprintf(command, 100, "AGC,%i", system_index); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + + check_err(command, answer); + + if (strncmp(answer, "AGC,OK", 6) != 0) + u_err("AGC", answer); + + sscanf(answer, "AGC,%d", &group_index); + + return (group_index); +} + +/*********************************************************************** +* Set Group Infomation +***********************************************************************/ +int set_group_info(int fd, int group_index , char **parsed_line) +{ + char answer[100], command[500]; + + memset(answer, 0, 100); + memset(command, 0, 500); + + snprintf(command, 500, "GIN,%i,%s,%s,%s,%s", group_index, + parsed_line[2], parsed_line[3], parsed_line[4], parsed_line[5]); + printf("\nCommand == %s\n", command); + do_command(fd, command, answer); + printf("%s\n(%i)\n", answer, strlen(answer)); + + check_err(command, answer); + + if (strncmp(answer, "GIN,OK", 6) != 0) + u_err(command, answer); + + return (0); +} + +/*********************************************************************** +* Append Channel or Trunk Frequency +***********************************************************************/ +int append_channel_freq(int fd, int group_index) +{ + char answer[100], command[100]; + int channel_index=0; + + memset(answer, 0, 100); + memset(command, 0, 100); + + snprintf(command, 100, "ACC,%i", group_index); + /*printf("\nCommand == %s\n", command); */ + do_command(fd, command, answer); + /*printf("%s\n(%i)\n", answer, strlen(answer)); */ + + check_err(command, answer); + + if (strncmp(answer, "ACC,OK", 6) != 0) + u_err(command, answer); + + sscanf(answer, "ACC,%d", &group_index); + + return (channel_index); +} + +/*********************************************************************** +* Set Channel Infomation +***********************************************************************/ +int channel_info(int fd, int channel_index , char **parsed_line) +{ + char answer[100], command[500]; + + memset(answer, 0, 100); + memset(command, 0, 500); + + snprintf(command, 500, "CIN,%i,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", channel_index, + parsed_line[1], parsed_line[2], parsed_line[3], parsed_line[4], + parsed_line[5], parsed_line[6], parsed_line[7], parsed_line[8], + parsed_line[9], parsed_line[10], parsed_line[15], parsed_line[16]); + printf("\nCommand == %s\n", command); + do_command(fd, command, answer); + printf("%s\n(%i)\n", answer, strlen(answer)); + + check_err(command, answer); + + if (strncmp(answer, "CIN,OK", 6) != 0) + u_err(command, answer); + + return (0); +} + +/*********************************************************************** +* Set TGID Infomation +***********************************************************************/ +int chan_info(int fd, int channel_index , char **parsed_line) +{ + char answer[100], command[500]; + + memset(answer, 0, 100); + memset(command, 0, 500); + + snprintf(command, 500, "TIN,%i,%s,%s,%s,%s,%s,%s,%s,%s", channel_index, + parsed_line[1], parsed_line[2], parsed_line[3], parsed_line[4], + parsed_line[5], parsed_line[6], parsed_line[11], parsed_line[12]); + printf("\nCommand == %s\n", command); + do_command(fd, command, answer); + printf("%s\n(%i)\n", answer, strlen(answer)); + + check_err(command, answer); + + if (strncmp(answer, "TIN,OK", 6) != 0) + u_err(command, answer); + + return (0); +} + +// AST - append site (recieves sys_index, sys_type, outputs site_index) +// SIF - set site info (recieves site_index, parsed_line string, outputs ok) +// MBP - set mot band plan (recieves site_index, parsed_string, outputs ok) +// ABP - set apco band plan (recieves site_index, parsed_string, outputs ok) +// TFQ - set trunk freq (receives channel_index, parsed_string, outputs ok) + +/*********************************************************************** * Download BCD memory contents +* TODO: Break This Into Functions. See above lower level SET functions +* and elongated functions at the bottom integrating the above SET +* functions for uploading. When this is complete, the below will be +* separated into lower level GET functions with elongated functions for +* implementation. (Reason I initially just gobbed this, had no idea how +* Uniden's memory tree worked.) ***********************************************************************/ /* TODO: All done. Just need to make things look nice. @@ -198,11 +369,13 @@ u_err("KEY", answer); return (1); }*/ - + + printf("dsctl version %s\n\n", FFVERSION); + enter_prg_mode(fd); /*********************************************************************** - * System Information + * Get System Information ***********************************************************************/ /* Get Model Info */ @@ -282,7 +455,7 @@ printf("\n"); /*********************************************************************** - * System Settings + * Get System Settings ***********************************************************************/ /* Get Backlight */ @@ -419,7 +592,7 @@ printf("\n"); /*********************************************************************** - * Search / Close Call Settings + * Get Search / Close Call Settings ***********************************************************************/ /* TODO: This needs testing! */ @@ -738,7 +911,7 @@ printf("\n"); /************************************************ - * Scan Settings + * Get Scan Settings ************************************************/ /* Get System Index Head */ @@ -1052,7 +1225,7 @@ } /************************************************ - * Location Alert Settings + * Get Location Alert Settings ************************************************/ /* Get Location Alert System Index Head Modified: src/utils.c =================================================================== --- src/utils.c 2007-07-05 21:42:50 UTC (rev 69) +++ src/utils.c 2007-07-06 02:09:37 UTC (rev 70) @@ -86,7 +86,7 @@ if (strncmp("ERR", answer, 3) == 0) { snprintf(errorstr, 512, - "The command failed because an error condition was returned.\n" + "The command failed because an \"Error\" condition was returned.\n" "Command: %s\n" "Reply: %s\n" "This error usually occurs when a command unsupported by your scanner is\n" @@ -98,7 +98,7 @@ else if (strncmp("NG", answer, 2) == 0) { snprintf(errorstr, 512, - "The command failed because a \"No Good\" condition was returned.\n" + "The command failed because a \"No Good\" error condition was returned.\n" "Command: %s\n" "Reply: %s\n" "This error usually occurs when you execute a command while in the wrong mode.\n" @@ -108,6 +108,30 @@ complain(errorstr); exit(EXIT_FAILURE); } + else if (strncmp("FER", answer, 3) == 0) + { + snprintf(errorstr, 512, + "The command failed because a \"Framing Error\" condition was returned.\n" + "Command: %s\n" + "Reply: %s\n" + "This error usually occurs when you execute a command ...\n" + "(I can only guess this is an error transferring packets.)", + command, answer); + complain(errorstr); + exit(EXIT_FAILURE); + } + else if (strncmp("ORER", answer, 4) == 0) + { + snprintf(errorstr, 512, + "The command failed because a \"Overrun Error\" condition was returned.\n" + "Command: %s\n" + "Reply: %s\n" + "This error usually occurs when you execute a command ....\n" + "(I can only guess this is an error transferring packets.)", + command, answer); + complain(errorstr); + exit(EXIT_FAILURE); + } } /*********************************************************************** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |