[Dsctl-devel] SF.net SVN: dsctl: [119] src
Status: Alpha
Brought to you by:
roger-linux
|
From: <rog...@us...> - 2007-07-17 08:07:33
|
Revision: 119
http://dsctl.svn.sourceforge.net/dsctl/?rev=119&view=rev
Author: roger-linux
Date: 2007-07-17 01:07:31 -0700 (Tue, 17 Jul 2007)
Log Message:
-----------
Move some things around within "dsctl status" command areas. Insert some debug printf's. Moved the "-t --test" option to "-n --ncurses" for now.
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
src/main.c
src/usage.c
Modified: src/commands.c
===================================================================
--- src/commands.c 2007-07-15 04:23:57 UTC (rev 118)
+++ src/commands.c 2007-07-17 08:07:31 UTC (rev 119)
@@ -50,7 +50,7 @@
/*printf ("%s\n(%i)\n", answer, strlen (answer)); */
parse_fields(answer, field);
- if (daemon_mode == 0)
+ if (daemon_mode == 0 || osd == 0)
printf("\nTalkgroup ID Status:\n");
/* We have 6 parsed fields to print for this command */
@@ -119,8 +119,9 @@
//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]); */
- /* Stop the effect of the 6th field SCAN */
- if (daemon_mode <= 1)
+ /* Stop the scroll effect of the 6th field SCANNING.
+ * And preserve the effect for daemon_mode & osd mode. */
+ if (daemon_mode == 0 || osd == 0)
{
char first_half[20];
char second_half[20];
@@ -132,10 +133,9 @@
strncpy(field[6], "SCANNING\0", 17);
}
- if (daemon_mode == 0)
+ /*if (daemon_mode == 0 || osd == 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]);
@@ -161,11 +161,12 @@
printf(" Alert LED: ON\n");
printf(" Signal Level: %i\n\n", atoi(field[20]));
- }
+ }*/
+ if (daemon_mode == 0 || osd == 0)
+ printf("Current Display Status:\n");
+
/* We have 23 parsed fields to print for this command */
- if (debug > 0 || daemon_mode > 0)
- {
for (i = 0; i <= 22; i++)
{
if (i != 0)
@@ -173,7 +174,6 @@
printf("%s", field[i]);
}
printf("\n");
- }
}
/***********************************************************************
@@ -192,8 +192,8 @@
/*printf ("%s\n(%i)\n", answer, strlen (answer)); */
parse_fields(answer, field);
- if (daemon_mode == 0)
- printf("Reception Status:\n");
+ if (daemon_mode == 0 || osd == 0)
+ printf("\nReception Status:\n");
/* We have 10 parsed fields to print for this command */
for (i = 0; i <= 9; i++)
Modified: src/commands.h
===================================================================
--- src/commands.h 2007-07-15 04:23:57 UTC (rev 118)
+++ src/commands.h 2007-07-17 08:07:31 UTC (rev 119)
@@ -34,6 +34,7 @@
extern int scannermodel;
extern int daemon_mode;
extern int debug;
+extern int osd;
/***********************************************************************
* Function Declarations
Modified: src/human_commands.c
===================================================================
--- src/human_commands.c 2007-07-15 04:23:57 UTC (rev 118)
+++ src/human_commands.c 2007-07-17 08:07:31 UTC (rev 119)
@@ -81,10 +81,12 @@
memset(command, 0, 100);
/* Get first arg of Key Command */
+ if (debug > 0)
+ {
+ printf("human_do_key: arg[0] char value %s\n", args[0]);
+ printf("human_do_key: arg[0] atoi value %i\n", atoi(args[0]));
+ }
- // if DEBUG = 1; printf("human_do_key: arg[0] char value %s\n", args[0]);
- // if DEBUG = 1; printf("human_do_key: arg[0] atoi value %i\n", atoi(args[0]));
-
if (args[0] == NULL)
usage(C_KEY);
else if (strncmp(args[0], "p", 1) == 0)
@@ -119,12 +121,10 @@
key_code = '<';
else if (strncmp(args[0], "x", 1) == 0)
{
- /* no where else to put exit_prg manually */
+ /* Good place to put "manually exit_prg" key? */
exit_prg_mode(fd);
return;
}
-
- /* put this at the end for catching 0 - 9 */
else if (*args[0] >= '0' && *args[0] <= '9')
key_code = *args[0];
else
@@ -144,9 +144,7 @@
else
usage(C_KEY);
- //snprintf(command, 100, "KEY,%c,%c", key_code, key_mode);
push_key(fd, key_code, key_mode);
-
}
/***********************************************************************
@@ -178,54 +176,70 @@
***********************************************************************/
void human_do_status(int fd, int argc, char **args)
{
- if (daemon_mode == 0)
+ while (daemon_mode != 0)
{
- get_current_status(fd);
-
- get_reception_status(fd);
-
- get_current_tgid_status(fd);
- }
- /* Give the user a daemon mode */
- else if (daemon_mode == 1)
- {
- while (daemon_mode != 0)
+ if (osd == 0)
{
+ /* User wants repeated no fancy status. */
get_current_status(fd);
-
get_reception_status(fd);
-
get_current_tgid_status(fd);
- sleep(1);
+ sleep(.5);
}
- }
- /* User just wants a console display in deamon mode */
- else if (daemon_mode == 2)
- {
- char buf[1024];
- char buf2[30];
- char *ap = buf2;
- char *osd_up, *osd_cr;
-
- tgetent(buf, getenv("TERM"));
-
- osd_up = tgetstr("up", &ap);
- osd_cr = tgetstr("cr", &ap);
-
- while (daemon_mode != 0) /* simple endless loop */
+ else if (osd == 1)
{
- //printf("TEST %i\n", osd);
+ /* User wants ncurses osd! */
+ char buf[1024];
+ char buf2[30];
+ char *ap = buf2;
+ char *osd_clear, *osd_clear_line, *osd_up, *osd_cr;
+
+ tgetent(buf, getenv("TERM"));
+
+ osd_clear = tgetstr("cl", &ap);
+ osd_clear_line = tgetstr("ce", &ap);
+ osd_up = tgetstr("up", &ap);
+ osd_cr = tgetstr("cr", &ap);
+
+ while (daemon_mode != 0) /* simple endless loop */
+ {
+ int i = 0;
+
+ if (debug > 0)
+ printf("osd value == %i\n", osd);
+
+ fputs(osd_clear_line, stdout);
+ get_current_status(fd);
+ printf("\n");
+
+ fputs(osd_clear_line, stdout);
+ get_reception_status(fd);
+ printf("\n");
+
+ fputs(osd_clear_line, stdout);
+ get_current_tgid_status(fd);
+ fputs(osd_cr, stdout);
+
+ for (i = 1; i <= 6 ; i ++)
+ fputs(osd_up, stdout);
+
+ sleep(.5);
- get_current_status(fd);
-
- fputs(osd_up, stdout);
- fputs(osd_up, stdout);
- fputs(osd_cr, stdout);
+ }
+ }
- sleep(.5);
- }
}
+
+ /* User just wants status once and no fancy stuff */
+ if (daemon_mode == 0)
+ {
+ get_current_status(fd);
+
+ get_reception_status(fd);
+
+ get_current_tgid_status(fd);
+ }
}
/***********************************************************************
Modified: src/human_commands.h
===================================================================
--- src/human_commands.h 2007-07-15 04:23:57 UTC (rev 118)
+++ src/human_commands.h 2007-07-17 08:07:31 UTC (rev 119)
@@ -34,8 +34,8 @@
# include <curses.h>
#endif
+extern int daemon_mode;
extern int debug;
-extern int daemon_mode;
extern int osd;
/***********************************************************************
Modified: src/main.c
===================================================================
--- src/main.c 2007-07-15 04:23:57 UTC (rev 118)
+++ src/main.c 2007-07-17 08:07:31 UTC (rev 119)
@@ -173,9 +173,10 @@
cmd_arg_loc += 1;
}
- else if (strcmp(argv[i], "-t") == 0 || strcmp(argv[i], "--test") == 0) /* osd */
+ else if (strcmp(argv[i], "-n") == 0 || strcmp(argv[i], "--ncurses") == 0) /* osd */
{
- daemon_mode = 2;
+ daemon_mode = 1;
+ osd = 1;
cmd_loc += 1;
cmd_arg_loc += 1;
Modified: src/usage.c
===================================================================
--- src/usage.c 2007-07-15 04:23:57 UTC (rev 118)
+++ src/usage.c 2007-07-17 08:07:31 UTC (rev 119)
@@ -71,7 +71,7 @@
fprintf(stderr,
" 4800, 9600, 19200, 38400, 57600, 115200\n\n");
- fprintf(stderr, " -d --daemon Daemon mode. (Experimental)\n");
+ fprintf(stderr, " -d --daemon Daemon mode. (Experimental)\n\n");
fprintf(stderr, " -h --help This help text.\n\n");
@@ -80,6 +80,8 @@
fprintf(stderr,
" (bcd models are work in progress and bcd396t needs a tester.)\n\n");
+ fprintf(stderr, " -n --ncurses Ncurses display. Implies daemon mode (Experimental)\n\n");
+
fprintf(stderr,
" -p --port ie. \"-p /dev/ttyS0\" or \"-p /dev/ttyUSB0\"\n\n");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|