CSE 466 Lab 8: Swarms


This page, like the final project, is still under development. It will change frequently, so check it often as you are developing your swarm agent. This page, not including linked resources, was last updated Friday, 07 December at 03:51 AM.


In this lab, you will:

Suggested Reading and Resources

Part 1: Develop a user interface

Two drivers are available for using the LCD on the SuperBird. One is a standard Linux framebuffer, which will display text. To use this driver, insmod lcd-fb.ko and write to /dev/vc/0. It works as a standard Linux console. Refer to man console_codes for information on the different control codes that you can send to the console. Note that you will need to unblank the display and set the blanking timeout to 0. See this sample code for an example. Note that you will need to do rmmod lcd before loading lcd-fb.ko, since the graphical LCD driver is loaded at startup and may conflict.

The other driver, lcd.ko, provides raw access to the LCD. This driver is already installed on your iMote2s, and is loaded at startup. It allows you to write raw pixels to the display. Each pixel is 12 bits, so three bytes comprise two pixels, in RG GR GB format. The display is 130x130 pixels, but the driver expects images that are 132x132 pixels. The two rightmost columns and the two bottommost rows are not displayed.

It is up to you to decide which driver you want to use. The lcd-fb.ko driver provides an easy way to display text, but it takes a long time (up to 1 second) to write to the device. The lcd.ko driver is much faster and allows you to do graphics, but you'll need to get the graphics into the right format and figure out how you're going to display text.

You can read the status of the jog dial and two pushbutton switches on the side of the SuperBird through an ioctl() on /dev/superbird. You'll need the superbird.h header file.

You should develop a user interface for your agent that allows you to select a zone number, start and stop the agent, and display various status information. See the Swarms specification for more information.

Try to make your interface efficient. Remember that it will become a part of your agent program, so it should use resources effectively (e.g. don't update the display every time through a tight infinite loop.)

Part 2: Pure Data

We will be using the PDa fixed-point port of Pure Data for sound generation. Download a version of PDa for the iMote2 here. Copy the contents of the bin folder to /usr/bin/ on your iMote2, and place the entire intern directory in /usr/.

You can run Pd with the following command:

	pd -noadc -nomidi -nogui <patch file>

Next, download pd_interface.zip, which contains example code for launching Pd from your programs, connecting to it with a socket, and sending commands. Unzip it on attu, run make, and copy the pd_interface program to your iMote2. Also, create a directory called '/root/patches' and put the simpleosc.pd file in it.

When you run pd_interface, it spawns a Pd process, connects to it with a socket, and steps through a range of frequencies and a range of amplitudes by sending commands to the Pd patch through the socket. When it finishes, it should terminate the Pd process, and then exit.

You should be able to use the start_pd_and_connect() and stop_pd_and_disconnect() functions in your own programs. Make sure you include all of the header files required for using sockets.

Look at the simpleosc.pd file for an example of how to make patches that receive commands from a socket.

Appendix A: Controlling the audio chip

There is a new version of the sndoutctl for controlling various parameters of the AK4642 audio codec available here. It will allow you to enable or disable any of the output devices (speaker, headphone, line), set the digital volume control, and alter several other parameters.

You will probably want to enable either the headphone or line outputs, disable the internal speaker, and disable the automatic level control before running your patches on the iMote2.

If you want to be able to control these parameters directly from your applications, you can use this header file and send the SUPERBIRD_AUDIO_WRITE_REGS ioctl() to the superbird-audio device. This allows you to alter the registers in the AK4642 codec chip.