Device Driver Concept Intro

Example: cat

          cat does this (not showing a lot of stuff, like error checking, end of file, etc).

            main(argc, argv) {

                while (1) {

                    s = read(stdin, buf, 1);

                    s = write(stdout, buf, 1);

            }

'cat < /dev/console >/dev/console' is equivalent to 'cat'

both will simply echo what you type. /dev/console is special file in the file system that has a "device driver" associated with it. When you call write() on this file, you are really calling a function in the device driver package associated with /dev/console. In this case, the device driver, running in kernel space, can send characters to the user's display and get them from the keyboard by accessing the physical memory space.

Device Drivers

Example

    With the proper device driver, you should be able to get sonar data from a sonar device using

    cat < /dev/sonar

    The device driver has to deal either with the sonar directly, or maybe it communicates with an 8051 that is driving the sonar.
    All of this is now hidden from the user.

Homework Assignment

Suppose you are building a robot with the Cerfboard as the central controller. The robot has two wheels and two motors to drive them (right and left). You can independently control the direction and speed of each motor. Specify a device driver interface that you think would be appropriate for the motors. All I want you do to is answer these questions:

This week's lab assignment has a template for a device driver.