JamesScottJr
New member
Folks,
With the help of prior post to this forum I was able to write a linux daemon for Ubuntu that does what I needed; display the appliance tpcip info via our 633 display. If permitted, I will attach a tarball (ok only zip files are support) that will compile on both 32 and 64bit systems, and has been tested on Fedora and Ubuntu systems. A readme is included with al the details.
I start with the code from "635 Linux Demonstration Code, Written by Brent A. Crosby" and wrapped it in a daemon shell, along with a few other improvements or simplifications.
James,
With the help of prior post to this forum I was able to write a linux daemon for Ubuntu that does what I needed; display the appliance tpcip info via our 633 display. If permitted, I will attach a tarball (ok only zip files are support) that will compile on both 32 and 64bit systems, and has been tested on Fedora and Ubuntu systems. A readme is included with al the details.
I start with the code from "635 Linux Demonstration Code, Written by Brent A. Crosby" and wrapped it in a daemon shell, along with a few other improvements or simplifications.
James,
Code:
README.debian Ubuntu 8.0.4
DESCRIPTION:
LCD_Manager
A demonstration program and utility for displaying
TCP/IP information on a Crystalfontz 633 16x2 LCD Display.
AUTHORS:
Major portions of this package were modeled after the following:
"635 Linux Demonstration Code"
"Copyright 2005, Crystalfontz America, Inc. Written by Brent A. Crosby"
"www.crystalfontz.com, [email]brent@crystalfontz.com[/email]"
Author: James Scott Jr <james.scott@tripractix.com>, 8/2008
PACKAGE DETAILS:
The package is composed of the following files:
* LCD_Manager-<version>.tar.bz2 -- Distribution file.
* LCDManager -- Package main directory
- README.debian -- this file
- Makefile -- standard C makefile, with all/clean/install/refresh/uninstall targets
- lcd_manager.initd -- Debian styled init.d script to supportthe runtime as a daemon
- lcd_manager.h -- Package header with required constants
- lcd_manager -- Executable produced by compile operation
- lcd_daemon.c -- Daemon management signal handling routines
- lcd_controller.c|h -- Management logic or progam mainline
(note: could be used a main() if daemon is removed)
- lcd_getip.c|h -- TCPIP information gathering routines
- lcd_link.c|h -- 633 Serial Communication and packet management routines
INSTALLATION:
1. Unpack distribution file
$ tar -jxvf LCD_Manager-<version>.tar.bz2
2. Change into that Directory
$ cd ./LCDManager
3. Compile the program
$ make clean all
4. Install the program
$ sudo make install
** effects: /usr/bin/lcd_manager -- binary
/etc/init.d/lcd_manager -- debian init script (supports /etc/init.d/lcd_manager [start|stop]
/etc/rcS.d/S91lcd_manager -- debian startup soft link, to start daemon during machine bootup
5. Observe and press buttons
RUNTIME OPTIONS:
lcd_manager -- manage CrystalFontz 633 16x2 LCD.
triPRACTIX, LLC <James.Scott@triPRACTIX.com>
Usage:
lcd_manager [-v] [-i] [-s dev-portname] [-d 1|88] [-h|--help]
Options:
-d 1|88 --debug=1 Debug mode=1, Debug & no demonize=88
-f, --forcepid Overwrite pid file.
-p, --pidfile fname default is /var/run/lcd_manager.pid
-s, --serial port for LCD defaults to /dev/ttyS1
-i, --upstart Do not fork off
-v, --version Version printout.
-h, --help Show this help screen.
FUNCTIONAL DESCRIPTION:
Objective:
* Establish a robust daemon environment with an options fork/no fork
* Support linux signals SIGHUP to cause a ip info refresh
SIGQUIT to cause an orderly shutdown of program
* Gather and display TCP/IP Information from LINUX OS
applying a preference for info from one interface via this order "bond0", "eth0", "eth1"
> Hostname: some.host.name
> Interface: bond0
> IP Address: ddd.ddd.ddd.ddd
> HW Address: xxxx.xxxx.xxxx
> Netmask: ddd.ddd.ddd.ddd
> Broadcast: ddd.ddd.ddd.ddd
> Gateway: ddd.ddd.ddd.ddd
* Collect external application status by query key files to determine state
> License Status: Enabled! | Setup Required!
>Application Status: Not Started | Starting | Ready
* Organize IP info and Status info into seven seperate displays, navigitable from the keypad
- Up/Down key rolls thru panels virtically
- Left/Right keys move to the top or bottom
- OK, causes a ip info refresh on each press
* Have a regular ip info and status polling cycle of about 20 seconds
* Have a status polling cycle of 2 seconds during program startup, until Application Status is Ready
- disabled in this demo
* Minimal use of globals provides the ability to support multiple 633 from one program in the future
REQUIREMENTS:
Standard Linux 2.6+ Kernel and gcc development tools with pthread support
Developed as both a 32bit and 64bit program, works in either mode.
Should work as is in debian, ubuntu, and red-hat/rpm based systems.
PROGRAM LOGIC:
1. Parse the commandline options and setup defaults and selections
2. Preform the demonize double-fork step if requested
3. Start a signal handling thread to process all signals for the app, and prevent main thread
from being interrupted, and create pidfile.
4. Call lctrl_controller() to handle primary function
A. Initial the 633 serial port to speed and 300ms wait times for first char x_cc[VTIME]
B. Perform a read to ring buffer for clean the serial channel
C. Call the getip() routine which collect ip info and application state into an array
of LCD_IPINFO structures (allocated per call)
D. Review the status cycle
E. Query and process any keypress
F. Loop to (B) until exit_signal
G. Write final page, "System Restarting"
H. return from lctrl_controller()
5. release allocated storage, shutdown signal thread, unlink_pidfile and exit.
DEBUG:
The commandline options cause extension debug logging to the system log /var/log/messages
--debug=1 -- send debugging messages to the system log
SUPPORT:
Type: Best Effort
email: Author [email]james.scott@tripractix.com[/email]
forum: Crystalfontz LCD Forum, [url]https://forum.crystalfontz.com/[/url]
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
Attachments
-
27.1 KB Views: 478
Last edited: