diff options
author | Seth Mos <seth.mos@xs4all.nl> | 2007-12-04 21:42:37 +0000 |
---|---|---|
committer | Seth Mos <seth.mos@xs4all.nl> | 2007-12-04 21:42:37 +0000 |
commit | c36893fcbf449b8dfde69beab05da3918c9c5163 (patch) | |
tree | 258e2373b651b08c1b4c925a98d093276c7700a6 | |
parent | d1a5fd714c3db3adaeec6d5198796f3926b7bae6 (diff) | |
download | pfsense-packages-c36893fcbf449b8dfde69beab05da3918c9c5163.tar.gz pfsense-packages-c36893fcbf449b8dfde69beab05da3918c9c5163.tar.bz2 pfsense-packages-c36893fcbf449b8dfde69beab05da3918c9c5163.zip |
Add function to send commands to the LCDd process.
-rw-r--r-- | packages/lcdproc/lcdproc.inc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/lcdproc/lcdproc.inc b/packages/lcdproc/lcdproc.inc index bd6c83e1..f268d4b3 100644 --- a/packages/lcdproc/lcdproc.inc +++ b/packages/lcdproc/lcdproc.inc @@ -33,6 +33,8 @@ /* LCDproc */ define('LCDPROC_RCFILE', '/usr/local/etc/rc.d/lcdproc.sh'); define('LCDPROC_CONFIG','/usr/local/etc/LCDd.conf'); + define('LCDPROC_PORT','localhost'); + define('LCDPROC_PORT','13666'); function lcdproc_notice ($msg) { syslog(LOG_NOTICE, "lcdproc: {$msg}"); } function lcdproc_warn ($msg) { syslog(LOG_WARNING, "lcdproc: {$msg}"); } @@ -268,4 +270,29 @@ EOD; config_unlock(); } + /* Connect to the LCDd port and interface with the LCD */ + function send_lcd_commands($lcd_cmds) { + if(!is_array($lcd_cmds) || (empty($lcd_cmds))) { + lcdproc_warn("Failed to interpret lcd commands"); + return; + } + $lcd = fsockopen(LCDPROC_HOST, LCDPROC_PORT, $errno, $errstr, 30); + if (!$lcd) { + lcdproc_warn("Failed to connect to LCDd process $errstr ($errno)"); + } else { + foreach($lcd_cmds as $lcd_cmd) { + $cmd_output = ""; + fwrite($lcd, $lcd_cmd); + while (!feof($lcd)) { + $cmd_output .= fgets($lcd, 128); + } + lcdproc_notice("LCDd output for cmd $lcd_cmd is: $cmd_output"); + usleep(100); + } + } + fclose($lcd); + } + + + ?> |