{"id":5803,"date":"2020-06-22T19:28:14","date_gmt":"2020-06-22T19:28:14","guid":{"rendered":"https:\/\/really.zonky.org\/?p=5803"},"modified":"2020-06-22T19:28:16","modified_gmt":"2020-06-22T19:28:16","slug":"linux-selecting-the-right-serial-port","status":"publish","type":"post","link":"https:\/\/really.zonky.org\/?p=5803","title":{"rendered":"Linux: Selecting The Right Serial Port"},"content":{"rendered":"\n<p>I have a problem with serial ports (usually &#8220;virtual ones&#8221; or USB\u2190\u2192serial port dongles) &#8211; I have too many of them, and I usually end up with the wrong one. And selecting a <a href=\"http:\/\/ubld.it\/truerng_v3\" class=\"aioseop-link\">TrueRNG<\/a> serial port and connecting a terminal emulator to it gets very messy very quickly. <\/p>\n\n\n\n<p>So I was searching around, semi-idly wondering if I could somehow build a device name to USB name mapping that I could stuff into <em>rofi<\/em> (or <em>dmenu<\/em>) and I discovered the <em>\/dev\/serial\/by-id\/<\/em> which did 99% of the work for me.<\/p>\n\n\n\n<p>So yes, I can invoke <em>kermit<\/em> and up will pop a menu allowing me to select which serial port to connect to :-<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls \/dev\/serial\/by-id |\\\n  rofi -dmenu -l 20 -p \"Pick a serial device\" -font \"mono 20\"<\/code><\/pre>\n\n\n\n<p>That is the core of it, but to make it functional I need to embed it into a command line argument to <em>kermit<\/em> :-<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>alias kermit='kermit -C \"set line \/dev\/serial\/by-id\/$(ls \/dev\/serial\/by-id | rofi -dmenu -l 20 -p \"Pick a serial device\" -font \"mono 20\"),set carrier-watch off\"'<\/code><\/pre>\n\n\n\n<p>Which is admittedly a bit of a mouthful!<\/p>\n\n\n\n<p>But <em>so<\/em> useful if you have two or three USB to serial adopters plugged in plus a switch&#8217;s console port and a Linux widget that provides a serial console. <\/p>\n\n\n\n<p> <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"695\" height=\"463\" src=\"https:\/\/i0.wp.com\/really.zonky.org\/wp-content\/uploads\/damascus-unix-prompt1.png?resize=695%2C463&#038;ssl=1\" alt=\"\" class=\"wp-image-3904\" srcset=\"https:\/\/i0.wp.com\/really.zonky.org\/wp-content\/uploads\/damascus-unix-prompt1.png?w=792&amp;ssl=1 792w, https:\/\/i0.wp.com\/really.zonky.org\/wp-content\/uploads\/damascus-unix-prompt1.png?resize=300%2C200&amp;ssl=1 300w\" sizes=\"auto, (max-width: 695px) 100vw, 695px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>I have a problem with serial ports (usually &#8220;virtual ones&#8221; or USB\u2190\u2192serial port dongles) &#8211; I have too many of them, and I usually end up with the wrong one. And selecting a TrueRNG serial port and connecting a terminal emulator to it gets very messy very quickly. So I was searching around, semi-idly wondering <a href='https:\/\/really.zonky.org\/?p=5803' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_share_on_mastodon":"0"},"categories":[4,209],"tags":[1950,1944,1949,1020],"class_list":["post-5803","post","type-post","status-publish","format-standard","hentry","category-it","category-linux-it","tag-dev-serial","tag-kermit","tag-serial","tag-usb","category-4-id","category-209-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"share_on_mastodon":{"url":"","error":""},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1f2KI-1vB","_links":{"self":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts\/5803","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5803"}],"version-history":[{"count":1,"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts\/5803\/revisions"}],"predecessor-version":[{"id":5804,"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts\/5803\/revisions\/5804"}],"wp:attachment":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5803"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5803"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}