Crystal Fontz 635 help!
-
No luck guys, still seems that it doesn't work. Even with Cino's work around.
Here is my syslog information:
At this point I'm not even sure the screen works since I have never seen anything other then the demo text on it.
I am going to install windows on the box and see if I can get it to work that way. I still don't have a clear understanding on how the package works so let me take a try and you guys can tell me if I'm right.In the FreeBSD there is a folder called /usr/local/etc/rc.d and anything that you put in there will autorun when the computer starts. Now the package LCDproc takes advantage of a demon called LCDd which gets its configuration information from LCDd.conf. LCDproc also uses LCDproc.inc and LCDproc.xml to get it's configuration information for such things as what text to display on the screen and also what driver to use and port, speed ect. Now the drivers are located in /usr/local/lib/lcdproc folder and have an extention of *.so. But the LCDd.conf addresses the driver without the extension, does this mean anyting? Also how is the LCDd.conf generated? I suspect it is generated from the lcdproc package. Below is my LCDd.conf
[server] Driver=CFontzPacket Bind=127.0.0.1 Port=13666 ReportLevel=3 ReportToSyslog=yes WaitTime=5 User=nobody ServerScreen=no Foreground=no DriverPath=/usr/local/lib/lcdproc/ GoodBye="Thanks for using" GoodBye=" pfSense " ToggleRotateKey=Enter PrevScreenKey=Left NextScreenKey=Right ScrollUpKey=Up ScrollDownKey=Down [menu] MenuKey=Escape EnterKey=Enter UpKey=Up DownKey=Down [CFontzPacket] Device=/dev/ugen3.2 Model=635 Size=20x4 Contrast=350 Brightness=1000 OffBrightness=50 Speed=115200 NewFirmware=yes Reboot=yes
Also does my port speed seem kind of high, I know typically serial devices use a port speed of 9600. My device is USB however just trying to think of all possibilities. I may also try to update to the lates version of lcdproc. One last thing it seems like I'm trying to connect to the LCDd on a different port than it's listening on but all of the config files say port=13666.
Thanks for all your help in advance. If anything I'm learning a whole lot about Unix (FreeBSD).
-
The system log looks a lot better though. It shows lcdd starting and listening for a client and then the client successfully connecting to it. So why is it not actually updating the screen?
Is it stuck in demo mode? It is set to the wrong baud rate?
The option Reboot=yes is supposed to be so that the screen resets itself and comes up in a known state. This implies it may be possible for it to setup wrong.Override the default communication speed known for the selected model.
[default: depending on model; legal: 19200, 115200]
#Speed=115200
So maybe try 19200.
The Newfirmware=yes option is a bit confusing. If you look at the code at the lcdproc site it seems to imply there isn't any new firmware so this does nothing. :-
In fact your display shows V1.6 and this option is V2.0 firmwares. Maybe try changing that to no.Set the firmware version (New means >= 2.0) [default: no; legal: yes, no]
Currently this flag is not in use, there is no such thing as NewFirmware. ;=)
#NewFirmware=no
Edit: Actually 1.6 is the most recent. the above only applies to the 633.
Your explanation of how it works is mostly accurate. However this isn't a "normal" install of lcdproc.
In order to use the pfSense package system the lcdproc package does things a bit differently. For example it writes out the lcdproc.conf file when you setup the package. Usually you would just edit the file directly.
It doesn't use the standard lcdproc client instead using it's own client. Lcdproc is written as a client/server combination just to make it easy for people to write their own client software.Steve
-
I know a 635 with scab works on my box as I tried it a few weeks ago as a test. I didn't change any settings other then add the usb port to the config files and selected the packet driver… I do have one extra driver that you may not have. In the http://forum.pfsense.org/index.php/topic,23919.msg123663.html#msg123663 thread, there are steps to add 'libusb.so.2' I needed this to get my piclcd driver to work but I wonder if its needed for any USB LCD device as it was already on my box when I tested with my 635. It also talked about 'libkvm.so.5' but I found I didn't need it.
-
I installed the libkvm.5, libusb.so.2, picolcd.so and now I'm getting:
/libexec/ld-elf.so.1: /lib/libkvm.so.5: Shared object has no run-time symbol table
Error.
I have tried to erase the files now I am just getting this error on my terminal and I get this error when I try to run the top command and also if I try to execute the LCDd or lcdproc. I am finishing my basement so I will have to take the router off line for a couple of days also I am making some upgrades so I can switch from operating systems more efficiently and will try to update on my progress later on in the week. I have still not tried to get the LCD working in Windows just as a test. I am also going to try to see if I can get the LCD to work in PfSense 1.2.3. I will update on my progress. -
you dont need the libkvm.5, libusb.so.2, picolcd.so files. They are needed if you have a picolcd display. A firmware update should overwrite the libkvm.5 file.
try it on a windows box to make sure its working.. download ccontrol and the window drivers to get it working on a windows box.
-
Are you sure you don't need libusb?
Just the fact that something changed when it was added to the box implies that it's being used?Steve
-
i think your right… libusb wasn't there on a fresh install and its needed for picolcd because it uses the usb interface.. the 635 may need it also since its attach via usb. libkvm, at first i did use that driver but after a few fresh installs, i found i didn't need it only libusb. I end up not installing the libkvm
-
Okay so I installed Windows 7 32 bit on my box and was able to get the 635 to work with little issues. I did notice that there were two drivers for this screen. There was a USB Driver (I'm guessing that is the CFontzPacket in FreeBSD) but there is also a serial port driver (Not sure which driver does this in FreeBSD) that gets installed even though this screen connects through my motherboard via USB. I remember reading somewhere that this device is a serial device with an USB controller attached to it. If that is the case is there another driver that I have to install before this screen will work? Also in Windows there is a separate program that is responsible for putting the information on the screen (lcdproc I'm guessing is what does that in FreeBSD). I did find out in Windows the screen will not function unless you have the serial port speed set to the Max 115200. I feel like I'm getting closer, I think the issue is the serial port driver. Any ideas?
I also notice that if I edit files with file manger a package I downloaded for PfSense I get all kind of errors trying to run LCDd but if I use the built in file editor then I don’t get the error. There may be a problem with File Manager. Not sure if anyone else has seen this.Here is a read out of my system logs:
LCDd: LCDd version 0.5.3 starting
Aug 11 21:56:32 LCDd: Using Configuration File: /usr/local/etc/LCDd.conf
Aug 11 21:56:32 LCDd: Listening for queries on 127.0.0.1:13666
Aug 11 21:56:38 LCDd: Connect from host 127.0.0.1:11527 on socket 6
Aug 11 21:56:39 LCDd: error: huh? Too much data received… quiet down!
Aug 11 21:56:39 LCDd: Client on socket 6 disconnected -
The USB-Serial port driver, uftdi, is in the FreeBSD kernel and is loading correctly as you can see from your system logs.
One thing that occurs to me is that you may have to point LCDd at the serial device rather than the usb port directly. E.g. at uftdi0
If you plug the screen in after pfSense has booted and you have the console up what messages do you get? Does it show an extra com port for example?
Steve
-
The USB-Serial port driver, uftdi, is in the FreeBSD kernel and is loading correctly as you can see from your system logs.
One thing that occurs to me is that you may have to point LCDd at the serial device rather than the usb port directly. E.g. at uftdi0
If you plug the screen in after pfSense has booted and you have the console up what messages do you get? Does it show an extra com port for example?
Steve
I will try that, right now the system is down due to basement construction. I did forget to mention one thing. I was messing around with the LCDd.conf and I copied the LCDd.conf.sample to LCDd.conf without editing it. I then ran the LCDd and lcdproc and it put all the lcdproc information on my terminal window (I was sshed into the box at the time) So it seems that the lcdproc and LCDd are working and it is just a matter of getting the information to the screen. I will try what you said and report back soon.
-
This makes for interesting reading, though it's an older version of FreeBSD and the com port labelling has changed since then:
http://www.tnpi.net/computing/freebsd/crystalfontz.shtmlPerhaps you need the ucom driver?
Steve
Edit: Further reading seems to show that the uftdi driver should automatically generate an extra com port which the CFontz packet driver can talk to. I don't see one in your dmesg from a while ago.
Edit: The ucom driver doesn't seem to be in the 32 bit kernel, you using 64 bit?
[2.0-RC3][root@pfsense.fire.box]/boot/modules(14): kldstat -v | grep ucom [2.0-RC3][root@pfsense.fire.box]/boot/modules(15): kldstat -v | grep uftdi 285 uhub/uftdi
-
This makes for interesting reading, though it's an older version of FreeBSD and the com port labelling has changed since then:
http://www.tnpi.net/computing/freebsd/crystalfontz.shtmlPerhaps you need the ucom driver?
Steve
Edit: Further reading seems to show that the uftdi driver should automatically generate an extra com port which the CFontz packet driver can talk to. I don't see one in your dmesg from a while ago.
Yeah I saw that post too, I think there is were I discovered that the LCD screen was really a serial device with a usb interface slapped on it or perhaps it would be more accurate to call it an serial LCD screen with a usb to serial device included?
So I turned on the router and unplugged the usb from the motherboard. (Kind of tricky as it is all individual wires!) and I got this :
ugen3.2 <crystalfontz>at usbus3 (disconnected)
uftdi0: at uhub3, Port2, addr 2 disconnectedWhen I plugged it back in I got:
ugen3.2: <crystalfontz>at usbus3
uftdi0: <crystalfontz cfa635-usb="" lcd="">on usbus3You may be correct. I ran the following command though I don't know what it means:
kldstat -v|grep ucom
and nothing was returned but the prompt.</crystalfontz></crystalfontz></crystalfontz>
-
In FreeBSD drivers can be either built into the kernel or loaded as a module. The drivers that are built in are decided at compile time.
kldstat usually lists the kernel modules that have been loaded with kldload or from /boot/loader.conf. kldstat -v lists modules that are compiled in, I think!I think you need to kldload the ucom.ko module but I only have the 32bit version to hand.
Steve
-
That's good because I have re-installed PfSense and used the 32bit version. I wanted to see if 64 bit was the cause of my troubles and just decided to keep it because I wasn't sure what 64 bit gave me other than the ability to address more memory. I would just need the driver and instructions on how to install it.
-
Edit: Don't bother with this see below! ;)
Hmm, looks like I was wrong about the kldstat command. Trying to load ucom on my system gives:
[2.0-RC3][root@pfsense.fire.box]/root(1): kldload ucom.ko kldload: can't load ucom.ko: File exists
This implies it's already in the kernel. It's probably worth trying though on your system.
I've attached the ucom.ko module from FreeBSD 8.1. Remove the .png suffix.
The file should be 20,607 Bytes.
Upload the file to /boot/modules then from the command line:
cd /boot/modules
kldload ucom.koSteve
-
Forget all that! ::)
I'm not sure why, perhaps the logging level is set differently, but the ucom driver output does not show up when you connect a device. However the resulting com port is created.
I happened to have an FTDI device to hand (it's a USB ODBII reader) so I gave it a go.
[2.0-RC3][root@pfsense.fire.box]/dev(36): dmesg | grep ftdi uftdi0: <ft232r usb="" uart="">on usbus0 [2.0-RC3][root@pfsense.fire.box]/dev(37): ls /dev/cua?? /dev/cuaU0 /dev/cuau0 /dev/cuau1</ft232r>
As you can see the device cuaU0 is created. The capital U is important it indicates a USB connected com port. It also appears as ttyU0.
Just use that in the lcdproc config page instead of ugen3.2.
Steve
-
Success! Adding the serial port and not the USB port was the key. Here is what I did.
1. Complete reinstall (Wanted to start clean)
2. Edited the lcdproc.xml file and added ttyU0
3. Edited the lcdproc.inc file and added ttyU0 in that file as well.The screen was showing 0 Clients, 0 Screens but after looking at some things I noticed that I didn't have a lcdproc.conf so I just cp lcdproc.conf.sample lcdproc.conf . Now everything seems to be running ok. I have not tried to restart the system to see if it will start automatically. I will report back on my finding. I just want to thank Stephenw10 and Cino, and all others in previous post. Without you guys I would have never figured this thing out.
-
Good to hear!! I was going to get back to you on this but glad you got it to work… Strange you had to use that... I wonder if its because when I tested this a few weeks ago, i had the LCD with SCAB built in.
-
Success! Adding the serial port and not the USB port was the key. Here is what I did.
1. Complete reinstall (Wanted to start clean)
2. Edited the lcdproc.xml file and added ttyU0
3. Edited the lcdproc.inc file and added ttyU0 in that file as well.The screen was showing 0 Clients, 0 Screens but after looking at some things I noticed that I didn't have a lcdproc.conf so I just cp lcdproc.conf.sample lcdproc.conf . Now everything seems to be running ok. I have not tried to restart the system to see if it will start automatically. I will report back on my finding. I just want to thank Stephenw10 and Cino, and all others in previous post. Without you guys I would have never figured this thing out.
Hi,
I order an CrystalFontz LCD for my Pfsense box
Can you explain step by step what you do you get it working (clarify)Thanks
-
Hi,
I order an CrystalFontz LCD for my Pfsense box
Can you explain step by step what you do you get it working (clarify)Thanks
Okay just as a disclaimer before I start, this is what worked for me, so please backup your systems before you change any files I would also suggest that you make a .bak file of anything that you edit that way you can always go back to a known good position.
I am using pfsense 2.0.1 - Release (amd64)
I'm using a MSI FUZZY RS690T AMD ATI AM2+ MINI ITX HDMI MOTHERBOARD
AMD Athlon X2 Dual Core Processor BE-2350
2 GB RAM
4 GB Trendnet CF
CF to SATA adatper with Half-Height Adaptor
CrystalFontz 635 LCD
Intel PWLA8492MTBLK5 10/ 100/ 1000Mbps PCI PRO/1000 MT Dual Port Server Adapter - with Half-Height Adaptor
NORCO RPC-230 2U Rackmount Server CaseI'm using the nano build of pfsense, I have gotten this to work with the full version of 2.0 32bit
The LCDproc package that I'm using is: lcdproc-0.5.3_1 Haven't got the developer one to work yetStop LCDProc if you have it running.
There are two files that you have to edit: use the file editor in pfsense under Diagnostics "Edit File"First one is /usr/local/pkg/lcdproc.xml add the following lines under <options>```
<option><value>ttyU0</value> <name>USB Com port 3 alternate (/dev/ttyU0)</name></option>
Save your file. Now you need to edit **_/usr/local/pkg/lcdproc.inc_** adding the following lines under the case statements:
case "ttyU0": continue; break;
**The scroll down to find the case statements with $realport varible and add**
case "ttyU0": $realport = "/dev/ttyU0"; break;
Save your file. Start LCDproc, if it doesn't start go to Services under Status and start the service there. You should be good to go. Here is my entire lcdproc.xml for your perusal:
<packagegui><title>Services: LCDproc</title>
<name>lcdproc</name>
<version>0.5.2_1-p12</version>
<savetext>Save</savetext>
<include_file>/usr/local/pkg/lcdproc.inc</include_file>
<tabs><tab><text>Server</text>
<url>/pkg_edit.php?xml=lcdproc.xml&id=0</url>
<active></active></tab>
<tab><text>Screens</text>
<url>/pkg_edit.php?xml=lcdproc_screens.xml&id=0</url></tab></tabs><menu>
<name>LCDproc</name>
<tooltiptext>Set LCDproc settings such as display driver and com port</tooltiptext>
Services
<url>/pkg_edit.php?xml=lcdproc.xml&id=0</url>
</menu><additional_files_needed>http://www.pfsense.org/packages/config/lcdproc/lcdproc.inc <prefix>/usr/local/pkg/</prefix> <chmod>0755</chmod></additional_files_needed> <additional_files_needed>http://www.pfsense.org/packages/config/lcdproc/lcdproc_screens.xml <prefix>/usr/local/pkg/</prefix> <chmod>0755</chmod></additional_files_needed> <additional_files_needed>http://www.pfsense.org/packages/config/lcdproc/lcdproc_client.php <prefix>/usr/local/pkg/</prefix> <chmod>0755</chmod></additional_files_needed> <additional_files_needed>http://www.pfsense.org/packages/config/lcdproc/bin/nexcom.so <prefix>/usr/local/lib/lcdproc/</prefix> <chmod>0755</chmod></additional_files_needed> <additional_files_needed>http://www.pfsense.org/packages/config/lcdproc/bin/SureElec.so <prefix>/usr/local/lib/lcdproc/</prefix> <chmod>0755</chmod></additional_files_needed> <additional_files_needed>http://www.pfsense.org/packages/config/lcdproc/bin/picolcd.so <prefix>/usr/local/lib/lcdproc/</prefix> <chmod>0755</chmod></additional_files_needed> <additional_files_needed>http://www.pfsense.org/packages/config/lcdproc/bin/libusb.so.2 <prefix>/usr/local/lib/lcdproc/</prefix> <chmod>0755</chmod></additional_files_needed> <service><name>lcdproc</name> <rcfile>lcdproc.sh</rcfile> <executable>LCDd</executable> <description>LCD Driver</description></service> <fields><field><fielddescr>Enable LCDproc</fielddescr> <fieldname>enable</fieldname> <type>checkbox</type></field> <field><fieldname>comport</fieldname> <fielddescr>Com Port</fielddescr> <description>Set the com port LCDproc should use.</description> <type>select</type> <options><option><value>none</value> <name>none</name></option> <option><value>com2</value> <name>Serial Com port 2 (/dev/cua1)</name></option> <option><value>ucom1</value> <name>USB Com port 1 (/dev/cuaU0)</name></option> <option><value>ucom2</value> <name>USB Com port 2 (/dev/cuaU1)</name></option> <option><value>lpt1</value> <name>Parallel port 1 (/dev/lpt0)</name></option> <option><value>ugen0.2</value> <name>USB Com port 1 alternate (/dev/ugen0.2)</name></option> <option><value>ugen1.2</value> <name>USB Com port 2 alternate (/dev/ugen1.2)</name></option> <option><value>ugen2.2</value> <name>USB Com port 3 alternate (/dev/ugen2.2)</name></option> <option><value>ttyU0</value> <name>USB Com port 3 alternate (/dev/ttyU0)</name></option></options> <default_value>ucom1</default_value></field> <field><fieldname>size</fieldname> <fielddescr>Display Size</fielddescr> <description>Set the display size lcdproc should use.</description> <type>select</type> <options><option><value>12x1</value> <name>1 rows 12 colums</name></option> <option><value>12x2</value> <name>2 rows 12 colums</name></option> <option><value>12x4</value> <name>4 rows 12 colums</name></option> <option><value>16x1</value> <name>1 row 16 colums</name></option> <option><value>16x2</value> <name>2 rows 16 colums</name></option> <option><value>16x4</value> <name>4 rows 16 colums</name></option> <option><value>20x1</value> <name>1 row 20 colums</name></option> <option><value>20x2</value> <name>2 rows 20 colums</name></option> <option><value>20x4</value> <name>4 rows 20 colums</name></option></options> <default_value>16x2</default_value></field> <field><fieldname>driver</fieldname> <fielddescr>Driver</fielddescr> <description>Set the LCD driver LCDproc should use.</description> <type>select</type> <options><option><value>nexcom</value> <name>nexcom</name></option> <option><value>bayrad</value> <name>bayrad</name></option> <option><value>CFontz</value> <name>CrystalFontz</name></option> <option><value>CFontz633</value> <name>CrystalFontz 633</name></option> <option><value>CFontzPacket</value> <name>CrystalFontz Packet</name></option> <option><value>curses</value> <name>curses</name></option> <option><value>CwLnx</value> <name>CwLnx</name></option> <option><value>ea65</value> <name>ea65</name></option> <option><value>EyeBoxOne</value> <name>EyeBoxOne</name></option> <option><value>gl5</value> <name>gl5</name></option> <option><value>glcdlib</value> <name>glcdlib</name></option> <option><value>glk</value> <name>glk</name></option> <option><value>hd44780</value> <name>hd44780</name></option> <option><value>icp_a106</value> <name>icp_a106</name></option> <option><value>imon</value> <name>imon</name></option> <option><value>IOWarrior</value> <name>IOWarrior</name></option> <option><value>irman</value> <name>irman</name></option> <option><value>joy</value> <name>joy</name></option> <option><value>lb216</value> <name>lb216</name></option> <option><value>lcdm001</value> <name>lcdm001</name></option> <option><value>lcterm</value> <name>lcterm</name></option> <option><value>lirc</value> <name>lirc</name></option> <option><value>MD8800</value> <name>MD8800</name></option> <option><value>ms6931</value> <name>ms6931</name></option> <option><value>mtc_s16209x</value> <name>mtc_s16209x</name></option> <option><value>MtxOrb</value> <name>MtxOrb</name></option> <option><value>NoritakeVFD</value> <name>NoritakeVFD</name></option> <option><value>pyramid</value> <name>pyramid</name></option> <option><value>picolcd</value> <name>picolcd</name></option> <option><value>Sed1330</value> <name>Sed1330</name></option> <option><value>sed1520</value> <name>sed1520</name></option> <option><value>serialpos</value> <name>serialpos</name></option> <option><value>serialVFD</value> <name>serialVFD</name></option> <option><value>sli</value> <name>sli</name></option> <option><value>stv5730</value> <name>stv5730</name></option> <option><value>SureElec</value> <name>SureElec</name></option> <option><value>svga</value> <name>svga</name></option> <option><value>t6963</value> <name>t6963</name></option> <option><value>text</value> <name>text</name></option> <option><value>tyan</value> <name>tyan</name></option> <option><value>ula200</value> <name>ula200</name></option> <option><value>xosd</value> <name>xosd</name></option></options> <default_value>pyramid</default_value></field> <field><fieldname>refresh_frequency</fieldname> <fielddescr>Refresh frequency</fielddescr> <description>Set the refresh frequency of the information on the LCD Panel</description> <type>select</type> <options><option><value>1</value> <name>1 second</name></option> <option><value>2</value> <name>2 seconds</name></option> <option><value>3</value> <name>3 seconds</name></option> <option><value>5</value> <name>5 seconds</name></option> <option><value>10</value> <name>10 seconds</name></option></options> <default_value>5</default_value></field></fields> <custom_php_command_before_form>before_form_lcdproc(&$pkg);</custom_php_command_before_form> <custom_php_validation_command>validate_form_lcdproc($_POST, &$input_errors);</custom_php_validation_command> <custom_php_resync_config_command>sync_package_lcdproc();</custom_php_resync_config_command></packagegui>
Here is my entire lcdproc.inc for your perusal:
/* $Id$ /
/
lcdproc.inc
Copyright (C) 2007 Seth Mos seth.mos@xs4all.nl
All rights reserved.Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/require_once("config.inc"); require_once("functions.inc"); /* LCDproc */ define('LCDPROC_RCFILE', '/usr/local/etc/rc.d/lcdproc.sh'); define('LCDPROC_CLIENT', '/tmp/lcdclient.sh'); define('LCDPROC_CONFIG','/usr/local/etc/LCDd.conf'); define('LCDPROC_HOST','localhost'); define('LCDPROC_PORT','13666'); function lcdproc_notice ($msg) { syslog(LOG_NOTICE, "lcdproc: {$msg}"); } function lcdproc_warn ($msg) { syslog(LOG_WARNING, "lcdproc: {$msg}"); } function lcdproc_action ($action) { if (file_exists(LCDPROC_RCFILE)) mwexec(LCDPROC_RCFILE.' '.$action); } function lcdproc_running () { if((int)exec('pgrep LCDd | wc -l') > 0) return true; return false; } function lcdproc_write_config($file, $text) { $handle = fopen($file, 'w'); if(!$handle) { lcdproc_warn("Could not open {$file} for writing."); exit; } fwrite($handle, $text); fclose($handle); } function lcdproc_write_script($file, $text) { $handle = fopen($file, 'wx'); if(!$handle) { lcdproc_warn("Could not open {$file} for writing."); exit; } fwrite($handle, $text); fclose($handle); chmod($file, 0755); } function before_form_lcdproc($pkg) { global $config; config_lock(); config_unlock(); } function before_form_lcdproc_screens($pkg) { global $config; config_lock(); config_unlock(); } function validate_form_lcdproc($post, $input_errors) { if($post['comport']) { switch($post['comport']) { case "none": continue; break; case "com2": continue; break; case "ucom1": continue; break; case "ucom2": continue; break; case "lpt1": continue; break; case "ugen0.2": continue; break; case "ugen1.2": continue; break; case "ugen2.2": continue; break; case "ttyU0": continue; break; default: $input_errors[] = "The chosen com port is not valid"; break; } } if($post['size']) { switch($post['size']) { case "12x1": continue; break; case "12x2": continue; break; case "12x4": continue; break; case "16x1": continue; break; case "16x2": continue; break; case "16x4": continue; break; case "20x1": continue; break; case "20x2": continue; break; case "20x4": continue; break; default: $input_errors[] = "The chosen display size is not valid"; break; } } } function validate_form_lcdproc_screens($post, $input_errors) { // No validation required ?! } function sync_package_lcdproc_screens() { sync_package_lcdproc(); } function sync_package_lcdproc() { global $g; global $config; global $input_errors; config_lock(); $lcdproc_config = $config['installedpackages']['lcdproc']['config'][0]; $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0]; /* since config is written before this file invoked we don't need to read post data */ if($lcdproc_config['enable'] && ($lcdproc_config['comport'] != "none")) { switch($lcdproc_config['comport']) { case "com2": $realport = "/dev/cua1"; break; case "ucom1": $realport = "/dev/cuaU0"; break; case "ucom2": $realport = "/dev/cuaU1"; break; case "lpt1": $realport = "/dev/lpt0"; break; case "ugen0.2": $realport = "/dev/ugen0.2"; break; case "ugen1.2": $realport = "/dev/ugen1.2"; break; case "ugen2.2": $realport = "/dev/ugen2.2"; break; case "ttyU0": $realport = "/dev/ttyU0"; break; default: lcdproc_warn("The selected com port is not valid!"); return; } $config_text = "[server]\n"; $config_text .= "Driver={$lcdproc_config[driver]}\n"; $config_text .= "Bind=127.0.0.1\n"; $config_text .= "Port=13666\n"; $config_text .= "ReportLevel=3\n"; $config_text .= "ReportToSyslog=yes\n"; $config_text .= "WaitTime=5\n"; $config_text .= "User=nobody\n"; $config_text .= "ServerScreen=no\n"; $config_text .= "Foreground=no\n"; $config_text .= "DriverPath=/usr/local/lib/lcdproc/\n"; $config_text .= "GoodBye=\"Thanks for using\"\n"; $config_text .= "GoodBye=\" {$g['product_name']} \"\n"; /* FIXME: Specific to the pyramid project */ $config_text .= "ToggleRotateKey=Enter\n"; $config_text .= "PrevScreenKey=Left\n"; $config_text .= "NextScreenKey=Right\n"; $config_text .= "ScrollUpKey=Up\n"; $config_text .= "ScrollDownKey=Down\n"; /* FIXME: pyramid test menu */ $config_text .= "[menu]\n"; $config_text .= "MenuKey=Escape\n"; $config_text .= "EnterKey=Enter\n"; $config_text .= "UpKey=Up\n"; $config_text .= "DownKey=Down\n"; /* lcdproc default driver definitions */ switch($lcdproc_config[driver]) { case "SureElec": $config_text .= "[{$lcdproc_config['driver']}]\n"; $config_text .= "driverpath =/usr/local/lib/lcdproc/\n"; $config_text .= "Device={$realport}\n"; $config_text .= "Size={$lcdproc_config['size']}\n"; $config_text .= "Edition=2\n"; $config_text .= "Contrast=200\n"; $config_text .= "Brightness=480\n"; $config_text .= "Speed=19200\n"; break; case "nexcom": $config_text .= "[{$lcdproc_config['driver']}]\n"; $config_text .= "driverpath =/usr/local/lib/lcdproc/\n"; $config_text .= "Device={$realport}\n"; $config_text .= "Size={$lcdproc_config['size']}\n"; break; case "bayrad": $config_text .= "[{$lcdproc_config['driver']}]\n"; $config_text .= "Device={$realport}\n"; $config_text .= "Speed=9600\n"; break; case "picolcd": $config_text .= "[{$lcdproc_config['driver']}]\n"; $config_text .= "driverpath=/usr/local/lib/lcdproc/\n"; $config_text .= "Device={$realport}\n"; $config_text .= "Size={$lcdproc_config['size']}\n"; $config_text .= "KeyTimeout=500\n"; $config_text .= "Brightness=1000\n"; $config_text .= "Blacklight_Timer=60\n"; $config_text .= "Contrast=1000\n"; $config_text .= "Keylights=on\n"; $config_text .= "Key0Light=on\n"; $config_text .= "Key1Light=off\n"; $config_text .= "Key2Light=off\n"; $config_text .= "Key3Light=off\n"; $config_text .= "Key4Light=off\n"; $config_text .= "Key5Light=off\n"; break; case "CFontz": $config_text .= "[{$lcdproc_config['driver']}]\n"; $config_text .= "Device={$realport}\n"; $config_text .= "Size={$lcdproc_config['size']}\n"; $config_text .= "Contrast=350\n"; $config_text .= "Brightness=1000\n"; $config_text .= "OffBrightness=50\n"; $config_text .= "Speed=9600\n"; $config_text .= "NewFirmware=no\n"; $config_text .= "Reboot=no\n"; break; case "CFontz633": $config_text .= "[{$lcdproc_config['driver']}]\n"; $config_text .= "Device={$realport}\n"; $config_text .= "Size={$lcdproc_config['size']}\n"; $config_text .= "Contrast=350\n"; $config_text .= "Brightness=1000\n"; $config_text .= "OffBrightness=50\n"; $config_text .= "Speed=19200\n"; $config_text .= "NewFirmware=yes\n"; $config_text .= "Reboot=yes\n"; break; case "CFontzPacket": $config_text .= "[{$lcdproc_config['driver']}]\n"; $config_text .= "Device={$realport}\n"; $config_text .= "Model=635\n"; $config_text .= "Size={$lcdproc_config['size']}\n"; $config_text .= "Contrast=350\n"; $config_text .= "Brightness=1000\n"; $config_text .= "OffBrightness=50\n"; $config_text .= "Speed=115200\n"; $config_text .= "NewFirmware=yes\n"; $config_text .= "Reboot=yes\n"; break; case "curses": $config_text .= "[{$lcdproc_config['driver']}]\n"; $config_text .= "Foreground=blue\n"; $config_text .= "Background=cyan\n"; $config_text .= "Backlight=red\n"; $config_text .= "Size={$lcdproc_config['size']}\n"; $config_text .= "TopLeftX=7\n"; $config_text .= "TopLeftY=7\n"; $config_text .= "UseACS=no\n"; break; case "CwLynx": $config_text .= "[{$lcdproc_config['driver']}]\n"; $config_text .= "Model=12232\n"; $config_text .= "Device={$realport}\n"; $config_text .= "Size={$lcdproc_config['size']}\n"; $config_text .= "Speed=19200\n"; $config_text .= "Reboot=no\n"; break; case "pyramid": $config_text .= "[{$lcdproc_config['driver']}]\n"; $config_text .= "Device={$realport}\n"; $config_text .= "Size={$lcdproc_config['size']}\n"; break; case "ea65": $config_text .= "[{$lcdproc_config['driver']}]\n"; $config_text .= "Device={$realport}\n"; $config_text .= "OffBrightness=0\n"; $config_text .= "Brightness=500\n"; break; default: lcdproc_warn("The chosen lcdproc driver is not a valid choice"); unset($lcdproc_config[driver]); } /* generate rc file start and stop */ $client_script = <<<eod<br>#!/bin/sh
script starts a lcd client and always keeps it active.
counter=1
while [ "$counter" -ne 0 ]
do
# loop the client to drive the display
/usr/local/bin/php -f /usr/local/pkg/lcdproc_client.php
sleep 1
doneEOD;
/* generate rc file start and stop */ $stop = << <eod<br>if [ `ps auxw |awk '/LCD[d]/ {print $2}'| wc -l` != 0 ]; then ps auxw |awk '/LCD[d]/ {print $2}'|xargs kill sleep 1
fi
if [ps auxw |awk '/lcdclient.s[h]/ {print $2}'| wc -l
!= 0 ]; then
ps auxw |awk '/lcdclient.s[h]/ {print $2}'|xargs kill
sleep 1
fiEOD;
$start = $stop ."\n";
$start .= "\t/usr/local/sbin/LCDd -c ". LCDPROC_CONFIG ."\n";
$start .= "\t". LCDPROC_CLIENT ." &\n";/* write out the configuration */ conf_mount_rw(); lcdproc_write_script(LCDPROC_CLIENT, $client_script); lcdproc_write_config(LCDPROC_CONFIG, $config_text); write_rcfile(array( 'file' => 'lcdproc.sh', 'start' => $start, 'stop' => $stop )); conf_mount_ro(); /* or restart lcdproc if settings were changed */ if(lcdproc_running($_POST['comport'])) { lcdproc_notice("Restarting service lcdproc"); lcdproc_action('restart'); } } if((! $lcdproc_config['driver']) || ($lcdproc_config['comport'] == "none")) { /* no parameters user does not want lcdproc running */ /* lets stop the service and remove the rc file */ if(file_exists(LCDPROC_RCFILE)) { if(!$lcdproc_config['enable']) { lcdproc_notice('Stopping service: lcdproc disabled'); } else { lcdproc_notice('Stopping service: no com port selected'); } lcdproc_action('stop'); conf_mount_rw(); unlink(LCDPROC_RCFILE); unlink(LCDPROC_CLIENT); unlink(LCDPROC_CONFIG); conf_mount_ro(); } } config_unlock(); }
?></eod<br></eod<br>/seth.mos@xs4all.nl
Hope this help!</options>