function send_lcd_commands($lcd, $lcd_cmds) { if (!is_array($lcd_cmds) || empty($lcd_cmds)) { lcdproc_warn("Failed to interpret lcd commands"); return; } foreach ($lcd_cmds as $lcd_cmd) { $cmd_output = ""; if (!fwrite($lcd, "{$lcd_cmd}\n")) { lcdproc_warn("Connection to LCDd process lost {$errstr} ({$errno})"); die; } $cmd_output = fgets($lcd, 256); // FIXME: add support for interpreting menu commands here. if (preg_match("/^huh?/", $cmd_output)) { lcdproc_notice("LCDd output: \"{$cmd_output}\". Executed \"{$lcd_cmd}\""); } } }
function send_lcd_commands($lcd, $lcd_cmds) { if (!is_array($lcd_cmds) || empty($lcd_cmds)) { lcdproc_warn("Failed to interpret lcd commands"); return; } while (($cmd_output = fgets($lcd, 8000)) !== false) { if (preg_match("/^huh?/", $cmd_output)) { lcdproc_notice("LCDd output: \"{$cmd_output}\". Executed \"{$lcd_cmd}\""); } } foreach ($lcd_cmds as $lcd_cmd) { if (!fwrite($lcd, "{$lcd_cmd}\n")) { lcdproc_warn("Connection to LCDd process lost {$errstr} ({$errno})"); $lcdproc_connect_errors++; return false; } } return true; }