Next: 9.1 Mouse Programming Up: e Previous: 8.23 [N]Curses Function Overview

# 9 Programming I/O ports

Usually a PC at least has 2 serial and 1 parallel interfaces. These interfaces are special devices and are mapped as follows:

- these are the RS232 serial devices 0-n where n depends on your hardware.
- these are the RS232 serial devices 0-n where n depends on your hardware.
- these are the parallel devices 0-n where n depends on your hardware.
- these are the joystick devices 0-n where .

The difference between the /dev/ttyS* and /dev/cua* devices is how a call to open() is handled. The /dev/cua* devices are supposed to be used as callout devices and thus get other default settings by a call to open() than the /dev/ttyS* devices which will be initalized for incoming and outgoing calls. By default the devices are controlling devices for the process that opened them. Normally ioctl() requests should handle all these special devices, but POSIX preferred to define new functions to handle asynchronous terminals heavily depending on the struct termios. Both methods require including <termios.h>.

1. method ioctl:
   TCSBRK, TCSBRKP, TCGETA (get attributes), TCSETA (set attributes)
   Terminal I/O control (TIOC) requests:
   TIOCGSOFTCAR (set soft carrier), TIOCSSOFTCAR (get soft carrier), TIOCSCTTY (set controlling tty), TIOCMGET (get modemlines), TIOCMSET (set modemlines), TIOCGSERIAL, TIOCSSERIAL, TIOCSERCONFIG, TIOCSERGWILD, TIOCSERSWILD, TIOCSERGSTRUCT, TIOCMBIS, TIOCMBIC, ...
2. method POSIX:
   tcgetattr(), tcsetattr(), tcsendbreak(), tcdrain(), tcflush(), tcflow(), tcgetpgrp(), tcsetpgrp()
   cfsetispeed(), cfgetispeed(), cfsetospeed(), cfgetospeed()
3. other methods:
   outb,inb for hardware near programming like using the printer port not for a printer.

- 9.1 Mouse Programming
- 9.2 Modem Programming
- 9.3 Printer Programming
- 9.4 Joystick Programming