A "character device" and "block device" are abstractions, usually used in Unix-style systems in classifying various devices. A Unix-style device node (/dev/<something>
) is usually classified as either a character device or a block device.
Basically, a character device can meaningfully process data even a single byte at a time, but a block device works with blocks of specific size (often 512, 1024 or 4096 bytes). If you supply an incomplete block to a block device, you may have to pad it with zeroes or other suitable padding to complete the block, or else the block device may not be able to complete its operation.
Disks are usually represented as block devices in Unix-style systems. However, in a traditional Unix system, a single disk may be represented as two devices: a block device for regular filesystem access, and another device for "raw access" and other special operations: the raw access device is often a character device.
In modern Linux, raw access can be achieved by opening the regular block device using an O_DIRECT
flag, but if an application that is ported from another Unix-style system specifically requires a dedicated raw device, one can be set up as needed using the raw
command.
Serial and parallel ports, on the other hand, usually refer to physical connection tehcnologies.
In PC hardware, serial port or COM port normally refers to a RS232 port (usually with a National Semiconductor 8250-compatible UART chip driving it). Since it does not need a fixed block size, it is normally classified as a character device in Unix systems. As the name serial port implies, this port transfers data serially, one bit at a time. The most modern specifications for this port are known as EIA/TIA-232.
Likewise in PC hardware, parallel port, printer port, LPT port or Centronics port all refer to a type of port whose most modern implementation is standardized as IEEE 1284. It is also represented as a character device in Unix-style systems, since it requires no fixed block size. As the name implies, it transfers data in parallel: it has 8 data lines, one for each bit in a byte.
Unlike the serial port, the parallel port in its oldest form is basically one-way: the computer can send data out one byte at a time, but the device on the other end has only a few fixed-meaning status lines it can use to communicate back to the computer. (An invalid state combination of these status lines was reported by early versions of Linux kernels as a semi-humorous lp<n> on fire
error message.)
Bi-directional communication modes were implemented as later enhancements.
Before the introduction of USB, the parallel port was probably the fastest general-purpose external connector on a typical PC. If external devices with faster data transfer speeds were needed, it often meant adding a dedicated interface card, or a SCSI adapter card with an external connector to the system. For example, a professional flatbed image scanner was likely to require a SCSI connection.