{"id":236,"date":"2021-10-14T07:13:15","date_gmt":"2021-10-14T07:13:15","guid":{"rendered":"https:\/\/sznetwork.systems\/?p=236"},"modified":"2025-05-19T11:38:21","modified_gmt":"2025-05-19T09:38:21","slug":"sz_io62_serial","status":"publish","type":"post","link":"https:\/\/sznetwork.systems\/?p=236","title":{"rendered":"SZ_IO62_serial (Migrated)"},"content":{"rendered":"\n<p>Small console utility to control SZ_IO62 controller<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Commands:<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">-h - Show help list with commands<br>.\/SZ_IO62R2 \"COMMAND\" or SZ_IO62R2.exe \"COMMAND\" - Send command to controller<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Command List:<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">Input activation commands:<br>sI1, cI1, sI2, cI2, sI3, cI3, sI4, cI4, sI5, cI5, sI6, cI6, sV7, sV8<br>Output activation commands:<br>out1, out2, out3, out4, out5, out6, out7, out8<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Starting app<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">Edit config.txt COM port settings Windows COM port name \"COMx\" x - Port name (1,2\u2026) Linux Com port name \"\/dev\/ttyUSB0\" USB0 - Port name (1,2\u2026)<br>Run \".\/bridge\" or \"bridge.exe\" as service<br>Run .\/SZ_IO62R2 \"COMMAND\" or SZ_IO62R2.exe \"COMMAND\"<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Depends<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">Program depends on pySerial Module can be installed by command pip install pyserial<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Screenshots<\/h2>\n\n\n\n<figure class=\"wp-block-gallery columns-3 wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\"><ul class=\"blocks-gallery-grid\"><li class=\"blocks-gallery-item\"><figure><a href=\"https:\/\/sznetwork.systems\/?attachment_id=260\"><img loading=\"lazy\" decoding=\"async\" width=\"396\" height=\"86\" src=\"https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/10\/screenshot.4-1.jpg\" alt=\"\" data-id=\"260\" data-full-url=\"https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/10\/screenshot.4-1.jpg\" data-link=\"https:\/\/sznetwork.systems\/?attachment_id=260\" class=\"wp-image-260\" srcset=\"https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/10\/screenshot.4-1.jpg 396w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/10\/screenshot.4-1-300x65.jpg 300w\" sizes=\"auto, (max-width: 396px) 100vw, 396px\" \/><\/a><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><a href=\"https:\/\/sznetwork.systems\/?attachment_id=259\"><img loading=\"lazy\" decoding=\"async\" width=\"977\" height=\"511\" src=\"https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/10\/screenshot.3-1.jpg\" alt=\"\" data-id=\"259\" data-full-url=\"https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/10\/screenshot.3-1.jpg\" data-link=\"https:\/\/sznetwork.systems\/?attachment_id=259\" class=\"wp-image-259\" srcset=\"https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/10\/screenshot.3-1.jpg 977w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/10\/screenshot.3-1-300x157.jpg 300w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/10\/screenshot.3-1-768x402.jpg 768w\" sizes=\"auto, (max-width: 977px) 100vw, 977px\" \/><\/a><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><a href=\"https:\/\/sznetwork.systems\/?attachment_id=258\"><img loading=\"lazy\" decoding=\"async\" width=\"977\" height=\"511\" src=\"https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/10\/screenshot.2-1.jpg\" alt=\"\" data-id=\"258\" data-full-url=\"https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/10\/screenshot.2-1.jpg\" data-link=\"https:\/\/sznetwork.systems\/?attachment_id=258\" class=\"wp-image-258\" srcset=\"https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/10\/screenshot.2-1.jpg 977w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/10\/screenshot.2-1-300x157.jpg 300w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/10\/screenshot.2-1-768x402.jpg 768w\" sizes=\"auto, (max-width: 977px) 100vw, 977px\" \/><\/a><\/figure><\/li><\/ul><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Code<\/h2>\n\n\n\n<p>main.py<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import sys \nimport os\n    \n# Help function\ndef help_f():\n    print(\"\"\"\n    \nSZ_IO62R2 controller serial utility\n    \nCommands:\n    \n    -h - Show help list with commands\n    .\/SZ_IO62R2 \"COMMAND\" or SZ_IO62R2.exe \"COMMAND\" -  Send command to controller\n\nCommand List:\n\n    Input activation commands:\n    sI1, cI1, sI2, cI2, sI3, cI3, sI4, cI4, sI5, cI5, sI6, cI6, sV7, sV8 \n    Output activation commands:\n    out1, out2, out3, out4, out5, out6, out7, out8\n\n    \"\"\")\n\n\n# Listen for arguments \nif len(sys.argv) &gt; 1:\n    with open('commands', 'w') as f:\n        f.write(sys.argv[1])\n        f.close()\nelse:\n    help_f()<\/pre>\n\n\n\n<p>bridge.py<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import serial\nimport time\nimport os\n\n\n# COM port config from config.txt\nwith open('config.txt') as f:\n   lines = f.readlines()\n\n\nfor line in lines:\n   if \"PORT\" in line:\n       port_com = line.split(\" = \")[1]\n       rep=[\"\\n\"]\n       for r in rep:\n          port_com=port_com.replace(r,\"\")\n\n\n# COM port starting\nser = serial.Serial(port=port_com, baudrate=9600, timeout=.1)\n\n# Wait while controller boot after serial connected\ntime.sleep(2)\n\n# Read boot stuff information\nwhile ser.readline():\n    unused_data = ser.readline()\n\n# Bridge function\nwhile True:\n\n    time.sleep(0.1)\n    if os.path.isfile('commands'):\n        with open('commands', 'r') as f:\n                cmd = f.read()+ '\\r\\n'\n                ser.write(cmd.encode())\n                f.close()\n        os.remove('commands')<\/pre>\n\n\n\n<p>config.txt<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">PORT = COM5<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Video<\/h2>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"SZ_IO62R2_serial small console utility to control SZ_IO62R2 module\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/Mc-OY7o20Do?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Source code<\/h2>\n\n\n\n<p class=\"has-black-color has-cyan-bluish-gray-background-color has-text-color has-background\"><a href=\"https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/10\/Code.zip\">Download<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Compiled to Windows and Linux<\/h2>\n\n\n\n<p class=\"has-black-color has-cyan-bluish-gray-background-color has-text-color has-background\"><a href=\"https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/10\/SZ_IO62R2.zip\">Download<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Link to SZ_IO62R2 module Page<\/h2>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-szn wp-block-embed-szn\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/sznetwork.systems\/index.php\/projects\/sz_io62r2\/\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Small console utility to control SZ_IO62 controller Commands: -h &#8211; Show help list with commands.\/SZ_IO62R2 &#8220;COMMAND&#8221; or SZ_IO62R2.exe &#8220;COMMAND&#8221; &#8211; Send command to controller Command List: Input activation commands:sI1, cI1,. <a class=\"read-more-link\" href=\"https:\/\/sznetwork.systems\/?p=236\">read more&#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[24,319],"tags":[6,12,11,19,10],"class_list":["post-236","post","type-post","status-publish","format-standard","hentry","category-software","category-sz-projects","tag-arduino","tag-code","tag-controller","tag-python","tag-uart"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/sznetwork.systems\/index.php?rest_route=\/wp\/v2\/posts\/236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sznetwork.systems\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sznetwork.systems\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sznetwork.systems\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sznetwork.systems\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=236"}],"version-history":[{"count":10,"href":"https:\/\/sznetwork.systems\/index.php?rest_route=\/wp\/v2\/posts\/236\/revisions"}],"predecessor-version":[{"id":1886,"href":"https:\/\/sznetwork.systems\/index.php?rest_route=\/wp\/v2\/posts\/236\/revisions\/1886"}],"wp:attachment":[{"href":"https:\/\/sznetwork.systems\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sznetwork.systems\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sznetwork.systems\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}