Project 1

Handler Tasks and Interrupt Hadlers

When a character arrives at the serial port of the 68332EVS board an interrupt occurs. You must write an interrupt handler (i.e. notifier) that takes the received character and passes it on to the Handler. The notifier does this by placing the character on a 'handler queue'. If no user task has opened the device for reading, characters received should be sent to the null device (i.e. discarded) and not be echoed at the terminal. If however, at least one user task has opened the device for reading then in the case of an alphanumeric character the Handler simply echoes the character to the screen; i.e. the character is placed on a 'notifier queue'. The character must be sent back out the serial channel. A transmit interrupt occurs just after the USART finishes transmitting a character; i.e. the USART is 'telling you' (by causing an interrupt) that it is ready to transmit another character.

The Handler task should be able to perform some simple line editing. That is it should interpret special command characters appearing in the input sequence (such as ^H: erase character, ^W: erase previous word, ^U erase line) and implement these commands by deleting the appropriate entity from the input stream to be delivered to the waiting tasks, and by erasing the echoed characters on the terminal window.

The termcap entry for the VT100 is given in Table P1.1

P1.1 Termcap
d0|vt100|vt100-am|vt100am|dec vt100:\

:do=^J:co#80:li#24:cl=50\E[;H\E[2J:sf=5\ED:\

:le=^H:bs:am:cm=5\E[%i%d;%dH:nd=2\E[C:up=2\E[A:\

:ce=3\E[K:cd=50\E[J:so=2\E[7m:se=2\E[m:us=2\E[4m:ue=2\E[m:\

:md=2\E[1m:mr=2\E[7m:mb=2\E[5m:me=2\E[m:is=\E[1;24r\E[24;1H:\

:rf=/usr/share/lib/tabset/vt100:\

:rs=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:ks=\E[?1h\E=:ke=\E[?1l\E>:\

:ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:kb=^H:\

:ho=\E[H:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:pt:sr=5\EM:vt#3:xn:\

:sc=\E7:rc=\E8:cs=\E[%i%d;%dr:

Termcap is a database that contains the capabilities of specific terminal devices. Information about termcap can be found on Unix man pages using the command man 5 termcap.

Some pseudo code for the Handler task is shown below.

Initialize system
Do forever
    Check handler queue
    If a user task has opened the device for reading
        Determine what the character is and
        If the character is alphanumeric put it on the notifier queue
        Else if the character is a special character handle it appropriately
        Else if the character is none of the above, ignore it
    Else discard the character

Once the first part of the project is completed (i.e. the Handler task and interrupt handlers are written and working correctly) you are required to write some functions that will allow user tasks to access the serial channel.