Monitoring Devices' Status on Amida

From OpenAlchemy.org

Alive package is used by the status application for showing any activity on the Amida peripharals and battery charge. In this chapter we discuss all the binary executables and kernel modules that the alive package contains.

Contents

Alive Kernel Module and Application

The alive kernel module is called alive.o in the package. Its purpose is to let other applications know about the connectivity on USB, IrDA, Serial and SmartCard interface of Amida. alive module exports this information in the /proc/alive in the format A:B:C:D, where,

  • A is the connectivity status on serial port,
  • B is the connectivity status on IrDA,
  • C is the connectivity status on USB and
  • D is the connectivity status of SmartCard.

If the status bit is set to 1 then there is some device attached (or within range for IrDA) to that peripharal.

Overview of implementation

The implementation is done by sharing one variable called alive in kernel and peripharal device drivers set its corresponding bit in that variable. alive is defined as unsigned char and hence 8 bit. The individual bits (in order of LSB to MSB) are defined as follows,

  • Bit 1, USB master status (set by the usbcore module)
  • Bit 2, USB slave status (set by the sa1100usb-core module)
  • Bit 3, IrDA status (set by the irda module)
  • Bit 4, SmartCard status (set by smartpoll module)
  • Bit 5, Serial Port status (set by the serial detect module)

Amida has two USB ports and /proc/alive does not distinguish between the USB ports. As long as there is some connectivity on one of the USB ports the USB connectivity status, C, will be set in /proc/alive.

In order to indicate an unambiguous status of peripharal connectivity the alive package contains /usr/local/bin/alive application. /usr/local/bin/alive looks up at /proc/bus/usb/devices and with the information in /proc/alive gives the peripharal connectivity in the format A:B:C:D:E, where,

  • A is the connectivity status on USB port 1
  • B is the connectivity status on USB mini port 2
  • C is the connectivity status on IrDA
  • D is the connectivity status on Serial Port
  • E is the connectivity status on SmartCard

The meaning of the status bit is same as before, i.e, if the status bit is set to 1 then some device is attached (or within range for IrDA) to that peripharal.
IrDA devices within range of Amida is shown by the status application by looking up in the /proc/net/irda/discovery.
In order to get information of the devices attached to the USB ports of Amida, alive package includes two more applications alive usb1 and alive usb2. The alive usb1 and alive usb2 applications, look up in the /proc/bus/usb/devices and lists out the devices attached to the USB port 1 and 2 respectively. If there is no USB slave device attached to USB port 2 then alive usb2 prints "Slave is Connected" to PC. So the status application should invoke alive usb2 iff it has found from /usr/local/bin/alive that the connectivity status on USB port 2, B, is set.

Reliability

On Strongarm, the USB slave device driver does not get disconnect of USB cable sometime. Hence, /usr/local/bin/alive might indicate that USB mini port 2 is connected to PC even after the cable is pulled out.

Serial Detect

Serial detection enables the kernel to launch a login shell on the serial port once the serial cable is connected iff there is no shell already running on the serial port.

Overview of the implementation

UCB IO 1 line generates an interrupt when a serial cable is plugged in. We register an handler for the interrupt and that calls the user level application /usr/local/bin/serial reset. /usr/local/bin/serial reset application checks for a shell on serial port and if it does not find one, it launches a shell on the serial port at 9600 baudrate. The UCB IO 1 interrupt handler also sets its alive bit in /proc/alive.

Reliablity

The UCB IO 1 interrupt happens only when the serial cable is plugged in or out. If the cable is already connected to the serial port and Amida is booted, the UCB IO 1 interrupt handler will not get invoked.

Battery Charge Indicator

The battery charge indication is a part of ucb1x00-battery.o kernel module. The current charge of the battery, as read from the ADC (UCB ADC INP AD0) is exported via /proc/apm interface. When read, the /proc/apm returns two integer values in the form of MN. M indicates the battery is getting charged or discharged with value 1 or 0 respectively. N indicates the current charge from battery.

apm thread

The ucb1x00-battery module starts apm thread. The apm thread wakes up every one minute and reads the current battery charge. If the current charge is 100% and the battery is still charging then, apm thread invokes /usr/local/bin/battery warning high, which bubbles the message battery charge is full.

Charge curveDischarge curve

If the current charge is less than 15% and the battery is not charging then apm thread invokes /usr/local/bin/battery warning low, which bubbles the the message battery charge is too low. If the current charge is equal to zero and the battery is not charging then apm thread invokes /usr/local/bin/shut battery to shutdown the machine after displaying the shutdown logo.

Users

OpenAlchemy is a Free and Open Source Software project
proudly supported by
Geodesic Information Systems Limited

Comments? Feedback? Contact Us.

MediaWiki