{"id":1393,"date":"2018-08-21T00:44:44","date_gmt":"2018-08-20T23:44:44","guid":{"rendered":"https:\/\/ofalcao.pt\/blog\/?p=1393"},"modified":"2018-08-21T02:57:21","modified_gmt":"2018-08-21T01:57:21","slug":"spock-was-correct","status":"publish","type":"post","link":"https:\/\/ofalcao.pt\/blog\/2018\/spock-was-correct","title":{"rendered":"Spock was correct"},"content":{"rendered":"<div class=\"seriesmeta\">This post is part 2 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>And at <del>57200<\/del> 57600 bps a pattern at last!!!<\/p>\n<p>So I put Bus Pirate capturing traffic between the LEGO BOOST Hub and the BOOT motor (the one with the encoder that LEGO calls &#8220;<span class=\"product-features__description markup\" data-test=\"product-features-description\">Interactive Motor<\/span>&#8220;) at 57200.<\/p>\n<p>I ran my serial sniffer:<\/p>\n<pre>jpnevulator --ascii --tty \/dev\/ttyUSB3 --read<\/pre>\n<p>I power up the Hub with the motor attached (to port C, not sure if important).<\/p>\n<p>And a pattern of 6 bytes appears:<\/p>\n<pre>0A EF EF 00 A0<\/pre>\n<p>Where &#8216;0A&#8217; and &#8216;A0&#8217; seem &#8220;start&#8221; and &#8220;end&#8221; of a message and &#8216;EF EF 00&#8217; the payload. Or something completely different, like the Monty Python would say.<\/p>\n<p>I connect to the Hub with gatttool in interactive mode and activate notifications and motor readings and then send a command to turn just 1 degree:<\/p>\n<pre>char-write-req 0x0f 0100\r\nchar-write-req 0x0e 0a004101020100000001\r\nchar-write-req 0x0e 0E018101110B0100000064647F03<\/pre>\n<p>no events return from the motor but something flows between the Hub and the motor and then the pattern returns:<\/p>\n<pre>0A EF EF 00 A0<\/pre>\n<p>Thats good! Because I knew that 1 degree is not enough to generate a new position notification (usually 4 to 6 commands are needed) and the payload didn&#8217;t change.<\/p>\n<p>1 more command to turn 1 degree. Same<\/p>\n<p>1 more. Same.<\/p>\n<p>1 more. Same. I already sent the same command 4 times.<\/p>\n<p>No 1 more command and a notification is received. And the pattern changes to<\/p>\n<pre>0A 00 00 00 A0<\/pre>\n<p>There was an increase! But not by +1..<\/p>\n<p>Now I move the axle myself a bit and the payload changes to &#8217;01 00 00&#8242;.<\/p>\n<p>I move again backwards so the payload changes back to &#8217;00 00 00&#8242;.<\/p>\n<p>Now I send again the same &#8216;turn 1 degree&#8217; command 5 times&#8230; and I get a position change notification and the payload increased to &#8217;01 00 00&#8242; as expected.<\/p>\n<p><del>So the payload is the encoder position in degrees. 3 bytes, reverted (or little endian).<\/del><\/p>\n<p>Edited: spoke too early. 5 bytes message yes, payload related to encoder position yes, payload meaning not so simple.<\/p>\n<p>Not enough yet to use the motor on other systems (like an Arduino or an Ev3) but it is a start. And a drop of wisdom on a hot night after a very pleasant day with family at water sliding park.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"seriesmeta\">This post is part 2  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>And at 57200 57600 bps a pattern at last!!! So I put Bus Pirate capturing traffic between the LEGO BOOST Hub and the BOOT motor (the one with the encoder that LEGO calls &#8220;Interactive Motor&#8220;) at 57200. I ran my serial sniffer: jpnevulator &#8211;ascii &#8211;tty \/dev\/ttyUSB3 &#8211;read I power up the Hub with the motor &hellip; <a href=\"https:\/\/ofalcao.pt\/blog\/2018\/spock-was-correct\" class=\"more-link\">Continuar a ler<span class=\"screen-reader-text\"> &#8220;Spock was correct&#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-1393","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-mt","_links":{"self":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1393","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=1393"}],"version-history":[{"count":0,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1393\/revisions"}],"wp:attachment":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/media?parent=1393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/categories?post=1393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/tags?post=1393"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/series?post=1393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}