{"id":1367,"date":"2012-12-16T12:56:38","date_gmt":"2012-12-16T10:56:38","guid":{"rendered":"http:\/\/blog.cipworx.org\/laserman\/?p=1367"},"modified":"2012-12-16T12:56:38","modified_gmt":"2012-12-16T10:56:38","slug":"android-als-usb-host-arduino","status":"publish","type":"post","link":"https:\/\/blog.cipworx.org\/laserman\/2012\/12\/16\/android-als-usb-host-arduino\/","title":{"rendered":"Android als USB Host, Arduino"},"content":{"rendered":"<p>Seit einiger Zeit entwickle ich Android Software in Python (mit SL4A, PythonAPK). Mein aktuelles Android Tablet ist das Arnova 10d G3 (Android 4.0.3, Linux Kernel 3.0.8). Es hat leider kein Bluetooth aber es hat 2 USB Anschl\u00fcsse, einer davon als USB Host. Also habe ich mit dmesg und logcat geschaut, was passiert, wenn man verschiedene USB Ger\u00e4te anschlie??t. <\/p>\n<p>* USB-Tastatur &#038; -Maus werden automatisch erkannt und k\u00f6nnen sofort benutzt werden. Tastatur-Layout ist aber immer US ?!<\/p>\n<p>* USB Drucker werden zwar vom Kernel als &#8220;full speed USB device&#8221; erkannt aber nicht als Drucker.<br \/>\nZum Vergleich ubuntu Linux:<\/p>\n<blockquote><p><code>usblp0: USB Bidirectional printer dev 14 if 0 alt 0 proto 2 vid 0x0482 pid 0x0011<br \/>\n[114688.541019] usbcore: registered new interface driver usblp<\/code><\/p><\/blockquote>\n<p>* USB-RS232-Konverter<br \/>\n1.) FTDI FT232RL &#8211; Das gleiche wie bei den Drucken. Ich habe zwar eine &#8220;Treiber-App&#8221; daf\u00fcr gefunden, hatte damit aber bisher keinen Erfolg damit. <a href=\"http:\/\/android.serverbox.ch\/?p=370\" title=\"http:\/\/android.serverbox.ch\/?p=370\">http:\/\/android.serverbox.ch\/?p=370<\/a><\/p>\n<p>2.) Prolific PL2303<br \/>\nDer Kernel erkennt diesen USB-nach-Seriell Converter und stellt das serielle Device \/dev\/ttyUSB5 zur Verf\u00fcgung:<\/p>\n<blockquote><p>\n<code>&lt;6>[27051.309145] usb 2-2: new full speed USB device number 3 using uhci_hcd<br \/>\n&lt;6>[27051.478195] pl2303 2-2:1.0: pl2303 converter detected<br \/>\n&lt;6>[27051.501198] usb 2-2: pl2303 converter now attached to ttyUSB5<\/code><\/p><\/blockquote>\n<p>Also habe ich versucht, von meinem Python Script aus den per pl2303 angeschlossenen Arduino anzusprechen. Es funktioniert! \ud83d\ude42 <\/p>\n<p>python code:<\/p>\n<blockquote><p>\n<code>import serial<br \/>\nser = serial.Serial('\/dev\/ttyUSB5', 2400, timeout=1)<br \/>\nser.write(\"hello\")<br \/>\nser.close()<br \/>\n<\/code><\/p><\/blockquote>\n<p>arduino code:<\/p>\n<blockquote><p><code><\/p>\n<pre>\r\n#include &lt;LiquidCrystal.h>\r\nint inByte = 0;         \/\/ incoming serial byte\r\n\/\/ initialize the library with the numbers of the interface pins\r\nLiquidCrystal lcd(8, 9, 4, 5, 6, 7);\r\n\r\nvoid setup() {\r\n  \/\/ set up the LCD's number of columns and rows:\r\n  lcd.begin(16, 2);\r\n  \/\/ Print a message to the LCD.\r\n  lcd.print(\".\");\r\n  lcd.setCursor(16, 0);\r\n  lcd.autoscroll();\r\n  Serial.begin(2400);\r\n}\r\nvoid loop() {\r\n  if (Serial.available() > 0) {\r\n    \/\/ get incoming byte:\r\n    inByte = Serial.read();\r\n    Serial.write(inByte);\r\n    lcd.write(inByte);\r\n  }\r\n}\r\n<\/pre>\n<p><\/code>\n<\/p><\/blockquote>\n<p>Alternativ gibt es f\u00fcr den pl2303 eine Erweiterung(Custom Facade) zu SL4A: <a href=\"https:\/\/bitbucket.org\/kuri65536\/usbhostserialfacade\" title=\"https:\/\/bitbucket.org\/kuri65536\/usbhostserialfacade\">https:\/\/bitbucket.org\/kuri65536\/usbhostserialfacade<br \/>\n<\/a><br \/>\nDie hat bei mir aber nicht funktioniert (&#8220;device was not found&#8221; ) M\u00f6glicherweise werden von der Android API Ger\u00e4te, die bereits durch einen Kernel Treiber verwaltet werden nicht mehr angeboten.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Seit einiger Zeit entwickle ich Android Software in Python (mit SL4A, PythonAPK). Mein aktuelles Android Tablet ist das Arnova 10d G3 (Android 4.0.3, Linux Kernel 3.0.8). Es hat leider kein Bluetooth aber es hat 2 USB Anschl\u00fcsse, einer davon als USB Host. Also habe ich mit dmesg und logcat geschaut, was passiert, wenn man verschiedene [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[132,11,4],"tags":[],"class_list":["post-1367","post","type-post","status-publish","format-standard","hentry","category-android","category-hardware","category-linux"],"_links":{"self":[{"href":"https:\/\/blog.cipworx.org\/laserman\/wp-json\/wp\/v2\/posts\/1367","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.cipworx.org\/laserman\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.cipworx.org\/laserman\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.cipworx.org\/laserman\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.cipworx.org\/laserman\/wp-json\/wp\/v2\/comments?post=1367"}],"version-history":[{"count":8,"href":"https:\/\/blog.cipworx.org\/laserman\/wp-json\/wp\/v2\/posts\/1367\/revisions"}],"predecessor-version":[{"id":1375,"href":"https:\/\/blog.cipworx.org\/laserman\/wp-json\/wp\/v2\/posts\/1367\/revisions\/1375"}],"wp:attachment":[{"href":"https:\/\/blog.cipworx.org\/laserman\/wp-json\/wp\/v2\/media?parent=1367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.cipworx.org\/laserman\/wp-json\/wp\/v2\/categories?post=1367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.cipworx.org\/laserman\/wp-json\/wp\/v2\/tags?post=1367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}