CAJUN Configuration

Configure CAJUN Web Site

Almost all CAJUN configuration is done through your CAJUN's web site. You created this when you installed the Apache web server, earlier. Since you configured it earlier, all you have to do is make sure it's running. If you haven't started it yet, start it now:

shell# /sbin/service httpd start

Once it's running, you can bring up mozilla on your CAJUN box, and browse to http://localhost. Or, from another computer connected on the same network. You'll be able to open this documentation from there.

Configure CAJUN Core

The CAJUN core doesn't need much attention. Just visit the 'Global Settings' menu on your CAJUN's web site. Most of the default settings should be fine, so you probably won't have to touch anything.

Some of the keys on your input devices will be marked as 'global', which means they'll do the same thing no matter which audio device is currently running - for example, Volume control. You will need to configure the Global ActionMaps, but only after you've installed your input and audio devices. This is all explained in the section for configuring audio devices; for now, just make a mental note that you'll need to set up "global actionMaps" after everything else is configured.

Configure mpg123

Most people use CAJUN to play MP3 files. The FilePlayer audio module uses a special build of 'mpg123', a Unix mp3 player. This build has been provided with CAJUN; it's found in the /usr/share/cajun/contrib/mpg123 directory. It's already been compiled for you, but you may need to rebuild it if you have problems running it (i.e., if there are shared library mismatches). To build it, just follow these steps:

shell# cd /usr/share/cajun/contrib/mpg123
shell# tar -xjf mpg123-(something-something).tar.bz2
shell# cd mpg123-(something-something)
shell# make linux
shell# cp mpg123 /usr/share/cajun/bin

Now the executable will be available for use by CAJUN software. Note that this is NOT the executable to use with the CAJUN Icecast client; you'll want to use the stock RedHat version for that. Further note that RedHat 8.0 ships without mpeg support at all; you'll want to remove the RedHat 8.0 mpg123 rpm and replace it with a new one you download from http://www.mpg123.de/ or http://www.rpmfind.net/

Note that mpg123 must have permission to access the audio device; if you're running CAJUN as anyone other than root, you'll need to check the permissions on the following devices:

  • /dev/dsp
  • /dev/audio
  • /dev/mixer

    Configure xmms

    If you'll be using xmms to play mp3's, you'll need to set up the iNetCtl module so CAJUN can talk to xmms:

    1. Follow the installation instructions for iNetCtl at: http://inetctrl.sourceforge.net/.
      Start up xmms, bring up the configure panel, and find iNetCtl under 'Effect/General +Plugin'. Check the 'enable' checkbox to turn on iNetCtl. Hit the 'configure' button to find out which port number iNetCtl is using - you'll need to tell CAJUN this when you set up FilePlayer.
    2. Xmms runs in its own window. After you get everything up and running well, you'll probably want to make it go away, since CAJUN shouldn't need to bring up a windowing system for use in a car. Install the VNC package that comes with RedHat, which provides virtual X displays, Then, at boot time, you'll want to run 'vncserver :1' to start a virtual X display before CAJUN is started (probably put this in /etc/rc.d/rc.local, right before CAJUN). You'll need to tell CAJUN's FilePlayer configuration (later) what the display number is, so CAJUN can send the Xmms window to the virtual display. You'll also probably want a small 'sleep' to let vncserver start up.
    3. Also, by default, vnc starts the 'twm' window manager. This WM expects that when a window appears, you'll move the cursor to a nice place and click the mouse to drop it. Of course, we can't do that in cajun, so you'll need to create an empty file '~/.vnc/xstartup' and make it executable (chmod 755 xstartup) - or make it empty if it's already been created before. Make sure it's the home dir of the user that runs vnc - probably root if you run vncserver from your startup scripts.

    Configure Mplayer

    Mplayer is another backend that will play mp3 files. You may try using it if both mpg123 and xmms won't work for you.

    To start, download and install mplayer from http://www.mplayerhq.hu. RPM format is the best for RedHat systems. You'll also need to download the codecs and unpack them into /usr/lib/win32.

    Next, define keys. Mplayer has a key configuration file, /etc/mplayer/input.conf. Edit it, and ensure that you have keys assigned to the functions required by FilePlayer (see next step). In particular, arrow keys and pageup/down don't have a single ascii value, so reassign those to key that do, like any alphanumeric key. Type 'man ascii' at any shell prompt to find out what the hexadecimal values are for each character.

    Next, edit FilePlayer's parameters (or add a new device), and set the output type to 'mplayer'. Ensure that the mplayer-keys parameter is set properly, according to the parameter description.

    Note that as of this writing, mplayer doesn't appear to tell CAJUN how long the song is, so the 'percent complete' display parameter will always be '00%'.

    Configure Input Drivers

    CAJUN must have at least one input device connected to be controllable. Input devices include keypads, keyboards, and infra-red remote control receivers. CAJUN can function as a dumb jukebox with no input devices; it will just boot up and start playing songs if properly configured via the following FilePlayer's options: playPlaylistOnLoad=on, playPlaylistOnLoadIndex=1 (the desired playlist) and maybe even shufflePlaylistOnLoad=on.

    To set up an input device, browse to your CAJUN's configuration web site, select 'Device Settings', and add to the configuration an input driver that matches your input hardware.

    After you've created the driver, you must create "keyStroke mappings". In CAJUN terms, a "keyStroke" is a symbolic name for a key on your input device. It's usually the name of the key as you would recognize it, for example 'Stop' or 'Rewind'. Input device hardware doesn't understand keyStrokes; they only know how to send a series of bytes (or characters or letters) to the software. Your job is to create a mapping of byte strings to keyStrokes, so that the input driver can tell the CAJUN core which key has been pressed. Byte streams are represented by pairs of hexadecimal numbers. It's much easier for us to understand that the 'Stop' key was pressed, instead of a key that generates the bytestream "FA04D2A129", don't you agree?

    Each keyStroke is unique to a particular device, so if you have more than one input device, you'll have more work to do. Each type of input device sends a different number of bytes. For example, keyboards always send one byte (two hex numbers), and the IRman remote control receiver always sends six bytes (twelve hex numbers) for each keypress.

    For most devices, the easiest way to configure a keyStroke mapping is to hit 'keyStroke Map' from the 'Device Settings' menu, and follow the instructions for auto-configuration. Press a key on your input device, and the byte stream will appear in your web browser. Just type in the keyStroke name, and you've created a keyStroke mapping. Continue this for all keys on your input device.

    If for some reason you have an input device that doesn't support auto-configuration, you'll have to discover (via other means) what the byte stream is for each key, and enter them manually. For most keyboard-based single-byte input devices, you can do a 'man ascii' from the shell to get a list of hex codes. Don't forget to take upper/lower case into account! - This is now largely automated via the "Click here to add the appropriate entries for the ATkeyboard" thing on the keyStroke editor page.

    Note that if you're configuring a multi-function remote control, they normally have different modes, such as 'TV', 'DVD', 'Video1', etc. Not all modes support all buttons; for example, you may not see any data when you press 'Fast Forward' on a remote in "TV mode". Likewise, most DVD players don't have volume controls, but the remote may let you control volume in DVD mode anyways. Try experimenting with each mode and see which one gives you access to the buttons you need.

    Configure Audio Drivers

    CAJUN must have at least one audio device connected to operate. Audio devices include MP3 players, CD players, FM Radios, etc.

    To set up an audio driver, browse to your CAJUN's configuration web site, select 'Device Settings', and add to the configuration an audio driver that gives you the functionality you wish and/or matches your audio hardware.

    Once you've added all of the audio drivers you'll be using, you need to set up action maps. In CAJUN terms, an "actionMap" is a mapping from a key on a particular input device into a string that a particular audio device knows about and can react to.

    For example, consider the actionMap:

    Channel Up => Tune Up

    This says that when the keyStroke 'Channel Up' is received from a certain input device (because my TV remote control that I'm using has a 'Channel Up' button), the action 'Tune Up' is sent to the audio device. If the audio device is a FM radio, this might cause the radio to tune up to the next station.

    To define all of the actionMaps for use with your CAJUN, first make sure all of the input devices, audio devices, and keyStrokes have been defined. Then, click on 'actionMap' from the 'Device Settings' menu, and choose which keyStrokes will trigger which actions. Don't forget that you must do this for each input device you have (if you have more than one). Submit your changes at the bottom of the form, and you're done.

    Configure Output Drivers

    CAJUN must have at least one output device connected to operate. Output devices include Xterm windows and LCD displays.

    To set up an audio device, browse to your CAJUN's configuration web site, select 'Device Settings', and add to the configuration an output driver that matches your display hardware.

    By default, the output driver probably knows how to display information nicely on your screen; you likely don't have to do anything. If it doesn't, or if you want to change the appearance of screen output, read the rest of this section.

    To display output on the output devices, audio devices send a "display map". This is a list of key/value pairs, each of which describe a particular part of the screen, when the audio device is in a particular state. For example, consider the FM Radio driver, which needed to update the screen when the channel was tuned up to the next station. The audio driver sends a display map that might look like this:

  • _state => "playing"
  • clock => "01:24:35"
  • name => "WBCN Boston"
  • frequency => "104.1"

    When the CAJUN core receives the display map, it is immediately forwarded to all output drivers connected. Each output driver receives the map and must convert it into something that will look good on the screen.

    The job of the "displayFilter" is to control how the display map is laid out on the screen. It consists of a list of fields, which consist of the following parameters:

  • state => Field is only shown when audio device is in this state
  • String/Field => The data that is actually shown can either be a static string, or one of the fields in a display map. We might want to display the 'clock' field from the display map above.
  • Coords => The X and Y coordinates on the output device of the left-hand most character of the string or field. X and Y both start at 0, and 0,0 is in the upper left corner.
  • Length => The length of this field. Strings or fields shorter than this will be padded with spaces; those longer will be either truncated or scrolled.
  • Alignment => Determines how the string or field will be padded with blank space. Can either be Left, Right, Center, or Scrolling. If Scrolling, then strings or fields longer than "Length" will automatically scroll for you, so you can see the entire field.

    The output driver positions all fields in the displayFilter as you have requested. Once they have been laid out, the lines are sent to the display for viewing by the user.

    Note that displayFilters are not attached to a particular output or audio device; they're created based on output device size. Therefore, if you have three 20x4 LCDs and a 40x4 LCD, the three 20x4 displays will all use the same displayFilter, and will therefore all look the same. The 40x4 display can have fields laid out completely differently.

    Configure Utility Drivers

    Utility functionality hasn't been written yet. It's projected that it will provide on-screen support for viewing the current volume/bass/treble setting, mount/umount disks, perhaps even a GPS display.

    Bootup/Tuning

    When you turn your computer on, you want CAJUN to start without touching the keypad. CAJUN is supplied with an rc file; the RPM installation automatically sets up the machine to load CAJUN on boot. If you installed via tarball, then you'll need to copy the /usr/share/cajun/install/cajun file to /etc/rc.d/init.d, and then run '/sbin/chkconfig --add cajun'.

    Just before you get the 'login' prompt, CAJUN will start. You won't have to log in, of course.

    Once your CAJUN is running, you'll probably want to tune it, which means to reduce its bootup time and reduce the load on the CPU for slower machines. You'll want to reduce system load especially for CPUs less than 233mhz. To tune your CAJUN:

  • Ensure that you're booting into the textmode runlevel

    Ensure that the line in /etc/inittab that begins with 'id:' looks like "id:3:initdefault" (RedHat) or "id:2:initdefault" (Debian), and does not contain a not 5. The graphics interface takes extra time to load.

  • Reduce the number of processes that start when you boot

    For starters, Linux loads and runs several processes at bootup; you certainlty don't need them all. MySQL should run, but you may decide that you'll only be using the Apache web site when you configure the machine; you don't always want Apache booting. By using the /usr/sbin/ntsysv command, you can control which daemons boot up at the default runlevel. An example of ones that you don't need are (as of RH8.0):

    autofs, finger, gpm, imap, iptables, isdn, lpd, anything with 'nfs' in
    the name, ntalk, privoxy, rhnsd, sendmail, smb, sgi_fam, anything
    that starts with 'yp'.
    

    Of course, the exact list is up to you, and depends on your situation. This is just a rough estimate. If you're not sure what a daemon does when in ntsysv, hit the 'F1' key when you've selected the name of the daemon, and a small window will pop up and tell you what it does.

    By eliminating daemon startup, not only are you reducing boot-up time, you're reducing memory consumption.

  • Edit lilo.conf or grub.conf and reduce the prompt time

    Examine either /etc/lilo.conf or /boot/grub/grub.conf. If you have both, you're probably using Grub. Look for a line like "delay=x" or "timeout=x"; make it 1 or 2 for fastest booting time. If you're using lilo, don't forget to rerun /sbin/lilo after making your change.

  • Optional: reduce memory consumption by installing a small memory model config for MySQL:

    Run one of these commands as root:

       /bin/cp /usr/share/mysql/my-small.cnf /etc/my.conf (RedHat) or
       /bin/cp /usr/share/doc/mysql-server/examples/my-small.cnf /etc/my.conf (Debian)
    
  • Optional: reduce memory consumption by rebuilding Perl:

    For those adventurous types, you can rebuild Perl and requesting that a shared library be used; this will reduce the amount of memory Perl consumes. Download the Perl installation from http://www.perl.com, and during configuration when prompted 'Use a shared libperl.so', respond 'y'. Don't forget to remove your existing copy of Perl first; it can get very confusing with two copies on your system!

  • Optional: reduce memory consumption by reducing the number of consoles:

    Linux comes default with about 6 or 8 ttys running on each of the system terminals (hit alt-F1, alt-F2, etc in text mode to see them all). Edit the /etc/inittab file and comment out the lines that look like

    "3:2345:respawn:/sbin/mingetty tty1"
    Leave at least the first two entries so you can actually log in and use the machine. (note: if you comment them all out, your machine is hosed.)

  • Optional: Reduce system load by removing cron entries:

    The cron program can sometimes kick off cronjobs while you're playing music; this slows your machine to a crawl and causes huge gaps in the sound. Examine /var/spool/cron and /etc/cron.daily to see if your system has any. If you suddenly notice slow speeds, do a "ps -aux" to see if any cron jobs are running. On RedHat, anacron and cron are both shipped. You can also turn them off with the 'ntsysv' program.

  • Optional: Reduce memory consumption by rebuilding your kernel:

    Also for the adventurous: this probably won't do much for you, since the default kernel is already pretty modular. You can, however, rebuild the kernel and remove modules that drive hardware you don't have. if you have never done this before, Google the web with 'linux Kernel-Build-HOWTO' for instructions, and prepare to reload your machine from scratch if you don't get it right the first time (very likely).

  • Optional: Eliminate swap to stop paging:

    Slower machines (i.e., less than 233mhz) can be adversely affected by swapping when the processes you ask the machine to run won't fit in ram. For the adventurous, you could reinstall the operating system without swap space allocated (or just turn it off from a running system). This can cause problems if you think you have enough memory, but start allocating more (by opening lots of containers in FilePlayer, for example)... but if you have enough physical memory, you really don't need swap. So disable it and see if it helps your situation.


    As soon as you're done configuring, you're ready to move on to usage.