{"id":4376,"date":"2024-03-25T02:21:00","date_gmt":"2024-03-25T06:21:00","guid":{"rendered":"https:\/\/www.both.org\/?p=4376"},"modified":"2024-03-16T09:26:05","modified_gmt":"2024-03-16T13:26:05","slug":"serial-communication-on-linux","status":"publish","type":"post","link":"https:\/\/www.both.org\/?p=4376","title":{"rendered":"Serial communication on Linux"},"content":{"rendered":"<div class=\"pld-like-dislike-wrap pld-template-1\">\r\n    <div class=\"pld-like-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"4376\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                        <i class=\"fas fa-thumbs-up\"><\/i>\r\n                <\/a>\r\n    <span class=\"pld-like-count-wrap pld-count-wrap\">1    <\/span>\r\n<\/div><\/div>\n<p>Systems engineers often spend a lot of time in a data center configuring servers and other computing and networking equipment. If your role includes these activities,  I recommend two items to keep in your toolkit; a RS-232 serial-to-USB converter and a standard DB-9 serial cable. These can be indispensable when you have no other way to access a device. You may need to deploy a new router that has not yet been configured for example. You might need to troubleshoot a firewall appliance that has become inaccessible via SSH. In a &#8220;lights-out&#8221; environment, particularly, new servers may have a management card that needs to be initialized. A serial connection provides a direct path to a console for accomplishing these tasks.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"608\" height=\"304\" src=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/03\/converter_n_cable.webp\" alt=\"\" class=\"wp-image-4379\" style=\"width:403px;height:auto\" \/><\/figure>\n\n\n\n<p>I will use a SOHO firewall appliance in this example. This device has no mouse, keyboard, monitor, or other GUI capabilities. Equipment like this is generally described as &#8220;headless.&#8221;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Serial communications<\/h2>\n\n\n\n<p>To connect with a device over serial, you need hardware that supports the RS-232 protocol. This is typically a nine-pin DB-9 serial port, often labeled serial, comm, or console. Most older computers have at least one. Most servers still have them, but most laptops and desktops don&#8217;t any longer.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"408\" height=\"192\" src=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/03\/console_port.webp\" alt=\"\" class=\"wp-image-4380\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Find the serial port<\/h2>\n\n\n\n<p>If your system doesn&#8217;t already have a serial port, you&#8217;ll need to use a converter like the one I mentioned. When you plug in the PL2303 converter to a USB port on your computer, the Linux kernel registers it as a USB TTY device. There are several commands that you can use to query your system for its serial port configuration. Here are a few examples:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># dmesg |grep tty\n[252464.891372] usb 6-1: pl2303 converter now attached to ttyUSB0\n\n# setserial -g \/dev\/ttyUSB[0123]\n\/dev\/ttyUSB0, UART: 16654, Port: 0x0000, IRQ: 0\n\n# ls \/dev\/serial\/by-id\/\nusb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0<\/pre>\n\n\n\n<p>In my case, it detects the converter as a pl2303 converter (or a Prolific Technology USB serial controller).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Connect a serial cable<\/h2>\n\n\n\n<p>Connect your serial cable between the converter and the serial port on the device.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"608\" height=\"363\" src=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/03\/netgate_rear.webp\" alt=\"\" class=\"wp-image-4381\" style=\"width:412px;height:auto\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Log in with tio<\/h2>\n\n\n\n<p>Over the years, I&#8217;ve used different tools, such as Minicom and Screen. Tio is a newer and simpler tool described as &#8220;a simple TTY terminal I\/O application.&#8221; It is available on most Linux distributions, FreeBSD, and OpenWRT, as well as a Snap package. I used the standard package tool to install version 1.32 onto my Red Hat Enterprise Linux 8.1 server:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># dnf info tio\n# dnf install tio<\/pre>\n\n\n\n<p>Initialize the connection with the tio command. In my experience, Tio didn&#8217;t need any advance configuration; it worked out of the box. Be sure that you have the correct device path, as shown above:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># tio \/dev\/ttyUSB0\n\n# tio \/dev\/serial\/by-id\/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"608\" height=\"470\" src=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/03\/tio_connected.webp\" alt=\"\" class=\"wp-image-4382\" \/><\/figure>\n\n\n\n<p>You can use the Ctrl+t command sequence to interact with Tio. For instance, Ctrl+t+? will list available commands, and Ctrl+t+q quits Tio and takes you back to your Linux command prompt.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>We rarely think about or even use serial communications these days, but it is still useful. Data center people still need to be familiar with it. Data centers can be remote, and once inside, you&#8217;ll want to make sure you have all the proper tools. Besides a good Linux laptop, of course, I recommend the items above for managing those serial-enabled devices when necessary.<\/p>\n\n\n\n<p>This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn to use the ancient serial communications hardware and software methods that are needed even today in many data centers. <\/p>\n","protected":false},"author":429,"featured_media":4380,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[5,89,80,178],"tags":[317],"class_list":["post-4376","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-system-administration","category-tips-and-tricks","category-tools","tag-serial-communications"],"modified_by":"David Both","_links":{"self":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/4376","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/users\/429"}],"replies":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4376"}],"version-history":[{"count":3,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/4376\/revisions"}],"predecessor-version":[{"id":4438,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/4376\/revisions\/4438"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/media\/4380"}],"wp:attachment":[{"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4376"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4376"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}