Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

USB Host APIで遊んでみた

11,954 views

Published on

Published in: Technology
  • DOWNLOAD FULL. BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • あざす!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

USB Host APIで遊んでみた

  1. 1. USB Host API P-touch RL RL-700S
  2. 2. • (@zaki50)•• Android ( StickyShortcut) A3
  3. 3. USB Host
  4. 4. USB Host Android 3.1 Platform highlights• Honeycomb 3.1• OS (HID Mass Storage)• ( )
  5. 5. USB Host API• USB API• OS• USB•
  6. 6. • : USB UsbDeviceConnection• : UsbDeviceConnection
  7. 7. • Intent (IntentFilter )• (listDevices )
  8. 8. IntentFilterAndroidManifest.xml <intent-filter>     <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /> </intent-filter> <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"     android:resource="@xml/device_filter" />res/device_filter.xml <?xml version="1.0" encoding="utf-8"?> <resources>     <usb-device vendor-id="1234" product-id="5678" /> </resources>
  9. 9. listDevice• USB Device•• BroadcastReceiver /
  10. 10. private static final String ACTION_USB_PERMISSION = "hogehoge.USB_PERMISSION";• IntentFilter private final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (ACTION_USB_PERMISSION.equals(action)) { synchronized (this) { final UsbDevice device = (UsbDevice) intent• BroadcastReceiver .getParcelableExtra(UsbManager.EXTRA_DEVICE); if (!intent.getBooleanExtra(UsbManager .EXTRA_PERMISSION_GRANTED, false)) { Log.i(TAG, "USB Permission denied"); PrintActivity.this.setResult(Activity.RESULT_CANCELED); PrintActivity.this.finish(); return; } // requestPermission } } } }; // registerReceiver(mUsbReceiver, new IntentFilter(ACTION_USB_PERMISSION)); final PendingIntent pi = PendingIntent.getBroadcast(this, 0, new Intent( ACTION_USB_PERMISSION), 0); mManager.requestPermission(device, pi);
  11. 11. USB• vendor ID product ID• Interface• interface Endpoint• Endpoint ( / )
  12. 12. Endpoint• Control ↓• Interrupt http://ja.wikipedia.org/wiki/ Universal_Serial_Bus• Bulk• Isochronous
  13. 13. • claimInterface• Endpoint • controlTransfer/bulkTransfer • UsbRequest
  14. 14. UsbEndpoint endpoint = ...; // Endpointbyte[] buffer = ...;int timeoutMillis = 5000;final int sent = conn.bulkTransfer(endpoint, buffer, buffer.length, timeoutMillis); • • buffer offset
  15. 15. UsbDeviceConnection conn = ...;UsbEndpoint in = ...;ByteBuffer recvBuffer = ByteBuffer.allocate(in.getMaxPacketSize());UsbRequest recvReq = new UsbRequest();recvReq.initialize(conn, in); // Endpointwhile (true) { recvReq.queue(recvBuffer, recvBuffer.remaining()); // UsbRequest request = conn.requestWait(); // if (request != recvReq) { // break; } // recvBuffer}
  16. 16. • 1 UsbConnection •
  17. 17. • bulkTransfer• UsbRequest• type Control bulkTransfer controlTransfer
  18. 18. • @touchRL twitter RFID• Windows• Mac
  19. 19. @touchRL
  20. 20. • DevGuide (USB - Host) http://developer.android.com/guide/topics/usb/host.html• http://developer.android.com/resources/samples/USB/ index.html• (github) • RL-700S http://goo.gl/fFA93 • RL-700S http://goo.gl/rV7TZ

×