[c5c522c] | 1 | <!DOCTYPE book PUBLIC "-//Davenport//DTD DocBook V3.0//EN"> |
---|
| 2 | |
---|
| 3 | <book> |
---|
| 4 | <bookinfo> |
---|
| 5 | <date>1999-02-08</date> |
---|
| 6 | <title>LCDproc User's Guide</title> |
---|
| 7 | <subtitle>Installation and Client Development Guide</subtitle> |
---|
| 8 | </bookinfo> |
---|
| 9 | <toc></toc> |
---|
| 10 | |
---|
| 11 | <chapter> |
---|
| 12 | <title>Introduction</title> |
---|
| 13 | <para>LCDproc is a system status monitoring application that drives a |
---|
| 14 | variety of different LCD-based display devices. It provides a powerful |
---|
| 15 | framework for networked statistic gathering, adding new monitors or |
---|
| 16 | LCD-aware applications, and adding new devices. |
---|
| 17 | </para> |
---|
| 18 | <para>The client shipped with LCDproc v0.4 can connect to an LCDproc |
---|
| 19 | server either on the local system or on a remote system as long as it |
---|
| 20 | is reachable. It extracts the same statistics regardless of where it |
---|
| 21 | sends this information. The statistics it gathers include CPU |
---|
| 22 | utilization, memory utilization, disk utilization, network utilization, |
---|
| 23 | system uptime, time, and date, and so on. It displays this information |
---|
| 24 | in assorted ways, and can be tailored to taste. |
---|
| 25 | </para> |
---|
| 26 | <sect1> |
---|
| 27 | <title>Supported Hardware</title> |
---|
| 28 | <para>As shipped, LCDproc v0.4 supports LCD modules from Matrix |
---|
| 29 | Orbital Corporation, HD447800-controlled LCDs, and can emulate an LCD with |
---|
| 30 | the curses library or plain, raw, ugly text. |
---|
| 31 | </para> |
---|
| 32 | <sect2> |
---|
| 33 | <title>Matrix Orbital LCD Modules</title> |
---|
| 34 | <para> |
---|
| 35 | LCDproc was born out of original tinkering by William Ferrell with |
---|
| 36 | one of these LCD modules. Their ease of installation and use (as well |
---|
| 37 | as the amazing amount of patience demonstrated by the folks at |
---|
| 38 | Matrix Orbital whilst William figured things out) meant one less thing |
---|
| 39 | to worry about during the early stages of LCDproc's life. |
---|
| 40 | </para> |
---|
| 41 | <para> |
---|
| 42 | These 20x4 alphanumeric modules are connected via standard DB-9 cabling and |
---|
| 43 | connectors. They draw either 5V or 12V, depending on the module purchased, |
---|
| 44 | and are attached with a standard floppy cable connector (with a slightly |
---|
| 45 | modified wire configuration). |
---|
| 46 | </para> |
---|
| 47 | <para> |
---|
| 48 | Once connected, using them is a breeze. They can operate at any number of |
---|
| 49 | different baud rates and serial configurations, but normally they run at |
---|
| 50 | 19,200 baud, 8-N-1, making them quite quick. Sending ASCII to the module |
---|
| 51 | will make it simply display that text at its current cursor position. The |
---|
| 52 | module has a built-in BIOS that recognizes commands (sent by transmitting a |
---|
| 53 | single-byte "marker" signifying that a command is on the way, followed by |
---|
| 54 | the single-byte command character itself along with any parameters, if needed) |
---|
| 55 | allowing the programmer to clear the screen, position the cursor anywhere, |
---|
| 56 | define custom characters (up to 8 at a time), draw bar graphs and large numbers, |
---|
| 57 | change the LCD's contrast, and so on. |
---|
| 58 | </para> |
---|
| 59 | <para> |
---|
| 60 | The BIOS included also implements line-wrapping (i.e. writing past the |
---|
| 61 | twentieth character on the first row will automatically move the cursor |
---|
| 62 | to the first character on the second row), and screen scrolling (i.e. |
---|
| 63 | writing past the twentieth character on the fourth row causes the whole |
---|
| 64 | screen to scroll up one row, clearing the fourth line and positioning the |
---|
| 65 | cursor at the first character on that line). |
---|
| 66 | </para> |
---|
| 67 | <para> |
---|
| 68 | These modules are fast. Using the auto-line-wrap feature and disabling |
---|
| 69 | the auto-scrolling feature, the screen can be updated thirty times per |
---|
| 70 | second if *every* character on the screen is changed. If updating less |
---|
| 71 | than the whole screen, the LCD can update faster than can be seen by |
---|
| 72 | the human eye. This, of course, more than meets LCDproc's needs. |
---|
| 73 | </para> |
---|
| 74 | </sect2> |
---|
| 75 | <sect2> |
---|
| 76 | <title>HD44780 Controller-Based LCDs</title> |
---|
| 77 | <para> |
---|
| 78 | These LCDs are controlled by the Hitachi HD44780 LCD controller, and |
---|
| 79 | connect to a system's parallel port. Not much else is known about these |
---|
| 80 | devices at this time. [Update this section]. |
---|
| 81 | </para> |
---|
| 82 | </sect2> |
---|
| 83 | <sect2> |
---|
| 84 | <title>LCD Emulation</title> |
---|
| 85 | <para> |
---|
| 86 | LCDproc can emulate an LCD on a curses terminal (or even on a dumb terminal |
---|
| 87 | by writing raw text out, if you're that desperate). The output is confined to |
---|
| 88 | a 20x4 character area, just like on a real LCD, and can be "swallowed" into |
---|
| 89 | window manager panels such as fvwmbuttons. |
---|
| 90 | </para> |
---|
| 91 | </sect2> |
---|
| 92 | </sect1> |
---|
| 93 | <sect1> |
---|
| 94 | <title>LCDproc Documentation</title> |
---|
| 95 | <para> |
---|
| 96 | This document is intended to be full, complete documentation for |
---|
| 97 | LCDproc. While some information presented in this document is present |
---|
| 98 | in assorted files scattered across the LCDproc distribution tarball, |
---|
| 99 | this document is meant to encompass all aspects of dealing with |
---|
| 100 | LCDproc, from installation, all the way to developing custom clients |
---|
| 101 | using LCDproc's client/server API. |
---|
| 102 | </para> |
---|
| 103 | <para> |
---|
| 104 | README and INSTALL files will always be distributed with LCDproc, along |
---|
| 105 | with the requisite copyright and licensing information, but this document |
---|
| 106 | will eventually replace the content of the README and INSTALL files. |
---|
| 107 | </para> |
---|
| 108 | <para> |
---|
| 109 | This documentation was written in SGML and |
---|
| 110 | <ULINK URL="http://www.oasis-open.org/docbook/">DocBook</ULINK>. SGML is a |
---|
| 111 | generalized markup language (of which HTML is a subset), and DocBook is a set of |
---|
| 112 | layout tools and markups using SGML that lends itself quite nicely to the publishing |
---|
| 113 | of technical manuals and software documentation like this. |
---|
| 114 | </para> |
---|
| 115 | <para> |
---|
| 116 | In Linux, one can produce DVI, PostScript, HTML, Unix Manual Pages and Info |
---|
| 117 | pages from the same SGML/DocBook source using |
---|
| 118 | <ULINK URL="http://www.sgmltools.org/">SGMLtools</ULINK>. Take a look at this set |
---|
| 119 | of tools if you have any large-scale documentation to write. It might have a bit of |
---|
| 120 | a steep learning curve, but it's certainly worth the effort. |
---|
| 121 | </para> |
---|
| 122 | </sect1> |
---|
| 123 | </chapter> |
---|
| 124 | |
---|
| 125 | <chapter> |
---|
| 126 | <title>Installation</title> |
---|
| 127 | <para> |
---|
| 128 | This chapter covers the installation process for both LCDproc, and the actual LCD |
---|
| 129 | module intended for use with LCDproc. Since our experience has involved almost |
---|
| 130 | exclusively the Matrix Orbital modules, we will spend little time on installation |
---|
| 131 | instructions for other hardware. |
---|
| 132 | </para> |
---|
| 133 | <para> |
---|
| 134 | If you have successfully installed LCDproc-compatible hardware and would care to |
---|
| 135 | document how you did so, please e-mail the author of this book |
---|
| 136 | (choadster@earthlink.net). |
---|
| 137 | </para> |
---|
| 138 | <para> |
---|
| 139 | We will examine the installation process of LCDproc and the hardware it drives in |
---|
| 140 | small steps, as it is vitally important to pay close attention to detail during |
---|
| 141 | hardware installation to avoid damaging equipment, as well as during LCDproc's |
---|
| 142 | installation, since things have become a little more complicated since LCDproc's |
---|
| 143 | split into a client and server model. |
---|
| 144 | </para> |
---|
| 145 | <para> |
---|
| 146 | First, hardware installation is discussed. If you are not using physical LCD |
---|
| 147 | hardware to run LCDproc, you can safely skip the hardware installation sections and |
---|
| 148 | move on to the software installation sections. |
---|
| 149 | </para> |
---|
| 150 | <sect1> |
---|
| 151 | <title>Hardware Installation</title> |
---|
| 152 | <para> |
---|
| 153 | Regardless of what specific type of hardware you intend to use with LCDproc, |
---|
| 154 | installation is usually straightforward, and requires only a few steps. Regardless, |
---|
| 155 | you must use caution while working inside your computer system or with any hardware |
---|
| 156 | attachments. |
---|
| 157 | </para> |
---|
| 158 | <Warning> |
---|
| 159 | <Title>Warning!</Title> |
---|
| 160 | <para> |
---|
| 161 | Installing new hardware inside a computer system can be dangerous to both |
---|
| 162 | system components and the installer. Use caution whenever adding a component |
---|
| 163 | to the inside of your system, altering a power cable, or physically mounting |
---|
| 164 | a device inside a computer system. |
---|
| 165 | </para> |
---|
| 166 | <para> |
---|
| 167 | When installing hardware inside a computer, make sure it's turned off and that |
---|
| 168 | its power is disconnected. This is especially important when making changes to |
---|
| 169 | power cables (as some LCD modules require). |
---|
| 170 | </para> |
---|
| 171 | </Warning> |
---|
| 172 | <sect2> |
---|
| 173 | <title>Matrix Orbital LCD/VFD Module Installation</title> |
---|
| 174 | <para> |
---|
| 175 | The LCD and VFD modules from Matrix Orbital are relatively straightforward |
---|
| 176 | to install. With a small, regular (flat-head) screwdriver, a spare floppy drive |
---|
| 177 | power cable, and a bit of luck, installation will take less than an hour. |
---|
| 178 | </para> |
---|
| 179 | <para> |
---|
| 180 | These installation instructions assume that you are installing the module into |
---|
| 181 | a PC or PC-style system (one with AT- or ATX-compliant power cabling) and that |
---|
| 182 | you have some idea of where you intend to permanently mount the module. For |
---|
| 183 | mounting ideas and tips, refer to the section "Mounting" below. |
---|
| 184 | </para> |
---|
| 185 | <Tip> |
---|
| 186 | <Title>Before you start</title> |
---|
| 187 | <para> |
---|
| 188 | Your Matrix Orbital LCD or VFD module should be clearly marked with an |
---|
| 189 | indication of the module's power requirements. It should be either a 5 volt |
---|
| 190 | or 12 volt unit. You should have this information available before proceeding. |
---|
| 191 | </para> |
---|
| 192 | </tip> |
---|
| 193 | <sect3> |
---|
| 194 | <title>Power Cable Modification</title> |
---|
| 195 | <para> |
---|
| 196 | The first step in installing the module is making the necessary modifications |
---|
| 197 | to a floppy drive power cable in order to provide power to the module. The |
---|
| 198 | modifications must be made based on the module's power requirements -- either |
---|
| 199 | 5V or 12V -- depending on which module you purchased. |
---|
| 200 | </para> |
---|
| 201 | <para> |
---|
| 202 | A standard floppy drive power cable has a smaller connection than a "normal" |
---|
| 203 | PC power connector. However, like a "normal" power connector, it has four |
---|
| 204 | wires: one yellow, one red, and two black. The red wire provides +5V power, and |
---|
| 205 | is "hot" or live when the system is powered up. The yellow wire provides +12V |
---|
| 206 | power, and is also hot when the system is powered up. Both black wires are |
---|
| 207 | ground. |
---|
| 208 | [TODO: INCLUDE A FIGURE HERE SHOWING A "STANDARD" FLOPPY CONNECTOR] |
---|
| 209 | </para> |
---|
| 210 | <para> |
---|
| 211 | One of the hot wires and one of the black wires will not be needed for your |
---|
| 212 | module's power connection; they will be completely removed when the power cable |
---|
| 213 | modification is complete. |
---|
| 214 | </para> |
---|
| 215 | <Warning> |
---|
| 216 | <title>Warning!</title> |
---|
| 217 | <para> |
---|
| 218 | Do NOT make this modification to a power cable attached to a running |
---|
| 219 | system! Electrocution resulting in personal injury and/or damage to the |
---|
| 220 | system can result. |
---|
| 221 | </para> |
---|
| 222 | </Warning> |
---|
| 223 | <para> |
---|
| 224 | Using a regular screwdriver, press down the small metal locking flap of one |
---|
| 225 | of the two black wires on the small end of the cable, and pull the black wire |
---|
| 226 | from the connector. Using a pair of needle-nose pliers, squeeze the other end |
---|
| 227 | of the same black wire, and pull it out of the large end of the cable. This |
---|
| 228 | black wire can be set aside; it will not be used for the module's power |
---|
| 229 | connection. Either wire can be safely removed; you may safely remove either |
---|
| 230 | wire. |
---|
| 231 | [TODO: INCLUDE A FIGURE HERE SHOWING THIS PROCESS] |
---|
| 232 | </para> |
---|
| 233 | <para> |
---|
| 234 | Next, using the same procedure, remove the unneeded hot wire. If your module |
---|
| 235 | is 5V, you do not need the yellow (+12V) wire. Conversely, if your module is |
---|
| 236 | 12V, you do not need the red (+5V) wire. The removed wire can be set aside; |
---|
| 237 | it will not be used for the module's power connection. |
---|
| 238 | [TODO: INCLUDE A FIGURE HERE] |
---|
| 239 | </para> |
---|
| 240 | <para> |
---|
| 241 | The floppy power connector should now have only two wires attached to it. |
---|
| 242 | Leave the larger end alone from now on; these connections are correct (the |
---|
| 243 | larger end connects to your system's power mains). Move the two remaining wires |
---|
| 244 | to the outside connectors on the small end of the cable. Orientation does not |
---|
| 245 | particularly matter here; the connector will fit on the module's receptacle |
---|
| 246 | in either orientation. |
---|
| 247 | [TODO: A FIGURE HERE] |
---|
| 248 | </para> |
---|
| 249 | <para> |
---|
| 250 | You should now have a properly modified power connector. When physically |
---|
| 251 | attaching this connector to the module, the black (ground) lead should be |
---|
| 252 | connected to the pin labelled GND, while the colored (+5V/+12V) lead should |
---|
| 253 | be connected to the pin labelled +5V/+12V. |
---|
| 254 | </para> |
---|
| 255 | <para> |
---|
| 256 | Test the power connection before connecting the data line or mounting the |
---|
| 257 | module. Connect the module to the power connector, and the connector to your |
---|
| 258 | system's power mains. Turn the system on. |
---|
| 259 | </para> |
---|
| 260 | <Caution> |
---|
| 261 | <Title>Caution</Title> |
---|
| 262 | <para> |
---|
| 263 | If the module does not immediately display its initial BIOS screen and light |
---|
| 264 | up its backlight (or light up the screen if a VFD module is being used), |
---|
| 265 | <EMPHASIS>immediately</EMPHASIS> power down the system, disconnect the module |
---|
| 266 | and connector, and double-check the modification before trying again. Do NOT |
---|
| 267 | leave the system on if the module does not immediately respond; module or |
---|
| 268 | system damage could result. |
---|
| 269 | </para> |
---|
| 270 | </Caution> |
---|
| 271 | <para> |
---|
| 272 | When the LCD powers up and displays its initial BIOS screen, you've gotten the |
---|
| 273 | power connection wired properly and can now properly mount the module and make |
---|
| 274 | its final connections. Matrix Orbital Corporation sells a PC bay insert mount |
---|
| 275 | for the 20x4 and 20x2 modules (LCDproc, however, only supports the 20x4 at |
---|
| 276 | present). The inserts provide an easy means of mounting the LCD modules inside |
---|
| 277 | a PC using one (for the 20x2) or two (for the 20x4) 5 1/4" bays. |
---|
| 278 | </para> |
---|
| 279 | <Note> |
---|
| 280 | <title>Note</title> |
---|
| 281 | <para> |
---|
| 282 | Describing how to physically mount the module in a PC case is beyond the |
---|
| 283 | scope of this document; LCDproc's website contains more detailed mounting |
---|
| 284 | information and examples. |
---|
| 285 | </para> |
---|
| 286 | </Note> |
---|
| 287 | </sect3> |
---|
| 288 | <sect3> |
---|
| 289 | <title>Serial Connection</title> |
---|
| 290 | <para> |
---|
| 291 | The LCD module uses a standard DB9 serial connector. You can attach the module |
---|
| 292 | to your system using a direct cable to the motherboard, or by removing one of |
---|
| 293 | your system's serial ports from the back of the case, then connecting it to a |
---|
| 294 | standard serial cable to the module. |
---|
| 295 | </para> |
---|
| 296 | <para> |
---|
| 297 | While connecting the serial cable to the module, be sure to configure the |
---|
| 298 | module's serial interface settings. Typically, setting the module to its fastest |
---|
| 299 | setting (19,200 baud, 8-N-1) is recommended. At present, the Matrix Orbital |
---|
| 300 | module driver in LCDproc is hardwired to use these settings; using different |
---|
| 301 | ones will require minor changes to the driver's code. |
---|
| 302 | </para> |
---|
| 303 | </sect3> |
---|
| 304 | </sect2> |
---|
| 305 | <sect2> |
---|
| 306 | <title>Other Display Types</title> |
---|
| 307 | <para> |
---|
| 308 | At present, we do not have any detailed information regarding the installation |
---|
| 309 | of other types of LCDs. If you have any information that would be useful to |
---|
| 310 | include here, please contact William Ferrell |
---|
| 311 | (<ULINK URL="mailto:choadster@earthlink.net">choadster@earthlink.net</ULINK>). |
---|
| 312 | </para> |
---|
| 313 | </sect2> |
---|
| 314 | </sect1> |
---|
| 315 | </chapter> |
---|
| 316 | <chapter> |
---|
| 317 | <title>LCDproc Distribution Layout</title> |
---|
| 318 | <para>The current LCDproc distribution contains both the LCDproc server |
---|
| 319 | and the LCDproc client. It also contains sparse documentation (this |
---|
| 320 | document will hopefully solve this problem), and a sample Perl client. |
---|
| 321 | [THIS WILL CHANGE -- REWRITE THIS PARAGRAPH]</para> |
---|
| 322 | |
---|
| 323 | <sect1> |
---|
| 324 | <title>Basic Layout</title> |
---|
| 325 | <para> |
---|
| 326 | LCDproc is distributed in a single archive containing both the client(s) |
---|
| 327 | and the server: |
---|
| 328 | <SimpleList columns=2> |
---|
| 329 | <Member>clients/</Member> |
---|
| 330 | <Member>docs/</Member> |
---|
| 331 | <Member>old/</Member> |
---|
| 332 | <Member>server/</Member> |
---|
| 333 | <Member>server/drivers/</Member> |
---|
| 334 | <Member>shared/</Member> |
---|
| 335 | <Member>tests/</Member> |
---|
| 336 | <Member>BUGS</Member> |
---|
| 337 | <Member>COPYING</Member> |
---|
| 338 | <Member>INSTALL</Member> |
---|
| 339 | <Member>Makefile</Member> |
---|
| 340 | <Member>Makefile.config</Member> |
---|
| 341 | <Member>README</Member> |
---|
| 342 | <Member>TODO</Member> |
---|
| 343 | <Member>WHATSNEW</Member> |
---|
| 344 | <Member>Contains the LCDproc client and the sample Perl client</Member> |
---|
| 345 | <Member>Documentation (sparse at the moment)</Member> |
---|
| 346 | <Member>Contains older source code, unused in compiling v0.4</Member> |
---|
| 347 | <Member>Contains the LCDproc server</Member> |
---|
| 348 | <Member>Contains LCDproc's device drivers</Member> |
---|
| 349 | <Member>Contains shared code</Member> |
---|
| 350 | <Member>Contains test code not used in compiling</Member> |
---|
| 351 | <Member>A list of known bugs in the current version</Member> |
---|
| 352 | <Member>The GNU General Public License</Member> |
---|
| 353 | <Member>Installation Instructions</Member> |
---|
| 354 | <Member>File for the "make" utility, used to compile LCDproc</Member> |
---|
| 355 | <Member>Contains compile-time user-tunable defaults for LCDproc</Member> |
---|
| 356 | <Member>Read this file first! Contains basic information regarding LCDproc, |
---|
| 357 | what it does, how it works, and how to start building it.</Member> |
---|
| 358 | <Member>List of planned changes and improvements.</Member> |
---|
| 359 | <Member>List of revisions that have been made to LCDproc throughout its |
---|
| 360 | development. [This should be changed to ChangeLog]</Member> |
---|
| 361 | </Simplelist> |
---|
| 362 | </para> |
---|
| 363 | </sect1> |
---|
| 364 | <sect1> |
---|
| 365 | <title>A Stroll Through the Code</title> |
---|
| 366 | <para> |
---|
| 367 | This section attempts to document how LCDproc works. Both the server and |
---|
| 368 | the client are explored at the source code level. This section was written |
---|
| 369 | as an exercise for the author to help him better understand LCDproc's |
---|
| 370 | inner workings, allowing him to better document LCDproc for end users and |
---|
| 371 | developers. Feel free to skip past this entire section unless you really |
---|
| 372 | feel like reading how LCDproc renders screens, manages clients, deals with |
---|
| 373 | input, and handles trouble. |
---|
| 374 | </para> |
---|
| 375 | <sect2> |
---|
| 376 | <title>The LCDproc Server, LCDd</title> |
---|
| 377 | <para> |
---|
| 378 | LCDd is the central component of LCDproc. It is responsible for several |
---|
| 379 | different activities: |
---|
| 380 | |
---|
| 381 | <SimpleList> |
---|
| 382 | <Member>Initializing the output device</Member> |
---|
| 383 | <Member>Initializing the incoming socket</Member> |
---|
| 384 | <Member>Listening for client connections and accepting them</Member> |
---|
| 385 | <Member>Storing screens provided by clients</Member> |
---|
| 386 | <Member>Storing stats provided by clients</Member> |
---|
| 387 | <Member>Choose the best screen to display on the LCD based on order of |
---|
| 388 | client and screen arrival, and by priority</Member> |
---|
| 389 | <Member>Provide a rich screen-drawing widget set for clients to use</Member> |
---|
| 390 | <Member>Render screens to the LCD</Member> |
---|
| 391 | <Member>Gracefully handle dead sockets and clients</Member> |
---|
| 392 | <Member>Gracefully remove screens and clients when asked to by clients or |
---|
| 393 | the user</Member> |
---|
| 394 | </SimpleList> |
---|
| 395 | </para> |
---|
| 396 | <para> |
---|
| 397 | To accomplish all this, LCDd splits into dozens of source files to handle |
---|
| 398 | different bits of the job. We will examine each of these source files one by |
---|
| 399 | one (and, to make things easier, in alphabetical order). Header files (*.h) |
---|
| 400 | will not be included in this discussion. |
---|
| 401 | </para> |
---|
| 402 | <sect3> |
---|
| 403 | <title>server/client_data.c</title> |
---|
| 404 | <para> |
---|
| 405 | This file appears to contain code that handles the creation and destruction |
---|
| 406 | of linked lists for client data. |
---|
| 407 | </para> |
---|
| 408 | </sect3> |
---|
| 409 | <sect3> |
---|
| 410 | <title>server/client_functions.c</title> |
---|
| 411 | <para> |
---|
| 412 | This file actually describes itself as its first comment! It contains |
---|
| 413 | definitions for all the functions that the clients can run. They are to |
---|
| 414 | be called only from server/parse.c. |
---|
| 415 | </para> |
---|
| 416 | <para> |
---|
| 417 | Here the functions that clients call when connected to LCDd are actually |
---|
| 418 | defined and performed. |
---|
| 419 | </para> |
---|
| 420 | </sect3> |
---|
| 421 | <sect3> |
---|
| 422 | <title>server/clients.c</title> |
---|
| 423 | <para> |
---|
| 424 | This file contains code allowing LCDd to handle client connections and |
---|
| 425 | data structures. It contains functions to initialize the internal list |
---|
| 426 | of clients, terminate client connections, add new clients to the list, |
---|
| 427 | add, remove, and retrieve messages to clients' message queues, and |
---|
| 428 | locating a client's socket. |
---|
| 429 | </para> |
---|
| 430 | </sect3> |
---|
| 431 | <sect3> |
---|
| 432 | <title>server/input.c</title> |
---|
| 433 | <para> |
---|
| 434 | This file contains functions that handle input from keypads, joysticks, |
---|
| 435 | etc. |
---|
| 436 | </para> |
---|
| 437 | </sect3> |
---|
| 438 | <sect3> |
---|
| 439 | <title>server/main.c</title> |
---|
| 440 | <para> |
---|
| 441 | Where the action is. |
---|
| 442 | </para> |
---|
| 443 | <para> |
---|
| 444 | This file contains LCDd's main() function and supporting code. It begins |
---|
| 445 | life by configuring signal handlers, then by immediately initializing the |
---|
| 446 | LCD drivers. (Huh?) It then parses the command line, configuring the |
---|
| 447 | LCD driver appropriately, then initializes its internal lists and the |
---|
| 448 | socket.</para> |
---|
| 449 | <para> |
---|
| 450 | Next, it forks into a daemon process (shedding its controlling terminal) |
---|
| 451 | and enters the main loop. The main loop: listens for connections from |
---|
| 452 | new clients and for input from already connected ones, parses all input |
---|
| 453 | from connected clients, checks for input, then updates the screen list |
---|
| 454 | and updates the LCD. |
---|
| 455 | </para> |
---|
| 456 | <para> |
---|
| 457 | Also present are functions to handle graceful exits when various signals |
---|
| 458 | are received, and a help screen. |
---|
| 459 | </para> |
---|
| 460 | </sect3> |
---|
| 461 | <sect3> |
---|
| 462 | <title>server/menu.c</title> |
---|
| 463 | <para> |
---|
| 464 | This appears to be code to handle server-generated menu screens on the LCD. |
---|
| 465 | [I don't understand this file in the slightest ... study this harder later] |
---|
| 466 | </para> |
---|
| 467 | </sect3> |
---|
| 468 | <sect3> |
---|
| 469 | <title>server/parse.c</title> |
---|
| 470 | <para> |
---|
| 471 | This file contains code that parses input from the clients. |
---|
| 472 | parse_all_client_messages() is called once each time through main()'s loop. |
---|
| 473 | </para> |
---|
| 474 | </sect3> |
---|
| 475 | <sect3> |
---|
| 476 | <title>server/render.c</title> |
---|
| 477 | <para> |
---|
| 478 | This file contains code that actually generates the full screen data to |
---|
| 479 | send to the LCD. draw_screen() takes a screen definition and a counter as its |
---|
| 480 | arguments. It builds the screen according to the definition, and using the |
---|
| 481 | counter as a reference. |
---|
| 482 | </para> |
---|
| 483 | </sect3> |
---|
| 484 | <sect3> |
---|
| 485 | <title>server/screen.c</title> |
---|
| 486 | <para> |
---|
| 487 | This file stores all the screen definition-handling code. Functions here |
---|
| 488 | provide means to create new screens and destroy existing ones. Screens are |
---|
| 489 | identified by client and by the client's own identifiers for screens. |
---|
| 490 | </para> |
---|
| 491 | </sect3> |
---|
| 492 | <sect3> |
---|
| 493 | <title>server/screenlist.c</title> |
---|
| 494 | <para> |
---|
| 495 | This appears to be the screenlist handler that decides which screen to |
---|
| 496 | display based on priorities and screen creation order. |
---|
| 497 | </para> |
---|
| 498 | </sect3> |
---|
| 499 | <sect3> |
---|
| 500 | <title>server/serverscreens.c</title> |
---|
| 501 | <para> |
---|
| 502 | This file contains code to allow the server to generate its own screens. |
---|
| 503 | Currently, only the server status screen is provided, showing total number |
---|
| 504 | of connected clients, and the combined total of screens they provide (this |
---|
| 505 | count does not include the server's screens). |
---|
| 506 | </para> |
---|
| 507 | <para> |
---|
| 508 | It is interesting to note that the server creates a special screen |
---|
| 509 | definition for its screens, but uses the same widget set made available |
---|
| 510 | to clients. |
---|
| 511 | </para> |
---|
| 512 | </sect3> |
---|
| 513 | <sect3> |
---|
| 514 | <title>server/sock.c</title> |
---|
| 515 | <para> |
---|
| 516 | This file contains all the sockets code used by the server. This contains |
---|
| 517 | the code called upon by main() to initialize the listening socket, as well |
---|
| 518 | as code to deal with sending messages to clients, maintaining connections, |
---|
| 519 | accepting new connections, closing dead connections (or connections |
---|
| 520 | associated with dying/exiting clients), etc. |
---|
| 521 | </para> |
---|
| 522 | </sect3> |
---|
| 523 | <sect3> |
---|
| 524 | <title>server/widget.c</title> |
---|
| 525 | <para> |
---|
| 526 | This file houses code that handles the creation and destruction of widget |
---|
| 527 | objects for the server. These functions are called using the arguments |
---|
| 528 | passed by the client, then they store the specified widget into a generic |
---|
| 529 | container that is parsed later by the screen renderer. |
---|
| 530 | </para> |
---|
| 531 | </sect3> |
---|
| 532 | <sect3> |
---|
| 533 | <title>server/drivers/*</title> |
---|
| 534 | <para> |
---|
| 535 | These are the individual driver files. Each driver allows LCDproc to display |
---|
| 536 | its output on a different device. A driver is responsible for accepting |
---|
| 537 | LCD-like handling instructions from LCDd, and for returning input from the |
---|
| 538 | device to LCDd. |
---|
| 539 | </para> |
---|
| 540 | <para> |
---|
| 541 | Currently, drivers provided are MtxOrb, hd44780, curses, and joy. The |
---|
| 542 | joystick (joy) driver doesn't provide output, but only input. |
---|
| 543 | </para> |
---|
| 544 | </sect3> |
---|
| 545 | </sect2> |
---|
| 546 | <sect2> |
---|
| 547 | <title>The LCDproc Client</title> |
---|
| 548 | <para> |
---|
| 549 | The client shipped with LCDproc performs all of the statistic gathering |
---|
| 550 | previously performed by LCDproc v0.3.x. Instead of driving the LCD directly, |
---|
| 551 | in this version it now connects to LCDd and sends its screens and data there. |
---|
| 552 | </para> |
---|
| 553 | <para> |
---|
| 554 | In this implementation of the statistic-gathering portions of LCDproc, the |
---|
| 555 | layout departs substantially from the older v0.3.x code. Each screen is |
---|
| 556 | generated by functions stored in separate files -- one file per screen. |
---|
| 557 | This keeps files smaller, and code much simpler to maintain and update. |
---|
| 558 | </para> |
---|
| 559 | <para> |
---|
| 560 | The client appears to use files from the share/ tree as well. |
---|
| 561 | </para> |
---|
| 562 | <sect3> |
---|
| 563 | <title>clients/lcdproc/batt.c, chrono.c, cpu.c, disk.c, load.c, mem.c</title> |
---|
| 564 | <para> |
---|
| 565 | These files contain the functions implementing all the screens provided by |
---|
| 566 | LCDproc. |
---|
| 567 | </para> |
---|
| 568 | <para> |
---|
| 569 | Each contains several functions, mostly related to actual statistic gathering. |
---|
| 570 | They are also apparently responsible for actually transmitting their screen |
---|
| 571 | definitions to the server and answering the server's requests for statistic |
---|
| 572 | updates. The functions here do *no* checking to determine if they are being |
---|
| 573 | asked for. They *do* check to see if they need to create a new screen |
---|
| 574 | definition or merely update it. It would appear that the client's main() or |
---|
| 575 | other higher-level function is responsible for calling this function when the |
---|
| 576 | server asks for an update. |
---|
| 577 | </para> |
---|
| 578 | </sect3> |
---|
| 579 | <sect3> |
---|
| 580 | <title>clients/lcdproc/main.c</title> |
---|
| 581 | <para> |
---|
| 582 | This file contains the LCDproc client's main() function, as well as a few |
---|
| 583 | supporting functions. |
---|
| 584 | </para> |
---|
| 585 | <para> |
---|
| 586 | It first declares and fills a modelist (used only internally by this client) |
---|
| 587 | that determines which screens will run by default (if the user doesn't |
---|
| 588 | specify a custom modelist on the command line). The first thing main() itself |
---|
| 589 | does is configure the signal handlers. |
---|
| 590 | </para> |
---|
| 591 | <para> |
---|
| 592 | Next, it parses the command line for options, yelling at the user if an |
---|
| 593 | invalid or nonsensical argument has been specified. After it has done this, |
---|
| 594 | it tries to open a socket connection to LCDd. If successful, execution |
---|
| 595 | continues. If unsuccessful, the client exits gracefully. |
---|
| 596 | </para> |
---|
| 597 | <para> |
---|
| 598 | Assuming a valid socket connection is established, it sends the "hello" |
---|
| 599 | command to the server, introducing itself and convincing the server that yes, |
---|
| 600 | it really *should* serve this client. Next, it calls the mode_init() function |
---|
| 601 | which appears to set up data structures for the various modes, and then finally |
---|
| 602 | the main_loop() function which executes indefinitely until the client is |
---|
| 603 | killed or is asked to stop. Then the program exits cleanly. |
---|
| 604 | </para> |
---|
| 605 | <para> |
---|
| 606 | main_loop() is defined in this file as well. The main loop listens for any |
---|
| 607 | input from the server, and reacts on what it receives. It appears capable of |
---|
| 608 | dealing with keypresses, listen/ignore signals, and menu activity. After it |
---|
| 609 | has reacted appropriately to inputs, it runs the screen asked for by the |
---|
| 610 | server. |
---|
| 611 | </para> |
---|
| 612 | <para> |
---|
| 613 | The old main() is commented out, but included here for reference. Eventually, |
---|
| 614 | this will be removed from LCDproc's source. For now, however, it serves as a |
---|
| 615 | useful reference. |
---|
| 616 | </para> |
---|
| 617 | </sect3> |
---|
| 618 | <sect3> |
---|
| 619 | <title>clients/lcdproc/mode.c</title> |
---|
| 620 | <para> |
---|
| 621 | This file contains functions responsible for initializing mode screens and |
---|
| 622 | calling the appropriate mode screen update function when asked to do so. |
---|
| 623 | main_loop() passes the server's parsed messages to this function to enable it |
---|
| 624 | to select which screen is called for. |
---|
| 625 | </para> |
---|
| 626 | <para> |
---|
| 627 | This file also contains reread() and getentry() functions which are used by |
---|
| 628 | many of the mode screens. |
---|
| 629 | </para> |
---|
| 630 | </sect3> |
---|
| 631 | </sect2> |
---|
| 632 | <sect2> |
---|
| 633 | <title>Shared Files</title> |
---|
| 634 | <para> |
---|
| 635 | Both LCDd and the LCDproc client make extensive use of linked lists and sockets |
---|
| 636 | code. Much of that code is shared, and stored in the shared/ tree. |
---|
| 637 | </para> |
---|
| 638 | <sect3> |
---|
| 639 | <title>shared/config.c</title> |
---|
| 640 | <para> |
---|
| 641 | This file contains the beginnings of configuration file code. |
---|
| 642 | </para> |
---|
| 643 | </sect3> |
---|
| 644 | <sect3> |
---|
| 645 | <title>shared/LL.c</title> |
---|
| 646 | <para> |
---|
| 647 | This file contains all of the functions used in implementing LCDproc's |
---|
| 648 | linked lists. Functions exist here to create new lists, destroy lists, |
---|
| 649 | remove an entry from a list, add an entry to a list, move a pointer to |
---|
| 650 | the beginning or end of a list, move a pointer to the next item in a |
---|
| 651 | list, the previous item of a list, or to retrieve individual items from |
---|
| 652 | a list. |
---|
| 653 | </para> |
---|
| 654 | </sect3> |
---|
| 655 | <sect3> |
---|
| 656 | <title>shared/sockets.c</title> |
---|
| 657 | <para> |
---|
| 658 | This file contains all the functions used in implementing LCDproc's socket |
---|
| 659 | handling capabilities. Full bi-directional communication is implemented by |
---|
| 660 | these functions. |
---|
| 661 | </para> |
---|
| 662 | </sect3> |
---|
| 663 | <sect3> |
---|
| 664 | <title>shared/str.c</title> |
---|
| 665 | <para> |
---|
| 666 | This file contains only one function, get_args(). It appears to parse |
---|
| 667 | command lines (or command line-like strings) for arguments, and returns them |
---|
| 668 | in a more useful form. |
---|
| 669 | </para> |
---|
| 670 | </sect3> |
---|
| 671 | </sect2> |
---|
| 672 | </sect1> |
---|
| 673 | </chapter> |
---|
| 674 | </book> |
---|