{"id":1410,"date":"2018-08-27T12:26:12","date_gmt":"2018-08-27T11:26:12","guid":{"rendered":"https:\/\/ofalcao.pt\/blog\/?p=1410"},"modified":"2018-08-27T16:17:57","modified_gmt":"2018-08-27T15:17:57","slug":"ftdi-adapter-working-sometimes","status":"publish","type":"post","link":"https:\/\/ofalcao.pt\/blog\/2018\/ftdi-adapter-working-sometimes","title":{"rendered":"FTDI adapter working&#8230; sometimes"},"content":{"rendered":"<div class=\"seriesmeta\">This post is part 7 of 8 of \u00a0<a href=\"https:\/\/ofalcao.pt\/blog\/series\/sniffing-the-lego-interactive-motor\" class=\"series-341\" title=\"Sniffing the LEGO Interactive Motor\">Sniffing the LEGO Interactive Motor<\/a><\/div><p>Gremlins once again.<\/p>\n<p>BOOST Interactive Motor connected to the FTDI Beefy 3 adapter.<\/p>\n<ul>\n<li>Wiring:\n<ul>\n<li>6 = RX<\/li>\n<li>5 = TX<\/li>\n<li>4 = 3V3<\/li>\n<li>3 = GND<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Just that, no pull up resistors or whatsoever.<\/p>\n<p>When it works, it&#8217;s like with the Bus Pirate (including sometimes it just receiving<\/p>\n<pre>C0 00 3F<\/pre>\n<p>When it doesn&#8217;t work&#8230; I just get &#8217;00&#8217; after &#8217;00&#8217;. Then I remove the 3V3 wire and\/or use picocom instead of jpnevulator&#8230; and after endless tries it now works?!?<\/p>\n<p><del>Also changed the FTDI Beefy to another USB port. But if that had any impact it wasn&#8217;t immediately.<\/del><\/p>\n<p>You ought to love the scientific precision present in these posts \ud83d\ude00<\/p>\n<p>If\/when these results gets consistent&#8230; I just need an H-Bridge to control the motor and use the FTDI Beefy to read the encoder status. Why didn&#8217;t I put an H-Bridge on my holidays luggage?<\/p>\n<p>Edit: found the Gremlin, doesn&#8217;t mean I understand it:<\/p>\n<p>Procedure:<\/p>\n<p>1. Connect the FTDI Beefy adapter to USB<br \/>\n2. Start <strong>picocom<\/strong> then exit (<strong>^A^Q<\/strong>)<\/p>\n<pre> picocom -b 115200 \/dev\/ttyUSB3<\/pre>\n<p>3. Start jpnevulator<\/p>\n<pre>jpnevulator -i 10 --tty \/dev\/ttyUSB3 --read<\/pre>\n<p>4. Start adapted shell script and manually remove and reinsert power (3V3) while the Motor is receiving zeros:<\/p>\n<pre>#!\/usr\/bin\/env bash\r\n\r\n# send lots of 0's\r\nfor i in {1..50000}\r\ndo\r\n    echo -e -n \"\\x00\" &gt; \/dev\/ttyUSB3\r\ndone\r\n\r\n# send Init Sequence\r\necho -e -n \"\\x54\\x22\\x00\\x10\\x20\\xB9\" &gt; \/dev\/ttyUSB3\r\n\r\n# send Keep Alive's\r\nfor i in {1..50000}\r\ndo\r\n    echo -e -n \"\\x02\" &gt; \/dev\/ttyUSB3\r\n    sleep 0.1\r\ndone<\/pre>\n<p>So what is this Gremlin inside <strong>picocom<\/strong> doing?<\/p>\n<p>From the <a href=\"https:\/\/linux.die.net\/man\/8\/picocom\">man page<\/a>:<\/p>\n<blockquote><p>Unless the <i>&#8211;noinit<\/i> option is given, it configures the device to the settings specified by the option-arguments (or to some default settings), and sets it to &#8220;raw&#8221; mode. If <i>&#8211;noinit<\/i> is given, the initialization and configuration is skipped; the device is just opened.<\/p><\/blockquote>\n<p>Looks like this &#8220;raw&#8221; mode is needed for <strong>jpnevulator<\/strong> to work. And exiting with <strong>^A^Q<\/strong>\u00a0 leaves the tty in that mode:<\/p>\n<blockquote><p>Quit the program *without* reseting the serial port, regardless of the &#8220;&#8211;noreset&#8221; option.<\/p><\/blockquote>\n<p>So what is this raw mode and how do I configure it without running <strong>picocom<\/strong>? Google points me to <a href=\"https:\/\/acassis.wordpress.com\/2016\/01\/22\/configuring-linuxs-serial-port-to-raw-mode\/\">Configuring Linux\u2019s serial port to raw mode<\/a> by <a href=\"https:\/\/acassis.wordpress.com\">Alan C. Assis<\/a>:<\/p>\n<p>So <strong>stty<\/strong> has a &#8216;raw&#8217; option and this is enough:<\/p>\n<pre>stty -F \/dev\/ttyUSB3 115200 raw<\/pre>\n<p>And it works. Yes, it really does!<\/p>\n<p>That&#8217;s also the reason Bus Pirate was also working: I was using <strong>picocom<\/strong> to configure it.<\/p>\n<p>Argh, so many nights with such a silly issue.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"seriesmeta\">This post is part 7  of 8 of \u00a0<a href=\"https:\/\/ofalcao.pt\/blog\/series\/sniffing-the-lego-interactive-motor\" class=\"series-341\" title=\"Sniffing the LEGO Interactive Motor\">Sniffing the LEGO Interactive Motor<\/a><\/div><p>Gremlins once again. BOOST Interactive Motor connected to the FTDI Beefy 3 adapter. Wiring: 6 = RX 5 = TX 4 = 3V3 3 = GND Just that, no pull up resistors or whatsoever. When it works, it&#8217;s like with the Bus Pirate (including sometimes it just receiving C0 00 3F When it doesn&#8217;t work&#8230; &hellip; <a href=\"https:\/\/ofalcao.pt\/blog\/2018\/ftdi-adapter-working-sometimes\" class=\"more-link\">Continuar a ler<span class=\"screen-reader-text\"> &#8220;FTDI adapter working&#8230; sometimes&#8221;<\/span><\/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":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[1],"tags":[],"series":[341],"class_list":["post-1410","post","type-post","status-publish","format-standard","hentry","category-sem-categoria","series-sniffing-the-lego-interactive-motor"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2Mhyv-mK","_links":{"self":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/comments?post=1410"}],"version-history":[{"count":0,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1410\/revisions"}],"wp:attachment":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/media?parent=1410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/categories?post=1410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/tags?post=1410"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/series?post=1410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}