diff --git a/clients/examples/fortune.pl b/clients/examples/fortune.pl index 8c42eb6..611db9f 100755 --- a/clients/examples/fortune.pl +++ b/clients/examples/fortune.pl @@ -49,6 +49,7 @@ while(1) @lines = split(/\n/, $input); foreach $line (@lines) { + if ( $line =~ /^success$/ ) next; if($line =~ /^ignore (\S)/) # Update just after disappearing { &update_text(); diff --git a/clients/examples/iosock.pl b/clients/examples/iosock.pl index 8f663d5..144e6fc 100755 --- a/clients/examples/iosock.pl +++ b/clients/examples/iosock.pl @@ -43,6 +43,7 @@ while(1) #print "Main loop...\n"; # Handle input... (just spew it to the console) while(defined($line = <$remote>)) { + if ( $line =~ /^success$/ ) next; print $line; } diff --git a/clients/examples/tail.pl b/clients/examples/tail.pl index c042ef2..35e07e6 100755 --- a/clients/examples/tail.pl +++ b/clients/examples/tail.pl @@ -58,6 +58,7 @@ while(1) # Handle input... (spew it to the console) # Also, certain keys scroll the display while(defined($input = <$remote>)) { + if ( $input =~ /^success$/ ) next; print $input; $slow = -10; diff --git a/clients/examples/x11amp.pl b/clients/examples/x11amp.pl index 2ac5113..267c564 100755 --- a/clients/examples/x11amp.pl +++ b/clients/examples/x11amp.pl @@ -72,6 +72,9 @@ while(1) elsif($command eq "ignore") { } + elsif($command eq "success") + { + } else { if($line =~ /\S/) {print "Huh? $line\n";} } diff --git a/clients/lcdproc/main.c b/clients/lcdproc/main.c index 79a0d03..27128a2 100644 --- a/clients/lcdproc/main.c +++ b/clients/lcdproc/main.c @@ -285,6 +285,7 @@ main_loop (mode * sequence) } else if (0 == strcmp (argv[0], "bye")) { //printf("Exiting LCDproc\n"); exit_program (0); + } else if (0 == strcmp (argv[0], "success")) { } else { int j; for (j = 0; j < argc; j++) diff --git a/clients/metar/lcdmetar.pl b/clients/metar/lcdmetar.pl index 396da40..e35dfee 100755 --- a/clients/metar/lcdmetar.pl +++ b/clients/metar/lcdmetar.pl @@ -148,6 +148,11 @@ while (1==1) { # print "The wind blows to $wind_dir_eng, speed $wind_mph mph\n"; } # end else + # eat all input from LCDd + while(defined($input = <$remote>)) { + if ( $input =~ /^success$/ ) next; + #print $input; + } print "Sleeping 15 minutes.\n"; sleep 900; } diff --git a/server/client_functions.c b/server/client_functions.c index 703dcf4..cb24f6f 100644 --- a/server/client_functions.c +++ b/server/client_functions.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "../shared/debug.h" #include "../shared/sockets.h" @@ -116,6 +117,7 @@ client_set_func (client * c, int argc, char **argv) if (c->data->name) free (c->data->name); c->data->name = strdup (argv[i]); + sock_send_string(c->sock, "success\n"); } else { sock_send_string (c->sock, "huh? name requires a parameter\n"); } @@ -185,10 +187,14 @@ screen_add_func (client * c, int argc, char **argv) debug ("screen_add: Adding screen %s\n", argv[1]); err = screen_add (c, argv[1]); - if (err < 0) + if (err < 0) { fprintf (stderr, "screen_add_func: Error adding screen\n"); + sock_send_string (c->sock, "huh? failed to add screen id#\n"); + } if (err > 0) sock_send_string (c->sock, "huh? You already have a screen with that id#\n"); + if (err == 0) + sock_send_string(c->sock, "success\n"); return 0; } @@ -215,10 +221,14 @@ screen_del_func (client * c, int argc, char **argv) debug ("screen_del: Deleting screen %s\n", argv[1]); err = screen_remove (c, argv[1]); - if (err < 0) + if (err < 0) { fprintf (stderr, "screen_del_func: Error removing screen\n"); + sock_send_string(c->sock, "huh? failed to remove screen\n"); + } if (err > 0) sock_send_string (c->sock, "huh? You don't have a screen with that id#\n"); + if ( err == 0 ) + sock_send_string(c->sock, "success\n"); return 0; } @@ -268,6 +278,7 @@ screen_set_func (client * c, int argc, char **argv) if (s->name) free (s->name); s->name = strdup (argv[i]); + sock_send_string(c->sock, "success\n"); } else { sock_send_string (c->sock, "huh? -name requires a parameter\n"); } @@ -282,6 +293,7 @@ screen_set_func (client * c, int argc, char **argv) number = atoi (argv[i]); if (number > 0) s->priority = number; + sock_send_string(c->sock, "success\n"); } else { sock_send_string (c->sock, "huh? -priority requires a parameter\n"); } @@ -296,6 +308,7 @@ screen_set_func (client * c, int argc, char **argv) number = atoi (argv[i]); if (number > 0) s->duration = number; + sock_send_string(c->sock, "success\n"); } else { sock_send_string (c->sock, "huh? -duration requires a parameter\n"); } @@ -321,6 +334,7 @@ screen_set_func (client * c, int argc, char **argv) s->heartbeat = 0; if (0 == strcmp (argv[i], "slash")) s->heartbeat = 2; + sock_send_string(c->sock, "success\n"); } else { sock_send_string (c->sock, "huh? -heartbeat requires a parameter\n"); } @@ -335,6 +349,7 @@ screen_set_func (client * c, int argc, char **argv) number = atoi (argv[i]); if (number > 0) s->wid = number; + sock_send_string(c->sock, "success\n"); } else { sock_send_string (c->sock, "huh? -wid requires a parameter\n"); } @@ -349,6 +364,7 @@ screen_set_func (client * c, int argc, char **argv) number = atoi (argv[i]); if (number > 0) s->hgt = number; + sock_send_string(c->sock, "success\n"); } else { sock_send_string (c->sock, "huh? -hgt requires a parameter\n"); } @@ -419,8 +435,12 @@ widget_add_func (client * c, int argc, char **argv) } // Add the widget and set its type... err = widget_add (s, wid, type, in, c->sock); - if (err < 0) + if (err < 0) { fprintf (stderr, "widget_add_func: Error adding widget\n"); + sock_send_string(c->sock, "huh? failed\n"); + } + else + sock_send_string(c->sock, "success\n"); return 0; } @@ -465,8 +485,12 @@ widget_del_func (client * c, int argc, char **argv) } err = widget_remove (s, wid, c->sock); - if (err < 0) + if (err < 0) { fprintf (stderr, "widget_del_func: Error removing widget\n"); + sock_send_string(c->sock, "huh? failed\n"); + } + else + sock_send_string(c->sock, "success\n"); return 0; } @@ -550,6 +574,7 @@ widget_set_func (client * c, int argc, char **argv) return -1; } debug ("Widget %s set to %s\n", wid, w->text); + sock_send_string(c->sock, "success\n"); } } break; @@ -568,6 +593,7 @@ widget_set_func (client * c, int argc, char **argv) w->length = length; } debug ("Widget %s set to %i\n", wid, w->length); + sock_send_string(c->sock, "success\n"); } break; case WID_VBAR: // Vbar takes "x y length" @@ -585,6 +611,7 @@ widget_set_func (client * c, int argc, char **argv) w->length = length; } debug ("Widget %s set to %i\n", wid, w->length); + sock_send_string(c->sock, "success\n"); } break; case WID_ICON: // Icon takes "x y binary_data" @@ -615,6 +642,7 @@ widget_set_func (client * c, int argc, char **argv) return -1; } debug ("Widget %s set to %s\n", wid, w->text); + sock_send_string(c->sock, "success\n"); } break; case WID_SCROLLER: // Scroller takes "left top right bottom direction speed text" @@ -650,10 +678,12 @@ widget_set_func (client * c, int argc, char **argv) free (w->text); w->text = strdup (argv[i + 6]); if (!w->text) { + sock_send_string(c->sock, "huh? out of memory\n"); fprintf (stderr, "widget_set_func: Error allocating string\n"); return -1; } debug ("Widget %s set to %s\n", wid, w->text); + sock_send_string(c->sock, "success\n"); } } } @@ -694,6 +724,7 @@ widget_set_func (client * c, int argc, char **argv) w->length = direction; w->speed = speed; debug ("Widget %s set to (%i,%i)-(%i,%i) %ix%i\n", wid, left, top, right, bottom, width, height); + sock_send_string(c->sock, "success\n"); } } } @@ -713,6 +744,7 @@ widget_set_func (client * c, int argc, char **argv) w->y = y; } debug ("Widget %s set to %i\n", wid, w->y); + sock_send_string(c->sock, "success\n"); } break; case WID_NONE: @@ -864,6 +896,7 @@ backlight_func (client * c, int argc, char **argv) case BACKLIGHT_VIS: break; } + sock_send_string(c->sock, "success\n"); return 0; @@ -874,16 +907,37 @@ backlight_func (client * c, int argc, char **argv) int output_func (client * c, int argc, char **argv) { + int rc = 0; if (argc != 2) { sock_send_string (c->sock, "huh? Too many parameters...\n"); + rc = 1; } else { if (0 == strcmp (argv[1], "on")) - output_state = 1; + /* switch all ouputs on */ + output_state = -1; else if (0 == strcmp (argv[1], "off")) - output_state = -1; - else - output_state = 0; + /* switch all ouputs off */ + output_state = 0; + else { + long out; + char *endptr; + + out = strtol(argv[1], &endptr, 0); + if ( (out == 0) && (errno != 0) ) { + sock_send_string (c->sock, + "huh? invalid parameter...\n"); + rc = 1; + } + else { + output_state = out; + } + } } + + if ( rc == 0 ) { + sock_send_string(c->sock, "success\n"); + } + return 0; } diff --git a/server/drivers/MtxOrb.c b/server/drivers/MtxOrb.c index ab66af8..4c50220 100644 --- a/server/drivers/MtxOrb.c +++ b/server/drivers/MtxOrb.c @@ -14,6 +14,7 @@ #include "../../config.h" static int custom = 0; +static enum {MTXORB_LCD, MTXORB_LKD, MTXORB_VFD, MTXORB_VKD} MtxOrb_type; // TODO: Remove this custom_type if not in use anymore. typedef enum { @@ -132,8 +133,26 @@ MtxOrb_init (lcd_logical_driver * driver, char *args) } else if (0 == strcmp (argv[i], "-h") || 0 == strcmp (argv[i], "--help")) { printf ("LCDproc Matrix-Orbital LCD driver\n" "\t-d\t--device\tSelect the output device to use [/dev/lcd]\n" // "\t-t\t--type\t\tSelect the LCD type (size) [20x4]\n" - "\t-c\t--contrast\tSet the initial contrast [140]\n" "\t-s\t--speed\t\tSet the communication speed [19200]\n" "\t-h\t--help\t\tShow this help information\n"); + "\t-c\t--contrast\tSet the initial contrast [140]\n" "\t-s\t--speed\t\tSet the communication speed [19200]\n" "\t-h\t--help\t\tShow this help information\n" "\t-t\t--type\t\tdisplay type: lcd, lkd, vfd, vkd\n"); return -1; + } else if (0 == strcmp (argv[i], "-t") || 0 == strcmp (argv[i], "--type")) { + if (i + 1 > argc) { + fprintf (stderr, "MtxOrb_init: %s requires an argument\n", argv[i]); + return -1; + } + i++; + if ( 0 == strcmp (argv[i], "lcd") ) { + MtxOrb_type = MTXORB_LCD; + } else if ( 0 == strcmp (argv[i], "lkd") ) { + MtxOrb_type = MTXORB_LKD; + } else if ( 0 == strcmp (argv[i], "vfd") ) { + MtxOrb_type = MTXORB_VFD; + } else if ( 0 == strcmp (argv[i], "vkd") ) { + MtxOrb_type = MTXORB_VKD; + } else { + fprintf (stderr, "MtxOrb_init: unknwon display type %s\n", argv[i]); + return(-1); + } } else { printf ("Invalid parameter: %s\n", argv[i]); } @@ -268,6 +287,8 @@ MtxOrb_chr (int x, int y, char c) ///////////////////////////////////////////////////////////////// // Changes screen contrast (0-255; 140 seems good) +// note: works only for LCD displays +// Is it better to use the brightness for VFD/VKD displays ? // int MtxOrb_contrast (int contrast) @@ -275,7 +296,8 @@ MtxOrb_contrast (int contrast) char out[4]; static int status = 140; - if (contrast > 0) { + if ( ((MtxOrb_type == MTXORB_LCD) || (MtxOrb_type == MTXORB_LKD)) && + (contrast > 0) ) { status = contrast; sprintf (out, "%cP%c", 254, status); write (fd, out, 3); @@ -287,6 +309,8 @@ MtxOrb_contrast (int contrast) ///////////////////////////////////////////////////////////////// // Sets the backlight on or off -- can be done quickly for // an intermediate brightness... +// WARN: off switches vfd/vkd displays off +// -> so it's maybe the best to start LCDd with -b on // void MtxOrb_backlight (int on) @@ -303,16 +327,30 @@ MtxOrb_backlight (int on) ///////////////////////////////////////////////////////////////// // Sets output port on or off +// displays with keypad have 6 outputs but the one without kepad +// have only one output +// NOTE: length of command are different void MtxOrb_output (int on) { - char out[4]; - if (on > 0) { - sprintf (out, "%cW", 254); - write (fd, out, 2); - } else if (on < 0) { - sprintf (out, "%cV", 254); + char out[5]; + if ( ((MtxOrb_type == MTXORB_LCD) || (MtxOrb_type == MTXORB_VFD)) ) { + if (on) { + sprintf (out, "%cW", 254); + } else { + sprintf (out, "%cV", 254); + } write (fd, out, 2); + } else { + int i; + for(i=0; i<6; i++) { + if ( on & (1 << i) ) { + sprintf (out, "%cW%c", 254, i+1); + } else { + sprintf (out, "%cW%c", 254, i+1); + } + write (fd, out, 3); + } } } @@ -600,29 +638,6 @@ MtxOrb_getkey () return in; } -void -MtxOrb_led (int which, int on) -{ - char out[4]; - - if (which < 0 || which > 7) - return; - - if (!which) { - if (on) - sprintf (out, "%cV", 254); - else - sprintf (out, "%cW", 254); - write (fd, out, 2); - } else { - if (on) - sprintf (out, "%cV%c", 254, which); - else - sprintf (out, "%cW%c", 254, which); - write (fd, out, 3); - } -} - ///////////////////////////////////////////////////////////////// // Ask for dynamic allocation of a custom caracter to be // a well none bar graphic. The function is suppose to diff --git a/server/input.c b/server/input.c index 281be43..39151b4 100644 --- a/server/input.c +++ b/server/input.c @@ -62,28 +62,18 @@ handle_input () debug ("handle_input(%c)\n", (char) key); if (key) { - s = screenlist_current (); - if (s) { - c = s->parent; - if (c) { - // TODO: Interpret and translate keys! - // If the client should have this keypress... - // Send keypress to client - if (key >= 'E' && key <= 'Z') { - // TODO: Implement client "acceptable key" lists - sprintf (str, "key %c\n", key); - sock_send_string (c->sock, str); - } - // Otherwise, tell the server about it. - else { - server_input (key); - } - } else { - // If no parent, it means we're on the server screen. - // so, the server gets all keypresses there. - server_input (key); - } + /* s = screenlist_current (); */ + c = (client *)LL_GetFirst(clients); + while(c) { + // TODO: Interpret and translate keys! + // If the client should have this keypress... + // Send keypress to client + // TODO: Implement client "acceptable key" lists + sprintf(str, "key %c\n", key); + sock_send_string(c->sock, str); + c = (client *)LL_GetNext(clients); } + server_input (key); } return 0;