You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(21) |
Aug
(12) |
Sep
(4) |
Oct
(13) |
Nov
(124) |
Dec
(35) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(19) |
Feb
(1) |
Mar
(10) |
Apr
(1) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(50) |
Oct
|
Nov
(15) |
Dec
(39) |
2008 |
Jan
(89) |
Feb
(1) |
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
(7) |
Feb
(7) |
Mar
(2) |
Apr
(23) |
May
(3) |
Jun
(10) |
Jul
(5) |
Aug
|
Sep
|
Oct
(3) |
Nov
|
Dec
|
2010 |
Jan
(3) |
Feb
(4) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(2) |
2011 |
Jan
(2) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <cza...@us...> - 2011-04-27 21:29:04
|
Revision: 539 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=539&view=rev Author: czarnyckm Date: 2011-04-27 21:28:57 +0000 (Wed, 27 Apr 2011) Log Message: ----------- Updated version Modified Paths: -------------- trunk/g15daemon-clients/g15stats/configure.in Modified: trunk/g15daemon-clients/g15stats/configure.in =================================================================== --- trunk/g15daemon-clients/g15stats/configure.in 2011-04-27 21:23:15 UTC (rev 538) +++ trunk/g15daemon-clients/g15stats/configure.in 2011-04-27 21:28:57 UTC (rev 539) @@ -1,7 +1,7 @@ AC_INIT(g15stats,[1.9.7], [mla...@us...]) PACKAGE=g15stats -VERSION=1.9.6 +VERSION=1.9.7 AC_PREFIX_DEFAULT(/usr) AC_CONFIG_AUX_DIR(config) AM_INIT_AUTOMAKE($PACKAGE, $VERSION) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cza...@us...> - 2011-04-27 21:23:23
|
Revision: 538 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=538&view=rev Author: czarnyckm Date: 2011-04-27 21:23:15 +0000 (Wed, 27 Apr 2011) Log Message: ----------- - Improve Summary Screen Fan / Temperature sensors bar calculation Modified Paths: -------------- trunk/g15daemon-clients/g15stats/ChangeLog trunk/g15daemon-clients/g15stats/configure.in trunk/g15daemon-clients/g15stats/g15stats.c Modified: trunk/g15daemon-clients/g15stats/ChangeLog =================================================================== --- trunk/g15daemon-clients/g15stats/ChangeLog 2011-01-10 09:35:55 UTC (rev 537) +++ trunk/g15daemon-clients/g15stats/ChangeLog 2011-04-27 21:23:15 UTC (rev 538) @@ -78,3 +78,5 @@ - Change refresh interval with the option -r seconds (The seconds must be between 1 and 300) SVN 534 (1.9.6) - Improve Summary Screen with 3 and 6 core CPU +SVN 538 (1.9.7) +- Improve Summary Screen Fan / Temperature sensors bar calculation Modified: trunk/g15daemon-clients/g15stats/configure.in =================================================================== --- trunk/g15daemon-clients/g15stats/configure.in 2011-01-10 09:35:55 UTC (rev 537) +++ trunk/g15daemon-clients/g15stats/configure.in 2011-04-27 21:23:15 UTC (rev 538) @@ -1,4 +1,4 @@ -AC_INIT(g15stats,[1.9.6], [mla...@us...]) +AC_INIT(g15stats,[1.9.7], [mla...@us...]) PACKAGE=g15stats VERSION=1.9.6 Modified: trunk/g15daemon-clients/g15stats/g15stats.c =================================================================== --- trunk/g15daemon-clients/g15stats/g15stats.c 2011-01-10 09:35:55 UTC (rev 537) +++ trunk/g15daemon-clients/g15stats/g15stats.c 2011-04-27 21:23:15 UTC (rev 538) @@ -644,11 +644,9 @@ if (rest > 0) { if ((j+1) < count) { y++; - last_y++; rest--; } else { y += rest; - last_y += rest; rest = 0; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2011-01-10 09:36:01
|
Revision: 537 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=537&view=rev Author: steelside Date: 2011-01-10 09:35:55 +0000 (Mon, 10 Jan 2011) Log Message: ----------- Removed some old code Modified Paths: -------------- trunk/g15daemon-clients/g15macro/g15macro.c Modified: trunk/g15daemon-clients/g15macro/g15macro.c =================================================================== --- trunk/g15daemon-clients/g15macro/g15macro.c 2011-01-07 19:50:55 UTC (rev 536) +++ trunk/g15daemon-clients/g15macro/g15macro.c 2011-01-10 09:35:55 UTC (rev 537) @@ -416,7 +416,6 @@ g15r_pixelReverseFill(canvas, 0, 24, 121, 33, 0,G15_COLOR_BLACK); g15_send(g15screen_fd,(char *)canvas->buffer,G15_BUFFER_LEN); - was_recording = 0; pthread_mutex_lock(&gui_select); gui_oldConfig = gui_selectConfig; pthread_mutex_unlock(&gui_select); @@ -1093,6 +1092,7 @@ break; // Change to selected + char newConfig[1024]; memset(newConfig,0,sizeof(newConfig)); strcpy(newConfig,configDir); @@ -1364,16 +1364,8 @@ // Only need to update selection, renderSelection(); } + was_recording = 0; -// printf("NumConfigs is %i\n",numConfigs); - -// int fg_check = g15_send_cmd (g15screen_fd, G15DAEMON_IS_FOREGROUND, dummy); -// if (fg_check==1) { // foreground -// do { -// g15_send_cmd (g15screen_fd, G15DAEMON_SWITCH_PRIORITIES, dummy); -// } while(g15_send_cmd (g15screen_fd, G15DAEMON_IS_FOREGROUND, dummy)==1); -// } - usleep(500*1000); } usleep(1000); @@ -1393,8 +1385,6 @@ currConfig = 0; gui_selectConfig = 0; G15Version = 0; -// mmedia_codes = {164, 162, 144, 153, 174, 176}; -// gkeycodes = { 177,152,190,208,129,130,231,209,210,136,220,143,246,251,137,138,133,183 }; config_fd = 0; mled_state = G15_LED_M1; mkey_state = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2011-01-07 19:51:01
|
Revision: 536 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=536&view=rev Author: steelside Date: 2011-01-07 19:50:55 +0000 (Fri, 07 Jan 2011) Log Message: ----------- Moved some parts out of main into their own functions. Made g15macro_log flush stdout after each call in order for piping output to file to work as expected. Modified Paths: -------------- trunk/g15daemon-clients/g15macro/g15macro.c Modified: trunk/g15daemon-clients/g15macro/g15macro.c =================================================================== --- trunk/g15daemon-clients/g15macro/g15macro.c 2010-12-12 01:30:30 UTC (rev 535) +++ trunk/g15daemon-clients/g15macro/g15macro.c 2011-01-07 19:50:55 UTC (rev 536) @@ -184,6 +184,7 @@ va_start (argp, fmt); vprintf(fmt,argp); va_end (argp); + fflush(stdout); } return 0; @@ -234,6 +235,17 @@ return str; } +// Trims a string to a specific length +// Caller needs to free the data. +char* stringTrim(const char* source, const unsigned int len) +{ + char* dest = malloc(len); + memset(dest,0,len); + strncpy(dest,source,len-1); + + return dest; +} + //TODO: Put into libg15render instead void drawXBM(g15canvas* canvas, unsigned char* data, int width, int height ,int pos_x, int pos_y) { @@ -353,6 +365,7 @@ void renderHelp() { + // Draws the helpbox in the bottom right corner. g15r_drawLine(canvas, G15_LCD_WIDTH-37, 16, G15_LCD_WIDTH, 16, G15_COLOR_BLACK); g15r_drawLine(canvas, G15_LCD_WIDTH-37, 16, G15_LCD_WIDTH-37, G15_LCD_HEIGHT, G15_COLOR_BLACK); g15r_renderString (canvas, (unsigned char *)"1:Default\0", 3, G15_TEXT_SMALL, G15_LCD_WIDTH-35, 0); @@ -361,17 +374,83 @@ g15r_renderString (canvas, (unsigned char *)"4: OK\0", 6, G15_TEXT_SMALL, G15_LCD_WIDTH-35, 0); } -// Trims a string to a specific length -// Caller needs to free the data. -char* stringTrim(const char* source, const unsigned int len) +void renderSelectionList() { - char* dest = malloc(len); - memset(dest,0,len); - strncpy(dest,source,len-1); + // Draws the three presets in the list (Selected-1,Selected,Selected+1) + // Find config id to render + pthread_mutex_lock(&gui_select); + /*static*/ int tmpRenderConfID = 0; - return dest; + // Render first entry + if (gui_selectConfig > 0) + tmpRenderConfID = gui_selectConfig-1; + else + tmpRenderConfID = numConfigs; + + char* renderLine = stringTrim((char*)getConfigName(tmpRenderConfID),25); + g15r_renderString(canvas, (unsigned char*)renderLine, 0, G15_TEXT_MED, 1, 17); + free(renderLine); + renderLine = NULL; + + + // Render middle entry available for selection + renderLine = stringTrim((char*)getConfigName(gui_selectConfig),25); + + g15r_renderString(canvas, (unsigned char*)renderLine, 0, G15_TEXT_MED, 1, 26); + free(renderLine); + renderLine = NULL; + + // Render third (last) entry + if (gui_selectConfig < numConfigs) + tmpRenderConfID = gui_selectConfig+1; + else + tmpRenderConfID = 0; + pthread_mutex_unlock(&gui_select); + + renderLine = stringTrim((char*)getConfigName(tmpRenderConfID),25); + g15r_renderString(canvas, (unsigned char*)renderLine, 0, G15_TEXT_MED, 1, 35); + free(renderLine); + renderLine = NULL; + + // Make middle look selected by inverting colours + g15r_pixelReverseFill(canvas, 0, 24, 121, 33, 0,G15_COLOR_BLACK); + + g15_send(g15screen_fd,(char *)canvas->buffer,G15_BUFFER_LEN); + was_recording = 0; + pthread_mutex_lock(&gui_select); + gui_oldConfig = gui_selectConfig; + pthread_mutex_unlock(&gui_select); } +void renderFull() +{ + char currPreset[1024]; + + g15macro_log("Redrawing whole screen.\n"); + + g15r_clearScreen(canvas,G15_COLOR_WHITE); + drawXBM(canvas, (unsigned char*)g15macro_small_bits, g15macro_small_width, g15macro_small_height, 0, 0); // Logo + renderHelp(); // Help box to the right + // Draw indicator of currently selected preset + memset(currPreset,0,sizeof(currPreset)); + snprintf(currPreset,1024,"Current:%s",getConfigName(currConfig)); + g15r_drawLine(canvas, 50, 2, 50, 11, G15_COLOR_BLACK); // Line separating logo from Current: <config> + g15r_renderString (canvas, (unsigned char *)currPreset, 0, G15_TEXT_MED, 53, 4); // Current: <config> + + // Draw selection list + renderSelectionList(); +} + +void renderSelection() +{ + g15macro_log("Redrawing only selection box.\n"); + //Clear only the selection box, since that's the only thing updated + g15r_pixelBox(canvas,0,15,G15_LCD_WIDTH-38,G15_LCD_HEIGHT,G15_COLOR_WHITE,0,1); + + // Draw selection list + renderSelectionList(); +} + void gui_selectChange(int change) { pthread_mutex_lock(&gui_select); @@ -390,6 +469,8 @@ gui_selectConfig += change; if (gui_selectConfig > numConfigs) gui_selectConfig = 0; + else if (gui_selectConfig < 0) + gui_selectConfig = numConfigs; } @@ -531,6 +612,7 @@ }else{ strcpy(tmpstr,"From Key "); + printf("%lu\n",keystate); strcat(tmpstr,gkeystring[map_gkey(keystate)]); g15macro_log("Macro deleted %s\n",tmpstr); g15r_renderString (canvas, (unsigned char *)"Macro", 0, G15_TEXT_LARGE, 80-((strlen("Macro")/2)*8), 4); @@ -1039,6 +1121,7 @@ break; } case G15_KEY_MR: { + g15macro_log("Key pressed is MR\n"); if(!recording) { if(0==g15_send_cmd (g15screen_fd, G15DAEMON_IS_FOREGROUND, foo)){ usleep(1000); @@ -1064,12 +1147,15 @@ } case G15_KEY_M1: handle_mkey_switch(G15_KEY_M1); + g15macro_log("Key pressed is M1\n"); break; case G15_KEY_M2: handle_mkey_switch(G15_KEY_M2); + g15macro_log("Key pressed is M2\n"); break; case G15_KEY_M3: handle_mkey_switch(G15_KEY_M3); + g15macro_log("Key pressed is M3\n"); break; default: if(keystate >=G15_KEY_G1 && keystate <=G15_KEY_G18){ @@ -1253,8 +1339,52 @@ printf("--help (-h) this help text\n\n"); } +void mainLoop() +{ + do + { + if(display_timeout >= 0) + --display_timeout; + if(recording) + { + was_recording = 1; + display_timeout=500; + } + if(display_timeout<=0 && (was_recording || gui_oldConfig != gui_selectConfig)) + { + g15macro_log("Display timeout is 0, and we were recording OR selected a new config.\n"); + if (was_recording || gui_oldConfig == MAX_CONFIGS+1) + { + renderFull(); + } + else + { + // Only need to update selection, + renderSelection(); + } + +// printf("NumConfigs is %i\n",numConfigs); + +// int fg_check = g15_send_cmd (g15screen_fd, G15DAEMON_IS_FOREGROUND, dummy); +// if (fg_check==1) { // foreground +// do { +// g15_send_cmd (g15screen_fd, G15DAEMON_SWITCH_PRIORITIES, dummy); +// } while(g15_send_cmd (g15screen_fd, G15DAEMON_IS_FOREGROUND, dummy)==1); +// } + + usleep(500*1000); + } + usleep(1000); + + } while( !leaving); + // Told to exit. + g15macro_log("Leaving mainloop\n"); +} + + + int main(int argc, char **argv) { // init vars @@ -1286,7 +1416,6 @@ unsigned int keysonly = 0; FILE *config; unsigned int convert = 0; - char currPreset[1024]; memset(configDir,0,sizeof(configDir)); strncpy(configDir,getenv("HOME"),1024); @@ -1411,7 +1540,7 @@ convert = 1; } else - cleanMstates(0); //0 - only null pointers + cleanMstates(0); //0 = only NULL the pointers /* new format */ strncpy(configpath,getenv("HOME"),1024); @@ -1519,90 +1648,10 @@ pthread_create(&Xkeys, &attr, xevent_thread, NULL); pthread_create(&Lkeys, &attr, Lkeys_thread, NULL); - do - { - if(display_timeout >= 0) - --display_timeout; - if(recording) - { - was_recording = 1; - display_timeout=500; - } - if(display_timeout<=0 && (was_recording || gui_oldConfig != gui_selectConfig)) - { - if (was_recording || gui_oldConfig == MAX_CONFIGS+1) - { - g15r_clearScreen(canvas,G15_COLOR_WHITE); - drawXBM(canvas, (unsigned char*)g15macro_small_bits, g15macro_small_width, g15macro_small_height, 0, 0); - renderHelp(); - // Draw indicator of currently selected preset - memset(currPreset,0,sizeof(currPreset)); - snprintf(currPreset,1024,"Current:%s",getConfigName(currConfig)); - g15r_drawLine(canvas, 50, 2, 50, 11, G15_COLOR_BLACK); - g15r_renderString (canvas, (unsigned char *)currPreset, 0, G15_TEXT_MED, 53, 4); - } - else - { - //Clear only the selection box, since that's the only thing updated - g15r_pixelBox(canvas,0,15,G15_LCD_WIDTH-38,G15_LCD_HEIGHT,G15_COLOR_WHITE,0,1); - } + mainLoop(); - // Draws the Selected-1,Selected,Selected+1 presets - // Find config id to render - pthread_mutex_lock(&gui_select); - static int tmpRenderConfID = 0; - if (gui_selectConfig > 0) - tmpRenderConfID = gui_selectConfig-1; - else - tmpRenderConfID = numConfigs; - - char* renderLine = stringTrim((char*)getConfigName(tmpRenderConfID),25); - g15r_renderString(canvas, (unsigned char*)renderLine, 0, G15_TEXT_MED, 1, 17); - free(renderLine); - renderLine = NULL; - - renderLine = stringTrim((char*)getConfigName(gui_selectConfig),25); - - g15r_renderString(canvas, (unsigned char*)renderLine, 0, G15_TEXT_MED, 1, 26); - free(renderLine); - renderLine = NULL; - - if (gui_selectConfig < numConfigs) - tmpRenderConfID = gui_selectConfig+1; - else - tmpRenderConfID = 0; - pthread_mutex_unlock(&gui_select); - - renderLine = stringTrim((char*)getConfigName(tmpRenderConfID),25); - g15r_renderString(canvas, (unsigned char*)renderLine, 0, G15_TEXT_MED, 1, 35); - free(renderLine); - renderLine = NULL; - - // Make middle look selected by inverting colours - g15r_pixelReverseFill(canvas, 0, 24, 121, 33, 0,G15_COLOR_BLACK); - - g15_send(g15screen_fd,(char *)canvas->buffer,G15_BUFFER_LEN); - was_recording = 0; - pthread_mutex_lock(&gui_select); - gui_oldConfig = gui_selectConfig; - pthread_mutex_unlock(&gui_select); -// printf("NumConfigs is %i\n",numConfigs); - -// int fg_check = g15_send_cmd (g15screen_fd, G15DAEMON_IS_FOREGROUND, dummy); -// if (fg_check==1) { // foreground -// do { -// g15_send_cmd (g15screen_fd, G15DAEMON_SWITCH_PRIORITIES, dummy); -// } while(g15_send_cmd (g15screen_fd, G15DAEMON_IS_FOREGROUND, dummy)==1); -// } - - usleep(500*1000); - } - usleep(1000); - }while( !leaving); - g15macro_log("Leaving mainloop\n"); - cleanup(); close_and_exit: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cza...@us...> - 2010-12-12 01:30:36
|
Revision: 535 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=535&view=rev Author: czarnyckm Date: 2010-12-12 01:30:30 +0000 (Sun, 12 Dec 2010) Log Message: ----------- - Fix typo Modified Paths: -------------- trunk/g15daemon-clients/g15stats/ChangeLog trunk/g15daemon-clients/g15stats/g15stats.c Modified: trunk/g15daemon-clients/g15stats/ChangeLog =================================================================== --- trunk/g15daemon-clients/g15stats/ChangeLog 2010-12-12 01:18:33 UTC (rev 534) +++ trunk/g15daemon-clients/g15stats/ChangeLog 2010-12-12 01:30:30 UTC (rev 535) @@ -76,5 +76,5 @@ - Improve refresh interval causing -nan error with the newer kernel on very fast machines due to too often glibtop probing - Fix possible -nan error on the fast screens switch - Change refresh interval with the option -r seconds (The seconds must be between 1 and 300) -SVN 533 (1.9.6) +SVN 534 (1.9.6) - Improve Summary Screen with 3 and 6 core CPU Modified: trunk/g15daemon-clients/g15stats/g15stats.c =================================================================== --- trunk/g15daemon-clients/g15stats/g15stats.c 2010-12-12 01:18:33 UTC (rev 534) +++ trunk/g15daemon-clients/g15stats/g15stats.c 2010-12-12 01:30:30 UTC (rev 535) @@ -902,7 +902,7 @@ break; case 3 : case 6 : - height =6; + height = 6; break; default : height = 8; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cza...@us...> - 2010-12-12 01:18:41
|
Revision: 534 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=534&view=rev Author: czarnyckm Date: 2010-12-12 01:18:33 +0000 (Sun, 12 Dec 2010) Log Message: ----------- - Improve Summary Screen with 3 and 6 core CPU Modified Paths: -------------- trunk/g15daemon-clients/g15stats/ChangeLog trunk/g15daemon-clients/g15stats/configure.in trunk/g15daemon-clients/g15stats/g15stats.c Modified: trunk/g15daemon-clients/g15stats/ChangeLog =================================================================== --- trunk/g15daemon-clients/g15stats/ChangeLog 2010-10-26 09:23:31 UTC (rev 533) +++ trunk/g15daemon-clients/g15stats/ChangeLog 2010-12-12 01:18:33 UTC (rev 534) @@ -76,3 +76,5 @@ - Improve refresh interval causing -nan error with the newer kernel on very fast machines due to too often glibtop probing - Fix possible -nan error on the fast screens switch - Change refresh interval with the option -r seconds (The seconds must be between 1 and 300) +SVN 533 (1.9.6) +- Improve Summary Screen with 3 and 6 core CPU Modified: trunk/g15daemon-clients/g15stats/configure.in =================================================================== --- trunk/g15daemon-clients/g15stats/configure.in 2010-10-26 09:23:31 UTC (rev 533) +++ trunk/g15daemon-clients/g15stats/configure.in 2010-12-12 01:18:33 UTC (rev 534) @@ -1,7 +1,7 @@ -AC_INIT(g15stats,[1.9.5], [mla...@us...]) +AC_INIT(g15stats,[1.9.6], [mla...@us...]) PACKAGE=g15stats -VERSION=1.9.5 +VERSION=1.9.6 AC_PREFIX_DEFAULT(/usr) AC_CONFIG_AUX_DIR(config) AM_INIT_AUTOMAKE($PACKAGE, $VERSION) Modified: trunk/g15daemon-clients/g15stats/g15stats.c =================================================================== --- trunk/g15daemon-clients/g15stats/g15stats.c 2010-10-26 09:23:31 UTC (rev 533) +++ trunk/g15daemon-clients/g15stats/g15stats.c 2010-12-12 01:18:33 UTC (rev 534) @@ -895,12 +895,15 @@ switch (ncpu) { case 1 : case 2 : - case 3 : case 5 : case 7 : move = 1; height = 6; break; + case 3 : + case 6 : + height =6; + break; default : height = 8; break; @@ -913,9 +916,9 @@ move = 1; break; } - height = 8; - } - + height = 8; + } + shift = height + 1; shift2 = (2 * shift); break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cza...@us...> - 2010-10-26 09:23:37
|
Revision: 533 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=533&view=rev Author: czarnyckm Date: 2010-10-26 09:23:31 +0000 (Tue, 26 Oct 2010) Log Message: ----------- - Fix typo Modified Paths: -------------- trunk/g15daemon-clients/g15stats/ChangeLog Modified: trunk/g15daemon-clients/g15stats/ChangeLog =================================================================== --- trunk/g15daemon-clients/g15stats/ChangeLog 2010-10-26 09:11:00 UTC (rev 532) +++ trunk/g15daemon-clients/g15stats/ChangeLog 2010-10-26 09:23:31 UTC (rev 533) @@ -72,7 +72,7 @@ - Improve Summary Screen multi bar (temperature and network) SVN 532 (1.9.5) - Improve Summary Screen multi bar (temperature and network) -- Fix compilation with the never version of the glibc -- Improve refresh interval causing -nan error with the never kernel on very fast machines due to too often glibtop probing +- Fix compilation with the newer version of the glibc +- Improve refresh interval causing -nan error with the newer kernel on very fast machines due to too often glibtop probing - Fix possible -nan error on the fast screens switch -- Change refresh interval with the option -r seconds (The seconds must be between 1 and 300) \ No newline at end of file +- Change refresh interval with the option -r seconds (The seconds must be between 1 and 300) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cza...@us...> - 2010-10-26 09:11:07
|
Revision: 532 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=532&view=rev Author: czarnyckm Date: 2010-10-26 09:11:00 +0000 (Tue, 26 Oct 2010) Log Message: ----------- - Improve Summary Screen multi bar (temperature and network) - Fix compilation with the never version of the glibc - Improve refresh interval causing -nan error with the never kernel on very fast machines due to too often glibtop probing - Fix possible -nan error on the fast screens switch - Change refresh interval with the option -r seconds (The seconds must be between 1 and 300) Modified Paths: -------------- trunk/g15daemon-clients/g15stats/ChangeLog trunk/g15daemon-clients/g15stats/Makefile.am trunk/g15daemon-clients/g15stats/README trunk/g15daemon-clients/g15stats/configure.in trunk/g15daemon-clients/g15stats/g15stats.c trunk/g15daemon-clients/g15stats/g15stats.h Modified: trunk/g15daemon-clients/g15stats/ChangeLog =================================================================== --- trunk/g15daemon-clients/g15stats/ChangeLog 2010-04-08 16:38:37 UTC (rev 531) +++ trunk/g15daemon-clients/g15stats/ChangeLog 2010-10-26 09:11:00 UTC (rev 532) @@ -70,3 +70,9 @@ - Improve Fan / Temperature Screens leading labels position - Improve Fan / Temperature Screens height calculation - Improve Summary Screen multi bar (temperature and network) +SVN 532 (1.9.5) +- Improve Summary Screen multi bar (temperature and network) +- Fix compilation with the never version of the glibc +- Improve refresh interval causing -nan error with the never kernel on very fast machines due to too often glibtop probing +- Fix possible -nan error on the fast screens switch +- Change refresh interval with the option -r seconds (The seconds must be between 1 and 300) \ No newline at end of file Modified: trunk/g15daemon-clients/g15stats/Makefile.am =================================================================== --- trunk/g15daemon-clients/g15stats/Makefile.am 2010-04-08 16:38:37 UTC (rev 531) +++ trunk/g15daemon-clients/g15stats/Makefile.am 2010-10-26 09:11:00 UTC (rev 532) @@ -1,5 +1,5 @@ -AM_CFLAGS = -O3 -Wall @CFLAGS@ -I$(top_builddir) -I$(top_srcdir) +AM_CFLAGS = -O3 -Wall @CFLAGS@ -I$(top_builddir) -I$(top_srcdir) METASOURCES = AUTO bin_PROGRAMS = g15stats noinst_HEADERS = g15stats.h @@ -7,7 +7,7 @@ docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION) doc_DATA = README ChangeLog AUTHORS NEWS COPYING -LIBS = -lg15daemon_client -lg15render +LIBS = -lg15daemon_client -lg15render -lpthread -lm -lrt IMCLUDES = -I g15stats_LDFLAGS = -avoid-version g15stats_SOURCES = g15stats.c g15stats.h Modified: trunk/g15daemon-clients/g15stats/README =================================================================== --- trunk/g15daemon-clients/g15stats/README 2010-04-08 16:38:37 UTC (rev 531) +++ trunk/g15daemon-clients/g15stats/README 2010-10-26 09:11:00 UTC (rev 532) @@ -30,6 +30,7 @@ -nsa Scale network graphs against highest speed recorded. The default is to scale against the highest peak in the current graph. -h Show help +-r seconds Set the refresh interval to seconds The seconds must be between 1 and 300. ie -r 15 -u Display unicore graphs only on the CPU screen -t id Force to monitor temperature sensor id on start (ie -t 1) The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input Modified: trunk/g15daemon-clients/g15stats/configure.in =================================================================== --- trunk/g15daemon-clients/g15stats/configure.in 2010-04-08 16:38:37 UTC (rev 531) +++ trunk/g15daemon-clients/g15stats/configure.in 2010-10-26 09:11:00 UTC (rev 532) @@ -1,7 +1,7 @@ -AC_INIT(g15stats,[1.9.4], [mla...@us...]) +AC_INIT(g15stats,[1.9.5], [mla...@us...]) PACKAGE=g15stats -VERSION=1.9.4 +VERSION=1.9.5 AC_PREFIX_DEFAULT(/usr) AC_CONFIG_AUX_DIR(config) AM_INIT_AUTOMAKE($PACKAGE, $VERSION) Modified: trunk/g15daemon-clients/g15stats/g15stats.c =================================================================== --- trunk/g15daemon-clients/g15stats/g15stats.c 2010-04-08 16:38:37 UTC (rev 531) +++ trunk/g15daemon-clients/g15stats/g15stats.c 2010-10-26 09:11:00 UTC (rev 532) @@ -39,6 +39,7 @@ #include <libg15render.h> #include <sched.h> #include <sys/socket.h> +#include <sys/time.h> #include <sys/types.h> #include <sys/stat.h> #include <time.h> @@ -70,6 +71,9 @@ int summary_rows = 4; int have_freq = 2; + +int wait_seconds = 1; + _Bool have_temp = 1; _Bool have_fan = 1; _Bool have_bat = 1; @@ -635,18 +639,23 @@ int last_y; for (j = 0; j < count; j++) { last_y = y; - if( j ) last_y++; - y += step; - if (rest > 0) { - if ((j+1) < count) { - y++; - rest--; - } else { - y += rest; - rest = 0; + if( j ) { + last_y++; + if (rest > 0) { + if ((j+1) < count) { + y++; + last_y++; + rest--; + } else { + y += rest; + last_y += rest; + rest = 0; + } } } + y += step; drawBar_both(canvas, last_y + move, y + move, sensors[j].cur + 1, tot_max, tot_max - sensors[j].cur, tot_max); + } drawLine_both(canvas, cur_shift + y1 + move, y + move); @@ -752,8 +761,8 @@ /* draw cpu screen. if drawgraph = 0 then no graph is drawn */ void draw_cpu_screen_unicore_logic(g15canvas *canvas, glibtop_cpu cpu, char *tmpstr, int drawgraph, int printlabels, int cpuandmemory) { int total,user,nice,sys,idle; - int b_total,b_user,b_nice,b_sys,b_idle,b_irq,b_iowait; - static int last_total,last_user,last_nice,last_sys,last_idle,last_iowait,last_irq; + static int last_total,last_user,last_nice,last_sys,last_idle,last_iowait, + last_irq,b_total,b_user,b_nice,b_sys,b_idle,b_irq,b_iowait; g15r_clearScreen (canvas, G15_COLOR_WHITE); @@ -763,21 +772,26 @@ sys = ((unsigned long) cpu.sys) ? ((double) cpu.sys) : 1.0; idle = ((unsigned long) cpu.idle) ? ((double) cpu.idle) : 1.0; - b_total = total - last_total; - b_user = user - last_user; - b_nice = nice - last_nice; - b_sys = sys - last_sys; - b_idle = idle - last_idle; - b_irq = cpu.irq - last_irq; - b_iowait= cpu.iowait - last_iowait; + if ((total - last_total) > 0) { + b_total = total - last_total; + b_user = user - last_user; + b_nice = nice - last_nice; + b_sys = sys - last_sys; + b_idle = idle - last_idle; + b_irq = cpu.irq - last_irq; + b_iowait= cpu.iowait - last_iowait; - last_total = total; - last_user = user; - last_nice = nice; - last_sys = sys; - last_idle = idle; - last_irq = cpu.irq; - last_iowait = cpu.iowait; + last_total = total; + last_user = user; + last_nice = nice; + last_sys = sys; + last_idle = idle; + last_irq = cpu.irq; + last_iowait = cpu.iowait; + } else if (b_total == 0) { + b_total = 100; + b_idle = 100; + } if(printlabels) { sprintf(tmpstr,"Usr %2.f%%",((float)b_user/(float)b_total)*100); @@ -820,10 +834,12 @@ int divider = 0; int total,user,nice,sys,idle; - int b_total,b_user,b_nice,b_sys,b_idle,b_irq,b_iowait; int sub_val; static int last_total[GLIBTOP_NCPU],last_user[GLIBTOP_NCPU],last_nice[GLIBTOP_NCPU], - last_sys[GLIBTOP_NCPU],last_idle[GLIBTOP_NCPU],last_iowait[GLIBTOP_NCPU],last_irq[GLIBTOP_NCPU]; + last_sys[GLIBTOP_NCPU],last_idle[GLIBTOP_NCPU],last_iowait[GLIBTOP_NCPU], + last_irq[GLIBTOP_NCPU],b_total[GLIBTOP_NCPU],b_user[GLIBTOP_NCPU], + b_nice[GLIBTOP_NCPU],b_sys[GLIBTOP_NCPU],b_idle[GLIBTOP_NCPU], + b_irq[GLIBTOP_NCPU],b_iowait[GLIBTOP_NCPU]; init_cpu_count(); @@ -923,21 +939,26 @@ sys = ((unsigned long) cpu.xcpu_sys[core]) ? ((double) cpu.xcpu_sys[core]) : 1.0; idle = ((unsigned long) cpu.xcpu_idle[core]) ? ((double) cpu.xcpu_idle[core]) : 1.0; - b_total = total - last_total[core]; - b_user = user - last_user[core]; - b_nice = nice - last_nice[core]; - b_sys = sys - last_sys[core]; - b_idle = idle - last_idle[core]; - b_irq = cpu.xcpu_irq[core] - last_irq[core]; - b_iowait = cpu.xcpu_iowait[core] - last_iowait[core]; + if ((total - last_total[core]) > 0) { + b_total[core] = total - last_total[core]; + b_user[core] = user - last_user[core]; + b_nice[core] = nice - last_nice[core]; + b_sys[core] = sys - last_sys[core]; + b_idle[core] = idle - last_idle[core]; + b_irq[core] = cpu.xcpu_irq[core] - last_irq[core]; + b_iowait[core] = cpu.xcpu_iowait[core] - last_iowait[core]; - last_total[core] = total; - last_user[core] = user; - last_nice[core] = nice; - last_sys[core] = sys; - last_idle[core] = idle; - last_irq[core] = cpu.xcpu_irq[core]; - last_iowait[core] = cpu.xcpu_iowait[core]; + last_total[core] = total; + last_user[core] = user; + last_nice[core] = nice; + last_sys[core] = sys; + last_idle[core] = idle; + last_irq[core] = cpu.xcpu_irq[core]; + last_iowait[core] = cpu.xcpu_iowait[core]; + } else if (b_total[core] == 0){ + b_total[core] = 100; + b_idle[core] = 100; + } y1 = (core * height) + (core * spacer); y2 = y1 + height - 1; @@ -947,7 +968,7 @@ if ((mode[SCREEN_FREQ]) && (have_freq)) { freq_cur = get_cpu_freq_cur(core); if (core < 6) { - result = ((float) (b_total - b_idle) / (float) b_total)*100; + result = ((float) (b_total[core] - b_idle[core]) / (float) b_total[core])*100; if (result < 100.0) { sprintf(tmpstr, "%2.f%% %s", result, show_hertz_short(freq_cur)); } else { @@ -966,9 +987,9 @@ if (core < 6) { if (have_freq) { freq_cur = get_cpu_freq_cur(core); - sprintf(tmpstr, "%s%3.f%%", show_hertz_short(freq_cur), ((float) (b_total - b_idle) / (float) b_total)*100); + sprintf(tmpstr, "%s%3.f%%", show_hertz_short(freq_cur), ((float) (b_total[core] - b_idle[core]) / (float) b_total[core])*100); } else { - sprintf(tmpstr, "CPU%.f%3.f%%", (float) core, ((float) (b_total - b_idle) / (float) b_total)*100); + sprintf(tmpstr, "CPU%.f%3.f%%", (float) core, ((float) (b_total[core] - b_idle[core]) / (float) b_total[core])*100); } if (ncpu < 5) { g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, y1 + 1); @@ -976,8 +997,8 @@ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 1, core * 6); } } - current_value = b_total - b_idle; - drawBar_both(canvas, y1, y2, current_value, b_total, b_total - current_value, b_total); + current_value = b_total[core] - b_idle[core]; + drawBar_both(canvas, y1, y2, current_value, b_total[core], b_total[core] - current_value, b_total[core]); y1 = 0; } break; @@ -985,29 +1006,29 @@ if (mode[SCREEN_CPU]) { divider = 9 / ncpu; sub_val = divider * core; - g15r_drawBar(canvas, BAR_START, sub_val, BAR_END, divider + sub_val, G15_COLOR_BLACK, b_user + 1, b_total, 4); - g15r_drawBar(canvas, BAR_START, shift + sub_val, BAR_END, shift + divider + sub_val, G15_COLOR_BLACK, b_sys + 1, b_total, 4); + g15r_drawBar(canvas, BAR_START, sub_val, BAR_END, divider + sub_val, G15_COLOR_BLACK, b_user[core] + 1, b_total[core], 4); + g15r_drawBar(canvas, BAR_START, shift + sub_val, BAR_END, shift + divider + sub_val, G15_COLOR_BLACK, b_sys[core] + 1, b_total[core], 4); y1 = 0; y2 = shift2 + divider + sub_val; - g15r_drawBar(canvas, BAR_START, shift2 + sub_val, BAR_END, y2, G15_COLOR_BLACK, b_nice + 1, b_total, 4); + g15r_drawBar(canvas, BAR_START, shift2 + sub_val, BAR_END, y2, G15_COLOR_BLACK, b_nice[core] + 1, b_total[core], 4); divider = y2 / ncpu; - drawBar_reversed(canvas, BAR_START, sub_val, BAR_END, y2, G15_COLOR_BLACK, b_idle + 1, b_total, 5); + drawBar_reversed(canvas, BAR_START, sub_val, BAR_END, y2, G15_COLOR_BLACK, b_idle[core] + 1, b_total[core], 5); } else { - current_value = b_total - b_idle; - drawBar_both(canvas, y1, y2, current_value, b_total, b_total - current_value, b_total); + current_value = b_total[core] - b_idle[core]; + drawBar_both(canvas, y1, y2, current_value, b_total[core], b_total[core] - current_value, b_total[core]); - drawBar_both(canvas, shift + y1, shift + y2, b_sys + 1, b_total, b_total - b_sys, b_total); + drawBar_both(canvas, shift + y1, shift + y2, b_sys[core] + 1, b_total[core], b_total[core] - b_sys[core], b_total[core]); y2 += shift2; - drawBar_both(canvas, shift2 + y1, y2, b_nice + 1, b_total, b_total - b_nice, b_total); + drawBar_both(canvas, shift2 + y1, y2, b_nice[core] + 1, b_total[core], b_total[core] - b_nice[core], b_total[core]); y1 = 0; } break; case SCREEN_SUMMARY: - current_value = b_total - b_idle; - drawBar_both(canvas, y1 + move, y2 + move, current_value, b_total, b_total - current_value, b_total); + current_value = b_total[core] - b_idle[core]; + drawBar_both(canvas, y1 + move, y2 + move, current_value, b_total[core], b_total[core] - current_value, b_total[core]); if (have_freq) { freq_cur = get_cpu_freq_cur(core); @@ -1641,18 +1662,24 @@ /* wait for a max of <seconds> seconds.. if condition &wake_now is received leave immediately */ void g15stats_wait(int seconds) { pthread_mutex_t dummy_mutex; + pthread_mutexattr_t mta; struct timespec timeout; /* Create a dummy mutex which doesn't unlock for sure while waiting. */ - pthread_mutex_init(&dummy_mutex, NULL); + pthread_mutexattr_init(&mta); + + pthread_mutex_init(&dummy_mutex, &mta); pthread_mutex_lock(&dummy_mutex); - time(&timeout.tv_sec); + if (clock_gettime(CLOCK_REALTIME, &timeout) != 0) { + perror("clock_gettime"); + } + timeout.tv_sec += seconds; - timeout.tv_nsec = 0L; pthread_cond_timedwait(&wake_now, &dummy_mutex, &timeout); pthread_mutex_unlock(&dummy_mutex); pthread_mutex_destroy(&dummy_mutex); + pthread_mutexattr_destroy(&mta); } int main(int argc, char *argv[]){ @@ -1709,6 +1736,7 @@ "\tDefault is to scale fullsize, similar to apps like gkrellm.\n"); printf("--info-rotate (-ir) enable the bottom info bar content rotate.\n"); printf("--variable-cpu (-vc) the cpu cores will be calculated every time (for systems with the cpu hotplug).\n"); + printf("--refresh [seconds] (-r) set the refresh interval to [seconds] The seconds must be between 1 and 300. ie -r 15\n"); printf("--disable-freq (-df) disable monitoring CPUs frequencies.\n\n"); return 0; } @@ -1745,6 +1773,16 @@ } } } + + if(0==strncmp(argv[i],"-r",2)||0==strncmp(argv[i],"--refresh",9)) { + if(argv[i+1]!=NULL) { + i++; + wait_seconds = atoi(argv[i]); + if ((wait_seconds < 1) || (wait_seconds > MAX_INTERVAL)) { + wait_seconds = 1; + } + } + } } if((g15screen_fd = new_g15_screen(G15_G15RBUF))<0){ printf("Sorry, cant connect to the G15daemon\n"); @@ -1885,7 +1923,7 @@ canvas->mode_xor = 0; g15_send(g15screen_fd,(char *)canvas->buffer,G15_BUFFER_LEN); - g15stats_wait(1); + g15stats_wait(wait_seconds); } glibtop_close(); Modified: trunk/g15daemon-clients/g15stats/g15stats.h =================================================================== --- trunk/g15daemon-clients/g15stats/g15stats.h 2010-04-08 16:38:37 UTC (rev 531) +++ trunk/g15daemon-clients/g15stats/g15stats.h 2010-10-26 09:11:00 UTC (rev 532) @@ -9,6 +9,8 @@ #define MAX_MODE 1 #define MAX_SUB_MODE 1 +#define MAX_INTERVAL 300 + #define PAUSE 6 #define RETRY_COUNT 10 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cza...@us...> - 2010-04-08 16:38:48
|
Revision: 531 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=531&view=rev Author: czarnyckm Date: 2010-04-08 16:38:37 +0000 (Thu, 08 Apr 2010) Log Message: ----------- - Fix time info - Improve Fan / Temperature Screens leading labels position - Improve Fan / Temperature Screens height calculation - Improve Summary Screen multi bar (temperature and network) Modified Paths: -------------- trunk/g15daemon-clients/g15stats/ChangeLog trunk/g15daemon-clients/g15stats/configure.in trunk/g15daemon-clients/g15stats/g15stats.c Modified: trunk/g15daemon-clients/g15stats/ChangeLog =================================================================== --- trunk/g15daemon-clients/g15stats/ChangeLog 2010-02-17 11:34:11 UTC (rev 530) +++ trunk/g15daemon-clients/g15stats/ChangeLog 2010-04-08 16:38:37 UTC (rev 531) @@ -65,3 +65,8 @@ - Change bottom info bar content to the component default one - Activate variable CPUs count with the option -vc - Improve Fan bottom info +SVN 531 (1.9.4) +- Fix time info +- Improve Fan / Temperature Screens leading labels position +- Improve Fan / Temperature Screens height calculation +- Improve Summary Screen multi bar (temperature and network) Modified: trunk/g15daemon-clients/g15stats/configure.in =================================================================== --- trunk/g15daemon-clients/g15stats/configure.in 2010-02-17 11:34:11 UTC (rev 530) +++ trunk/g15daemon-clients/g15stats/configure.in 2010-04-08 16:38:37 UTC (rev 531) @@ -1,7 +1,7 @@ -AC_INIT(g15stats,[1.9.3], [mla...@us...]) +AC_INIT(g15stats,[1.9.4], [mla...@us...]) PACKAGE=g15stats -VERSION=1.9.3 +VERSION=1.9.4 AC_PREFIX_DEFAULT(/usr) AC_CONFIG_AUX_DIR(config) AM_INIT_AUTOMAKE($PACKAGE, $VERSION) Modified: trunk/g15daemon-clients/g15stats/g15stats.c =================================================================== --- trunk/g15daemon-clients/g15stats/g15stats.c 2010-02-17 11:34:11 UTC (rev 530) +++ trunk/g15daemon-clients/g15stats/g15stats.c 2010-04-08 16:38:37 UTC (rev 531) @@ -566,6 +566,7 @@ time(&now); sprintf(tmpstr,"%s",ctime(&now)); + tmpstr[(strlen(tmpstr) - 1)] = '\0'; g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, INFO_ROW); } @@ -627,17 +628,23 @@ if (count) { int j = 0; - int rest; - int step = (int) (y2 / count); + int rest, step; + step = y2 / count; rest = y2 - (step * count); int y = cur_shift + y1; int last_y; for (j = 0; j < count; j++) { last_y = y; + if( j ) last_y++; y += step; if (rest > 0) { - rest--; - y++; + if ((j+1) < count) { + y++; + rest--; + } else { + y += rest; + rest = 0; + } } drawBar_both(canvas, last_y + move, y + move, sensors[j].cur + 1, tot_max, tot_max - sensors[j].cur, tot_max); } @@ -687,11 +694,10 @@ y = y2 / 2; drawLine_both(canvas, cur_shift + y1 + move, cur_shift + y2 + move); + drawBar_both(canvas, cur_shift + y1 + move, cur_shift + y + move, net_cur_in + 1, net_max_in, net_max_in - net_cur_in, net_max_in); + drawBar_both(canvas, cur_shift + y + move + 1, cur_shift + y2 + move, net_cur_out + 1, net_max_out, net_max_out - net_cur_out, net_max_out); - - drawBar_both(canvas, cur_shift + y + move, cur_shift + y2 + move, net_cur_out + 1, net_max_out, net_max_out - net_cur_out, net_max_out); - if (net_cur_in > net_cur_out) { sprintf(tmpstr, "IN %s", show_bytes_short((int) net_cur_in)); } else { @@ -1266,36 +1272,56 @@ int j = 0; - int shift; - shift = 32 / count; + if (all) { + int shift; + int info_shift; - if (count) { - if (all) { - g15r_clearScreen(canvas, G15_COLOR_WHITE); - print_vert_label(canvas, vert_label); + shift = BAR_BOTTOM / count; - for (j = 0; j < count; j++) { - register int bar_top = (j * shift) + 1 + j; - register int bar_bottom = ((j + 1)*shift) + j; - sprintf(tmpstr, format_main, j + 1, probes[j].cur); - g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, bar_top + 1); - drawBar_both(canvas, bar_top, bar_bottom, probes[j].cur + 1, tot_max, tot_max - probes[j].cur, tot_max); - } - drawLine_both(canvas, 1, ((j*shift) + j-1)); + switch (count) { + case 1: + info_shift = 14; + shift = 33; + break; + case 2: + info_shift = 5; + break; + case 3: + info_shift = 2; + shift = 10; + break; + default: + info_shift = 1; + break; } - if ((!all) || (info_cycle == screen_type)) { - char extension[16]; - tmpstr[0] = '\0'; - for (j = 0; j < count; j++) { - sprintf(extension, format_bottom, j + 1, probes[j].cur); - if (j) { - strcat(tmpstr, "| "); - } - strcat(tmpstr, extension); + g15r_clearScreen(canvas, G15_COLOR_WHITE); + print_vert_label(canvas, vert_label); + + int bar_top, bar_bottom; + bar_bottom = BAR_BOTTOM; + for (j = 0; j < count; j++) { + bar_top = (j * shift) + 1 + j; + bar_bottom = ((j + 1)*shift) + j; + + sprintf(tmpstr, format_main, j + 1, probes[j].cur); + g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, bar_top + info_shift); + drawBar_both(canvas, bar_top, bar_bottom, probes[j].cur + 1, tot_max, tot_max - probes[j].cur, tot_max); + } + drawLine_both(canvas, 1, bar_bottom); + } + + if ((!all) || (info_cycle == screen_type)) { + char extension[16]; + tmpstr[0] = '\0'; + for (j = 0; j < count; j++) { + sprintf(extension, format_bottom, j + 1, probes[j].cur); + if (j) { + strcat(tmpstr, "| "); } - g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 80 - (strlen(tmpstr)*4) / 2, INFO_ROW); + strcat(tmpstr, extension); } + g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 80 - (strlen(tmpstr)*4) / 2, INFO_ROW); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cza...@us...> - 2010-02-17 11:34:20
|
Revision: 530 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=530&view=rev Author: czarnyckm Date: 2010-02-17 11:34:11 +0000 (Wed, 17 Feb 2010) Log Message: ----------- - Activate the bottom info bar content rotate with the option -ir - Change bottom info bar content to the component default one - Activate variable CPUs count with the option -vc - Improve Fan bottom info Modified Paths: -------------- trunk/g15daemon-clients/g15stats/ChangeLog trunk/g15daemon-clients/g15stats/README trunk/g15daemon-clients/g15stats/configure.in trunk/g15daemon-clients/g15stats/g15stats.c Modified: trunk/g15daemon-clients/g15stats/ChangeLog =================================================================== --- trunk/g15daemon-clients/g15stats/ChangeLog 2010-02-06 18:09:38 UTC (rev 529) +++ trunk/g15daemon-clients/g15stats/ChangeLog 2010-02-17 11:34:11 UTC (rev 530) @@ -60,3 +60,8 @@ SVN 520 (1.9.2) - Disable monitoring CPUs frequencies with the option -df - Improve Summary Screen without CPUs frequencies +SVN 530 (1.9.3) +- Activate the bottom info bar content rotate with the option -ir +- Change bottom info bar content to the component default one +- Activate variable CPUs count with the option -vc +- Improve Fan bottom info Modified: trunk/g15daemon-clients/g15stats/README =================================================================== --- trunk/g15daemon-clients/g15stats/README 2010-02-06 18:09:38 UTC (rev 529) +++ trunk/g15daemon-clients/g15stats/README 2010-02-17 11:34:11 UTC (rev 530) @@ -40,6 +40,8 @@ -gt id Show temperature [id] in place of the maximal one on the Summary Screen with the option -gt id ie -gt 1 The id should point to sysfs path /sys/class/hwmon/hwmon../device/temp[id]_input -df Disable monitoring CPUs frequencies. +-ir enable the bottom info bar content rotate cycle over all available sensors +-vc The cpu cores will be calculated every time (for systems with the cpu hotplug) Usage: $> g15stats Modified: trunk/g15daemon-clients/g15stats/configure.in =================================================================== --- trunk/g15daemon-clients/g15stats/configure.in 2010-02-06 18:09:38 UTC (rev 529) +++ trunk/g15daemon-clients/g15stats/configure.in 2010-02-17 11:34:11 UTC (rev 530) @@ -1,7 +1,7 @@ -AC_INIT(g15stats,[1.1], [mla...@us...]) +AC_INIT(g15stats,[1.9.3], [mla...@us...]) PACKAGE=g15stats -VERSION=1.9.2 +VERSION=1.9.3 AC_PREFIX_DEFAULT(/usr) AC_CONFIG_AUX_DIR(config) AM_INIT_AUTOMAKE($PACKAGE, $VERSION) Modified: trunk/g15daemon-clients/g15stats/g15stats.c =================================================================== --- trunk/g15daemon-clients/g15stats/g15stats.c 2010-02-06 18:09:38 UTC (rev 529) +++ trunk/g15daemon-clients/g15stats/g15stats.c 2010-02-17 11:34:11 UTC (rev 530) @@ -15,7 +15,7 @@ along with g15daemon; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -(c) 2008-2009 Mike Lampard +(c) 2008-2010 Mike Lampard $Revision$ - $Date$ $Author$ @@ -62,7 +62,7 @@ /** Holds the mode type variable of the application running */ int mode[MAX_SCREENS]; /** Holds the sub mode type variable of the application running */ -int submode = 0; +int submode = 1; int info_cycle_timer = -1; @@ -74,6 +74,7 @@ _Bool have_fan = 1; _Bool have_bat = 1; _Bool have_nic = 0; +_Bool variable_cpu = 0; _Bool sensor_type_temp[MAX_SENSOR]; _Bool sensor_type_fan[MAX_SENSOR]; @@ -305,8 +306,7 @@ } void init_cpu_count(void) { - // initialize cpu count once - if (!ncpu) { + if ((variable_cpu) || (!ncpu)) { const glibtop_sysinfo *cpuinfo = glibtop_get_sysinfo(); if(cpuinfo->ncpu == 0) { @@ -548,7 +548,7 @@ for (core = 0; (core < ncpu) && (core < 6); core++) { sprintf(proc, "C%d ", core); strcat(tmpstr,proc); - if (ncpu < 5) { + if (ncpu < 4) { strcat(tmpstr, show_hertz(get_cpu_freq_cur(core))); } else { strcat(tmpstr, show_hertz_short(get_cpu_freq_cur(core))); @@ -1656,8 +1656,16 @@ have_freq=0; } + if(0==strncmp(argv[i],"-rc",3)||0==strncmp(argv[i],"--info-rotate",13)) { + submode = 0; + } + + if(0==strncmp(argv[i],"-vc",3)||0==strncmp(argv[i],"--variable-cpu",14)) { + variable_cpu = 1; + } + if(0==strncmp(argv[i],"-h",2)||0==strncmp(argv[i],"--help",6)) { - printf("%s %s - (c) 2008-2009 Mike Lampard, Piotr Czarnecki\n",PACKAGE_NAME,VERSION); + printf("%s %s - (c) 2008-2010 Mike Lampard, Piotr Czarnecki\n",PACKAGE_NAME,VERSION); printf("Usage: %s [Options]\n", PACKAGE_NAME); printf("Options:\n"); printf("--daemon (-d) run in background\n"); @@ -1673,6 +1681,8 @@ "\t[id] should point to sysfs path /sys/class/hwmon/hwmon[id]/device/fan1_input\n"); printf("--net-scale-absolute (-nsa) scale net graphs against maximum speed seen.\n" "\tDefault is to scale fullsize, similar to apps like gkrellm.\n"); + printf("--info-rotate (-ir) enable the bottom info bar content rotate.\n"); + printf("--variable-cpu (-vc) the cpu cores will be calculated every time (for systems with the cpu hotplug).\n"); printf("--disable-freq (-df) disable monitoring CPUs frequencies.\n\n"); return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ane...@us...> - 2010-02-06 18:09:44
|
Revision: 529 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=529&view=rev Author: aneurysm9 Date: 2010-02-06 18:09:38 +0000 (Sat, 06 Feb 2010) Log Message: ----------- Update configure.in to check for g15font support in libg15render-1.3 Modified Paths: -------------- trunk/g15daemon-wip/configure.in Modified: trunk/g15daemon-wip/configure.in =================================================================== --- trunk/g15daemon-wip/configure.in 2010-02-05 04:38:41 UTC (rev 528) +++ trunk/g15daemon-wip/configure.in 2010-02-06 18:09:38 UTC (rev 529) @@ -21,7 +21,7 @@ # Checks for libraries. AC_CHECK_LIB([g15], [initLibG15],,AC_MSG_ERROR(["libg15 (or its devel package) not found. please install it"])) -AC_CHECK_LIB([g15render], [g15r_loadWbmpSplash],,AC_MSG_ERROR([">=libg15render-1.2 (or its devel package) not found. please install it"])) +AC_CHECK_LIB([g15render], [g15r_requestG15DefaultFont],,AC_MSG_ERROR([">=libg15render-1.3 (or its devel package) not found. please install it"])) AC_CHECK_LIB([m], [sin]) AC_CHECK_LIB([pthread], [pthread_mutex_init]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ane...@us...> - 2010-02-05 04:38:47
|
Revision: 528 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=528&view=rev Author: aneurysm9 Date: 2010-02-05 04:38:41 +0000 (Fri, 05 Feb 2010) Log Message: ----------- Bump version to prep for 1.9.5.4 release Modified Paths: -------------- trunk/g15daemon-wip/ChangeLog trunk/g15daemon-wip/configure.in trunk/g15daemon-wip/debian/changelog trunk/g15daemon-wip/rpm/g15daemon.spec Modified: trunk/g15daemon-wip/ChangeLog =================================================================== --- trunk/g15daemon-wip/ChangeLog 2010-02-01 18:52:49 UTC (rev 527) +++ trunk/g15daemon-wip/ChangeLog 2010-02-05 04:38:41 UTC (rev 528) @@ -173,6 +173,8 @@ to set the backlight level for the currently shown screen only. Default is now to disallow clients changing backlight, and to set backlight globally via the button. -SVN: +1.9.5.4: - Bugfix: Clock plugin can now be disabled. - \ No newline at end of file +- Bugfix: g15_send_cmd() can now be used without needing to call g15_send() + first +- Bugfix: Fix event queue issue with G-keys and newer versions of Xorg Modified: trunk/g15daemon-wip/configure.in =================================================================== --- trunk/g15daemon-wip/configure.in 2010-02-01 18:52:49 UTC (rev 527) +++ trunk/g15daemon-wip/configure.in 2010-02-05 04:38:41 UTC (rev 528) @@ -4,7 +4,7 @@ AC_PREREQ(2.59) -AC_INIT(g15daemon, [1.9.5.3], [mla...@us...]) +AC_INIT(g15daemon, [1.9.5.4], [mla...@us...]) AC_PREFIX_DEFAULT(/usr) AC_CONFIG_AUX_DIR(config) AC_CANONICAL_HOST() Modified: trunk/g15daemon-wip/debian/changelog =================================================================== --- trunk/g15daemon-wip/debian/changelog 2010-02-01 18:52:49 UTC (rev 527) +++ trunk/g15daemon-wip/debian/changelog 2010-02-05 04:38:41 UTC (rev 528) @@ -1,3 +1,12 @@ +g15daemon 1.9.5.4 karmic; urgency=low +1.9.5.4: +- Bugfix: Clock plugin can now be disabled. +- Bugfix: g15_send_cmd() can now be used without needing to call g15_send() + first +- Bugfix: Fix event queue issue with G-keys and newer versions of Xorg + + -- Anthony Mirabella <ane...@us...> Thu, 04 Feb 2010 22:39:55 -0500 + g15daemon 1.9.5.3 edgy; urgency=low * BugFix: plugins/g15daemon_net.c: ensure that OOB traffic is not mixed with normal image buffers. Modified: trunk/g15daemon-wip/rpm/g15daemon.spec =================================================================== --- trunk/g15daemon-wip/rpm/g15daemon.spec 2010-02-01 18:52:49 UTC (rev 527) +++ trunk/g15daemon-wip/rpm/g15daemon.spec 2010-02-05 04:38:41 UTC (rev 528) @@ -3,11 +3,11 @@ %define prefix /usr Summary: Daemon to control logitech G15 keyboards Name: g15daemon -Version: 1.9.5.3 +Version: 1.9.5.4 Release: 1 License: GPL Group: Applications/System -Source: ftp://prdownloads.sf.net/g15daemon-1.9.5.3.tar.bz2 +Source: ftp://prdownloads.sf.net/g15daemon-1.9.5.4.tar.bz2 URL: http://g15daemon.sf.net Distribution: Linux Vendor: NONE This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-02-01 18:52:55
|
Revision: 527 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=527&view=rev Author: steelside Date: 2010-02-01 18:52:49 +0000 (Mon, 01 Feb 2010) Log Message: ----------- Applied patch ( http://www.g15tools.com/forum/viewtopic.php?f=4&t=314 ) to have g-keys working on systems running a newer version of xorg. Modified Paths: -------------- trunk/g15daemon-wip/plugins/g15_plugin_uinput.c Modified: trunk/g15daemon-wip/plugins/g15_plugin_uinput.c =================================================================== --- trunk/g15daemon-wip/plugins/g15_plugin_uinput.c 2010-01-30 14:24:53 UTC (rev 526) +++ trunk/g15daemon-wip/plugins/g15_plugin_uinput.c 2010-02-01 18:52:49 UTC (rev 527) @@ -125,6 +125,14 @@ event.value = G15KEY_DOWN; write (uinp_fd, &event, sizeof(event)); + + /* Need to write sync event */ + memset(&event, 0, sizeof(event)); + event.type = EV_SYN; + event.code = SYN_REPORT; + event.value = 0; + write(uinp_fd, &event, sizeof(event)); + } static void g15_uinput_keyup(unsigned char code) @@ -137,6 +145,13 @@ event.value = G15KEY_UP; write (uinp_fd, &event, sizeof(event)); + + /* Need to write sync event */ + memset(&event, 0, sizeof(event)); + event.type = EV_SYN; + event.code = SYN_REPORT; + event.value = 0; + write(uinp_fd, &event, sizeof(event)); } void (*keyup)(unsigned char code) = &g15_uinput_keyup; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-01-30 14:25:00
|
Revision: 526 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=526&view=rev Author: steelside Date: 2010-01-30 14:24:53 +0000 (Sat, 30 Jan 2010) Log Message: ----------- The bug about needing a g15_send before g15_send_cmd should be fixed. Modified Paths: -------------- trunk/g15daemon-wip/plugins/g15_plugin_net.c Modified: trunk/g15daemon-wip/plugins/g15_plugin_net.c =================================================================== --- trunk/g15daemon-wip/plugins/g15_plugin_net.c 2010-01-24 13:38:22 UTC (rev 525) +++ trunk/g15daemon-wip/plugins/g15_plugin_net.c 2010-01-30 14:24:53 UTC (rev 526) @@ -16,9 +16,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA (c) 2006-2008 Mike Lampard, Philip Lawatsch, and others - + $Revision$ - $Date$ $Author$ - + This daemon listens on localhost port 15550 for client connections, and arbitrates LCD display. Allows for multiple simultaneous clients. Client screens can be cycled through by pressing the 'L1' key. @@ -86,7 +86,7 @@ pthread_mutex_unlock(&lcdlist_mutex); send(sock,msgbuf,1,MSG_OOB); break; - } + } case CLIENT_CMD_IS_USER_SELECTED: { /* client wants to know if it was set to foreground by the user */ pthread_mutex_lock(&lcdlist_mutex); if(lcdnode->lcd->usr_foreground==1) /* user manually selected this lcd */ @@ -96,39 +96,39 @@ pthread_mutex_unlock(&lcdlist_mutex); send(sock,msgbuf,1,MSG_OOB); break; - } + } default: - if(msgbuf[0] & CLIENT_CMD_MKEY_LIGHTS) + if(msgbuf[0] & CLIENT_CMD_MKEY_LIGHTS) { /* client wants to change the M-key backlights */ lcdnode->lcd->mkey_state = msgbuf[0]-0x20; lcdnode->lcd->state_changed = 1; //if the client is the keyhandler, allow full, direct control over the mled status if(lcdnode->lcd->masterlist->remote_keyhandler_sock==lcdnode->lcd->connection) setLEDs(msgbuf[0]-0x20); - } else if (msgbuf[0] & CLIENT_CMD_KEY_HANDLER) - { + } else if (msgbuf[0] & CLIENT_CMD_KEY_HANDLER) + { g15daemon_log(LOG_WARNING, "Client is taking over keystate"); - + lcdnode->list->remote_keyhandler_sock = sock; g15daemon_log(LOG_WARNING, "Client has taken over keystate"); } - else if (msgbuf[0] & CLIENT_CMD_BACKLIGHT) + else if (msgbuf[0] & CLIENT_CMD_BACKLIGHT) { unsigned char retval = lcdnode->lcd->backlight_state; send(sock,&retval,1,MSG_OOB); lcdnode->lcd->backlight_state = msgbuf[0]-0x80; lcdnode->lcd->state_changed = 1; } - else if (msgbuf[0] & CLIENT_CMD_KB_BACKLIGHT) + else if (msgbuf[0] & CLIENT_CMD_KB_BACKLIGHT) { setKBBrightness((unsigned int)msgbuf[0]-0x8); } - else if (msgbuf[0] & CLIENT_CMD_CONTRAST) - { + else if (msgbuf[0] & CLIENT_CMD_CONTRAST) + { send(sock,&lcdnode->lcd->contrast_state,1,MSG_OOB); lcdnode->lcd->contrast_state = msgbuf[0]-0x40; lcdnode->lcd->state_changed = 1; - } + } } } @@ -138,7 +138,7 @@ int yes=1; int tos = 0x18; - struct sockaddr_in servaddr; + struct sockaddr_in servaddr; if ((listening_socket = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) { g15daemon_log(LOG_WARNING, "Unable to create socket.\n"); @@ -147,7 +147,7 @@ setsockopt(listening_socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)); setsockopt(listening_socket, SOL_SOCKET, SO_PRIORITY, &tos, sizeof(tos)); - + memset(&servaddr, 0, sizeof(servaddr)); servaddr.sin_family = AF_INET; inet_aton (LISTEN_ADDR, &servaddr.sin_addr); @@ -173,7 +173,7 @@ int retval = 0; int bytesleft = len; struct pollfd pfd[1]; - + while(total < len && !leaving) { memset(pfd,0,sizeof(pfd)); pfd[0].fd = sock; @@ -181,8 +181,8 @@ if(poll(pfd,1,500)>0) { if(pfd[0].revents & POLLOUT && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)) { retval = send(sock, buf+total, bytesleft, 0); - if (retval == -1) { - break; + if (retval == -1) { + break; } bytesleft -= retval; total += retval; @@ -194,55 +194,90 @@ } } return retval==-1?-1:0; -} +} static int g15_recv(lcdnode_t *lcdnode, int sock, char *buf, unsigned int len) { - int total = 0; - int retval = 0; - int msgret = 0; - int bytesleft = len; - struct pollfd pfd[1]; - unsigned int msgbuf[20]; + int total = 0; + int retval = 0; + int msgret = 0; + int bytesleft = len; + struct pollfd pfd[1]; + unsigned int msgbuf[20]; - while(total < len && !leaving) { - memset(pfd,0,sizeof(pfd)); - pfd[0].fd = sock; - pfd[0].events = POLLIN | POLLPRI | POLLERR | POLLHUP | POLLNVAL; - if(poll(pfd,1,500)>0){ - if(pfd[0].revents & POLLPRI && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)) { /* receive out-of-band request from client and deal with it */ - memset(msgbuf,0,20); - msgret = recv(sock, msgbuf, 10 , MSG_OOB); - if (msgret < 1) { - break; - } - process_client_cmds(lcdnode, sock, msgbuf,len); - } - else if(pfd[0].revents & POLLIN && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL || pfd[0].revents & POLLPRI)) { + int flags = 0; + flags = fcntl(sock,F_GETFL,0); + if (fcntl(sock, F_SETFL, flags | O_NONBLOCK) <0 ) + { + g15daemon_log(LOG_ERR,"Unable to set lcd-client socket to nonblocking. Light updates might need a screencontent update to go through."); + } + while(total < len && !leaving) { + memset(pfd,0,sizeof(pfd)); + pfd[0].fd = sock; + pfd[0].events = POLLIN | POLLPRI | POLLERR | POLLHUP | POLLNVAL; + if(poll(pfd,1,500)>0) + { + if(pfd[0].revents & POLLPRI && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)) + { + /* receive out-of-band request from client and deal with it */ + memset(msgbuf,0,20); + g15daemon_log(LOG_INFO, "Receiving OOB dataupdate."); + msgret = recv(sock, msgbuf, 10 , MSG_OOB); + g15daemon_log(LOG_INFO, "Received OOB dataupdate."); + if (msgret < 1) + { + break; + } + process_client_cmds(lcdnode, sock, msgbuf,len); + } + else if(pfd[0].revents & POLLIN && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL || pfd[0].revents & POLLPRI)) + { - retval = recv(sock, buf+total, bytesleft, 0); - if (retval < 1) { - break; - } - total += retval; - bytesleft -= retval; - } - if((pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)){ - retval=-1; - break; - } - } - } - return total; -} + g15daemon_log(LOG_INFO, "Receiving normal dataupdate."); + retval = recv(sock, buf+total, bytesleft, 0); + g15daemon_log(LOG_INFO, "Received normal dataupdate."); + if (retval == 0) + { + break; + } + else if (retval == -1) + { + if ( !(errno == EAGAIN || errno == EWOULDBLOCK) ) + { + g15daemon_log(LOG_ERR,"Socket error in recv: %s", strerror(errno)); + break; + } + continue; + } + total += retval; + bytesleft -= retval; + } + if((pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)) + { + // Should not happen due to polling + // But read should also not have been called when there is no data + // Which it got on my machine after an upgrade, and likely on others + if ( !(errno == EAGAIN || errno == EWOULDBLOCK) ) + { + g15daemon_log(LOG_ERR,"Socket error in poll: %s", strerror(errno)); + retval=-1; + break; + } + } + } + } + return total; +} + + /* the client must send 6880 bytes for each lcd screen. This thread will continue to copy data -* into the clients LCD buffer for as long as the connection remains open. +* into the clients LCD buffer for as long as the connection remains open. * so, the client should open a socket, check to ensure that the server is a g15daemon, -* and send multiple 6880 byte packets (1 for each screen update) -* once the client disconnects by closing the socket, the LCD buffer is +* and send multiple 6880 byte packets (1 for each screen update) +* once the client disconnects by closing the socket, the LCD buffer is * removed and will no longer be displayed. */ static void *lcd_client_thread(void *display) { @@ -255,7 +290,7 @@ int client_sock = client_lcd->connection; char helo[]=SERV_HELO; unsigned char *tmpbuf=g15daemon_xmalloc(6880); - + if(g15_send(client_sock, (char*)helo, strlen(SERV_HELO))<0){ goto exitthread; } @@ -271,7 +306,7 @@ break; } pthread_mutex_lock(&lcdlist_mutex); - memset(client_lcd->buf,0,1024); + memset(client_lcd->buf,0,1024); g15daemon_convert_buf(client_lcd,tmpbuf); g15daemon_send_refresh(client_lcd); pthread_mutex_unlock(&lcdlist_mutex); @@ -309,7 +344,7 @@ if(buflen>860){ /* grab the remainder of the image and discard excess bytes */ /* retval=g15_recv(client_sock,(char*)tmpbuf+865,buflen-860); */ - retval=g15_recv(g15node, client_sock,NULL,buflen-860); + retval=g15_recv(g15node, client_sock,NULL,buflen-860); buflen = 860; } @@ -328,7 +363,7 @@ close(client_sock); free(tmpbuf); g15daemon_lcdnode_remove(display); - + pthread_exit(NULL); } @@ -380,7 +415,7 @@ return 0; } -/* this thread only listens for new connections. +/* this thread only listens for new connections. * sockserver_accept will spawn a new thread for each connected client */ static void lcdserver_thread(void *lcdlist){ @@ -413,7 +448,7 @@ { case G15_EVENT_KEYPRESS:{ if(lcd->connection && lcd->masterlist->remote_keyhandler_sock!=lcd->connection) { /* server client */ - if((send(lcd->connection,(void *)&event->value,sizeof(event->value),0))<0) + if((send(lcd->connection,(void *)&event->value,sizeof(event->value),0))<0) g15daemon_log(LOG_WARNING,"Error in send: %s\n",strerror(errno)); } break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-01-24 13:38:29
|
Revision: 525 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=525&view=rev Author: steelside Date: 2010-01-24 13:38:22 +0000 (Sun, 24 Jan 2010) Log Message: ----------- Reverted last changes. Worked in an outdated tree (oops). Modified Paths: -------------- trunk/g15daemon/g15daemon/g15_net.c trunk/g15daemon/g15daemon/linked_lists.c trunk/g15daemon/g15daemon/main.c trunk/g15daemon/g15daemon/utility_funcs.c Modified: trunk/g15daemon/g15daemon/g15_net.c =================================================================== --- trunk/g15daemon/g15daemon/g15_net.c 2010-01-23 18:53:46 UTC (rev 524) +++ trunk/g15daemon/g15daemon/g15_net.c 2010-01-24 13:38:22 UTC (rev 525) @@ -16,9 +16,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA (c) 2006-2007 Mike Lampard, Philip Lawatsch, and others - + $Revision$ - $Date$ $Author$ - + This daemon listens on localhost port 15550 for client connections, and arbitrates LCD display. Allows for multiple simultaneous clients. Client screens can be cycled through by pressing the 'L1' key. @@ -32,9 +32,7 @@ #include <arpa/inet.h> #include <unistd.h> #include <pthread.h> -#include <fcntl.h> - #include <errno.h> #include <libg15.h> #include "g15daemon.h" @@ -53,7 +51,7 @@ int msgret; if(current_key_state){ /* send the keystate inband back to the client */ - if((msgret = send(sock,(void *)¤t_key_state,sizeof(current_key_state),0))<0) + if((msgret = send(sock,(void *)¤t_key_state,sizeof(current_key_state),0))<0) daemon_log(LOG_WARNING,"Error in send: %s\n",strerror(errno)); current_key_state = 0; } @@ -62,11 +60,11 @@ static void process_client_cmds(lcdnode_t *lcdnode, int sock, unsigned int *msgbuf, unsigned int len) { int msgret; - if(msgbuf[0] == CLIENT_CMD_GET_KEYSTATE) + if(msgbuf[0] == CLIENT_CMD_GET_KEYSTATE) { /* client wants keypresses */ if(lcdnode->list->current == lcdnode){ /* send the keystate inband back to the client */ - if((msgret = send(sock,(void *)¤t_key_state,sizeof(current_key_state),0))<0) + if((msgret = send(sock,(void *)¤t_key_state,sizeof(current_key_state),0))<0) daemon_log(LOG_WARNING,"Error in send: %s\n",strerror(errno)); current_key_state = 0; } @@ -74,7 +72,7 @@ memset(msgbuf,0,4); /* client isn't currently being displayed.. tell them nothing */ msgret=send(sock,(void *)msgbuf,sizeof(current_key_state),0); } - } else if(msgbuf[0] == CLIENT_CMD_SWITCH_PRIORITIES) + } else if(msgbuf[0] == CLIENT_CMD_SWITCH_PRIORITIES) { /* client wants to switch priorities */ pthread_mutex_lock(&lcdlist_mutex); if(lcdnode->list->current != lcdnode){ @@ -94,7 +92,7 @@ } } pthread_mutex_unlock(&lcdlist_mutex); - } else if(msgbuf[0] == CLIENT_CMD_IS_FOREGROUND) + } else if(msgbuf[0] == CLIENT_CMD_IS_FOREGROUND) { /* client wants to know if it's currently viewable */ pthread_mutex_lock(&lcdlist_mutex); if(lcdnode->list->current == lcdnode){ @@ -104,7 +102,7 @@ } pthread_mutex_unlock(&lcdlist_mutex); send(sock,msgbuf,1,0); - } else if (msgbuf[0] == CLIENT_CMD_IS_USER_SELECTED) + } else if (msgbuf[0] == CLIENT_CMD_IS_USER_SELECTED) { /* client wants to know if it was set to foreground by the user */ pthread_mutex_lock(&lcdlist_mutex); if(lcdnode->lcd->usr_foreground) /* user manually selected this lcd */ @@ -113,32 +111,29 @@ msgbuf[0] = '0'; pthread_mutex_unlock(&lcdlist_mutex); send(sock,msgbuf,1,0); - } else if (msgbuf[0] & CLIENT_CMD_BACKLIGHT) + } else if (msgbuf[0] & CLIENT_CMD_BACKLIGHT) { /* client wants to change the backlight */ lcdnode->lcd->backlight_state = msgbuf[0]-0x80; - daemon_log(LOG_INFO,"CLIENT_CMD_BACKLIGHT. state_changed=1"); lcdnode->lcd->state_changed = 1; - } else if (msgbuf[0] & CLIENT_CMD_CONTRAST) + } else if (msgbuf[0] & CLIENT_CMD_CONTRAST) { /* client wants to change the LCD contrast */ lcdnode->lcd->contrast_state = msgbuf[0]-0x40; - daemon_log(LOG_INFO,"CLIENT_CMD_CONTRAST. state_changed=1"); lcdnode->lcd->state_changed = 1; - } else if (msgbuf[0] & CLIENT_CMD_MKEY_LIGHTS) + } else if (msgbuf[0] & CLIENT_CMD_MKEY_LIGHTS) { /* client wants to change the M-key backlights */ lcdnode->lcd->mkey_state = msgbuf[0]-0x20; - daemon_log(LOG_INFO,"CLIENT_CMD_MKEY_LIGHTS. state_changed=1"); lcdnode->lcd->state_changed = 1; - } else if (msgbuf[0] & CLIENT_CMD_KEY_HANDLER) + } else if (msgbuf[0] & CLIENT_CMD_KEY_HANDLER) { /* client wants to take control of the G&M keys */ daemon_log(LOG_WARNING, "Client is taking over keystate"); - - client_handles_keys=1; + + client_handles_keys=1; keyhandler = &lcdnode->lcd; keyhandler->connection = sock; - + daemon_log(LOG_WARNING, "Client has taken over keystate"); } - + } /* create and open a socket for listening */ @@ -147,7 +142,7 @@ int yes=1; int tos = 0x18; - struct sockaddr_in servaddr; + struct sockaddr_in servaddr; if ((listening_socket = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) { daemon_log(LOG_WARNING, "Unable to create socket.\n"); @@ -156,7 +151,7 @@ setsockopt(listening_socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)); setsockopt(listening_socket, SOL_SOCKET, SO_PRIORITY, &tos, sizeof(tos)); - + memset(&servaddr, 0, sizeof(servaddr)); servaddr.sin_family = AF_INET; inet_aton (LISTEN_ADDR, &servaddr.sin_addr); @@ -182,7 +177,7 @@ int retval = 0; int bytesleft = len; struct pollfd pfd[1]; - + while(total < len && !leaving) { memset(pfd,0,sizeof(pfd)); pfd[0].fd = sock; @@ -190,8 +185,8 @@ if(poll(pfd,1,500)>0) { if(pfd[0].revents & POLLOUT && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)) { retval = send(sock, buf+total, bytesleft, 0); - if (retval == -1) { - break; + if (retval == -1) { + break; } bytesleft -= retval; total += retval; @@ -203,7 +198,7 @@ } } return retval==-1?-1:0; -} +} int g15_recv(lcdnode_t *lcdnode, int sock, char *buf, unsigned int len) @@ -211,75 +206,37 @@ int total = 0; int retval = 0; int msgret = 0; - int bytesleft = len; + int bytesleft = len; struct pollfd pfd[1]; unsigned int msgbuf[20]; - int pollresult = 0; - int flags; - flags = fcntl(sock,F_GETFL,0); - fcntl(sock, F_SETFL, flags | O_NONBLOCK); - while(total < len && !leaving) { memset(pfd,0,sizeof(pfd)); - pfd[0].fd = sock; pfd[0].events = POLLIN | POLLPRI | POLLERR | POLLHUP | POLLNVAL; - daemon_log(LOG_INFO,"loop: g15_recv"); - pollresult = poll(pfd,1,500); - if(pollresult > 0) - { - daemon_log(LOG_INFO, "Polling socket"); - if(pfd[0].revents & POLLPRI && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)) - { /* receive out-of-band request from client and deal with it */ - daemon_log(LOG_INFO,"Reading OOB data"); + if(poll(pfd,1,500)>0){ + if(pfd[0].revents & POLLPRI && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)) { /* receive out-of-band request from client and deal with it */ memset(msgbuf,0,20); - msgret = recv(sock, msgbuf, 20 , MSG_OOB); - daemon_log(LOG_INFO,"Read OOB data"); - if (msgret < 1) - { - daemon_log(LOG_INFO,"Breaking due to low returnvalue from recv()"); + msgret = recv(sock, msgbuf, 10 , MSG_OOB); + if (msgret < 1) { break; } - daemon_log(LOG_INFO,"Processing commands"); - process_client_cmds(lcdnode, sock, msgbuf,len); - daemon_log(LOG_INFO,"Processed commands"); + process_client_cmds(lcdnode, sock, msgbuf,len); } - else if(pfd[0].revents & POLLIN && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL || pfd[0].revents & POLLPRI)) - { - daemon_log(LOG_INFO,"Reading normal data"); + else if(pfd[0].revents & POLLIN && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)) { + retval = recv(sock, buf+total, bytesleft, 0); - daemon_log(LOG_INFO,"Reading normal data finished"); - if (retval == 0) - { - break; + if (retval < 1) { + break; } - else if (retval == -1) - continue; - - total += retval; - bytesleft -= retval; - } - if((pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)) - { - daemon_log(LOG_ERR,"Socket error: %s", strerror(errno)); - // Due to polling the above should never occur! - if (errno != EAGAIN) - { - retval=-1; - break; - } - } - daemon_log(LOG_INFO,"Total: %i. len: %i. Leaving: %i %i",total,len,leaving, (total < len)); - } - else if (pollresult == 0) - { - daemon_log(LOG_INFO, "Polling timeout"); - } - else - { - daemon_log(LOG_INFO,"Poll: %i", pollresult); - } + total += retval; + bytesleft -= retval; + } + if((pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)){ + retval=-1; + break; + } + } } return total; -} +} Modified: trunk/g15daemon/g15daemon/linked_lists.c =================================================================== --- trunk/g15daemon/g15daemon/linked_lists.c 2010-01-23 18:53:46 UTC (rev 524) +++ trunk/g15daemon/g15daemon/linked_lists.c 2010-01-24 13:38:22 UTC (rev 525) @@ -14,11 +14,11 @@ You should have received a copy of the GNU General Public License along with g15daemon; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + (c) 2006-2007 Mike Lampard, Philip Lawatsch, and others $Revision$ - $Date$ $Author$ - + This daemon listens on localhost port 15550 for client connections, and arbitrates LCD display. Allows for multiple simultaneous clients. Client screens can be cycled through by pressing the 'L1' key. @@ -39,11 +39,11 @@ lcd->max_x = LCD_WIDTH; lcd->max_y = LCD_HEIGHT; lcd->backlight_state = G15_BRIGHTNESS_MEDIUM; - lcd->mkey_state = 0; + lcd->mkey_state = G15_LED_MR; lcd->contrast_state = G15_CONTRAST_MEDIUM; lcd->state_changed = 1; - lcd->usr_foreground = 0; - + lcd->usr_foreground = 0; + return (lcd); } @@ -54,67 +54,67 @@ /* initialise a new displaylist, and add an initial node at the tail (used for the clock) */ lcdlist_t *lcdlist_init () { - + lcdlist_t *displaylist = NULL; - + pthread_mutex_init(&lcdlist_mutex, NULL); pthread_mutex_lock(&lcdlist_mutex); - + displaylist = g15_xmalloc(sizeof(lcdlist_t)); - + displaylist->head = g15_xmalloc(sizeof(lcdnode_t)); - + displaylist->tail = displaylist->head; displaylist->current = displaylist->head; - + displaylist->head->lcd = create_lcd(); displaylist->head->lcd->mkey_state = 0; - + displaylist->head->prev = displaylist->head; displaylist->head->next = displaylist->head; displaylist->head->list = displaylist; - + pthread_mutex_unlock(&lcdlist_mutex); return displaylist; } lcdnode_t *lcdnode_add(lcdlist_t **display_list) { - + lcdnode_t *new = NULL; - + pthread_mutex_lock(&lcdlist_mutex); - + new = g15_xmalloc(sizeof(lcdnode_t)); new->prev = (*display_list)->head; - new->next = (*display_list)->tail; + new->next = (*display_list)->tail; new->lcd = create_lcd(); new->last_priority = NULL; - + (*display_list)->head->next=new; (*display_list)->current = new; - + (*display_list)->head = new; (*display_list)->head->list = *display_list; - + pthread_mutex_unlock(&lcdlist_mutex); - + return new; } void lcdnode_remove (lcdnode_t *oldnode) { - + lcdlist_t **display_list = NULL; lcdnode_t **prev = NULL; lcdnode_t **next = NULL; - + pthread_mutex_lock(&lcdlist_mutex); - + display_list = &oldnode->list; prev = &oldnode->prev; next = &oldnode->next; - + quit_lcd(oldnode->lcd); - + if((*display_list)->current == oldnode) { if((*display_list)->current!=(*display_list)->head){ (*display_list)->current = oldnode->next; @@ -123,13 +123,13 @@ } (*display_list)->current->lcd->state_changed = 1; } - + if(&oldnode->lcd == keyhandler) { client_handles_keys = 0; keyhandler = NULL; daemon_log(LOG_WARNING,"Client key handler quit, going back to defaults"); } - + if((*display_list)->head!=oldnode){ (*next)->prev = oldnode->prev; (*prev)->next = oldnode->next; @@ -139,23 +139,23 @@ } free(oldnode); - + pthread_mutex_unlock(&lcdlist_mutex); } void lcdlist_destroy(lcdlist_t **displaylist) { - + int i = 0; - + while ((*displaylist)->head != (*displaylist)->tail) { i++; lcdnode_remove((*displaylist)->head); } - + free((*displaylist)->tail->lcd); free((*displaylist)->tail); free(*displaylist); - + pthread_mutex_destroy(&lcdlist_mutex); } Modified: trunk/g15daemon/g15daemon/main.c =================================================================== --- trunk/g15daemon/g15daemon/main.c 2010-01-23 18:53:46 UTC (rev 524) +++ trunk/g15daemon/g15daemon/main.c 2010-01-24 13:38:22 UTC (rev 525) @@ -14,11 +14,11 @@ You should have received a copy of the GNU General Public License along with g15daemon; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + (c) 2006-2007 Mike Lampard, Philip Lawatsch, and others - + $Revision$ - $Date$ $Author$ - + This daemon listens on localhost port 15550 for client connections, and arbitrates LCD display. Allows for multiple simultaneous clients. Client screens can be cycled through by pressing the 'L1' key. @@ -59,20 +59,20 @@ extern unsigned int connected_clients; static void *keyboard_watch_thread(void *lcdlist){ - + lcdlist_t *displaylist = (lcdlist_t*)(lcdlist); - + static unsigned int lastkeypresses = 0; unsigned int keypresses = 0; int retval = 0; current_key_state = 0; - + while (!leaving) { - + pthread_mutex_lock(&g15lib_mutex); retval = getPressedKeys(&keypresses, 40); pthread_mutex_unlock(&g15lib_mutex); - + if(retval == G15_NO_ERROR){ if(keypresses != lastkeypresses){ current_key_state = keypresses; @@ -82,22 +82,15 @@ lastkeypresses = keypresses; } } - if(retval == -ENODEV && LIBG15_VERSION>=1200) - { - pthread_mutex_lock(&g15lib_mutex); - while((retval=re_initLibG15() != G15_NO_ERROR) && !leaving) - { - daemon_log(LOG_ERR,"Keyboard went away! retrying..."); - sleep(1); - } - if(!leaving) - { - displaylist->current->lcd->state_changed=1; - daemon_log(LOG_INFO,"keyboard_watch_thread. state_changed=1 and ident=random()"); - displaylist->current->lcd->ident=random(); - } - pthread_mutex_unlock(&g15lib_mutex); - } + if(retval == -ENODEV && LIBG15_VERSION>=1200) { + pthread_mutex_lock(&g15lib_mutex); + while((retval=re_initLibG15() != G15_NO_ERROR) && !leaving){ + daemon_log(LOG_ERR,"Keyboard went away! retrying..."); + sleep(1); + } + if(!leaving) { displaylist->current->lcd->state_changed=1; displaylist->current->lcd->ident=random();} + pthread_mutex_unlock(&g15lib_mutex); + } pthread_msleep(10); } @@ -108,63 +101,57 @@ lcdlist_t *displaylist = (lcdlist_t*)(lcdlist); static long int lastlcd = 1; - + lcd_t *displaying = displaylist->tail->lcd; memset(displaying->buf,0,1024); - + writePixmapToLCD(logo_data); pthread_sleep(2); - + while (!leaving) { pthread_mutex_lock(&lcdlist_mutex); - + displaying = displaylist->current->lcd; - + if(displaylist->tail == displaylist->current){ lcdclock(displaying); displaying->mkey_state = 0; } - + if(displaying->ident != lastlcd){ - daemon_log(LOG_INFO,"ident changed is true, updating LCD contents"); write_buf_to_g15(displaying); lastlcd = displaying->ident; } - + if(displaying->state_changed ){ - daemon_log(LOG_INFO,"state_changed is true, updating all LEDs and LCD"); setLCDContrast(displaying->contrast_state); -// if(connected_clients) -// { -// displaying->mkey_state = displaying->mkey_state | G15_LED_MR; -// daemon_log(LOG_INFO,"Adding G15_LED_MR to LEDS shown."); -// } + if(connected_clients) + displaying->mkey_state = displaying->mkey_state | G15_LED_MR; setLEDs(displaying->mkey_state); setLCDBrightness(displaying->backlight_state); displaying->state_changed = 0; - daemon_log(LOG_INFO,"Done updating. state_changed=0"); } - + pthread_mutex_unlock(&lcdlist_mutex); - + pthread_msleep(100); } return NULL; } -/* this thread only listens for new connections. +/* this thread only listens for new connections. * sockserver_accept will spawn a new thread for each connected client */ static void *lcdserver_thread(void *lcdlist){ lcdlist_t *displaylist = (lcdlist_t*) lcdlist ; int g15_socket=-1; - + if((g15_socket = init_sockserver())<0){ daemon_log(LOG_ERR,"Unable to initialise the server at port %i",LISTEN_PORT); return NULL; } - + if (fcntl(g15_socket, F_SETFL, O_NONBLOCK) <0 ) { daemon_log(LOG_ERR,"Unable to set socket to nonblocking"); } @@ -172,7 +159,7 @@ while ( !leaving ) { g15_clientconnect(&displaylist,g15_socket); } - + close(g15_socket); return NULL; } @@ -184,22 +171,22 @@ int retval; int i; int g15daemon_debug = 0; - + pthread_t keyboard_thread; pthread_t lcd_thread; pthread_t server_thread; - daemon_pid_file_ident = - daemon_log_ident = + daemon_pid_file_ident = + daemon_log_ident = daemon_ident_from_argv0(argv[0]); - + for (i=0;i<argc;i++) { char daemonargs[20]; memset(daemonargs,0,20); strncpy(daemonargs,argv[i],19); if (!strncmp(daemonargs, "-k",2) || !strncmp(daemonargs, "--kill",6)) { -#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE +#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE if ((retval = daemon_pid_file_kill_wait(SIGINT, 15)) != 0) #else if ((retval = daemon_pid_file_kill(SIGINT)) != 0) @@ -208,7 +195,7 @@ return retval < 0 ? 1 : 0; } if (!strncmp(daemonargs, "-K",2) || !strncmp(daemonargs, "--KILL",6)) { -#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE +#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE if ((retval = daemon_pid_file_kill_wait(SIGUSR1, 15)) != 0) #else if ((retval = daemon_pid_file_kill(SIGUSR1)) != 0) @@ -221,8 +208,8 @@ printf("G15Daemon version %s - %s\n",VERSION,daemon_pid_file_is_running() >= 0 ?"Loaded & Running":"Not Running"); printf("compiled with libg15 version %.3f\n\n",lg15ver/1000); exit(0); - } - + } + if (!strncmp(daemonargs, "-h",2) || !strncmp(daemonargs, "--help",6)) { printf("G15Daemon version %s - %s\n",VERSION,daemon_pid_file_is_running() >= 0 ?"Loaded & Running":"Not Running"); printf("%s -h (--help) or -k (--kill) or -s (--switch) or -d (--debug) or -v (--version)\n\n -k will kill a previous incarnation",argv[0]); @@ -242,9 +229,6 @@ cycle_key = G15_KEY_MR; } -// Uncomment when debugging if you want L1 as switch key (which I think is the only sane option) -// cycle_key = G15_KEY_L1; - if (!strncmp(daemonargs, "-d",2) || !strncmp(daemonargs, "--debug",7)) { g15daemon_debug = 1; if((argv[i+1])!=NULL) @@ -269,7 +253,7 @@ return 1; } } - + if (daemonpid && !g15daemon_debug){ retval=0; char * g15_errors[] = { "No Error", @@ -277,13 +261,13 @@ "Unable to initialise keyboard", "Unable to configure the linux kernel UINPUT driver", "Unable to register signal handler", - "Unable to create new keyboard thread", + "Unable to create new keyboard thread", "Unable to create new display thread", "Unable to create server thread", #ifdef OSTYPE_DARWIN "Unable to load USB shield kext", "Unable to launch kextload", -#endif +#endif NULL }; if((retval = daemon_retval_wait(20)) !=0) { if(retval) @@ -292,9 +276,9 @@ daemon_log(LOG_ERR,"A library error occurred. Please file a bug report stating the g15daemon version, your kernel version, libdaemon version and your distribution name."); return 255; } - + return retval; - + }else{ /* daemonised now */ int fd; @@ -302,13 +286,13 @@ lcdlist_t *lcdlist; pthread_attr_t attr; struct passwd *nobody; - int disable_kb_backlight_onexit = 0; - + int disable_kb_backlight_onexit = 0; + nobody = getpwnam("nobody"); - + if(daemon_pid_file_create() !=0){ daemon_log(LOG_ERR,"Unable to create PID File! Exiting"); - daemon_retval_send(1); + daemon_retval_send(1); goto exitnow; } @@ -317,10 +301,10 @@ libg15Debug(g15daemon_debug); #ifdef OSTYPE_DARWIN - + /* OS X: load codeless kext */ retval = system("/sbin/kextload " "/System/Library/Extensions/libusbshield.kext"); - + if (WIFEXITED(retval)){ if (WEXITSTATUS(retval) !=0){ daemon_log(LOG_ERR,"Unable to load USB shield kext"); @@ -339,9 +323,9 @@ goto exitnow; } - setLCDContrast(1); + setLCDContrast(1); setLEDs(0); - setLCDBrightness(1); + setLCDBrightness(1); #ifdef LIBG15_VERSION #if LIBG15_VERSION >= 1200 setKBBrightness(1); @@ -358,7 +342,7 @@ daemon_retval_send(3); goto exitnow; } - + if(daemon_signal_init(SIGINT,SIGQUIT,SIGHUP,SIGPIPE,SIGUSR1,0) <0){ daemon_log(LOG_ERR,"Unable to register signal handler. Exiting"); daemon_retval_send(4); @@ -382,7 +366,7 @@ daemon_retval_send(5); goto exitnow; } - pthread_attr_setstacksize(&attr,128*1024); + pthread_attr_setstacksize(&attr,128*1024); if (pthread_create(&lcd_thread, &attr, lcd_draw_thread, lcdlist) != 0) { daemon_log(LOG_ERR,"Unable to create display thread. Exiting"); @@ -399,14 +383,14 @@ daemon_log(LOG_INFO,"%s loaded\n",PACKAGE_STRING); FD_ZERO(&fds); FD_SET(fd=daemon_signal_fd(),&fds); - + do { fd_set myfds = fds; if(select(FD_SETSIZE,&myfds,0,0,0) <0){ if(errno == EINTR) continue; break; } - + if(FD_ISSET(fd,&fds)){ int sig; sig = daemon_signal_next(); @@ -423,7 +407,7 @@ } } } while ( leaving == 0 ); - + daemon_signal_done(); pthread_join(server_thread,NULL); pthread_join(lcd_thread,NULL); @@ -433,7 +417,7 @@ memset(blank,0,G15_BUFFER_LEN); writePixmapToLCD(blank); free(blank); - setLCDBrightness(0); + setLCDBrightness(0); #ifdef LIBG15_VERSION #if LIBG15_VERSION >= 1200 if(disable_kb_backlight_onexit) @@ -446,7 +430,7 @@ #endif #ifdef LIBG15_VERSION #if LIBG15_VERSION >= 1100 - exitLibG15(); + exitLibG15(); #endif #endif lcdlist_destroy(&lcdlist); Modified: trunk/g15daemon/g15daemon/utility_funcs.c =================================================================== --- trunk/g15daemon/g15daemon/utility_funcs.c 2010-01-23 18:53:46 UTC (rev 524) +++ trunk/g15daemon/g15daemon/utility_funcs.c 2010-01-24 13:38:22 UTC (rev 525) @@ -14,11 +14,11 @@ You should have received a copy of the GNU General Public License along with g15daemon; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + (c) 2006-2007 Mike Lampard, Philip Lawatsch, and others $Revision$ - $Date$ $Author$ - + This daemon listens on localhost port 15550 for client connections, and arbitrates LCD display. Allows for multiple simultaneous clients. Client screens can be cycled through by pressing the 'L1' key. @@ -58,8 +58,8 @@ #endif void g15_process_keys(lcdlist_t *displaylist, unsigned int currentkeys, unsigned int lastkeys){ + - /* 'G' keys */ if(!client_handles_keys) { if((currentkeys & G15_KEY_G1) && !(lastkeys & G15_KEY_G1)) @@ -191,7 +191,7 @@ displaylist->current = displaylist->head; else displaylist->current = displaylist->current->prev; - } + } while (current_screen != displaylist->current); if(displaylist->tail == displaylist->current) { displaylist->current = displaylist->head; @@ -200,20 +200,19 @@ } displaylist->current->lcd->usr_foreground = 1; displaylist->current->lcd->state_changed = 1; - daemon_log(LOG_INFO,"L1 pressed. state_changed=1 for current->lcd"); displaylist->current->last_priority = displaylist->current; pthread_mutex_unlock(&lcdlist_mutex); } } - + /* 'L' keys... */ - if(cycle_key!=G15_KEY_L1) { + if(cycle_key!=G15_KEY_L1) { if((currentkeys & G15_KEY_L1) && !(lastkeys & G15_KEY_L1)) keydown(LKEY_OFFSET); else if(!(currentkeys & G15_KEY_L1) && (lastkeys & G15_KEY_L1)) keyup(LKEY_OFFSET); } - + if((currentkeys & G15_KEY_L2) && !(lastkeys & G15_KEY_L2)) keydown(LKEY_OFFSET+1); else if(!(currentkeys & G15_KEY_L2) && (lastkeys & G15_KEY_L2)) @@ -258,8 +257,8 @@ for(y=0;y<43;y++) setpixel(lcd,x,y,orig_buf[x+(y*160)]); } + - /* wrap the libg15 function */ void write_buf_to_g15(lcd_t *lcd) { @@ -292,7 +291,7 @@ /* millisecond sleep routine. */ int pthread_msleep(int milliseconds) { - + struct timespec timeout; if(milliseconds>999) milliseconds=999; @@ -310,25 +309,25 @@ int narrows=0; int totalwidth=0; char buf[10]; - + time_t currtime = time(NULL); - - if(lcd->ident < currtime - 60) { + + if(lcd->ident < currtime - 60) { memset(lcd->buf,0,1024); memset(buf,0,10); strftime(buf,6,"%H:%M",localtime(&currtime)); - if(buf[0]==49) + if(buf[0]==49) narrows=1; - len = strlen(buf); + len = strlen(buf); if(narrows) totalwidth=(len*20)+(15); else totalwidth=len*20; - for (col=0;col<len;col++) + for (col=0;col<len;col++) { draw_bignum (lcd, (80-(totalwidth)/2)+col*20, 1,(80-(totalwidth)/2)+(col+1)*20, LCD_HEIGHT, BLACK, buf[col]); @@ -339,10 +338,10 @@ /* the client must send 6880 bytes for each lcd screen. This thread will continue to copy data -* into the clients LCD buffer for as long as the connection remains open. +* into the clients LCD buffer for as long as the connection remains open. * so, the client should open a socket, check to ensure that the server is a g15daemon, -* and send multiple 6880 byte packets (1 for each screen update) -* once the client disconnects by closing the socket, the LCD buffer is +* and send multiple 6880 byte packets (1 for each screen update) +* once the client disconnects by closing the socket, the LCD buffer is * removed and will no longer be displayed. */ void *lcd_client_thread(void *display) { @@ -356,15 +355,11 @@ int client_sock = client_lcd->connection; char helo[]=SERV_HELO; unsigned char *tmpbuf=g15_xmalloc(6880); - -// if(!connected_clients) -// { -// daemon_log(LOG_INFO,"Seting LEDs to MR"); -// setLEDs(G15_LED_MR); /* -// turn on the MR backlight to show that it's now being used for lcd-switching */ -// } + + if(!connected_clients) + setLEDs(G15_LED_MR); /* turn on the MR backlight to show that it's now being used for lcd-switching */ connected_clients++; - + if(g15_send(client_sock, (char*)helo, strlen(SERV_HELO))<0){ goto exitthread; } @@ -380,7 +375,7 @@ break; } pthread_mutex_lock(&lcdlist_mutex); - memset(client_lcd->buf,0,1024); + memset(client_lcd->buf,0,1024); convert_buf(client_lcd,tmpbuf); client_lcd->ident = random(); pthread_mutex_unlock(&lcdlist_mutex); @@ -388,12 +383,8 @@ } else if (tmpbuf[0]=='R') { /* libg15render buffer */ while(!leaving) { - daemon_log(LOG_INFO,"loop: libg15render lcd thread"); retval = g15_recv(g15node, client_sock, (char *)tmpbuf, 1048); - daemon_log(LOG_INFO,"loop: libg15render lcd thread2"); - if(retval != 1048) - { - daemon_log(LOG_INFO,"libg15render lcd thread exiting"); + if(retval != 1048) { break; } pthread_mutex_lock(&lcdlist_mutex); @@ -417,18 +408,18 @@ height = tmpbuf[3]; header = 4; } - + buflen = (width/8)*height; if(buflen>860){ /* grab the remainder of the image and discard excess bytes */ /* retval=g15_recv(client_sock,(char*)tmpbuf+865,buflen-860); */ - retval=g15_recv(g15node, client_sock,NULL,buflen-860); + retval=g15_recv(g15node, client_sock,NULL,buflen-860); buflen = 860; } - + if(width!=160) /* FIXME - we ought to scale images I suppose */ goto exitthread; - + pthread_mutex_lock(&lcdlist_mutex); memcpy(client_lcd->buf,tmpbuf+header,buflen+header); client_lcd->ident = random(); @@ -487,7 +478,7 @@ } } - + pthread_detach(client_connection); } return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-01-23 18:53:52
|
Revision: 524 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=524&view=rev Author: steelside Date: 2010-01-23 18:53:46 +0000 (Sat, 23 Jan 2010) Log Message: ----------- The bug about needing a g15_send before g15_send_cmd should be fixed. This commit has alot of debugprints (kdevelop + gdb + this project = no go) which will be removed later. Also, the MR key will not light up by default no longer, and will only activate if told to. Modified Paths: -------------- trunk/g15daemon/g15daemon/g15_net.c trunk/g15daemon/g15daemon/linked_lists.c trunk/g15daemon/g15daemon/main.c trunk/g15daemon/g15daemon/utility_funcs.c Modified: trunk/g15daemon/g15daemon/g15_net.c =================================================================== --- trunk/g15daemon/g15daemon/g15_net.c 2009-10-17 22:22:46 UTC (rev 523) +++ trunk/g15daemon/g15daemon/g15_net.c 2010-01-23 18:53:46 UTC (rev 524) @@ -16,9 +16,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA (c) 2006-2007 Mike Lampard, Philip Lawatsch, and others - + $Revision$ - $Date$ $Author$ - + This daemon listens on localhost port 15550 for client connections, and arbitrates LCD display. Allows for multiple simultaneous clients. Client screens can be cycled through by pressing the 'L1' key. @@ -32,7 +32,9 @@ #include <arpa/inet.h> #include <unistd.h> #include <pthread.h> +#include <fcntl.h> + #include <errno.h> #include <libg15.h> #include "g15daemon.h" @@ -51,7 +53,7 @@ int msgret; if(current_key_state){ /* send the keystate inband back to the client */ - if((msgret = send(sock,(void *)¤t_key_state,sizeof(current_key_state),0))<0) + if((msgret = send(sock,(void *)¤t_key_state,sizeof(current_key_state),0))<0) daemon_log(LOG_WARNING,"Error in send: %s\n",strerror(errno)); current_key_state = 0; } @@ -60,11 +62,11 @@ static void process_client_cmds(lcdnode_t *lcdnode, int sock, unsigned int *msgbuf, unsigned int len) { int msgret; - if(msgbuf[0] == CLIENT_CMD_GET_KEYSTATE) + if(msgbuf[0] == CLIENT_CMD_GET_KEYSTATE) { /* client wants keypresses */ if(lcdnode->list->current == lcdnode){ /* send the keystate inband back to the client */ - if((msgret = send(sock,(void *)¤t_key_state,sizeof(current_key_state),0))<0) + if((msgret = send(sock,(void *)¤t_key_state,sizeof(current_key_state),0))<0) daemon_log(LOG_WARNING,"Error in send: %s\n",strerror(errno)); current_key_state = 0; } @@ -72,7 +74,7 @@ memset(msgbuf,0,4); /* client isn't currently being displayed.. tell them nothing */ msgret=send(sock,(void *)msgbuf,sizeof(current_key_state),0); } - } else if(msgbuf[0] == CLIENT_CMD_SWITCH_PRIORITIES) + } else if(msgbuf[0] == CLIENT_CMD_SWITCH_PRIORITIES) { /* client wants to switch priorities */ pthread_mutex_lock(&lcdlist_mutex); if(lcdnode->list->current != lcdnode){ @@ -92,7 +94,7 @@ } } pthread_mutex_unlock(&lcdlist_mutex); - } else if(msgbuf[0] == CLIENT_CMD_IS_FOREGROUND) + } else if(msgbuf[0] == CLIENT_CMD_IS_FOREGROUND) { /* client wants to know if it's currently viewable */ pthread_mutex_lock(&lcdlist_mutex); if(lcdnode->list->current == lcdnode){ @@ -102,7 +104,7 @@ } pthread_mutex_unlock(&lcdlist_mutex); send(sock,msgbuf,1,0); - } else if (msgbuf[0] == CLIENT_CMD_IS_USER_SELECTED) + } else if (msgbuf[0] == CLIENT_CMD_IS_USER_SELECTED) { /* client wants to know if it was set to foreground by the user */ pthread_mutex_lock(&lcdlist_mutex); if(lcdnode->lcd->usr_foreground) /* user manually selected this lcd */ @@ -111,29 +113,32 @@ msgbuf[0] = '0'; pthread_mutex_unlock(&lcdlist_mutex); send(sock,msgbuf,1,0); - } else if (msgbuf[0] & CLIENT_CMD_BACKLIGHT) + } else if (msgbuf[0] & CLIENT_CMD_BACKLIGHT) { /* client wants to change the backlight */ lcdnode->lcd->backlight_state = msgbuf[0]-0x80; + daemon_log(LOG_INFO,"CLIENT_CMD_BACKLIGHT. state_changed=1"); lcdnode->lcd->state_changed = 1; - } else if (msgbuf[0] & CLIENT_CMD_CONTRAST) + } else if (msgbuf[0] & CLIENT_CMD_CONTRAST) { /* client wants to change the LCD contrast */ lcdnode->lcd->contrast_state = msgbuf[0]-0x40; + daemon_log(LOG_INFO,"CLIENT_CMD_CONTRAST. state_changed=1"); lcdnode->lcd->state_changed = 1; - } else if (msgbuf[0] & CLIENT_CMD_MKEY_LIGHTS) + } else if (msgbuf[0] & CLIENT_CMD_MKEY_LIGHTS) { /* client wants to change the M-key backlights */ lcdnode->lcd->mkey_state = msgbuf[0]-0x20; + daemon_log(LOG_INFO,"CLIENT_CMD_MKEY_LIGHTS. state_changed=1"); lcdnode->lcd->state_changed = 1; - } else if (msgbuf[0] & CLIENT_CMD_KEY_HANDLER) + } else if (msgbuf[0] & CLIENT_CMD_KEY_HANDLER) { /* client wants to take control of the G&M keys */ daemon_log(LOG_WARNING, "Client is taking over keystate"); - - client_handles_keys=1; + + client_handles_keys=1; keyhandler = &lcdnode->lcd; keyhandler->connection = sock; - + daemon_log(LOG_WARNING, "Client has taken over keystate"); } - + } /* create and open a socket for listening */ @@ -142,7 +147,7 @@ int yes=1; int tos = 0x18; - struct sockaddr_in servaddr; + struct sockaddr_in servaddr; if ((listening_socket = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) { daemon_log(LOG_WARNING, "Unable to create socket.\n"); @@ -151,7 +156,7 @@ setsockopt(listening_socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)); setsockopt(listening_socket, SOL_SOCKET, SO_PRIORITY, &tos, sizeof(tos)); - + memset(&servaddr, 0, sizeof(servaddr)); servaddr.sin_family = AF_INET; inet_aton (LISTEN_ADDR, &servaddr.sin_addr); @@ -177,7 +182,7 @@ int retval = 0; int bytesleft = len; struct pollfd pfd[1]; - + while(total < len && !leaving) { memset(pfd,0,sizeof(pfd)); pfd[0].fd = sock; @@ -185,8 +190,8 @@ if(poll(pfd,1,500)>0) { if(pfd[0].revents & POLLOUT && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)) { retval = send(sock, buf+total, bytesleft, 0); - if (retval == -1) { - break; + if (retval == -1) { + break; } bytesleft -= retval; total += retval; @@ -198,7 +203,7 @@ } } return retval==-1?-1:0; -} +} int g15_recv(lcdnode_t *lcdnode, int sock, char *buf, unsigned int len) @@ -206,37 +211,75 @@ int total = 0; int retval = 0; int msgret = 0; - int bytesleft = len; + int bytesleft = len; struct pollfd pfd[1]; unsigned int msgbuf[20]; + int pollresult = 0; + int flags; + flags = fcntl(sock,F_GETFL,0); + fcntl(sock, F_SETFL, flags | O_NONBLOCK); + while(total < len && !leaving) { memset(pfd,0,sizeof(pfd)); + pfd[0].fd = sock; pfd[0].events = POLLIN | POLLPRI | POLLERR | POLLHUP | POLLNVAL; - if(poll(pfd,1,500)>0){ - if(pfd[0].revents & POLLPRI && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)) { /* receive out-of-band request from client and deal with it */ + daemon_log(LOG_INFO,"loop: g15_recv"); + pollresult = poll(pfd,1,500); + if(pollresult > 0) + { + daemon_log(LOG_INFO, "Polling socket"); + if(pfd[0].revents & POLLPRI && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)) + { /* receive out-of-band request from client and deal with it */ + daemon_log(LOG_INFO,"Reading OOB data"); memset(msgbuf,0,20); - msgret = recv(sock, msgbuf, 10 , MSG_OOB); - if (msgret < 1) { + msgret = recv(sock, msgbuf, 20 , MSG_OOB); + daemon_log(LOG_INFO,"Read OOB data"); + if (msgret < 1) + { + daemon_log(LOG_INFO,"Breaking due to low returnvalue from recv()"); break; } - process_client_cmds(lcdnode, sock, msgbuf,len); + daemon_log(LOG_INFO,"Processing commands"); + process_client_cmds(lcdnode, sock, msgbuf,len); + daemon_log(LOG_INFO,"Processed commands"); } - else if(pfd[0].revents & POLLIN && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)) { - + else if(pfd[0].revents & POLLIN && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL || pfd[0].revents & POLLPRI)) + { + daemon_log(LOG_INFO,"Reading normal data"); retval = recv(sock, buf+total, bytesleft, 0); - if (retval < 1) { - break; + daemon_log(LOG_INFO,"Reading normal data finished"); + if (retval == 0) + { + break; } - total += retval; - bytesleft -= retval; - } - if((pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)){ - retval=-1; - break; - } - } + else if (retval == -1) + continue; + + total += retval; + bytesleft -= retval; + } + if((pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)) + { + daemon_log(LOG_ERR,"Socket error: %s", strerror(errno)); + // Due to polling the above should never occur! + if (errno != EAGAIN) + { + retval=-1; + break; + } + } + daemon_log(LOG_INFO,"Total: %i. len: %i. Leaving: %i %i",total,len,leaving, (total < len)); + } + else if (pollresult == 0) + { + daemon_log(LOG_INFO, "Polling timeout"); + } + else + { + daemon_log(LOG_INFO,"Poll: %i", pollresult); + } } return total; -} +} Modified: trunk/g15daemon/g15daemon/linked_lists.c =================================================================== --- trunk/g15daemon/g15daemon/linked_lists.c 2009-10-17 22:22:46 UTC (rev 523) +++ trunk/g15daemon/g15daemon/linked_lists.c 2010-01-23 18:53:46 UTC (rev 524) @@ -14,11 +14,11 @@ You should have received a copy of the GNU General Public License along with g15daemon; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + (c) 2006-2007 Mike Lampard, Philip Lawatsch, and others $Revision$ - $Date$ $Author$ - + This daemon listens on localhost port 15550 for client connections, and arbitrates LCD display. Allows for multiple simultaneous clients. Client screens can be cycled through by pressing the 'L1' key. @@ -39,11 +39,11 @@ lcd->max_x = LCD_WIDTH; lcd->max_y = LCD_HEIGHT; lcd->backlight_state = G15_BRIGHTNESS_MEDIUM; - lcd->mkey_state = G15_LED_MR; + lcd->mkey_state = 0; lcd->contrast_state = G15_CONTRAST_MEDIUM; lcd->state_changed = 1; - lcd->usr_foreground = 0; - + lcd->usr_foreground = 0; + return (lcd); } @@ -54,67 +54,67 @@ /* initialise a new displaylist, and add an initial node at the tail (used for the clock) */ lcdlist_t *lcdlist_init () { - + lcdlist_t *displaylist = NULL; - + pthread_mutex_init(&lcdlist_mutex, NULL); pthread_mutex_lock(&lcdlist_mutex); - + displaylist = g15_xmalloc(sizeof(lcdlist_t)); - + displaylist->head = g15_xmalloc(sizeof(lcdnode_t)); - + displaylist->tail = displaylist->head; displaylist->current = displaylist->head; - + displaylist->head->lcd = create_lcd(); displaylist->head->lcd->mkey_state = 0; - + displaylist->head->prev = displaylist->head; displaylist->head->next = displaylist->head; displaylist->head->list = displaylist; - + pthread_mutex_unlock(&lcdlist_mutex); return displaylist; } lcdnode_t *lcdnode_add(lcdlist_t **display_list) { - + lcdnode_t *new = NULL; - + pthread_mutex_lock(&lcdlist_mutex); - + new = g15_xmalloc(sizeof(lcdnode_t)); new->prev = (*display_list)->head; - new->next = (*display_list)->tail; + new->next = (*display_list)->tail; new->lcd = create_lcd(); new->last_priority = NULL; - + (*display_list)->head->next=new; (*display_list)->current = new; - + (*display_list)->head = new; (*display_list)->head->list = *display_list; - + pthread_mutex_unlock(&lcdlist_mutex); - + return new; } void lcdnode_remove (lcdnode_t *oldnode) { - + lcdlist_t **display_list = NULL; lcdnode_t **prev = NULL; lcdnode_t **next = NULL; - + pthread_mutex_lock(&lcdlist_mutex); - + display_list = &oldnode->list; prev = &oldnode->prev; next = &oldnode->next; - + quit_lcd(oldnode->lcd); - + if((*display_list)->current == oldnode) { if((*display_list)->current!=(*display_list)->head){ (*display_list)->current = oldnode->next; @@ -123,13 +123,13 @@ } (*display_list)->current->lcd->state_changed = 1; } - + if(&oldnode->lcd == keyhandler) { client_handles_keys = 0; keyhandler = NULL; daemon_log(LOG_WARNING,"Client key handler quit, going back to defaults"); } - + if((*display_list)->head!=oldnode){ (*next)->prev = oldnode->prev; (*prev)->next = oldnode->next; @@ -139,23 +139,23 @@ } free(oldnode); - + pthread_mutex_unlock(&lcdlist_mutex); } void lcdlist_destroy(lcdlist_t **displaylist) { - + int i = 0; - + while ((*displaylist)->head != (*displaylist)->tail) { i++; lcdnode_remove((*displaylist)->head); } - + free((*displaylist)->tail->lcd); free((*displaylist)->tail); free(*displaylist); - + pthread_mutex_destroy(&lcdlist_mutex); } Modified: trunk/g15daemon/g15daemon/main.c =================================================================== --- trunk/g15daemon/g15daemon/main.c 2009-10-17 22:22:46 UTC (rev 523) +++ trunk/g15daemon/g15daemon/main.c 2010-01-23 18:53:46 UTC (rev 524) @@ -14,11 +14,11 @@ You should have received a copy of the GNU General Public License along with g15daemon; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + (c) 2006-2007 Mike Lampard, Philip Lawatsch, and others - + $Revision$ - $Date$ $Author$ - + This daemon listens on localhost port 15550 for client connections, and arbitrates LCD display. Allows for multiple simultaneous clients. Client screens can be cycled through by pressing the 'L1' key. @@ -59,20 +59,20 @@ extern unsigned int connected_clients; static void *keyboard_watch_thread(void *lcdlist){ - + lcdlist_t *displaylist = (lcdlist_t*)(lcdlist); - + static unsigned int lastkeypresses = 0; unsigned int keypresses = 0; int retval = 0; current_key_state = 0; - + while (!leaving) { - + pthread_mutex_lock(&g15lib_mutex); retval = getPressedKeys(&keypresses, 40); pthread_mutex_unlock(&g15lib_mutex); - + if(retval == G15_NO_ERROR){ if(keypresses != lastkeypresses){ current_key_state = keypresses; @@ -82,15 +82,22 @@ lastkeypresses = keypresses; } } - if(retval == -ENODEV && LIBG15_VERSION>=1200) { - pthread_mutex_lock(&g15lib_mutex); - while((retval=re_initLibG15() != G15_NO_ERROR) && !leaving){ - daemon_log(LOG_ERR,"Keyboard went away! retrying..."); - sleep(1); - } - if(!leaving) { displaylist->current->lcd->state_changed=1; displaylist->current->lcd->ident=random();} - pthread_mutex_unlock(&g15lib_mutex); - } + if(retval == -ENODEV && LIBG15_VERSION>=1200) + { + pthread_mutex_lock(&g15lib_mutex); + while((retval=re_initLibG15() != G15_NO_ERROR) && !leaving) + { + daemon_log(LOG_ERR,"Keyboard went away! retrying..."); + sleep(1); + } + if(!leaving) + { + displaylist->current->lcd->state_changed=1; + daemon_log(LOG_INFO,"keyboard_watch_thread. state_changed=1 and ident=random()"); + displaylist->current->lcd->ident=random(); + } + pthread_mutex_unlock(&g15lib_mutex); + } pthread_msleep(10); } @@ -101,57 +108,63 @@ lcdlist_t *displaylist = (lcdlist_t*)(lcdlist); static long int lastlcd = 1; - + lcd_t *displaying = displaylist->tail->lcd; memset(displaying->buf,0,1024); - + writePixmapToLCD(logo_data); pthread_sleep(2); - + while (!leaving) { pthread_mutex_lock(&lcdlist_mutex); - + displaying = displaylist->current->lcd; - + if(displaylist->tail == displaylist->current){ lcdclock(displaying); displaying->mkey_state = 0; } - + if(displaying->ident != lastlcd){ + daemon_log(LOG_INFO,"ident changed is true, updating LCD contents"); write_buf_to_g15(displaying); lastlcd = displaying->ident; } - + if(displaying->state_changed ){ + daemon_log(LOG_INFO,"state_changed is true, updating all LEDs and LCD"); setLCDContrast(displaying->contrast_state); - if(connected_clients) - displaying->mkey_state = displaying->mkey_state | G15_LED_MR; +// if(connected_clients) +// { +// displaying->mkey_state = displaying->mkey_state | G15_LED_MR; +// daemon_log(LOG_INFO,"Adding G15_LED_MR to LEDS shown."); +// } setLEDs(displaying->mkey_state); setLCDBrightness(displaying->backlight_state); displaying->state_changed = 0; + daemon_log(LOG_INFO,"Done updating. state_changed=0"); } - + pthread_mutex_unlock(&lcdlist_mutex); - + pthread_msleep(100); } return NULL; } -/* this thread only listens for new connections. +/* this thread only listens for new connections. * sockserver_accept will spawn a new thread for each connected client */ static void *lcdserver_thread(void *lcdlist){ lcdlist_t *displaylist = (lcdlist_t*) lcdlist ; int g15_socket=-1; - + if((g15_socket = init_sockserver())<0){ daemon_log(LOG_ERR,"Unable to initialise the server at port %i",LISTEN_PORT); return NULL; } - + if (fcntl(g15_socket, F_SETFL, O_NONBLOCK) <0 ) { daemon_log(LOG_ERR,"Unable to set socket to nonblocking"); } @@ -159,7 +172,7 @@ while ( !leaving ) { g15_clientconnect(&displaylist,g15_socket); } - + close(g15_socket); return NULL; } @@ -171,22 +184,22 @@ int retval; int i; int g15daemon_debug = 0; - + pthread_t keyboard_thread; pthread_t lcd_thread; pthread_t server_thread; - daemon_pid_file_ident = - daemon_log_ident = + daemon_pid_file_ident = + daemon_log_ident = daemon_ident_from_argv0(argv[0]); - + for (i=0;i<argc;i++) { char daemonargs[20]; memset(daemonargs,0,20); strncpy(daemonargs,argv[i],19); if (!strncmp(daemonargs, "-k",2) || !strncmp(daemonargs, "--kill",6)) { -#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE +#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE if ((retval = daemon_pid_file_kill_wait(SIGINT, 15)) != 0) #else if ((retval = daemon_pid_file_kill(SIGINT)) != 0) @@ -195,7 +208,7 @@ return retval < 0 ? 1 : 0; } if (!strncmp(daemonargs, "-K",2) || !strncmp(daemonargs, "--KILL",6)) { -#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE +#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE if ((retval = daemon_pid_file_kill_wait(SIGUSR1, 15)) != 0) #else if ((retval = daemon_pid_file_kill(SIGUSR1)) != 0) @@ -208,8 +221,8 @@ printf("G15Daemon version %s - %s\n",VERSION,daemon_pid_file_is_running() >= 0 ?"Loaded & Running":"Not Running"); printf("compiled with libg15 version %.3f\n\n",lg15ver/1000); exit(0); - } - + } + if (!strncmp(daemonargs, "-h",2) || !strncmp(daemonargs, "--help",6)) { printf("G15Daemon version %s - %s\n",VERSION,daemon_pid_file_is_running() >= 0 ?"Loaded & Running":"Not Running"); printf("%s -h (--help) or -k (--kill) or -s (--switch) or -d (--debug) or -v (--version)\n\n -k will kill a previous incarnation",argv[0]); @@ -229,6 +242,9 @@ cycle_key = G15_KEY_MR; } +// Uncomment when debugging if you want L1 as switch key (which I think is the only sane option) +// cycle_key = G15_KEY_L1; + if (!strncmp(daemonargs, "-d",2) || !strncmp(daemonargs, "--debug",7)) { g15daemon_debug = 1; if((argv[i+1])!=NULL) @@ -253,7 +269,7 @@ return 1; } } - + if (daemonpid && !g15daemon_debug){ retval=0; char * g15_errors[] = { "No Error", @@ -261,13 +277,13 @@ "Unable to initialise keyboard", "Unable to configure the linux kernel UINPUT driver", "Unable to register signal handler", - "Unable to create new keyboard thread", + "Unable to create new keyboard thread", "Unable to create new display thread", "Unable to create server thread", #ifdef OSTYPE_DARWIN "Unable to load USB shield kext", "Unable to launch kextload", -#endif +#endif NULL }; if((retval = daemon_retval_wait(20)) !=0) { if(retval) @@ -276,9 +292,9 @@ daemon_log(LOG_ERR,"A library error occurred. Please file a bug report stating the g15daemon version, your kernel version, libdaemon version and your distribution name."); return 255; } - + return retval; - + }else{ /* daemonised now */ int fd; @@ -286,13 +302,13 @@ lcdlist_t *lcdlist; pthread_attr_t attr; struct passwd *nobody; - int disable_kb_backlight_onexit = 0; - + int disable_kb_backlight_onexit = 0; + nobody = getpwnam("nobody"); - + if(daemon_pid_file_create() !=0){ daemon_log(LOG_ERR,"Unable to create PID File! Exiting"); - daemon_retval_send(1); + daemon_retval_send(1); goto exitnow; } @@ -301,10 +317,10 @@ libg15Debug(g15daemon_debug); #ifdef OSTYPE_DARWIN - + /* OS X: load codeless kext */ retval = system("/sbin/kextload " "/System/Library/Extensions/libusbshield.kext"); - + if (WIFEXITED(retval)){ if (WEXITSTATUS(retval) !=0){ daemon_log(LOG_ERR,"Unable to load USB shield kext"); @@ -323,9 +339,9 @@ goto exitnow; } - setLCDContrast(1); + setLCDContrast(1); setLEDs(0); - setLCDBrightness(1); + setLCDBrightness(1); #ifdef LIBG15_VERSION #if LIBG15_VERSION >= 1200 setKBBrightness(1); @@ -342,7 +358,7 @@ daemon_retval_send(3); goto exitnow; } - + if(daemon_signal_init(SIGINT,SIGQUIT,SIGHUP,SIGPIPE,SIGUSR1,0) <0){ daemon_log(LOG_ERR,"Unable to register signal handler. Exiting"); daemon_retval_send(4); @@ -366,7 +382,7 @@ daemon_retval_send(5); goto exitnow; } - pthread_attr_setstacksize(&attr,128*1024); + pthread_attr_setstacksize(&attr,128*1024); if (pthread_create(&lcd_thread, &attr, lcd_draw_thread, lcdlist) != 0) { daemon_log(LOG_ERR,"Unable to create display thread. Exiting"); @@ -383,14 +399,14 @@ daemon_log(LOG_INFO,"%s loaded\n",PACKAGE_STRING); FD_ZERO(&fds); FD_SET(fd=daemon_signal_fd(),&fds); - + do { fd_set myfds = fds; if(select(FD_SETSIZE,&myfds,0,0,0) <0){ if(errno == EINTR) continue; break; } - + if(FD_ISSET(fd,&fds)){ int sig; sig = daemon_signal_next(); @@ -407,7 +423,7 @@ } } } while ( leaving == 0 ); - + daemon_signal_done(); pthread_join(server_thread,NULL); pthread_join(lcd_thread,NULL); @@ -417,7 +433,7 @@ memset(blank,0,G15_BUFFER_LEN); writePixmapToLCD(blank); free(blank); - setLCDBrightness(0); + setLCDBrightness(0); #ifdef LIBG15_VERSION #if LIBG15_VERSION >= 1200 if(disable_kb_backlight_onexit) @@ -430,7 +446,7 @@ #endif #ifdef LIBG15_VERSION #if LIBG15_VERSION >= 1100 - exitLibG15(); + exitLibG15(); #endif #endif lcdlist_destroy(&lcdlist); Modified: trunk/g15daemon/g15daemon/utility_funcs.c =================================================================== --- trunk/g15daemon/g15daemon/utility_funcs.c 2009-10-17 22:22:46 UTC (rev 523) +++ trunk/g15daemon/g15daemon/utility_funcs.c 2010-01-23 18:53:46 UTC (rev 524) @@ -14,11 +14,11 @@ You should have received a copy of the GNU General Public License along with g15daemon; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + (c) 2006-2007 Mike Lampard, Philip Lawatsch, and others $Revision$ - $Date$ $Author$ - + This daemon listens on localhost port 15550 for client connections, and arbitrates LCD display. Allows for multiple simultaneous clients. Client screens can be cycled through by pressing the 'L1' key. @@ -58,8 +58,8 @@ #endif void g15_process_keys(lcdlist_t *displaylist, unsigned int currentkeys, unsigned int lastkeys){ - + /* 'G' keys */ if(!client_handles_keys) { if((currentkeys & G15_KEY_G1) && !(lastkeys & G15_KEY_G1)) @@ -191,7 +191,7 @@ displaylist->current = displaylist->head; else displaylist->current = displaylist->current->prev; - } + } while (current_screen != displaylist->current); if(displaylist->tail == displaylist->current) { displaylist->current = displaylist->head; @@ -200,19 +200,20 @@ } displaylist->current->lcd->usr_foreground = 1; displaylist->current->lcd->state_changed = 1; + daemon_log(LOG_INFO,"L1 pressed. state_changed=1 for current->lcd"); displaylist->current->last_priority = displaylist->current; pthread_mutex_unlock(&lcdlist_mutex); } } - + /* 'L' keys... */ - if(cycle_key!=G15_KEY_L1) { + if(cycle_key!=G15_KEY_L1) { if((currentkeys & G15_KEY_L1) && !(lastkeys & G15_KEY_L1)) keydown(LKEY_OFFSET); else if(!(currentkeys & G15_KEY_L1) && (lastkeys & G15_KEY_L1)) keyup(LKEY_OFFSET); } - + if((currentkeys & G15_KEY_L2) && !(lastkeys & G15_KEY_L2)) keydown(LKEY_OFFSET+1); else if(!(currentkeys & G15_KEY_L2) && (lastkeys & G15_KEY_L2)) @@ -257,8 +258,8 @@ for(y=0;y<43;y++) setpixel(lcd,x,y,orig_buf[x+(y*160)]); } - + /* wrap the libg15 function */ void write_buf_to_g15(lcd_t *lcd) { @@ -291,7 +292,7 @@ /* millisecond sleep routine. */ int pthread_msleep(int milliseconds) { - + struct timespec timeout; if(milliseconds>999) milliseconds=999; @@ -309,25 +310,25 @@ int narrows=0; int totalwidth=0; char buf[10]; - + time_t currtime = time(NULL); - - if(lcd->ident < currtime - 60) { + + if(lcd->ident < currtime - 60) { memset(lcd->buf,0,1024); memset(buf,0,10); strftime(buf,6,"%H:%M",localtime(&currtime)); - if(buf[0]==49) + if(buf[0]==49) narrows=1; - len = strlen(buf); + len = strlen(buf); if(narrows) totalwidth=(len*20)+(15); else totalwidth=len*20; - for (col=0;col<len;col++) + for (col=0;col<len;col++) { draw_bignum (lcd, (80-(totalwidth)/2)+col*20, 1,(80-(totalwidth)/2)+(col+1)*20, LCD_HEIGHT, BLACK, buf[col]); @@ -338,10 +339,10 @@ /* the client must send 6880 bytes for each lcd screen. This thread will continue to copy data -* into the clients LCD buffer for as long as the connection remains open. +* into the clients LCD buffer for as long as the connection remains open. * so, the client should open a socket, check to ensure that the server is a g15daemon, -* and send multiple 6880 byte packets (1 for each screen update) -* once the client disconnects by closing the socket, the LCD buffer is +* and send multiple 6880 byte packets (1 for each screen update) +* once the client disconnects by closing the socket, the LCD buffer is * removed and will no longer be displayed. */ void *lcd_client_thread(void *display) { @@ -355,11 +356,15 @@ int client_sock = client_lcd->connection; char helo[]=SERV_HELO; unsigned char *tmpbuf=g15_xmalloc(6880); - - if(!connected_clients) - setLEDs(G15_LED_MR); /* turn on the MR backlight to show that it's now being used for lcd-switching */ + +// if(!connected_clients) +// { +// daemon_log(LOG_INFO,"Seting LEDs to MR"); +// setLEDs(G15_LED_MR); /* +// turn on the MR backlight to show that it's now being used for lcd-switching */ +// } connected_clients++; - + if(g15_send(client_sock, (char*)helo, strlen(SERV_HELO))<0){ goto exitthread; } @@ -375,7 +380,7 @@ break; } pthread_mutex_lock(&lcdlist_mutex); - memset(client_lcd->buf,0,1024); + memset(client_lcd->buf,0,1024); convert_buf(client_lcd,tmpbuf); client_lcd->ident = random(); pthread_mutex_unlock(&lcdlist_mutex); @@ -383,8 +388,12 @@ } else if (tmpbuf[0]=='R') { /* libg15render buffer */ while(!leaving) { + daemon_log(LOG_INFO,"loop: libg15render lcd thread"); retval = g15_recv(g15node, client_sock, (char *)tmpbuf, 1048); - if(retval != 1048) { + daemon_log(LOG_INFO,"loop: libg15render lcd thread2"); + if(retval != 1048) + { + daemon_log(LOG_INFO,"libg15render lcd thread exiting"); break; } pthread_mutex_lock(&lcdlist_mutex); @@ -408,18 +417,18 @@ height = tmpbuf[3]; header = 4; } - + buflen = (width/8)*height; if(buflen>860){ /* grab the remainder of the image and discard excess bytes */ /* retval=g15_recv(client_sock,(char*)tmpbuf+865,buflen-860); */ - retval=g15_recv(g15node, client_sock,NULL,buflen-860); + retval=g15_recv(g15node, client_sock,NULL,buflen-860); buflen = 860; } - + if(width!=160) /* FIXME - we ought to scale images I suppose */ goto exitthread; - + pthread_mutex_lock(&lcdlist_mutex); memcpy(client_lcd->buf,tmpbuf+header,buflen+header); client_lcd->ident = random(); @@ -478,7 +487,7 @@ } } - + pthread_detach(client_connection); } return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2009-10-17 22:22:57
|
Revision: 523 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=523&view=rev Author: steelside Date: 2009-10-17 22:22:46 +0000 (Sat, 17 Oct 2009) Log Message: ----------- Added some necessary stuff for when forking. Moved cleanup things to an own function Modified Paths: -------------- trunk/g15daemon-clients/g15macro/fileHandling.c trunk/g15daemon-clients/g15macro/g15macro.c trunk/g15daemon-clients/g15macro/g15macro.h Modified: trunk/g15daemon-clients/g15macro/fileHandling.c =================================================================== --- trunk/g15daemon-clients/g15macro/fileHandling.c 2009-10-15 15:53:54 UTC (rev 522) +++ trunk/g15daemon-clients/g15macro/fileHandling.c 2009-10-17 22:22:46 UTC (rev 523) @@ -183,6 +183,11 @@ printf("Saving macros to %s\n",filename); FILE *configfile; configfile=fopen(filename,"w"); + if (!configfile) + { + printf("Unable to open %s\n",filename); + return; + } dump_config(configfile); Modified: trunk/g15daemon-clients/g15macro/g15macro.c =================================================================== --- trunk/g15daemon-clients/g15macro/g15macro.c 2009-10-15 15:53:54 UTC (rev 522) +++ trunk/g15daemon-clients/g15macro/g15macro.c 2009-10-17 22:22:46 UTC (rev 523) @@ -31,6 +31,7 @@ #include <stdlib.h> #include <string.h> #include <sys/types.h> +#include <sys/wait.h> #include <sys/stat.h> #include <fcntl.h> #include <poll.h> @@ -146,6 +147,9 @@ unsigned int rec_index=0; +pthread_t Xkeys; +pthread_t Lkeys; + int map_gkey(keystate){ int retval = -1; switch(keystate){ @@ -261,6 +265,58 @@ } } +void cleanup() +{ + int i; + if(recording){ + recording = 0; + XUngrabKeyboard(dpy,CurrentTime); + } + + memset(configpath,0,sizeof(configpath)); + strcpy(configpath,configDir); + strncat(configpath,configs[currConfig]->configfile,sizeof(configpath)-strlen(configpath)); + save_macros(configpath); + + for (i = 0; i < MAX_CONFIGS; ++i) + { + if(configs[i]) + { + if (configs[i]->configfile) + { + free(configs[i]->configfile); + configs[i]->configfile = NULL; + } + free(configs[i]); + } + configs[i] = NULL; + } + + g15_send_cmd (g15screen_fd,G15DAEMON_MKEYLEDS,0); + + pthread_join(Xkeys,NULL); + pthread_join(Lkeys,NULL); + pthread_mutex_destroy(&x11mutex); + pthread_mutex_destroy(&config_mutex); + pthread_mutex_destroy(&gui_select); + + + /* revert the keymap to g15daemon default on exit */ + change_keymap(0); + close(g15screen_fd); + + emptyMstates(1); + free(mstates[0]); + free(mstates[1]); + free(mstates[2]); +} + +void cleanupChildren (int signal_number) +{ + int status; + wait (&status); +} + int runFile(char* file) { pid_t pid; @@ -285,7 +341,8 @@ if(execlp(file,file,NULL) == -1) { g15macro_log("Unable to execute %s\n", file); - return 1; + cleanup(); + exit(1); } } @@ -518,7 +575,8 @@ } g15macro_log("Macro Playback: for key %s\n",gkeystring[gkey]); pthread_mutex_lock(&config_mutex); - runFile(mstates[mkey_state]->gkeys[gkey].execFile); + if (mstates[mkey_state]->gkeys[gkey].execFile) + runFile(mstates[mkey_state]->gkeys[gkey].execFile); for(i=0;i<mstates[mkey_state]->gkeys[gkey].keysequence.record_steps;i++){ fake_keyevent(mstates[mkey_state]->gkeys[gkey].keysequence.recorded_keypress[i].keycode, @@ -581,6 +639,7 @@ { printf("Config file is version %i. I support up to %i. Exiting.\n",configver,G15MACRO_CONF_VER); fclose(f); + cleanup(); exit(1); } } @@ -1194,6 +1253,8 @@ printf("--help (-h) this help text\n\n"); } + + int main(int argc, char **argv) { // init vars @@ -1212,9 +1273,6 @@ gui_oldConfig = MAX_CONFIGS+1; // To make sure it will be redrawn at first was_recording = 1; - - pthread_t Xkeys; - pthread_t Lkeys; #ifdef USE_XTEST int xtest_major_version = 0; int xtest_minor_version = 0; @@ -1432,6 +1490,13 @@ sigaction(SIGPIPE, &new_action, NULL); sigaction(SIGHUP, &new_action, NULL); + // So that forked processes that die can actually die instead of going defunct. + struct sigaction act; + memset(&act,0,sizeof(act)); + act.sa_handler = &cleanupChildren; + sigaction(SIGCHLD,&act,NULL); + + snprintf((char*)splashpath,1024,"%s/%s",DATADIR,"g15macro/splash/g15macro.wbmp"); g15r_loadWbmpSplash(canvas, splashpath); g15_send(g15screen_fd,(char *)canvas->buffer,G15_BUFFER_LEN); @@ -1538,47 +1603,8 @@ }while( !leaving); g15macro_log("Leaving mainloop\n"); - if(recording){ - recording = 0; - XUngrabKeyboard(dpy,CurrentTime); - } + cleanup(); - memset(configpath,0,sizeof(configpath)); - strcpy(configpath,configDir); - strncat(configpath,configs[currConfig]->configfile,sizeof(configpath)-strlen(configpath)); - save_macros(configpath); - - for (i = 0; i < MAX_CONFIGS; ++i) - { - if(configs[i]) - { - if (configs[i]->configfile) - { - free(configs[i]->configfile); - configs[i]->configfile = NULL; - } - free(configs[i]); - } - configs[i] = NULL; - } - - g15_send_cmd (g15screen_fd,G15DAEMON_MKEYLEDS,0); - - pthread_join(Xkeys,NULL); - pthread_join(Lkeys,NULL); - pthread_mutex_destroy(&x11mutex); - pthread_mutex_destroy(&config_mutex); - pthread_mutex_destroy(&gui_select); - /* revert the keymap to g15daemon default on exit */ - change_keymap(0); - close(g15screen_fd); - - emptyMstates(1); - free(mstates[0]); - free(mstates[1]); - free(mstates[2]); - - close_and_exit: /* XCloseDisplay(dpy); */ return 0; Modified: trunk/g15daemon-clients/g15macro/g15macro.h =================================================================== --- trunk/g15daemon-clients/g15macro/g15macro.h 2009-10-15 15:53:54 UTC (rev 522) +++ trunk/g15daemon-clients/g15macro/g15macro.h 2009-10-17 22:22:46 UTC (rev 523) @@ -146,6 +146,8 @@ //g15macro.c int calc_mkey_offset(); +void change_keymap(); +void emptyMstates(int purge); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2009-10-15 15:54:02
|
Revision: 522 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=522&view=rev Author: steelside Date: 2009-10-15 15:53:54 +0000 (Thu, 15 Oct 2009) Log Message: ----------- Oops missing file. Read last commitlog for interresting stuff Added Paths: ----------- trunk/g15daemon-clients/g15macro/fileHandling.c trunk/g15daemon-clients/g15macro/g15macro.h Added: trunk/g15daemon-clients/g15macro/fileHandling.c =================================================================== --- trunk/g15daemon-clients/g15macro/fileHandling.c (rev 0) +++ trunk/g15daemon-clients/g15macro/fileHandling.c 2009-10-15 15:53:54 UTC (rev 522) @@ -0,0 +1,191 @@ +/* + This file is part of g15daemon. + + g15daemon is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + g15daemon is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with g15daemon; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + (c) 2006-2009 Mike Lampard + + $Revision: 508 $ - $Date: 2009-06-02 16:52:42 +0200 (Tue, 02 Jun 2009) $ $Author: steelside $ + + This daemon listens on localhost port 15550 for client connections, + and arbitrates LCD display. Allows for multiple simultaneous clients. + Client screens can be cycled through by pressing the 'L1' key. + + This is a macro recorder and playback utility for the G15 and g15daemon. +*/ + +#include <unistd.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <poll.h> +#include <arpa/inet.h> +#include <signal.h> +#include <pwd.h> +#include <pthread.h> +#include <sys/time.h> +#include <config.h> +#include <X11/Xlib.h> +#include <stdarg.h> +#include <math.h> +#include <ctype.h> + +#include <g15daemon_client.h> +#include <libg15.h> +#include <libg15render.h> +#include "config.h" + +#define XK_MISCELLANY +#define XK_LATIN1 +#define XK_LATIN2 +#include <X11/keysymdef.h> + +#include "g15macro.h" + +unsigned char* getConfigName(unsigned int id) +{ + if (id < 0 || id > numConfigs) + return NULL; + + if (id != 0) + return (unsigned char*)configs[id]->configfile; + else + return (unsigned char*)"Default\0"; +} + +// Various distributions have started giving +// different keycodes to the special keys +// Next 2 functions handles this +// TODO: We got alot of config files for very little info in each now.. +// Also this is most likely systemwide, but get's written for each user. +int writeKeyDefs(char *filename) +{ + FILE *f; + unsigned int i=0; + f = fopen(filename,"w"); + if(!f) + { + printf("ERROR: Unable to open keycode definition file (%s). Aborting.\n",filename); + return False; + } + fprintf(f,"#Use this file to define what keycode each key has.\n"); + fprintf(f,"#You can use the following command to get the keycodes:.\n"); + fprintf(f,"#xev | grep 'keycode' --line-buffered | grep --line-buffered -o -E 'keycode [0-9]+' | cut -d' ' -f 2\n"); + fprintf(f,"#Run the command and hit each key, remember in what order you pressed the keys,then write the number returned at the right place.\n"); + fprintf(f,"#Keep in mind; each number will appear twice.\n"); + fprintf(f,"#Format is Key:Keycode. Example: G1:138\n"); + for (i = 0;i < 18;++i) + { + fprintf(f,"G%i:%i\n",i+1,gkeycodes[i]); + } + fprintf(f,"AudioStop:%i\n",mmedia_codes[0]); + fprintf(f,"AudioPlay:%i\n",mmedia_codes[1]); + fprintf(f,"AudioPrev:%i\n",mmedia_codes[2]); + fprintf(f,"AudioNext:%i\n",mmedia_codes[3]); + fprintf(f,"AudioLowerVolume:%i\n",mmedia_codes[4]); + fprintf(f,"AudioRaiseVolume:%i\n",mmedia_codes[5]); + + fclose(f); + return True; +} +void getKeyDefs(char *filename) +{ + FILE *f = NULL; + char buf[1024]; + unsigned int key=0; +// unsigned int i=0; + unsigned int keycode=0; + + while (!f) + { + f=fopen(filename,"r"); + if (!f) + { + if (!writeKeyDefs(filename)) + return; + } + } + + printf("Reading keycodes for keys from %s\n",filename); + while (!feof(f)) + { + memset(buf,0,sizeof(buf)); + fgets(buf,sizeof(buf),f); + + // Ignore comments and blanklines + if (buf[0] == '#' || strlen(buf) == 0) + continue; + + if (sscanf(buf,"G%i:%i", &key,&keycode)){ +// printf("%i:%i\n",key,keycode); +// printf("Gkeycode%i:%i\n",key,gkeycodes[key-1]); + gkeycodes[key-1] = keycode; +// printf("Gkeycode%i:%i\n",key,gkeycodes[key-1]); + } + sscanf(buf,"AudioStop:%i",&mmedia_codes[0]); + sscanf(buf,"AudioPlay:%i",&mmedia_codes[1]); + sscanf(buf,"AudioPrev:%i",&mmedia_codes[2]); + sscanf(buf,"AudioNext:%i",&mmedia_codes[3]); + sscanf(buf,"AudioLowerVolume:%i",&mmedia_codes[4]); + sscanf(buf,"AudioRaiseVolume:%i",&mmedia_codes[5]); + } + fclose(f); +} + +/* WARNING: uses global mkey state */ +void dump_config(FILE *configfile) +{ + int i=0,gkey=0; + KeySym key; + pthread_mutex_lock(&config_mutex); + int orig_mkeystate=mkey_state; + for(mkey_state=0;mkey_state<3;mkey_state++){ + if (mkey_state > 0) + fprintf(configfile,"\n\n"); + fprintf(configfile,"Codes for MKey %i\n",mkey_state+1); + for(gkey=0;gkey<18;gkey++){ + fprintf(configfile,"Key %s:",gkeystring[gkey]); + /* if no macro has been recorded for this key, dump the g15daemon default keycode */ + if(mstates[mkey_state]->gkeys[gkey].keysequence.record_steps==0){ + int mkey_offset=0; + mkey_offset = calc_mkey_offset(); + fprintf(configfile,"\t%s\n",XKeysymToString(gkeydefaults[gkey+mkey_offset])); + }else{ + fprintf(configfile,"\n"); + for(i=0;i<mstates[mkey_state]->gkeys[gkey].keysequence.record_steps;i++){ + key = XKeycodeToKeysym(dpy,mstates[mkey_state]->gkeys[gkey].keysequence.recorded_keypress[i].keycode,0); + fprintf(configfile,"\t%s %s %u\n",XKeysymToString(key),mstates[mkey_state]->gkeys[gkey].keysequence.recorded_keypress[i].pressed?"Down":"Up",(unsigned int)mstates[mkey_state]->gkeys[gkey].keysequence.recorded_keypress[i].modifiers); + } + } + } + } + mkey_state=orig_mkeystate; + pthread_mutex_unlock(&config_mutex); +} + +void save_macros(char *filename) +{ + printf("Saving macros to %s\n",filename); + FILE *configfile; + configfile=fopen(filename,"w"); + + dump_config(configfile); + + fsync( fileno(configfile) ); + fclose(configfile); +} \ No newline at end of file Property changes on: trunk/g15daemon-clients/g15macro/fileHandling.c ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/g15daemon-clients/g15macro/g15macro.h =================================================================== --- trunk/g15daemon-clients/g15macro/g15macro.h (rev 0) +++ trunk/g15daemon-clients/g15macro/g15macro.h 2009-10-15 15:53:54 UTC (rev 522) @@ -0,0 +1,160 @@ +/* + This file is part of g15daemon. + + g15daemon is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + g15daemon is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with g15daemon; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + (c) 2006-2009 Mike Lampard + + $Revision: 508 $ - $Date: 2009-06-02 16:52:42 +0200 (Tue, 02 Jun 2009) $ $Author: steelside $ + + This daemon listens on localhost port 15550 for client connections, + and arbitrates LCD display. Allows for multiple simultaneous clients. + Client screens can be cycled through by pressing the 'L1' key. + + This is a macro recorder and playback utility for the G15 and g15daemon. +*/ + +#ifndef __G15MACRO_H__ +#define __G15MACRO_H__ +#include <unistd.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <poll.h> +#include <arpa/inet.h> +#include <signal.h> +#include <pwd.h> +#include <pthread.h> +#include <sys/time.h> +#include <config.h> +#include <X11/Xlib.h> +#include <stdarg.h> +#include <math.h> +#include <ctype.h> +#ifdef HAVE_X11_EXTENSIONS_XTEST_H +#include <X11/extensions/XTest.h> +#endif +#include <X11/XF86keysym.h> + +#include <g15daemon_client.h> +#include <libg15.h> +#include <libg15render.h> +#include "config.h" + +#define XK_MISCELLANY +#define XK_LATIN1 +#define XK_LATIN2 +#include <X11/keysymdef.h> + +#define G15MACRO_CONF_VER 2 + +int g15screen_fd; +int config_fd; +g15canvas *canvas; + +Display *dpy; +Window root_win; + +pthread_mutex_t x11mutex; +pthread_mutex_t config_mutex; +pthread_mutex_t gui_select; + +int have_xtest; +unsigned char recstring[1024]; + +typedef struct keypress_s { + unsigned long keycode; + unsigned long time_ms; + unsigned char pressed; + unsigned long modifiers; + unsigned int mouse_x; + unsigned int mouse_y; + unsigned int buttons; +}keypress_t; + +#define MAX_KEYSTEPS 1024 +typedef struct keysequence_s { + keypress_t recorded_keypress[MAX_KEYSTEPS]; + unsigned int record_steps; +} keysequence_t; + +typedef struct gkeys_s{ + unsigned int recorded; + keysequence_t keysequence; + char* execFile; +}gkeys_t; + +typedef struct mstates_s { + gkeys_t gkeys[18]; +}mstates_t; + +mstates_t *mstates[3]; + + +int mmedia_codes[6]; +const long mmedia_defaults[6]; +int gkeycodes[18]; +const char *gkeystring[19]; +const long gkeydefaults[54]; + + +// This variable = G15 keyboard version -1 +// So G15v1 == (G15Version = 0) +// G15v2 == (G15Version = 1) +int G15Version; + +char configpath[1024]; + +char configDir[1024]; +char GKeyCodeCfg[1024]; + +#define MAX_CONFIGS 32 +unsigned int numConfigs; +unsigned int currConfig; +unsigned int gui_selectConfig; + +//char *configs[MAX_CONFIGS]; // Max posible configs are 32. Too lazy to create a struct for storing dynamically. +typedef struct configs_s +{ + char *configfile; + unsigned int confver; +}configs_t; +configs_t *configs[MAX_CONFIGS]; + +unsigned int gui_oldConfig; // To make sure it will be redrawn at first +unsigned char was_recording; + +unsigned int mled_state; +int mkey_state; +int recording; + + +//g15macro.c +int calc_mkey_offset(); + + + + +//fileHandling.c +unsigned char* getConfigName(unsigned int id); +int writeKeyDefs(char *filename); +void getKeyDefs(char *filename); +void dump_config(FILE *configfile); +void save_macros(char *filename); + +#endif //__G15MACRO_H__ \ No newline at end of file Property changes on: trunk/g15daemon-clients/g15macro/g15macro.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2009-10-15 15:46:56
|
Revision: 521 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=521&view=rev Author: steelside Date: 2009-10-15 15:46:43 +0000 (Thu, 15 Oct 2009) Log Message: ----------- Added versioninfo to configuration files Started to add support for execution of files (not doing any kind of privilige dropping, if anyone knows how to do this be my guest and add it in, for now i left a warning when starting) Currently it will only parse new configurationfiles and save in the old format, but future commits will also save in the new format, so be advised if you plan on using anything older than current SVN. Modified Paths: -------------- trunk/g15daemon-clients/g15macro/Makefile.am trunk/g15daemon-clients/g15macro/g15macro.c Modified: trunk/g15daemon-clients/g15macro/Makefile.am =================================================================== --- trunk/g15daemon-clients/g15macro/Makefile.am 2009-07-22 22:24:45 UTC (rev 520) +++ trunk/g15daemon-clients/g15macro/Makefile.am 2009-10-15 15:46:43 UTC (rev 521) @@ -13,6 +13,7 @@ LIBS = -lg15daemon_client -lg15render -lX11 -lXtst IMCLUDES = -I g15macro_LDFLAGS = -avoid-version -g15macro_SOURCES = g15macro.c +g15macro_SOURCES = g15macro.c fileHandling.c +noinst_HEADERS = g15macro.h Modified: trunk/g15daemon-clients/g15macro/g15macro.c =================================================================== --- trunk/g15daemon-clients/g15macro/g15macro.c 2009-07-22 22:24:45 UTC (rev 520) +++ trunk/g15daemon-clients/g15macro/g15macro.c 2009-10-15 15:46:43 UTC (rev 521) @@ -60,160 +60,92 @@ #define XK_LATIN2 #include <X11/keysymdef.h> -int g15screen_fd; -int config_fd = 0; -g15canvas *canvas; +#include "g15macro.h" -static Display *dpy; -static Window root_win; - -pthread_mutex_t x11mutex; -pthread_mutex_t config_mutex; -pthread_mutex_t gui_select; - int leaving = 0; int display_timeout=500; -int have_xtest = False; int debug = 0; -// This variable = G15 keyboard version -1 -// So G15v1 == (G15Version = 0) -// G15v2 == (G15Version = 1) -int G15Version = 0; -char configpath[1024]; +int mmedia_codes[6] = {164, 162, 144, 153, 174, 176}; +const long mmedia_defaults[] = { + XF86XK_AudioStop, + XF86XK_AudioPlay, + XF86XK_AudioPrev, + XF86XK_AudioNext, + XF86XK_AudioLowerVolume, + XF86XK_AudioRaiseVolume +}; -char configDir[1024]; -char GKeyCodeCfg[1024]; -// Sloopppyyy :( +int gkeycodes[18] = { 177,152,190,208,129,130,231,209,210,136,220,143,246,251,137,138,133,183 }; +const char *gkeystring[19] = { "G1","G2","G3","G4","G5","G6","G7","G8","G9","G10","G11","G12","G13","G14","G15","G16","G17","G18","Unknown"}; +/* because this is an X11 client, we can work around the kernel limitations on key numbers */ +const long gkeydefaults[54] = { + /* M1 palette */ + XF86XK_Launch4, + XF86XK_Launch5, + XF86XK_Launch6, + XF86XK_Launch7, + XF86XK_Launch8, + XF86XK_Launch9, + XF86XK_LaunchA, + XF86XK_LaunchB, + XF86XK_LaunchC, + XF86XK_LaunchD, + XF86XK_LaunchE, + XF86XK_LaunchF, + XF86XK_iTouch, + XF86XK_Calculater, + XF86XK_Support, + XF86XK_Word, + XF86XK_Messenger, + XF86XK_WebCam, + /* M2 palette */ + XK_F13, + XK_F14, + XK_F15, + XK_F16, + XK_F17, + XK_F18, + XK_F19, + XK_F20, + XK_F21, + XK_F22, + XK_F23, + XK_F24, + XK_F25, + XK_F26, + XK_F27, + XK_F28, + XK_F29, + XK_F30, + /* M3 palette */ + XK_Tcedilla, + XK_racute, + XK_abreve, + XK_lacute, + XK_cacute, + XK_ccaron, + XK_eogonek, + XK_ecaron, + XK_dcaron, + XK_dstroke, + XK_nacute, + XK_ncaron, + XK_odoubleacute, + XK_udoubleacute, + XK_rcaron, + XK_uring, + XK_scaron, + XK_abovedot +}; -#define MAX_CONFIGS 32 -unsigned int numConfigs = 0; -unsigned int currConfig = 0; -unsigned int gui_selectConfig = 0; -// this is for keeping track of when to redraw -unsigned int gui_oldConfig = MAX_CONFIGS+1; // To make sure it will be redrawn at first -unsigned char was_recording = 1; - -char *configs[MAX_CONFIGS]; // Max possible configs are 32. Too lazy to create a struct for storing dynamically. - -unsigned char recstring[1024]; - -static unsigned int mled_state = G15_LED_M1; -static int mkey_state = 0; -static int recording = 0; - -typedef struct keypress_s { - unsigned long keycode; - unsigned long time_ms; - unsigned char pressed; - unsigned long modifiers; - unsigned int mouse_x; - unsigned int mouse_y; - unsigned int buttons; -}keypress_t; - - -#define MAX_KEYSTEPS 1024 - -typedef struct keysequence_s { - keypress_t recorded_keypress[MAX_KEYSTEPS]; - unsigned int record_steps; -} keysequence_t; - -typedef struct gkeys_s{ - unsigned int recorded; - keysequence_t keysequence; -}gkeys_t; - -typedef struct mstates_s { - gkeys_t gkeys[18]; -}mstates_t; - -mstates_t *mstates[3]; - struct current_recording { - keypress_t recorded_keypress[MAX_KEYSTEPS]; + keypress_t recorded_keypress[MAX_KEYSTEPS]; }current_recording; unsigned int rec_index=0; -const char *gkeystring[] = { "G1","G2","G3","G4","G5","G6","G7","G8","G9","G10","G11","G12","G13","G14","G15","G16","G17","G18","Unknown" }; - -int gkeycodes[] = { 177,152,190,208,129,130,231,209,210,136,220,143,246,251,137,138,133,183 }; - -int mmedia_codes[6] = {164, 162, 144, 153, 174, 176}; // For G15 v1 -// {174, 172, 173, 171, 122, 123} }; // For G15 v2 - -const long mmedia_defaults[] = { - XF86XK_AudioStop, - XF86XK_AudioPlay, - XF86XK_AudioPrev, - XF86XK_AudioNext, - XF86XK_AudioLowerVolume, - XF86XK_AudioRaiseVolume -}; -/* because this is an X11 client, we can work around the kernel limitations on key numbers */ -const long gkeydefaults[] = { - /* M1 palette */ - XF86XK_Launch4, - XF86XK_Launch5, - XF86XK_Launch6, - XF86XK_Launch7, - XF86XK_Launch8, - XF86XK_Launch9, - XF86XK_LaunchA, - XF86XK_LaunchB, - XF86XK_LaunchC, - XF86XK_LaunchD, - XF86XK_LaunchE, - XF86XK_LaunchF, - XF86XK_iTouch, - XF86XK_Calculater, - XF86XK_Support, - XF86XK_Word, - XF86XK_Messenger, - XF86XK_WebCam, - /* M2 palette */ - XK_F13, - XK_F14, - XK_F15, - XK_F16, - XK_F17, - XK_F18, - XK_F19, - XK_F20, - XK_F21, - XK_F22, - XK_F23, - XK_F24, - XK_F25, - XK_F26, - XK_F27, - XK_F28, - XK_F29, - XK_F30, - /* M3 palette */ - XK_Tcedilla, - XK_racute, - XK_abreve, - XK_lacute, - XK_cacute, - XK_ccaron, - XK_eogonek, - XK_ecaron, - XK_dcaron, - XK_dstroke, - XK_nacute, - XK_ncaron, - XK_odoubleacute, - XK_udoubleacute, - XK_rcaron, - XK_uring, - XK_scaron, - XK_abovedot -}; - int map_gkey(keystate){ int retval = -1; switch(keystate){ @@ -329,16 +261,39 @@ } } -unsigned char* getConfigName(unsigned int id) +int runFile(char* file) { - if (id < 0 || id > numConfigs) - return NULL; + pid_t pid; - if (id != 0) - return (unsigned char*)configs[id]; + g15macro_log("Attempting to run %s\n",file); + /* Attempt to fork and check for errors */ + if( (pid=fork()) == -1) + { + g15macro_log("Fork error\n"); + return 1; + } + + if(pid) + { + /* A positive (non-negative) PID indicates the parent process */ + g15macro_log("Successfully forked. Child is %i\n", pid); + } else - return (unsigned char*)"Default\0"; + { + /* A zero PID indicates that this is the child process */ + /* Replace the child fork with a new process */ + if(execlp(file,file,NULL) == -1) + { + g15macro_log("Unable to execute %s\n", file); + return 1; + } + } + + + return 0; } + + void renderHelp() { g15r_drawLine(canvas, G15_LCD_WIDTH-37, 16, G15_LCD_WIDTH, 16, G15_COLOR_BLACK); @@ -383,12 +338,30 @@ pthread_mutex_unlock(&gui_select); } - +void emptyMstates(int purge) +{ + int m = 0; + int g = 0; + for (m = 0; m < 3; ++m) + { + for (g = 0; g < 18; ++g) + { + if (mstates[m]->gkeys[g].execFile && purge) + { + free(mstates[m]->gkeys[g].execFile); + } + mstates[m]->gkeys[g].execFile = NULL; + } + } +} //TODO: Make it so that if logitech ever makes fewer or more m states that it could iterate. -void cleanMstates() +void cleanMstates(int purge) { pthread_mutex_lock(&config_mutex); - //TODO: Reduce memory usage + + emptyMstates(purge); + + //TODO: Reduce memory usage? //printf("Cleaning mstates. Size of mstates[0]->gkeys = %i\n",sizeof(mstates[0]->gkeys)); //Cleaning mstates. Size of mstates[0]->gkeys = 516240 //That's alot of memory for an empty set of gkeys. And about 1.5 megabyte of memory for all 3. @@ -415,128 +388,7 @@ } return mkey_offset; } -// Various distributions have started giving -// different keycodes to the special keys -// Next 2 functions handles this -// TODO: We got alot of config files for very little info in each now.. -// Also this is most likely systemwide, but get's written for each user. -int writeKeyDefs(char *filename) -{ - FILE *f; - unsigned int i=0; - f = fopen(filename,"w"); - if(!f) - { - printf("ERROR: Unable to open keycode definition file (%s). Aborting.\n",filename); - return False; - } - fprintf(f,"#Use this file to define what keycode each key has.\n"); - fprintf(f,"#You can use the following command to get the keycodes:.\n"); - fprintf(f,"#xev | grep 'keycode' --line-buffered | grep --line-buffered -o -E 'keycode [0-9]+' | cut -d' ' -f 2\n"); - fprintf(f,"#Run the command and hit each key, remember in what order you pressed the keys,then write the number returned at the right place.\n"); - fprintf(f,"#Keep in mind; each number will appear twice.\n"); - fprintf(f,"#Format is Key:Keycode. Example: G1:138\n"); - for (i = 0;i < 18;++i) - { - fprintf(f,"G%i:%i\n",i+1,gkeycodes[i]); - } - fprintf(f,"AudioStop:%i\n",mmedia_codes[0]); - fprintf(f,"AudioPlay:%i\n",mmedia_codes[1]); - fprintf(f,"AudioPrev:%i\n",mmedia_codes[2]); - fprintf(f,"AudioNext:%i\n",mmedia_codes[3]); - fprintf(f,"AudioLowerVolume:%i\n",mmedia_codes[4]); - fprintf(f,"AudioRaiseVolume:%i\n",mmedia_codes[5]); - fclose(f); - return True; -} -void getKeyDefs(char *filename) -{ - FILE *f = NULL; - char buf[1024]; - unsigned int key=0; -// unsigned int i=0; - unsigned int keycode=0; - - while (!f) - { - f=fopen(filename,"r"); - if (!f) - { - if (!writeKeyDefs(filename)) - return; - } - } - - printf("Reading keycodes for keys from %s\n",filename); - while (!feof(f)) - { - memset(buf,0,sizeof(buf)); - fgets(buf,sizeof(buf),f); - - // Ignore comments and blanklines - if (buf[0] == '#' || strlen(buf) == 0) - continue; - - if (sscanf(buf,"G%i:%i", &key,&keycode)){ -// printf("%i:%i\n",key,keycode); -// printf("Gkeycode%i:%i\n",key,gkeycodes[key-1]); - gkeycodes[key-1] = keycode; -// printf("Gkeycode%i:%i\n",key,gkeycodes[key-1]); - } - sscanf(buf,"AudioStop:%i",&mmedia_codes[0]); - sscanf(buf,"AudioPlay:%i",&mmedia_codes[1]); - sscanf(buf,"AudioPrev:%i",&mmedia_codes[2]); - sscanf(buf,"AudioNext:%i",&mmedia_codes[3]); - sscanf(buf,"AudioLowerVolume:%i",&mmedia_codes[4]); - sscanf(buf,"AudioRaiseVolume:%i",&mmedia_codes[5]); - } - fclose(f); -} - -/* WARNING: uses global mkey state */ -void dump_config(FILE *configfile) -{ - int i=0,gkey=0; - KeySym key; - pthread_mutex_lock(&config_mutex); - int orig_mkeystate=mkey_state; - for(mkey_state=0;mkey_state<3;mkey_state++){ - if (mkey_state > 0) - fprintf(configfile,"\n\n"); - fprintf(configfile,"Codes for MKey %i\n",mkey_state+1); - for(gkey=0;gkey<18;gkey++){ - fprintf(configfile,"Key %s:",gkeystring[gkey]); - /* if no macro has been recorded for this key, dump the g15daemon default keycode */ - if(mstates[mkey_state]->gkeys[gkey].keysequence.record_steps==0){ - int mkey_offset=0; - mkey_offset = calc_mkey_offset(); - fprintf(configfile,"\t%s\n",XKeysymToString(gkeydefaults[gkey+mkey_offset])); - }else{ - fprintf(configfile,"\n"); - for(i=0;i<mstates[mkey_state]->gkeys[gkey].keysequence.record_steps;i++){ - key = XKeycodeToKeysym(dpy,mstates[mkey_state]->gkeys[gkey].keysequence.recorded_keypress[i].keycode,0); - fprintf(configfile,"\t%s %s %u\n",XKeysymToString(key),mstates[mkey_state]->gkeys[gkey].keysequence.recorded_keypress[i].pressed?"Down":"Up",(unsigned int)mstates[mkey_state]->gkeys[gkey].keysequence.recorded_keypress[i].modifiers); - } - } - } - } - mkey_state=orig_mkeystate; - pthread_mutex_unlock(&config_mutex); -} - -void save_macros(char *filename) -{ - printf("Saving macros to %s\n",filename); - FILE *configfile; - configfile=fopen(filename,"w"); - - dump_config(configfile); - - fsync( fileno(configfile) ); - fclose(configfile); -} - void fake_keyevent(int keycode,int keydown,unsigned long modifiers){ if(have_xtest && !recording) { #ifdef HAVE_X11_EXTENSIONS_XTEST_H @@ -646,8 +498,11 @@ if(gkey<0) return; - /* if no macro has been recorded for this key, send the g15daemon default keycode */ - if(mstates[mkey_state]->gkeys[gkey].keysequence.record_steps==0){ + /* if no macro has been recorded for this key, + and no program set to execute, + send the g15daemon default keycode */ + if(mstates[mkey_state]->gkeys[gkey].keysequence.record_steps==0 && + mstates[mkey_state]->gkeys[gkey].execFile == NULL){ int mkey_offset=0; mkey_offset = calc_mkey_offset(); @@ -663,6 +518,7 @@ } g15macro_log("Macro Playback: for key %s\n",gkeystring[gkey]); pthread_mutex_lock(&config_mutex); + runFile(mstates[mkey_state]->gkeys[gkey].execFile); for(i=0;i<mstates[mkey_state]->gkeys[gkey].keysequence.record_steps;i++){ fake_keyevent(mstates[mkey_state]->gkeys[gkey].keysequence.recorded_keypress[i].keycode, @@ -695,23 +551,70 @@ g15macro_log("Macro Playback Complete\n"); } +int identify_configver(char *filename) +{ + FILE *f; + char tmpstring[1024]; -void restore_config(char *filename) + unsigned int configver = 0; + + f=fopen(filename,"r"); + + do + { + memset(tmpstring,0,1024); + fgets(tmpstring,1024,f); + + // We ignore parsing comments + // but next time this file is saved (like changing macro), they will be lost. + if(tmpstring[0]=='#') + continue; + + if (!configver && strncmp(tmpstring,"G15Macro config version",23) == 0) + { + sscanf(tmpstring,"G15Macro config version %i\n",&configver); + if (G15MACRO_CONF_VER >= configver) + { + printf("Using config version %i. Highest supported is %i\n",configver,G15MACRO_CONF_VER); + } + else + { + printf("Config file is version %i. I support up to %i. Exiting.\n",configver,G15MACRO_CONF_VER); + fclose(f); + exit(1); + } + } + + }while(!feof(f)); + + fclose(f); + + return configver; +} + +void restore_v1_config(char *filename) { - pthread_mutex_lock(&config_mutex); FILE *f; char tmpstring[1024]; unsigned int key=0; unsigned int mkey=0; unsigned int i=0; unsigned int keycode; + + f=fopen(filename,"r"); printf("Restoring macros from %s\n",filename); + do { memset(tmpstring,0,1024); fgets(tmpstring,1024,f); + // We ignore parsing comments + // but next time this file is saved (like changing macro), they will be lost. + if(tmpstring[0]=='#') + continue; + if(tmpstring[0]=='C'){ sscanf(tmpstring,"Codes for MKey %i\n",&mkey); mkey--; @@ -736,6 +639,94 @@ }while(!feof(f)); fclose(f); +} +void restore_v2_config(char *filename) +{ + FILE *f; + char tmpstring[1024]; + unsigned int key=0; + unsigned int mkey=0; + unsigned int i=0; + unsigned int keycode; + + f=fopen(filename,"r"); + printf("Restoring macros from version 2 config: %s\n",filename); + + do + { + memset(tmpstring,0,1024); + fgets(tmpstring,1024,f); + + // We ignore parsing comments + // but next time this file is saved (like changing macro), they will be lost. + if(tmpstring[0]=='#') + continue; + + + if(tmpstring[0]=='C'){ + sscanf(tmpstring,"Codes for MKey %i\n",&mkey); + mkey--; + i=0; + } + if(tmpstring[0]=='K'){ + sscanf(tmpstring,"Key G%i:",&key); + key--; + i=0; + } + if(tmpstring[0]=='\t') + { + char* substring = &tmpstring[1]; + if (strncmp(substring,"keypress",8) == 0) + { + char codestr[64]; + char pressed[20]; + unsigned int modifiers = 0; + sscanf(substring,"keypress %s %s %i\n",(char*)&codestr,(char*)&pressed,&modifiers); + keycode = XKeysymToKeycode(dpy,XStringToKeysym(codestr)); + mstates[mkey]->gkeys[key].keysequence.recorded_keypress[i].keycode = keycode; + mstates[mkey]->gkeys[key].keysequence.recorded_keypress[i].pressed = strncmp(pressed,"Up",2)?1:0; + mstates[mkey]->gkeys[key].keysequence.recorded_keypress[i].modifiers = modifiers; + mstates[mkey]->gkeys[key].keysequence.record_steps=++i; + } + else if (strncmp(substring,"run",3) == 0) + { + char file[1024]; + memset(&file,0,sizeof(file)); +// printf("Supposed to run from following line: %s",substring); + sscanf(substring,"run %s\n",(char*)&file); +// printf("filename: %s\n",file); + if (mstates[mkey]->gkeys[key].execFile) + { + printf("But key already has %s as file, not changing.\n",mstates[mkey]->gkeys[key].execFile); + continue; + } + mstates[mkey]->gkeys[key].execFile = malloc(strlen(file)+1); + memset(mstates[mkey]->gkeys[key].execFile,0,strlen(file)+1); + strcpy(mstates[mkey]->gkeys[key].execFile,file); +// printf("Stored filename %s\n",mstates[mkey]->gkeys[key].execFile); + } + } + }while(!feof(f)); + + fclose(f); +} + +void restore_config(char *filename) +{ + pthread_mutex_lock(&config_mutex); + unsigned int configver = 0; + configver = identify_configver(filename); + + if (configver == 0) // Original configuration + { + restore_v1_config(filename); + } + // Skipping V1 as i would call the original one for that. + else if (configver == 2) + { + restore_v2_config(filename); + } + pthread_mutex_unlock(&config_mutex); } @@ -749,18 +740,23 @@ // unsigned int numConfigs = 0; int i = 0; - // Initialize configs array + // Initialize configs array of structs for (i = 0; i < MAX_CONFIGS; ++i) { configs[i] = NULL; } - configs[0] = malloc(256); - memset(configs[0],0,sizeof(configs[0])); - strcpy(configs[0], "g15macro.conf"); + + configs[0] = malloc(sizeof(configs_t)); + + configs[0]->configfile = malloc(128); + memset(configs[0]->configfile,0,sizeof(configs[0]->configfile)); + strcpy(configs[0]->configfile, "g15macro.conf"); + configs[0]->confver = 0; currConfig = 0; - strncpy(configPath,configDir,1024); - strncat(configPath,"multipleConfigs.cfg",1024-strlen(configPath)); + printf("default: %s\n",configs[0]->configfile); + strncpy(configPath,configDir,sizeof(configPath)); + strncat(configPath,"multipleConfigs.cfg",sizeof(configPath)-strlen(configPath)); f = fopen(configPath,"r"); // File not created yet @@ -802,7 +798,7 @@ printf("Too long line found when reading in configs. Offending config name is %s\n",buf); continue; } - i = strcspn(buf,"\n"); // i returns "the length of the initial segment of buf which consists entirely of characters not in reject." + i = strcspn(buf,"\n"); // strcspn returns "the length of the initial segment of buf which consists entirely of characters not in reject." memset(cfgName,0,sizeof(cfgName)); strncpy(cfgName,buf,i); trim(cfgName); @@ -822,9 +818,11 @@ // Add it to list of availible configurations g15macro_log("Adding Config %i with length %i - name %s\n",numConfigs,(int)strlen(cfgName),cfgName); - configs[numConfigs] = malloc(strlen(cfgName)+1); //+1 for null termination - memset(configs[numConfigs],0,sizeof(configs[numConfigs])); - strcpy(configs[numConfigs],cfgName); + configs[numConfigs] = (configs_t*)malloc(sizeof(configs_t)); + configs[numConfigs]->configfile = malloc(strlen(cfgName)+1); //+1 for null termination + memset(configs[numConfigs]->configfile,0,strlen(cfgName)+1/*sizeof(configs[numConfigs]->configfile)*/); + strcpy(configs[numConfigs]->configfile,cfgName); + configs[numConfigs]->confver = 0; } fclose(f); @@ -854,7 +852,7 @@ pthread_mutex_lock(&x11mutex); for(i=0;i<6;i++){ newmap[0]=mmedia_defaults[i]; - XChangeKeyboardMapping (dpy, mmedia_codes/*[G15Version]*/[i], 1, newmap, 1); + XChangeKeyboardMapping (dpy, mmedia_codes[i], 1, newmap, 1); } XFlush(dpy); pthread_mutex_unlock(&x11mutex); @@ -957,24 +955,26 @@ char newConfig[1024]; memset(newConfig,0,sizeof(newConfig)); strcpy(newConfig,configDir); - strncat(newConfig,configs[currConfig],sizeof(newConfig)-strlen(newConfig)); + strncat(newConfig,configs[currConfig]->configfile,sizeof(newConfig)-strlen(newConfig)); // Actually not the newConfig, it's the old, but didn't come up with a good name. save_macros(newConfig); // Purge all old data - cleanMstates(); + cleanMstates(1); // Now load the new config currConfig = gui_selectConfig; memset(newConfig,0,sizeof(newConfig)); strcpy(newConfig,configDir); - strncat(newConfig,configs[currConfig],sizeof(newConfig)-strlen(newConfig)); + strncat(newConfig,configs[currConfig]->configfile,sizeof(newConfig)-strlen(newConfig)); + restore_config(newConfig); + // Set the configpath to reflect the change memset(configpath,0,sizeof(configpath)); strcpy(configpath,configDir); - strncat(configpath,configs[currConfig],sizeof(configpath)-strlen(configpath)); + strncat(configpath,configs[currConfig]->configfile,sizeof(configpath)-strlen(configpath)); gui_oldConfig = MAX_CONFIGS+1; break; @@ -1196,6 +1196,23 @@ int main(int argc, char **argv) { + // init vars + have_xtest = False; + numConfigs = 0; + currConfig = 0; + gui_selectConfig = 0; + G15Version = 0; +// mmedia_codes = {164, 162, 144, 153, 174, 176}; +// gkeycodes = { 177,152,190,208,129,130,231,209,210,136,220,143,246,251,137,138,133,183 }; + config_fd = 0; + mled_state = G15_LED_M1; + mkey_state = 0; + recording = 0; + // this is for keeping track of when to redraw + gui_oldConfig = MAX_CONFIGS+1; // To make sure it will be redrawn at first + was_recording = 1; + + pthread_t Xkeys; pthread_t Lkeys; #ifdef USE_XTEST @@ -1274,6 +1291,7 @@ else printf("Unable to run as user \"%s\" - you dont have permissions for that.\nRunning as \"%s\"\n",username->pw_name,getenv("USER")); } + printf("BEWARE: this program will run files WITHOUT dropping any kind of privilegies.\n"); } canvas = (g15canvas *) malloc (sizeof (g15canvas)); @@ -1335,7 +1353,7 @@ convert = 1; } else - cleanMstates(); + cleanMstates(0); //0 - only null pointers /* new format */ strncpy(configpath,getenv("HOME"),1024); @@ -1358,14 +1376,14 @@ { if(!configs[i]) continue; - printf("%i:%s%s\n",i,configDir,configs[i]); + printf("%i:%s%s\n",i,configDir,configs[i]->configfile); } if(!convert) { memset(configpath,0,sizeof(configpath)); strcpy(configpath,configDir); - strncat(configpath,configs[currConfig],1024-strlen(configpath)); + strncat(configpath,configs[currConfig]->configfile,1024-strlen(configpath)); restore_config(configpath); } @@ -1527,13 +1545,20 @@ memset(configpath,0,sizeof(configpath)); strcpy(configpath,configDir); - strncat(configpath,configs[currConfig],sizeof(configpath)-strlen(configpath)); + strncat(configpath,configs[currConfig]->configfile,sizeof(configpath)-strlen(configpath)); save_macros(configpath); for (i = 0; i < MAX_CONFIGS; ++i) { if(configs[i]) + { + if (configs[i]->configfile) + { + free(configs[i]->configfile); + configs[i]->configfile = NULL; + } free(configs[i]); + } configs[i] = NULL; } @@ -1548,10 +1573,12 @@ change_keymap(0); close(g15screen_fd); + emptyMstates(1); free(mstates[0]); free(mstates[1]); free(mstates[2]); + close_and_exit: /* XCloseDisplay(dpy); */ return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cza...@us...> - 2009-07-22 22:24:49
|
Revision: 520 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=520&view=rev Author: czarnyckm Date: 2009-07-22 22:24:45 +0000 (Wed, 22 Jul 2009) Log Message: ----------- - Disable monitoring CPUs frequencies with the option -df - Improve Summary Screen without CPUs frequencies Modified Paths: -------------- trunk/g15daemon-clients/g15stats/ChangeLog trunk/g15daemon-clients/g15stats/README trunk/g15daemon-clients/g15stats/configure.in trunk/g15daemon-clients/g15stats/g15stats.c Modified: trunk/g15daemon-clients/g15stats/ChangeLog =================================================================== --- trunk/g15daemon-clients/g15stats/ChangeLog 2009-07-16 22:11:49 UTC (rev 519) +++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-07-22 22:24:45 UTC (rev 520) @@ -57,3 +57,6 @@ SVN 519 - Change default mode for Freq and Summary Screen - Improve Summary Screen for cpus with more then 7 cores +SVN 520 (1.9.2) +- Disable monitoring CPUs frequencies with the option -df +- Improve Summary Screen without CPUs frequencies Modified: trunk/g15daemon-clients/g15stats/README =================================================================== --- trunk/g15daemon-clients/g15stats/README 2009-07-16 22:11:49 UTC (rev 519) +++ trunk/g15daemon-clients/g15stats/README 2009-07-22 22:24:45 UTC (rev 520) @@ -39,6 +39,7 @@ Default the sensor id is auto-detected. -gt id Show temperature [id] in place of the maximal one on the Summary Screen with the option -gt id ie -gt 1 The id should point to sysfs path /sys/class/hwmon/hwmon../device/temp[id]_input +-df Disable monitoring CPUs frequencies. Usage: $> g15stats Modified: trunk/g15daemon-clients/g15stats/configure.in =================================================================== --- trunk/g15daemon-clients/g15stats/configure.in 2009-07-16 22:11:49 UTC (rev 519) +++ trunk/g15daemon-clients/g15stats/configure.in 2009-07-22 22:24:45 UTC (rev 520) @@ -1,7 +1,7 @@ AC_INIT(g15stats,[1.1], [mla...@us...]) PACKAGE=g15stats -VERSION=1.92 +VERSION=1.9.2 AC_PREFIX_DEFAULT(/usr) AC_CONFIG_AUX_DIR(config) AM_INIT_AUTOMAKE($PACKAGE, $VERSION) Modified: trunk/g15daemon-clients/g15stats/g15stats.c =================================================================== --- trunk/g15daemon-clients/g15stats/g15stats.c 2009-07-16 22:11:49 UTC (rev 519) +++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-07-22 22:24:45 UTC (rev 520) @@ -660,8 +660,13 @@ if (summary_rows > 4){ if (shift > 7) { - y2=4; - shift=6; + if (id == 2) { + y2 = 4; + shift = 6; + } else { + y2 = 5; + shift = 7; + } } } @@ -860,8 +865,6 @@ spacer = 0; } height = 12; - - ncpumax = height; break; case SCREEN_SUMMARY : spacer = 0; @@ -893,10 +896,10 @@ shift = height + 1; shift2 = (2 * shift); - ncpumax = height; break; } + ncpumax = height; if (ncpumax < ncpu) { height = (height - ((ncpumax - 1) * spacer)) / (ncpumax); } else { @@ -1649,6 +1652,10 @@ net_scale_absolute=1; } + if(0==strncmp(argv[i],"-df",3)||0==strncmp(argv[i],"--disable-freq",14)) { + have_freq=0; + } + if(0==strncmp(argv[i],"-h",2)||0==strncmp(argv[i],"--help",6)) { printf("%s %s - (c) 2008-2009 Mike Lampard, Piotr Czarnecki\n",PACKAGE_NAME,VERSION); printf("Usage: %s [Options]\n", PACKAGE_NAME); @@ -1665,7 +1672,8 @@ printf("--fan [id] (-f) monitor fans sensor [id] ie -f 1\n" "\t[id] should point to sysfs path /sys/class/hwmon/hwmon[id]/device/fan1_input\n"); printf("--net-scale-absolute (-nsa) scale net graphs against maximum speed seen.\n" - "\tDefault is to scale fullsize, similar to apps like gkrellm.\n\n"); + "\tDefault is to scale fullsize, similar to apps like gkrellm.\n"); + printf("--disable-freq (-df) disable monitoring CPUs frequencies.\n\n"); return 0; } if(0==strncmp(argv[i],"-i",2)||0==strncmp(argv[i],"--interface",11)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cza...@us...> - 2009-07-16 22:11:56
|
Revision: 519 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=519&view=rev Author: czarnyckm Date: 2009-07-16 22:11:49 +0000 (Thu, 16 Jul 2009) Log Message: ----------- - Change default mode for Freq and Summary Screen - Improve Summary Screen for cpus with more then 7 cores Modified Paths: -------------- trunk/g15daemon-clients/g15stats/ChangeLog trunk/g15daemon-clients/g15stats/configure.in trunk/g15daemon-clients/g15stats/g15stats.c Modified: trunk/g15daemon-clients/g15stats/ChangeLog =================================================================== --- trunk/g15daemon-clients/g15stats/ChangeLog 2009-07-14 19:32:16 UTC (rev 518) +++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-07-16 22:11:49 UTC (rev 519) @@ -44,13 +44,16 @@ (the id should point to sysfs path /sys/class/hwmon/hwmon../device/temp[id]_input) - On the Fan / Temp Screen Current sensor is controlled with the L4 key (on systems with more then one sensor only). - Every Screen has his own mode now (except Swap, Memory and Battery Screen) -SVN 515: +SVN 515 (1.90): - Fixed temperature / fan sensor lost - Fixed screen cycle SVN 516: - Refactored temperature and fan speed - share the logic SVN 517: - Improve Bat Screen deactivation logic (now is it similar to SVN 515: Fixed temperature / fan sensor lost) -SVN 518: +SVN 518 (1.91): - Fix Summary, Freq and CPU Screens for some variants of the cpu cores number - Improve Summary Screen +SVN 519 +- Change default mode for Freq and Summary Screen +- Improve Summary Screen for cpus with more then 7 cores Modified: trunk/g15daemon-clients/g15stats/configure.in =================================================================== --- trunk/g15daemon-clients/g15stats/configure.in 2009-07-14 19:32:16 UTC (rev 518) +++ trunk/g15daemon-clients/g15stats/configure.in 2009-07-16 22:11:49 UTC (rev 519) @@ -1,7 +1,7 @@ AC_INIT(g15stats,[1.1], [mla...@us...]) PACKAGE=g15stats -VERSION=1.91 +VERSION=1.92 AC_PREFIX_DEFAULT(/usr) AC_CONFIG_AUX_DIR(config) AM_INIT_AUTOMAKE($PACKAGE, $VERSION) Modified: trunk/g15daemon-clients/g15stats/g15stats.c =================================================================== --- trunk/g15daemon-clients/g15stats/g15stats.c 2009-07-14 19:32:16 UTC (rev 518) +++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-07-16 22:11:49 UTC (rev 519) @@ -658,7 +658,7 @@ int cur_shift = shift * id; - if (mode[SCREEN_SUMMARY]){ + if (summary_rows > 4){ if (shift > 7) { y2=4; shift=6; @@ -789,7 +789,7 @@ sprintf(tmpstr,"CPU %3.f%%",((float)(b_total-b_idle)/(float)b_total)*100); print_label(canvas, tmpstr, 0); - } else if ((cycle == SCREEN_FREQ) && (!mode[SCREEN_FREQ]) && (have_freq)) { + } else if ((cycle == SCREEN_FREQ) && (mode[SCREEN_FREQ]) && (have_freq)) { print_vert_label(canvas, "FREQ"); } else { print_vert_label(canvas, "Idle"); @@ -865,28 +865,20 @@ break; case SCREEN_SUMMARY : spacer = 0; - if (mode[SCREEN_SUMMARY]) { + if (!mode[SCREEN_SUMMARY]) { summary_rows = 5; switch (ncpu) { case 1 : case 2 : case 3 : case 5 : + case 7 : move = 1; height = 6; - shift = 7; - shift2 = (2 * shift); break; - case 4 : + default : height = 8; - shift = 9; - shift2 = (2 * shift); break; - default : - height = 7; - shift = height; - shift2 = (2 * shift)-1; - break; } } else { summary_rows = 4; @@ -895,14 +887,12 @@ case 5 : move = 1; break; - default : - break; } height = 8; - shift = 9; - shift2 = (2 * shift); } + shift = height + 1; + shift2 = (2 * shift); ncpumax = height; break; } @@ -945,7 +935,7 @@ switch (cycle) { case SCREEN_FREQ: - if ((!mode[SCREEN_FREQ]) && (have_freq)) { + if ((mode[SCREEN_FREQ]) && (have_freq)) { freq_cur = get_cpu_freq_cur(core); if (core < 6) { result = ((float) (b_total - b_idle) / (float) b_total)*100; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cza...@us...> - 2009-07-14 19:32:26
|
Revision: 518 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=518&view=rev Author: czarnyckm Date: 2009-07-14 19:32:16 +0000 (Tue, 14 Jul 2009) Log Message: ----------- - Fix Summary, Freq and CPU Screens for some variants of the cpu cores number - Improve Summary Screen Modified Paths: -------------- trunk/g15daemon-clients/g15stats/ChangeLog trunk/g15daemon-clients/g15stats/g15stats.c Modified: trunk/g15daemon-clients/g15stats/ChangeLog =================================================================== --- trunk/g15daemon-clients/g15stats/ChangeLog 2009-07-12 10:12:21 UTC (rev 517) +++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-07-14 19:32:16 UTC (rev 518) @@ -51,3 +51,6 @@ - Refactored temperature and fan speed - share the logic SVN 517: - Improve Bat Screen deactivation logic (now is it similar to SVN 515: Fixed temperature / fan sensor lost) +SVN 518: +- Fix Summary, Freq and CPU Screens for some variants of the cpu cores number +- Improve Summary Screen Modified: trunk/g15daemon-clients/g15stats/g15stats.c =================================================================== --- trunk/g15daemon-clients/g15stats/g15stats.c 2009-07-12 10:12:21 UTC (rev 517) +++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-07-14 19:32:16 UTC (rev 518) @@ -622,27 +622,33 @@ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, cur_shift + 1); } -void draw_summary_sensors_logic(g15canvas *canvas, char *tmpstr, g15_stats_info *sensors, char *label, int y1, int y2, int cur_shift, int shift, int count, float tot_cur, float tot_max) { +void draw_summary_sensors_logic(g15canvas *canvas, char *tmpstr, g15_stats_info *sensors, + char *label, int text_shift, int y1, int y2, int move, int cur_shift, int shift, int count, float tot_cur, float tot_max) { + if (count) { int j = 0; + int rest; int step = (int) (y2 / count); + rest = y2 - (step * count); int y = cur_shift + y1; int last_y; for (j = 0; j < count; j++) { last_y = y; y += step; - drawBar_both(canvas, last_y, y, sensors[j].cur + 1, tot_max, tot_max - sensors[j].cur, tot_max); + if (rest > 0) { + rest--; + y++; + } + drawBar_both(canvas, last_y + move, y + move, sensors[j].cur + 1, tot_max, tot_max - sensors[j].cur, tot_max); } - drawLine_both(canvas, cur_shift + y1, y); + drawLine_both(canvas, cur_shift + y1 + move, y + move); sprintf(tmpstr, label, tot_cur); - print_label(canvas, tmpstr, cur_shift); - - cur_shift += shift; + print_label(canvas, tmpstr, text_shift); } } -void draw_summary_screen(g15canvas *canvas, char *tmpstr, int y1, int y2, int shift, int id) { +void draw_summary_screen(g15canvas *canvas, char *tmpstr, int y1, int y2, int move, int shift, int text_shift, int id) { // Memory section glibtop_mem mem; glibtop_get_mem(&mem); @@ -652,14 +658,21 @@ int cur_shift = shift * id; + if (mode[SCREEN_SUMMARY]){ + if (shift > 7) { + y2=4; + shift=6; + } + } + int y; int count; // Memory section sprintf(tmpstr, "MEM %3.f%%", ((float) (mem_used) / (float) mem_total)*100); - print_label(canvas, tmpstr, cur_shift); + print_label(canvas, tmpstr, text_shift * id); - drawAll_both(canvas, cur_shift + y1, cur_shift + y2, mem_used + 1, mem_total, mem_total - mem_used, mem_total); + drawAll_both(canvas, cur_shift + y1 + move, cur_shift + y2 + move, mem_used + 1, mem_total, mem_total - mem_used, mem_total); id++; cur_shift += shift; @@ -668,21 +681,18 @@ if (have_nic) { y = y2 / 2; - drawLine_both(canvas, cur_shift + y1, cur_shift + y2); - drawBar_both(canvas, cur_shift + y1, cur_shift + y, net_cur_in + 1, net_max_in, net_max_in - net_cur_in, net_max_in); + drawLine_both(canvas, cur_shift + y1 + move, cur_shift + y2 + move); + drawBar_both(canvas, cur_shift + y1 + move, cur_shift + y + move, net_cur_in + 1, net_max_in, net_max_in - net_cur_in, net_max_in); - if ((y * 2) < y2) { - y++; - } + + drawBar_both(canvas, cur_shift + y + move, cur_shift + y2 + move, net_cur_out + 1, net_max_out, net_max_out - net_cur_out, net_max_out); - drawBar_both(canvas, cur_shift + y, cur_shift + y2, net_cur_out + 1, net_max_out, net_max_out - net_cur_out, net_max_out); - if (net_cur_in > net_cur_out) { sprintf(tmpstr, "IN %s", show_bytes_short((int) net_cur_in)); } else { sprintf(tmpstr, "OUT%s", show_bytes_short((int) net_cur_out)); } - print_label(canvas, tmpstr, cur_shift); + print_label(canvas, tmpstr, text_shift * id); id++; cur_shift += shift; @@ -693,7 +703,7 @@ if ((have_temp) && (id < summary_rows)) { count = get_sensors(sensors, SCREEN_TEMP, sensor_type_temp, sensor_lost_temp, sensor_temp_id); if ((count) && (have_temp)) { - draw_summary_sensors_logic(canvas, tmpstr, sensors, "TEM %3.f\xb0", y1, y2, cur_shift, shift, count, temp_tot_cur, temp_tot_max); + draw_summary_sensors_logic(canvas, tmpstr, sensors, "TEM %3.f\xb0", text_shift * id, y1, y2, move, cur_shift, shift, count, temp_tot_cur, temp_tot_max); id++; cur_shift += shift; } @@ -703,7 +713,7 @@ if ((have_fan) && (id < summary_rows)) { count = get_sensors(sensors, SCREEN_FAN, sensor_type_fan, sensor_lost_fan, sensor_fan_id); if ((count) && (have_fan)) { - draw_summary_sensors_logic(canvas, tmpstr, sensors, "RPM%5.f", y1, y2, cur_shift, shift, count, fan_tot_cur, fan_tot_max); + draw_summary_sensors_logic(canvas, tmpstr, sensors, "RPM%5.f", text_shift * id, y1, y2, move, cur_shift, shift, count, fan_tot_cur, fan_tot_max); id++; cur_shift += shift; } @@ -719,10 +729,10 @@ int swap_used = swap.used / 1024; int swap_total = swap.total / 1024; - drawAll_both(canvas, cur_shift + y1, cur_shift + y2, swap_used, swap_total, swap_total - swap_used, swap_total); + drawAll_both(canvas, cur_shift + y1 + move, cur_shift + y2 + move, swap_used, swap_total, swap_total - swap_used, swap_total); sprintf(tmpstr, "Swp %3i%%", (unsigned int) (((float) swap_used / (float) swap_total)*100)); - print_label(canvas, tmpstr, cur_shift); + print_label(canvas, tmpstr, text_shift * id); id++; cur_shift += shift; @@ -836,7 +846,8 @@ float result; int spacer = 1; - int height = 8; + int height = 9; + int move = 0; switch (cycle) { case SCREEN_FREQ : if(ncpu > 11){ @@ -859,32 +870,37 @@ switch (ncpu) { case 1 : case 2 : + case 3 : + case 5 : + move = 1; height = 6; shift = 7; shift2 = (2 * shift); break; - case 3 : - height = 6; - shift = height; - shift2 = (2 * shift) -1; + case 4 : + height = 8; + shift = 9; + shift2 = (2 * shift); break; default : - height = 8; - shift = 7; + height = 7; + shift = height; shift2 = (2 * shift)-1; break; } } else { summary_rows = 4; - if (ncpu % 2){ - height = 9; - shift = height; - shift2 = (2 * shift)-1; - } else { - height = 9; - shift = height; - shift2 = (2 * shift); + switch (ncpu) { + case 3 : + case 5 : + move = 1; + break; + default : + break; } + height = 8; + shift = 9; + shift2 = (2 * shift); } ncpumax = height; @@ -931,7 +947,7 @@ case SCREEN_FREQ: if ((!mode[SCREEN_FREQ]) && (have_freq)) { freq_cur = get_cpu_freq_cur(core); - if (ncpu < 6) { + if (core < 6) { result = ((float) (b_total - b_idle) / (float) b_total)*100; if (result < 100.0) { sprintf(tmpstr, "%2.f%% %s", result, show_hertz_short(freq_cur)); @@ -941,7 +957,7 @@ if (ncpu < 5) { g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, y1 + 1); } else { - g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 1, y1 + 1); + g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 1, core * 6); } } freq_total = get_cpu_freq_max(core); @@ -958,7 +974,7 @@ if (ncpu < 5) { g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, y1 + 1); } else { - g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 1, y1 + 1); + g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 1, core * 6); } } current_value = b_total - b_idle; @@ -992,13 +1008,13 @@ break; case SCREEN_SUMMARY: current_value = b_total - b_idle; - drawBar_both(canvas, y1, y2, current_value, b_total, b_total - current_value, b_total); + drawBar_both(canvas, y1 + move, y2 + move, current_value, b_total, b_total - current_value, b_total); if (have_freq) { freq_cur = get_cpu_freq_cur(core); freq_total = get_cpu_freq_max(core); freq_sum = maxi(freq_sum, freq_cur); - drawBar_both(canvas, shift + y1, shift + y2, freq_cur, freq_total, freq_total - freq_cur, freq_total); + drawBar_both(canvas, shift + y1 + move, shift + y2 + move, freq_cur, freq_total, freq_total - freq_cur, freq_total); } y1 = 0; @@ -1006,18 +1022,25 @@ } } - drawLine_both(canvas, y1, y2); + drawLine_both(canvas, y1 + move, y2 + move); if (cycle == SCREEN_SUMMARY) { + int text_shift; + if (summary_rows > 4) { + text_shift = 7; + } else { + text_shift = 9; + } if (have_freq) { - drawLine_both(canvas, shift + y1, shift + y2); + drawLine_both(canvas, shift + y1 + move, shift + y2 + move); sprintf(tmpstr, "FRQ %s", show_hertz_short((int) freq_sum)); - print_label(canvas, tmpstr, shift); - draw_summary_screen(canvas, tmpstr, y1, y2, shift, 2); + print_label(canvas, tmpstr, text_shift); + + draw_summary_screen(canvas, tmpstr, y1, y2, move, shift, text_shift, 2); } else { - draw_summary_screen(canvas, tmpstr, y1, y2, shift, 1); + draw_summary_screen(canvas, tmpstr, y1, y2, move, shift, text_shift, 1); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cza...@us...> - 2009-07-12 10:12:27
|
Revision: 517 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=517&view=rev Author: czarnyckm Date: 2009-07-12 10:12:21 +0000 (Sun, 12 Jul 2009) Log Message: ----------- - Improve Bat Screen deactivation logic Modified Paths: -------------- trunk/g15daemon-clients/g15stats/ChangeLog trunk/g15daemon-clients/g15stats/g15stats.c trunk/g15daemon-clients/g15stats/g15stats.h Modified: trunk/g15daemon-clients/g15stats/ChangeLog =================================================================== --- trunk/g15daemon-clients/g15stats/ChangeLog 2009-07-11 23:17:13 UTC (rev 516) +++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-07-12 10:12:21 UTC (rev 517) @@ -49,3 +49,5 @@ - Fixed screen cycle SVN 516: - Refactored temperature and fan speed - share the logic +SVN 517: +- Improve Bat Screen deactivation logic (now is it similar to SVN 515: Fixed temperature / fan sensor lost) Modified: trunk/g15daemon-clients/g15stats/g15stats.c =================================================================== --- trunk/g15daemon-clients/g15stats/g15stats.c 2009-07-11 23:17:13 UTC (rev 516) +++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-07-12 10:12:21 UTC (rev 517) @@ -80,6 +80,7 @@ int sensor_lost_temp[MAX_SENSOR]; int sensor_lost_fan[MAX_SENSOR]; +int sensor_lost_bat = 1; int sensor_temp_id = 0; int sensor_temp_main = 0; @@ -1160,10 +1161,15 @@ } } - if (!i) { - printf("Battery sensor doesn't appear to exist. Battery screen will be disabled.\n"); - have_bat = 0; - return; + if (i) { + sensor_lost_bat = RETRY_COUNT; + } else { + sensor_lost_bat--; + if (sensor_lost_bat <= 0) { + printf("Battery sensor doesn't appear to exist. Battery screen will be disabled.\n"); + have_bat = 0; + return; + } } if (all) { @@ -1239,7 +1245,7 @@ if ((!count) || (probes[0].cur == SENSOR_ERROR)) { return; } else { - sensor_lost[sensor_id] = 10; + sensor_lost[sensor_id] = RETRY_COUNT; } int j = 0; Modified: trunk/g15daemon-clients/g15stats/g15stats.h =================================================================== --- trunk/g15daemon-clients/g15stats/g15stats.h 2009-07-11 23:17:13 UTC (rev 516) +++ trunk/g15daemon-clients/g15stats/g15stats.h 2009-07-12 10:12:21 UTC (rev 517) @@ -10,6 +10,7 @@ #define MAX_SUB_MODE 1 #define PAUSE 6 +#define RETRY_COUNT 10 #define VL_LEFT 42 #define BAR_START 45 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cza...@us...> - 2009-07-11 23:17:20
|
Revision: 516 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=516&view=rev Author: czarnyckm Date: 2009-07-11 23:17:13 +0000 (Sat, 11 Jul 2009) Log Message: ----------- - Refactored temperature and fan speed - share the logic Modified Paths: -------------- trunk/g15daemon-clients/g15stats/ChangeLog trunk/g15daemon-clients/g15stats/configure.in trunk/g15daemon-clients/g15stats/g15stats.c trunk/g15daemon-clients/g15stats/g15stats.h Modified: trunk/g15daemon-clients/g15stats/ChangeLog =================================================================== --- trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-29 22:42:13 UTC (rev 515) +++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-07-11 23:17:13 UTC (rev 516) @@ -47,3 +47,5 @@ SVN 515: - Fixed temperature / fan sensor lost - Fixed screen cycle +SVN 516: +- Refactored temperature and fan speed - share the logic Modified: trunk/g15daemon-clients/g15stats/configure.in =================================================================== --- trunk/g15daemon-clients/g15stats/configure.in 2009-06-29 22:42:13 UTC (rev 515) +++ trunk/g15daemon-clients/g15stats/configure.in 2009-07-11 23:17:13 UTC (rev 516) @@ -1,7 +1,7 @@ AC_INIT(g15stats,[1.1], [mla...@us...]) PACKAGE=g15stats -VERSION=1.90 +VERSION=1.91 AC_PREFIX_DEFAULT(/usr) AC_CONFIG_AUX_DIR(config) AM_INIT_AUTOMAKE($PACKAGE, $VERSION) Modified: trunk/g15daemon-clients/g15stats/g15stats.c =================================================================== --- trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-29 22:42:13 UTC (rev 515) +++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-07-11 23:17:13 UTC (rev 516) @@ -16,7 +16,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA (c) 2008-2009 Mike Lampard -(c) 2009 Piotr Czarnecki $Revision$ - $Date$ $Author$ @@ -348,7 +347,7 @@ ret_val = get_processor_freq("scaling_cur_freq", core); break; default: - ret_val = get_processor_freq("cpuinfo_%s_freq", core); + ret_val = get_processor_freq("cpuinfo_%d_freq", core); break; } if ((!core) && (ret_val == SENSOR_ERROR)) { @@ -379,30 +378,22 @@ return get_sysfs_value(tmpstr); } -int get_fan(char *which, int id) { - return get_hwmon(sensor_fan_id, "fan", which, id, sensor_type_fan[sensor_fan_id]); +int get_sensor_cur(int id, int screen_id) { + if (screen_id == SCREEN_TEMP) { + return get_hwmon(sensor_temp_id, "temp", "input", id, sensor_type_temp[sensor_temp_id]); + } else { + return get_hwmon(sensor_fan_id, "fan", "input", id, sensor_type_fan[sensor_fan_id]); + } } -int get_fan_cur(int id) { - return get_fan("input", id); +int get_sensor_max(int id, int screen_id) { + if (screen_id == SCREEN_TEMP) { + return get_hwmon(sensor_temp_id, "temp", "max", id, sensor_type_temp[sensor_temp_id]); + } else { + return get_hwmon(sensor_fan_id, "fan", "alarm", id, sensor_type_fan[sensor_fan_id]); + } } -int get_fan_max(int id) { - return get_fan("alarm", id); -} - -int get_temp(char *which, int id) { - return get_hwmon(sensor_temp_id, "temp", which, id, sensor_type_temp[sensor_temp_id]); -} - -int get_temp_cur(int id) { - return get_temp("input", id); -} - -int get_temp_max(int id) { - return get_temp("max", id); -} - int get_next(int sensor_id, int *sensor_lost){ int new_sensor_id; new_sensor_id = sensor_id; @@ -418,105 +409,78 @@ return SENSOR_ERROR; } -int get_temperature(g15_stats_info *temps) { +int get_sensors(g15_stats_info *sensors, int screen_id, _Bool *sensor_type, int *sensor_lost, int sensor_id) { + char label[16]; int count = 0; - temp_tot_cur = 0; - - for (count = 0; count < NUM_TEMP; count++) { - if ((temps[count].cur = get_temp_cur(count + 1)) == SENSOR_ERROR) { - break; - } - temps[count].cur /= 1000; - temps[count].max = get_temp_max(count + 1); - temps[count].max /= 1000; - if (temp_tot_max < temps[count].max) { - temp_tot_max = temps[count].max; - } - - if ((sensor_temp_main == (count +1)) || ((!sensor_temp_main) && (temp_tot_cur <temps[count].cur))) { - temp_tot_cur = temps[count].cur; - } + if (screen_id == SCREEN_TEMP) { + temp_tot_cur = 0; + sprintf(label, "Temperature"); + } else { //SCREEN_FAN + fan_tot_cur = 0; + sprintf(label, "Fan"); } - if ((!count) && (temps[0].cur == SENSOR_ERROR)) { - if (sensor_type_temp[sensor_temp_id]) { - sensor_lost_temp[sensor_temp_id]--; - if(sensor_lost_temp[sensor_temp_id] < 0) { - sensor_lost_temp[sensor_temp_id] = 0; - } - printf("Temperature sensor doesn't appear to exist with id=%d .\n", sensor_temp_id); - sensor_temp_id = get_next(sensor_temp_id, sensor_lost_temp); - if (sensor_temp_id != SENSOR_ERROR) { - return get_temperature(temps); - } - } else { - sensor_type_temp[sensor_temp_id] = 1; - return get_temperature(temps); - } - - if (sensor_temp_id == SENSOR_ERROR) { - have_temp = 0; - printf("Temperature sensor doesn't appear to exist. Temperature screen will be disabled.\n"); - return 0; - } - } - if (count >= NUM_TEMP) { - count = NUM_TEMP; - } else if(temps[count].cur != SENSOR_ERROR) { - count++; - } - return count; -} - -int get_fans(g15_stats_info *fans) { - int count = 0; - fan_tot_cur = 0; - for (count = 0; count < NUM_FAN; count++) { - if ((fans[count].cur = get_fan_cur(count + 1)) == SENSOR_ERROR) { + for (count = 0; count < NUM_PROBES; count++) { + if ((sensors[count].cur = get_sensor_cur(count + 1, screen_id)) == SENSOR_ERROR) { break; } - fans[count].max = get_fan_max(count + 1); + sensors[count].max = get_sensor_max(count + 1, screen_id); - if (fan_tot_max < fans[count].max) { - fan_tot_max = fans[count].max; - } + if (screen_id == SCREEN_TEMP) { + sensors[count].cur /= 1000; + sensors[count].max /= 1000; + if (temp_tot_max < sensors[count].max) { + temp_tot_max = sensors[count].max; + } + if ((sensor_temp_main == (count +1)) || ((!sensor_temp_main) && (temp_tot_cur < sensors[count].cur))) { + temp_tot_cur = sensors[count].cur; + } + } else { //SCREEN_FAN + if (fan_tot_cur <sensors[count].cur) { + fan_tot_cur = sensors[count].cur; + } - if (fan_tot_cur <fans[count].cur) { - fan_tot_cur = fans[count].cur; + if (fan_tot_max < fan_tot_cur) { + fan_tot_max = (fan_tot_cur * 1.2); + } } - - if (fan_tot_max < fan_tot_cur) { - fan_tot_max = (fan_tot_cur * 1.2); - } } - if ((!count) && (fans[0].cur == SENSOR_ERROR)) { - if (sensor_type_fan[sensor_fan_id]) { - sensor_lost_fan[sensor_fan_id]--; - if(sensor_lost_fan[sensor_fan_id] < 0) { - sensor_lost_fan[sensor_fan_id] = 0; + if ((!count) && (sensors[0].cur == SENSOR_ERROR)) { + if (sensor_type[sensor_id]) { + sensor_lost[sensor_id]--; + if(sensor_lost[sensor_id] < 0) { + sensor_lost[sensor_id] = 0; } - - printf("Fan sensor doesn't appear to exist with id=%d .\n", sensor_fan_id); - sensor_fan_id = get_next(sensor_fan_id, sensor_lost_fan); - if (sensor_fan_id != SENSOR_ERROR) { - return get_fans(fans); + printf("%s sensor doesn't appear to exist with id=%d .\n", label, sensor_id); + sensor_id = get_next(sensor_id, sensor_lost); + if (screen_id == SCREEN_TEMP) { + sensor_temp_id = sensor_id; + } else { //SCREEN_FAN + sensor_fan_id = sensor_id; } + if (sensor_id != SENSOR_ERROR) { + return get_sensors(sensors, screen_id, sensor_type, sensor_lost, sensor_id); + } } else { - sensor_type_fan[sensor_fan_id] = 1; - return get_fans(fans); + sensor_type[sensor_id] = 1; + return get_sensors(sensors, screen_id, sensor_type, sensor_lost, sensor_id); } - if (sensor_fan_id == SENSOR_ERROR) { - have_fan = 0; - printf("Fan sensor doesn't appear to exist. Fan screen will be disabled.\n"); + + if (sensor_id == SENSOR_ERROR) { + if (screen_id == SCREEN_TEMP) { + have_temp = 0; + } else { //SCREEN_FAN + have_fan = 0; + } + printf("%s sensor doesn't appear to exist. %s screen will be disabled.\n", label, label); return 0; } - } - if (count >= NUM_FAN) { - count = NUM_FAN; - } else if(fans[count].cur != SENSOR_ERROR) { + if (count >= NUM_PROBES) { + count = NUM_PROBES; + } else if(sensors[count].cur != SENSOR_ERROR) { count++; } return count; @@ -657,19 +621,37 @@ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, cur_shift + 1); } +void draw_summary_sensors_logic(g15canvas *canvas, char *tmpstr, g15_stats_info *sensors, char *label, int y1, int y2, int cur_shift, int shift, int count, float tot_cur, float tot_max) { + if (count) { + int j = 0; + int step = (int) (y2 / count); + int y = cur_shift + y1; + int last_y; + for (j = 0; j < count; j++) { + last_y = y; + y += step; + drawBar_both(canvas, last_y, y, sensors[j].cur + 1, tot_max, tot_max - sensors[j].cur, tot_max); + } + drawLine_both(canvas, cur_shift + y1, y); + + sprintf(tmpstr, label, tot_cur); + print_label(canvas, tmpstr, cur_shift); + + cur_shift += shift; + } +} + void draw_summary_screen(g15canvas *canvas, char *tmpstr, int y1, int y2, int shift, int id) { // Memory section glibtop_mem mem; glibtop_get_mem(&mem); + int mem_total = (mem.total / 1024); int mem_used = mem_total - (mem.free / 1024); int cur_shift = shift * id; int y; - int last_y; - int j; - int step; int count; // Memory section @@ -704,49 +686,26 @@ id++; cur_shift += shift; } - // Temperature section - if ((have_temp) && (id < summary_rows)) { - g15_stats_info sensors[NUM_FAN]; - count = get_temperature(sensors); - if ((count) && (have_temp)) { - j = 0; - step = (int) (y2 / count); - y = cur_shift + y1; - for (j = 0; j < count; j++) { - last_y = y; - y += step; - drawBar_both(canvas, last_y, y, sensors[j].cur + 1, temp_tot_max, temp_tot_max - sensors[j].cur, temp_tot_max); + if ((have_temp) || (have_fan)) { + g15_stats_info sensors[NUM_PROBES]; + // Temperature section + if ((have_temp) && (id < summary_rows)) { + count = get_sensors(sensors, SCREEN_TEMP, sensor_type_temp, sensor_lost_temp, sensor_temp_id); + if ((count) && (have_temp)) { + draw_summary_sensors_logic(canvas, tmpstr, sensors, "TEM %3.f\xb0", y1, y2, cur_shift, shift, count, temp_tot_cur, temp_tot_max); + id++; + cur_shift += shift; } - drawLine_both(canvas, cur_shift + y1, y); - - sprintf(tmpstr, "TEM %3.f\xb0", temp_tot_cur); - print_label(canvas, tmpstr, cur_shift); - - id++; - cur_shift += shift; } - } - // Fan section - if ((have_fan) && (id < summary_rows)) { - g15_stats_info sensors[NUM_FAN]; - count = get_fans(sensors); - if ((count) && (have_fan)) { - j = 0; - step = (int) (y2 / count); - y = cur_shift + y1; - for (j = 0; j < count; j++) { - last_y = y; - y += step; - drawBar_both(canvas, last_y, y, sensors[j].cur + 1, fan_tot_max, fan_tot_max - sensors[j].cur, fan_tot_max); + // Fan section + if ((have_fan) && (id < summary_rows)) { + count = get_sensors(sensors, SCREEN_FAN, sensor_type_fan, sensor_lost_fan, sensor_fan_id); + if ((count) && (have_fan)) { + draw_summary_sensors_logic(canvas, tmpstr, sensors, "RPM%5.f", y1, y2, cur_shift, shift, count, fan_tot_cur, fan_tot_max); + id++; + cur_shift += shift; } - drawLine_both(canvas, cur_shift + y1, y); - - sprintf(tmpstr, "RPM%5.f", fan_tot_cur); - print_label(canvas, tmpstr, cur_shift); - - id++; - cur_shift += shift; } } @@ -840,6 +799,7 @@ int total,user,nice,sys,idle; int b_total,b_user,b_nice,b_sys,b_idle,b_irq,b_iowait; + int sub_val; static int last_total[GLIBTOP_NCPU],last_user[GLIBTOP_NCPU],last_nice[GLIBTOP_NCPU], last_sys[GLIBTOP_NCPU],last_idle[GLIBTOP_NCPU],last_iowait[GLIBTOP_NCPU],last_irq[GLIBTOP_NCPU]; @@ -1008,14 +968,15 @@ case SCREEN_CPU: if (mode[SCREEN_CPU]) { divider = 9 / ncpu; - g15r_drawBar(canvas, BAR_START, (divider * core), BAR_END, (divider + (divider * (core))), G15_COLOR_BLACK, b_user + 1, b_total, 4); - g15r_drawBar(canvas, BAR_START, shift + (divider * (core)), BAR_END, shift + (divider + (divider * (core))), G15_COLOR_BLACK, b_sys + 1, b_total, 4); + sub_val = divider * core; + g15r_drawBar(canvas, BAR_START, sub_val, BAR_END, divider + sub_val, G15_COLOR_BLACK, b_user + 1, b_total, 4); + g15r_drawBar(canvas, BAR_START, shift + sub_val, BAR_END, shift + divider + sub_val, G15_COLOR_BLACK, b_sys + 1, b_total, 4); y1 = 0; - y2 = shift2 + (divider + (divider * (core))); - g15r_drawBar(canvas, BAR_START, shift2 + (divider * (core)), BAR_END, y2, G15_COLOR_BLACK, b_nice + 1, b_total, 4); + y2 = shift2 + divider + sub_val; + g15r_drawBar(canvas, BAR_START, shift2 + sub_val, BAR_END, y2, G15_COLOR_BLACK, b_nice + 1, b_total, 4); divider = y2 / ncpu; - drawBar_reversed(canvas, BAR_START, (divider * core), BAR_END, y2, G15_COLOR_BLACK, b_idle + 1, b_total, 5); + drawBar_reversed(canvas, BAR_START, sub_val, BAR_END, y2, G15_COLOR_BLACK, b_idle + 1, b_total, 5); } else { current_value = b_total - b_idle; drawBar_both(canvas, y1, y2, current_value, b_total, b_total - current_value, b_total); @@ -1271,14 +1232,14 @@ } } -void draw_temp_screen(g15canvas *canvas, char *tmpstr, int all) { - static g15_stats_info temps[NUM_TEMP]; - int count = get_temperature(temps); - - if ((!count) || (temps[0].cur == SENSOR_ERROR)) { +void draw_g15_stats_info_screen_logic(g15canvas *canvas, char *tmpstr, int all, int screen_type, + g15_stats_info *probes, int count, float tot_max, int *sensor_lost, int sensor_id, + char *vert_label, char *format_main, char *format_bottom) { + + if ((!count) || (probes[0].cur == SENSOR_ERROR)) { return; } else { - sensor_lost_temp[sensor_temp_id] = 10; + sensor_lost[sensor_id] = 10; } int j = 0; @@ -1289,23 +1250,23 @@ if (count) { if (all) { g15r_clearScreen(canvas, G15_COLOR_WHITE); - print_vert_label(canvas, "TEMP"); + print_vert_label(canvas, vert_label); for (j = 0; j < count; j++) { register int bar_top = (j * shift) + 1 + j; register int bar_bottom = ((j + 1)*shift) + j; - sprintf(tmpstr, "t-%d %3.f\xb0", j + 1, temps[j].cur); + sprintf(tmpstr, format_main, j + 1, probes[j].cur); g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, bar_top + 1); - drawBar_both(canvas, bar_top, bar_bottom, temps[j].cur + 1, temp_tot_max, temp_tot_max - temps[j].cur, temp_tot_max); + drawBar_both(canvas, bar_top, bar_bottom, probes[j].cur + 1, tot_max, tot_max - probes[j].cur, tot_max); } drawLine_both(canvas, 1, ((j*shift) + j-1)); } - if ((!all) || (info_cycle == SCREEN_TEMP)) { + if ((!all) || (info_cycle == screen_type)) { char extension[16]; - sprintf(tmpstr, " "); + tmpstr[0] = '\0'; for (j = 0; j < count; j++) { - sprintf(extension, "temp%d %1.f\xb0 ", j + 1, temps[j].cur); + sprintf(extension, format_bottom, j + 1, probes[j].cur); if (j) { strcat(tmpstr, "| "); } @@ -1316,49 +1277,23 @@ } } -void draw_fan_screen(g15canvas *canvas, char *tmpstr, int all) { - static g15_stats_info fans[NUM_FAN]; - int count = get_fans(fans); - - if ((!count) || (fans[0].cur == SENSOR_ERROR)) { - return; - } else { - sensor_lost_fan[sensor_fan_id] = 10; +void draw_g15_stats_info_screen(g15canvas *canvas, char *tmpstr, int all, int screen_type) { + static g15_stats_info probes[NUM_PROBES]; + int count; + switch (screen_type) { + case SCREEN_TEMP: + count = get_sensors(probes, SCREEN_TEMP, sensor_type_temp, sensor_lost_temp, sensor_temp_id); + draw_g15_stats_info_screen_logic(canvas, tmpstr, all, screen_type, probes, + count, temp_tot_max, sensor_lost_temp, sensor_temp_id, "TEMP", "t-%d %3.f\xb0", "temp%d %1.f\xb0 "); + break; + case SCREEN_FAN: + count = get_sensors(probes, SCREEN_FAN, sensor_type_fan, sensor_lost_fan, sensor_fan_id); + draw_g15_stats_info_screen_logic(canvas, tmpstr, all, screen_type, probes, + count, fan_tot_max, sensor_lost_fan, sensor_fan_id, "RPM", "F-%d%5.f", "Fan%d %1.f "); + break; + default: + break; } - - int j = 0; - - int shift; - shift = 32 / count; - - if (count) { - if (all) { - g15r_clearScreen(canvas, G15_COLOR_WHITE); - print_vert_label(canvas, "RPM"); - - for (j = 0; j < count; j++) { - register int bar_top = (j * shift) + 1 + j; - register int bar_bottom = ((j + 1)*shift) + j; - sprintf(tmpstr, "F-%d%5.f", j + 1, fans[j].cur); - g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, bar_top + 1); - drawBar_both(canvas, bar_top, bar_bottom, fans[j].cur + 1, fan_tot_max, fan_tot_max - fans[j].cur, fan_tot_max); - } - drawLine_both(canvas, 1, ((j*shift) + j-1)); - } - - if ((!all) || (info_cycle == SCREEN_FAN)) { - char extension[16]; - sprintf(tmpstr, " "); - for (j = 0; j < count; j++) { - sprintf(extension, "Fan%d %1.f ", j + 1, fans[j].cur); - if (j) { - strcat(tmpstr, "| "); - } - strcat(tmpstr, extension); - } - g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 80 - (strlen(tmpstr)*4) / 2, INFO_ROW); - } - } } void calc_info_cycle(void) { @@ -1450,12 +1385,12 @@ break; case SCREEN_TEMP : if (cycle != SCREEN_TEMP) { - draw_temp_screen(canvas, tmpstr, 0); + draw_g15_stats_info_screen(canvas, tmpstr, 0, SCREEN_TEMP); } break; case SCREEN_FAN : if (cycle != SCREEN_FAN) { - draw_fan_screen(canvas, tmpstr, 0); + draw_g15_stats_info_screen(canvas, tmpstr, 0, SCREEN_FAN); } break; case SCREEN_NET2 : @@ -1796,7 +1731,7 @@ switch (cycle) { case SCREEN_FAN: if (have_fan) { - draw_fan_screen(canvas, tmpstr, 1); + draw_g15_stats_info_screen(canvas, tmpstr, 1, SCREEN_FAN); if (have_fan) { break; } @@ -1805,7 +1740,7 @@ info_cycle = cycle; case SCREEN_TEMP: if (have_temp) { - draw_temp_screen(canvas, tmpstr, 1); + draw_g15_stats_info_screen(canvas, tmpstr, 1, SCREEN_TEMP); if (have_temp) { break; } @@ -1854,7 +1789,7 @@ info_cycle = cycle; case SCREEN_TEMP: if (have_temp) { - draw_temp_screen(canvas, tmpstr, 1); + draw_g15_stats_info_screen(canvas, tmpstr, 1, SCREEN_TEMP); if (have_temp) { break; } @@ -1863,7 +1798,7 @@ info_cycle = cycle; case SCREEN_FAN: if (have_fan) { - draw_fan_screen(canvas, tmpstr, 1); + draw_g15_stats_info_screen(canvas, tmpstr, 1, SCREEN_FAN); if (have_fan) { break; } @@ -1895,4 +1830,3 @@ free(canvas); return 0; } - Modified: trunk/g15daemon-clients/g15stats/g15stats.h =================================================================== --- trunk/g15daemon-clients/g15stats/g15stats.h 2009-06-29 22:42:13 UTC (rev 515) +++ trunk/g15daemon-clients/g15stats/g15stats.h 2009-07-11 23:17:13 UTC (rev 516) @@ -1,7 +1,6 @@ #define TEXT_LEFT 1 #define NUM_BATS 3 -#define NUM_TEMP 4 -#define NUM_FAN 4 +#define NUM_PROBES 4 #define MAX_NET_HIST 107 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cza...@us...> - 2009-06-29 22:43:16
|
Revision: 515 http://g15daemon.svn.sourceforge.net/g15daemon/?rev=515&view=rev Author: czarnyckm Date: 2009-06-29 22:42:13 +0000 (Mon, 29 Jun 2009) Log Message: ----------- - Fixed temperature / fan sensor lost - Fixed screen cycle Modified Paths: -------------- trunk/g15daemon-clients/g15stats/ChangeLog trunk/g15daemon-clients/g15stats/g15stats.c Modified: trunk/g15daemon-clients/g15stats/ChangeLog =================================================================== --- trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-28 18:57:28 UTC (rev 514) +++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-29 22:42:13 UTC (rev 515) @@ -44,3 +44,6 @@ (the id should point to sysfs path /sys/class/hwmon/hwmon../device/temp[id]_input) - On the Fan / Temp Screen Current sensor is controlled with the L4 key (on systems with more then one sensor only). - Every Screen has his own mode now (except Swap, Memory and Battery Screen) +SVN 515: +- Fixed temperature / fan sensor lost +- Fixed screen cycle Modified: trunk/g15daemon-clients/g15stats/g15stats.c =================================================================== --- trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-28 18:57:28 UTC (rev 514) +++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-29 22:42:13 UTC (rev 515) @@ -79,8 +79,8 @@ _Bool sensor_type_temp[MAX_SENSOR]; _Bool sensor_type_fan[MAX_SENSOR]; -_Bool sensor_lost_temp[MAX_SENSOR]; -_Bool sensor_lost_fan[MAX_SENSOR]; +int sensor_lost_temp[MAX_SENSOR]; +int sensor_lost_fan[MAX_SENSOR]; int sensor_temp_id = 0; int sensor_temp_main = 0; @@ -144,7 +144,7 @@ format_float(tmpstr, "%2.1fMB","%liMB", (float)bytes / (1024*1024)); } else if(bytes >= 1024) { - format_float(tmpstr, "%2.1fMB","%likB", (float)bytes / 1024); + format_float(tmpstr, "%2.1fkB","%likB", (float)bytes / 1024); } else { sprintf(tmpstr,"%liB",bytes); @@ -403,7 +403,7 @@ return get_temp("max", id); } -int get_next(int sensor_id, _Bool *sensor_lost){ +int get_next(int sensor_id, int *sensor_lost){ int new_sensor_id; new_sensor_id = sensor_id; do { @@ -411,7 +411,7 @@ if (new_sensor_id >= MAX_SENSOR) { new_sensor_id = 0; } - if (!sensor_lost[new_sensor_id]){ + if (sensor_lost[new_sensor_id]){ return new_sensor_id; } } while(sensor_id != new_sensor_id); @@ -440,7 +440,10 @@ } if ((!count) && (temps[0].cur == SENSOR_ERROR)) { if (sensor_type_temp[sensor_temp_id]) { - sensor_lost_temp[sensor_temp_id] = 1; + sensor_lost_temp[sensor_temp_id]--; + if(sensor_lost_temp[sensor_temp_id] < 0) { + sensor_lost_temp[sensor_temp_id] = 0; + } printf("Temperature sensor doesn't appear to exist with id=%d .\n", sensor_temp_id); sensor_temp_id = get_next(sensor_temp_id, sensor_lost_temp); if (sensor_temp_id != SENSOR_ERROR) { @@ -470,7 +473,6 @@ int count = 0; fan_tot_cur = 0; for (count = 0; count < NUM_FAN; count++) { - if ((fans[count].cur = get_fan_cur(count + 1)) == SENSOR_ERROR) { break; } @@ -488,9 +490,13 @@ fan_tot_max = (fan_tot_cur * 1.2); } } - if ((!count) && (fans[count].cur == SENSOR_ERROR)) { + if ((!count) && (fans[0].cur == SENSOR_ERROR)) { if (sensor_type_fan[sensor_fan_id]) { - sensor_lost_fan[sensor_fan_id] = 1; + sensor_lost_fan[sensor_fan_id]--; + if(sensor_lost_fan[sensor_fan_id] < 0) { + sensor_lost_fan[sensor_fan_id] = 0; + } + printf("Fan sensor doesn't appear to exist with id=%d .\n", sensor_fan_id); sensor_fan_id = get_next(sensor_fan_id, sensor_lost_fan); if (sensor_fan_id != SENSOR_ERROR) { @@ -1271,6 +1277,8 @@ if ((!count) || (temps[0].cur == SENSOR_ERROR)) { return; + } else { + sensor_lost_temp[sensor_temp_id] = 10; } int j = 0; @@ -1314,6 +1322,8 @@ if ((!count) || (fans[0].cur == SENSOR_ERROR)) { return; + } else { + sensor_lost_fan[sensor_fan_id] = 10; } int j = 0; @@ -1326,8 +1336,6 @@ g15r_clearScreen(canvas, G15_COLOR_WHITE); print_vert_label(canvas, "RPM"); - - for (j = 0; j < count; j++) { register int bar_top = (j * shift) + 1 + j; register int bar_bottom = ((j + 1)*shift) + j; @@ -1508,7 +1516,7 @@ if (have_fan) { break; } - cycle++; + cycle = 0; break; } info_cycle_timer = cycle * PAUSE; @@ -1760,6 +1768,11 @@ if(have_nic==1) pthread_create(&net_thread,NULL,(void*)network_watch,&interface); + for (i=0;i<MAX_SENSOR;i++) { + sensor_lost_fan[i] = 1; + sensor_lost_temp[i] = 1; + } + int cycle_old = cycle; while(1) { calc_info_cycle(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |