inp_task()This function is the central input function of the OSDI. It should take the form of an infinite loop. inp_task() should read input from whatever devices are currently selected and pass the input to the function inp_avail() (the latter is not for user-modification). The global variable inp_device indicates which devices are currently selected; it is the sum of the numbers of the selected devices. The function inp_avail() takes three arguments: the address of the data which has been read, the number of bytes read and the device number from which the data came.
If input is being obtained from more than one source, care should be taken to ensure that data from different sources is not interleaved. For example, if a character has been read from a magnetic stripe, the whole contents of the stripe should be read and presented to inp_avail(), not interleaved with any data from the keyboard. See the section on Concurrent Input for further details.
The DP4 Terminal Manager is automatically informed by inp_avail() when the source of the input changes.
In our example inp_task() has a very simple form, where first the keyboard is polled for input, then the scanner (via the serial port). No account is taken of concurrent input. For example, inp_device() could take a value (INP_KEYBOARD + INP_SCANNER). The user may start field entry from the keyboard but use the scanner before field termination. This example code would send data back to the application consisting of a mixture of input from keyboard and scanner.
/**/ void |
Note that inp_avail() is called if input is successfully taken from an input device. get_kbd_data() and get_com1_data() are not shown.