{"id":457,"date":"2019-06-12T19:09:22","date_gmt":"2019-06-12T19:09:22","guid":{"rendered":"https:\/\/geekblog.febo.com\/?p=457"},"modified":"2019-06-12T19:13:53","modified_gmt":"2019-06-12T19:13:53","slug":"usr-iot-serial-to-ethernet-converters-with-linux","status":"publish","type":"post","link":"https:\/\/blog.febo.com\/?p=457","title":{"rendered":"USR-IOT Serial-to-Ethernet Converters with Linux"},"content":{"rendered":"<p>I&#8217;m posting this mainly because Google didn&#8217;t turn up any help when I queried about using the <A HREF=\"https:\/\/www.usriot.com\/products\/serial-to-ethernet-converters\/\">USR-IOT serial port to ethernet converters<\/A> (also known as terminal servers) with Linux.  They make several low-cost devices that are really handy if you need to talk to serial devices that are far from the host computer.  In particular, the <A HREF=\"https:\/\/www.usriot.com\/products\/modbus-serial-to-ethernet-converters.html\">USR-TCP232-410S<\/A> single port converter and <A HREF=\"https:\/\/www.usriot.com\/products\/4-ports-serial-to-ethernet-converter.html\">USR-N540<\/A> four port device are quite inexpensive.  Their website has nary a mention of Linux compatibility, and I didn&#8217;t find any Google hits indicating that they work with anything other than Windows and maybe Mac.<br \/>\n<P><br \/>\nIt turns out that they work just fine under Linux, using standard protocols.  You can even change speed as if the port were physically connected to the computer.  Leaving the server set at its default settings, all you need to do on the Linux end is install the <A HREF=\"https:\/\/www.usriot.com\/products\/4-ports-serial-to-ethernet-converter.html\">socat<\/A> &#8220;multipurpose relay&#8221; tool (it&#8217;s available as a package in Debian-based distributions) and write a simple shell script.<\/p>\n<p>Here&#8217;s what I&#8217;m using:<\/p>\n<p><code><br \/>\n#!\/bin\/bash<br \/>\n# open virtual serial port<br \/>\nsocat pty,link=$HOME\/vmodem0,waitslave tcp:10.73.1.71:23 &<br \/>\n# run the program<br \/>\n.\/testcomms.py<br \/>\n# kill socat afterwards<br \/>\nkillall socat<br \/>\n<\/code><\/p>\n<p>Customize the socat command line with the name of the port device (here $HOME\/vmodem0, but you can name it and place it wherever you want), and the IP address and port of the serial server.<\/p>\n<p>This worked on the first try, suspiciously easily.<\/p>\n<p>It appears that socat destroys the vmodem0 device when the called program finishes running, but does not kill its process.  That&#8217;s why I stuck the killall command on the last line.  There is probably a way to make the device persistent so you would only need to run the socat command once at bootup, but I haven&#8217;t dug around for it yet.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m posting this mainly because Google didn&#8217;t turn up any help when I queried about using the USR-IOT serial port to ethernet converters (also known as terminal servers) with Linux.&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","ngg_post_thumbnail":0,"footnotes":""},"categories":[6,55,7],"tags":[61,60,56,57,59,58],"class_list":["post-457","post","type-post","status-publish","format-standard","hentry","category-general","category-networking","category-test-and-lab-equipment","tag-ethernet","tag-serial-port","tag-usr","tag-usr-iot","tag-usr-n540","tag-usr-tcp232"],"_links":{"self":[{"href":"https:\/\/blog.febo.com\/index.php?rest_route=\/wp\/v2\/posts\/457","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.febo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.febo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.febo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.febo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=457"}],"version-history":[{"count":6,"href":"https:\/\/blog.febo.com\/index.php?rest_route=\/wp\/v2\/posts\/457\/revisions"}],"predecessor-version":[{"id":464,"href":"https:\/\/blog.febo.com\/index.php?rest_route=\/wp\/v2\/posts\/457\/revisions\/464"}],"wp:attachment":[{"href":"https:\/\/blog.febo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.febo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=457"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.febo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}