{"id":289,"date":"2020-08-18T19:23:47","date_gmt":"2020-08-18T20:23:47","guid":{"rendered":"http:\/\/www.linux-tutorial.info\/?page_id=77"},"modified":"2020-08-22T19:26:19","modified_gmt":"2020-08-22T20:26:19","slug":"this-is-the-page-title-toplevel-124","status":"publish","type":"page","link":"http:\/\/www.linux-tutorial.info\/?page_id=289","title":{"rendered":"Serial Ports"},"content":{"rendered":"\n<title>Serial Ports<\/title>\n<p>\nFor the most part, all PC computers, even laptops are sold with at least\none <glossary>serial port<\/glossary> and desktop machines or servers typically have two.\n These can be built into the motherboard, as part of a serial\/parallel card, or\nas  part of an &#8220;all-in-one&#8221; card that has serial ports, parallel ports, games\nports, and even hard disk and floppy controllers. (<i>Note: I have been told that newer\nlaptops, particularly those from Compaq and IBM have only USB and no serial ports!<\/i>)\n<\/p>\n<p>\nAs the name implies, serial device communicate serially. That is, each byte\nis split into 8 bits, which are sent one after the other. At the pyhsical\nlevel, what this means is that voltage on the transmit pin (line) is toggled\nto indicate the bits: negative is a 1 bit, and a positive voltage is a 0 bit.\nOn the receiving end, the serial port accept the data on the receive pin\nand recognizes the voltage and therefore whether the bit is a 0 or 1.\n<\/p>\n<p>\nAgreeing on the speed at which the voltage is toggled, is an import apect of\nthe communication. The speed of the change determine how many bits per second\ncan be sent, which is thus the speed of the serial port or serial device. A\nmouse will communicate with speeds between 1,200 and 9,600 bps, whereas modems\ncan reach as high as 115,200 bps.\n<p>\nDeciding on speed is not the only thing used with serial communication to\ndata arrives correctly. In some cases, like with modems, additional pins\nare used to say\nthat one side is read to send the data (using the RTS pin) and the other side\nsays that they are clear to send (CTS). Here a voltage of +12 is used\nfor the respective signal. Other kinds of devices uses the pins\ndata terminal ready (DTR) and data set ready (DSR). This has the same\nfunctionality, but just uses different pins. Typically, serial terminal use\nthe DTR and DSR pins\n<p>\nRegardless of what pair of pins are used, this mechanism is used to ensure\nthat data only flows when the appropriate side is ready. That is, it is used\nto control the flow and such a mechanism is thus called &#8220;flow control&#8221;. Since\nit the hardware that is used to control the flow, using pins like this is\nlogically called hardware flow control. In other cases, such as when there is\nno phyiscal connection, you can use &#8220;software flow control&#8221;, which uses\nspecial &#8220;control characters&#8221;. For example, pressing the control key (CTRL) and\nthe the &#8220;s&#8221; key (CTRL-S) you can stop the flow. Pressing CTRL-Q, you can start\nit up again.\n<p>\nWith modems, you will typically find that a couple of other pins are used\nas well: ring indicator (RI) pin and the carrier detect (CD)\npin. These indicate (respectively) an incoming call and that a\nthe carrier signal has been detected.\n<p>\nA serial board is an <glossary>expansion card<\/glossary>\nthat translates <glossary>bus<\/glossary>\nsignals in which at least eight bits arrive simultaneously into signals that\nsend  single bits at a time. These  bits are encapsulated into groups of one\nbyte. The <glossary>encapsulation<\/glossary> contains other signals that\nrepresent the start and end of the byte, as well as a\n<glossary>parity<\/glossary> bit. Additionally, the number of bits used to\nrepresent data can be either 7 or 8.\n<\/p>\n<p>\nParity is the mechanism by which single-bit errors can be detected during\ntransmission. The number of bits set  to one is counted and based on whether\neven or odd <glossary>parity<\/glossary> is used, and the <glossary>parity\nbit<\/glossary> is set. For example, if even parity is used and there are three\nbits set, then the parity bit is also set to make the total number of bits set\nan even number. However, if odd parity is used, the number of bits set is\nalready odd, therefore the parity bit is left unset. When you use some other\nmeans to detect errors, you can turn parity off, and you are said to be using no\nparity. This is the default for modems in Linux.\n<\/p>\n<p>\nSerial communication parameters must be agreed upon by both ends. These\nparameters are often referred to  in triples, such as 8-1-N (read as\neight-one-none). In this instance, there are eight data bits, 1\n<glossary>stop bit<\/glossary>,\nand no <glossary>parity<\/glossary> is used. This is the default\nfor Linux systems.\n<\/p>\n<p>\nOne key element of a serial board is the Universal Asynchronous\nReceiver-Transmitter, or <i><em>UART<\/i><\/em>. The transmitter portion takes a\nbyte of parallel data written by the serial driver to the card and transmits it\none bit at a time (serially). The receiver does just the opposite: It takes the\nserial bits and converts them into parallel data that is sent down the\n<glossary>bus<\/glossary> and is read by the serial driver.\n<\/p>\n<p>\nOriginally, Linux only provided drivers for standard serial ports;\nintelligent boards are often installed to allow many more logins (or other\nconnections) to the system. The most significant difference is that intelligent\nserial boards (often referred to as smart serial boards) have a built-in\n<glossary>CPU<\/glossary>,  which allows it to take all responsibility for\nprocessing the signals away from the system CPU.\n<\/p>\n<p>\nIn the newer versions, you can find drivers for commercial multiport boards,\nsuch as the Stallion Easy IO, which allows you to quickly extend the number of\nserial ports on your system as the drivers are built in. Stallion is very\nsupportive of the Linux world and even advertises the fact that their boards run\non Linux.\n<\/p>\n<p>\nIn addition, intelligent serial boards can better <glossary>buffer<\/glossary>\nincoming signals that keep them from getting lost. With non-intelligent boards,\nthe system may be so busy that it does not get around in time to read\ncharacters off the board. Although the 16550 <glossary>UART<\/glossary>,  common\non most serial boards today, contains 16-byte buffers, this is often not enough.\nUnder heavy load, the serial driver does not react fast enough and the\ncharacters are overwritten.\n<\/p>\n<p>\nSerial board performance is also increased by intelligent boards. Because\nsignals are buffered and  sent in large chunks, there is less overhead on a\nper-character basis. With non-intelligent boards, single characters are often\ntransmitted, so the per-character overhead is much larger. In fact, most\nnon-intelligent boards generate and <glossary>interrupt<\/glossary> the\nassociated overhead with <em>each<\/em> character.\n<\/p>\n<p>\nIt is possible to obtain supported serial boards that have multiple ports.\nAlthough such boards have  multiple UARTs, they do not have the performance of\nintelligent boards, though they do provide a low-cost alternative. For a\ndiscussion on the <glossary>device nodes<\/glossary> used for such boards, see\nthe section on the device directory.\n<\/p>\n<p>\nThe pin assignments mentioned above and the commincation protocol\n(among other thinfs) is known as the RS-232 standard. RS-232 is easily\neffected by electrical noise, and thus has some limits the length and speed\nat which it can communicate. The longer the cable the slower the connection\nmust be to ensure communication is not disrupted.\n<p>\nOriginally designed to connect mainframe computers to modems, the RS-232\nstandard is used exclusively for <glossary>serial port<\/glossary> connections\non PCs. Two kinds of devices are considered with RS-232: Data Terminal Equipment\n(DTE) and Data Communication Equipment (DCE). <glossary>DTE<\/glossary> is the\nserial port side and <glossary>DCE<\/glossary> is the <glossary>modem<\/glossary>\nside.\n<\/p>\n<p>\nTwo types of connections are used: DB25 (with 25 pins) and DB9 (with 9 pins).\nAlthough they both serve  the same basic function, the numbering of the pins is\nslightly different. Table 0-3 lists the main pins of the DB25 connector, their\nfunctions, and a mnemonic that is commonly used to refer to them. Table 0-4\nlists the pins for the DB9 connector. The physical layout of the pins is shown\nin Figure 0-13.\n<\/p>\n<p>\n<center>\n<table BORDER cellspacing=1 bordercolor=\"#000000\" cellpadding=7 WIDTH=288><tr><td>\nPin<\/td><td>\nFunction<\/td><td>\nMnemonic<\/td><\/tr><tr><td>\n2<\/td><td>\nTransmit<\/td><td>\nTXD or TX<\/td><\/tr><tr><td>\n3<\/td><td>\nReceive<\/td><td>\nRXD or RX<\/td><\/tr><tr><td>\n4<\/td><td>\nRequest to send<\/td><td>\nRTS<\/td><\/tr><tr><td>\n5<\/td><td>\nClear to send<\/td><td>\nCTS<\/td><\/tr><tr><td>\n6 <\/td><td>\nData set ready<\/td><td>\nDSR<\/td><\/tr><tr><td>\n7<\/td><td>\nSignal ground<\/td><td>\nGND<\/td><\/tr><tr><td>\n8<\/td><td>\nCarrier detect<\/td><td>\nCD<\/td><\/tr><tr><td>\n20<\/td><td>\nData <glossary>terminal<\/glossary>\nready<\/td><td>\nDTR<\/td><\/tr><tr><td>\n22 <\/td><td>\nRing indicator<\/td><td>\nRI<\/td><\/tr>\n<\/table>\nTable -3 Common Pins on the DB25 Connector\n<\/p>\n<\/center>\n<\/p>\n<center><br \/><br \/>\n<table BORDER cellspacing=1 bordercolor=\"#000000\" cellpadding=7 WIDTH=273><tr><td>\nPin<\/td><td>\nFunction<\/td><td>\nMnemonic<\/td><\/tr><tr><td>\n1<\/td><td>\nCarrier detect<\/td><td>\nCD<\/td><\/tr><tr><td>\n2<\/td><td>\nReceive<\/td><td>\nRXD or RX<\/td><\/tr><tr><td>\n3<\/td><td>\nTransmit<\/td><td>\nTXD or TX<\/td><\/tr><tr><td>\n4<\/td><td>\nData <glossary>terminal<\/glossary>\nready<\/td><td>\nDTR<\/td><\/tr><tr><td>\n5<\/td><td>\nSignal ground<\/td><td>\nGND<\/td><\/tr><tr><td>\n6 <\/td><td>\nData set ready<\/td><td>\nDSR<\/td><\/tr><tr><td>\n7<\/td><td>\nRequest to send<\/td><td>\nRTS<\/td><\/tr><tr><td>\n8<\/td><td>\nClear to send<\/td><td>\nCTS<\/td><\/tr><tr><td>\n9 <\/td><td>\nRing indicator<\/td><td>\nRI<\/td><\/tr><\/table>\n<\/center>\n<p>\n<center>\nTable -4 Pins on DB9 Connector\n<\/p>\n<\/center>\n<br \/><br \/>\n<center>\n<img decoding=\"async\" src=\"db_9_25.png\" width=314 height=79 border=0>\n<br \/>Figure &#8211; The Physical Layout of Pins on Serial Cables\n<\/p>\n<\/center>\n<p>\nNote that on a DB25 connector, pin 1 is <i>chassis ground<\/i>, which is\ndifferent from <glossary>signal<\/glossary> ground. Chassis ground ensures that\nboth serial connectors are operating at the same electric potential and keeps\nyou from getting a shock.\n<\/p>\n<p>\nTo communicate properly, the <glossary>DTE<\/glossary>\ndevice must say that it is ready to work by sending a <glossary>signal<\/glossary>\non the DTR line. The <glossary>DCE<\/glossary>\ndevice must do the same on the DSR line.\n<\/p>\n<p>\nOne side indicates that it has data by sending a <glossary>signal<\/glossary>\non the RTS line (it is requesting to send data). If ready, the other side says\nthat it is ready by sending a signal on the CTS line (the sender is clear to\nsend the data). What happens when the receiving side can&#8217;t keep up (that is, if\nthe sending side is sending too fast)? If the receiving side needs to stop\n(perhaps a <glossary>buffer<\/glossary> is full), it stops the CTS signal\n(meaning the sender is no longer clear to send the data). This causes the\nsending side to stop. This process is referred to as <i>hardware\nhandshaking<\/i>, <i>hardware flow control<\/i>,<i> <\/i>or <i>RTS\/CTS flow\ncontrol<\/i>.\n<\/p>\n<p>\nProblems arise when connecting other types of devices. Some devices, such as\nprinters, are themselves <glossary>DTE<\/glossary> devices. If you tried to\nconnect a standard RS-232 cable, TX is connected to TX, RX is connect to RX, DSR\nis connected to DSR, and DTR is connected to DTR. The result is that nothing\nhappens. The solution is a <i>cross-over <\/i>cable, which internally swaps the\nappropriate signals and makes sure they go to the right place.\n<\/p>\n<p>\nIf you have a <glossary>terminal<\/glossary>,\nthings are easier. First, though the data is going in both directions, the data\ncoming from  the terminal will never exceed the speed of the serial port (I&#8217;d\nlike to see you type 240 characters per second). Data heading toward the\nterminal is displayed on the screen, which will display it as quickly as it\ncomes. Therefore, you only need three signals: send, transmit, and ground.\n<\/p>\n<p>\nIf the <glossary>terminal<\/glossary>\ndisplays the data too fast for you to read, you can stop it by sending an XOFF\ncharacter back to the system. This is usually Ctrl+S and unless it is turned\noff, it will stop incoming data. To turn the flow of data back on again, send\nthe system an XON (Ctrl+Q) character. This type of <glossary>flow control<\/glossary>\nis called <i>software flow control <\/i>or <i>XON\/XOFF flow\ncontrol<\/i>. In some cases, depending on how the terminal is configured, sending\n<i>any<\/i> character restarts the flow.\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Serial Ports For the most part, all PC computers, even laptops are sold with at least one serial port and desktop machines or servers typically have two. These can be built into the motherboard, as part of a serial\/parallel card, &hellip; <a href=\"http:\/\/www.linux-tutorial.info\/?page_id=289\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-289","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/289","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=289"}],"version-history":[{"count":1,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/289\/revisions"}],"predecessor-version":[{"id":697,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/289\/revisions\/697"}],"wp:attachment":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}