|
124 | 124 | <li class="toctree-l4"><a class="reference internal" href="#webview">WebView</a></li> |
125 | 125 | </ul> |
126 | 126 | </li> |
| 127 | +<li class="toctree-l3"><a class="reference internal" href="#usb-host-serial-facade">USB Host Serial Facade</a><ul> |
| 128 | +<li class="toctree-l4"><a class="reference internal" href="#requirements">Requirements</a></li> |
| 129 | +<li class="toctree-l4"><a class="reference internal" href="#status">Status</a></li> |
| 130 | +<li class="toctree-l4"><a class="reference internal" href="#author">Author</a></li> |
| 131 | +<li class="toctree-l4"><a class="reference internal" href="#apis">APIs</a></li> |
| 132 | +</ul> |
| 133 | +</li> |
127 | 134 | </ul> |
128 | 135 | </li> |
129 | 136 | <li class="toctree-l2"><a class="reference internal" href="guide_extend.html">QPython Open API</a></li> |
@@ -3427,6 +3434,221 @@ <h2>WebView<a class="headerlink" href="#webview" title="Permalink to this headli |
3427 | 3434 | </dd></dl> |
3428 | 3435 | </div> |
3429 | 3436 | </div> |
| 3437 | +<div class="section" id="usb-host-serial-facade"> |
| 3438 | +<h1>USB Host Serial Facade<a class="headerlink" href="#usb-host-serial-facade" title="Permalink to this headline">¶</a></h1> |
| 3439 | +<p><em>QPython 1.3.1+ and QPython3 1.0.3+ contains this feature</em></p> |
| 3440 | +<p>SL4A Facade for USB Serial devices by Android USB Host API.</p> |
| 3441 | +<p>It control the USB-Serial like devices |
| 3442 | +from Andoroid which has USB Host Controller .</p> |
| 3443 | +<p>The sample |
| 3444 | +<a class="reference external" href="http://www.youtube.com/watch?v=EJ7qiGXaI74">demonstration is also available at youtube video</a></p> |
| 3445 | +<div class="section" id="requirements"> |
| 3446 | +<h2>Requirements<a class="headerlink" href="#requirements" title="Permalink to this headline">¶</a></h2> |
| 3447 | +<ul> |
| 3448 | +<li><p class="first">Android device which has USB Host controller (and enabled in that firmware).</p> |
| 3449 | +</li> |
| 3450 | +<li><p class="first">Android 4.0 (API14) or later.</p> |
| 3451 | +</li> |
| 3452 | +<li><p class="first">USB Serial devices (see [Status](#Status)).</p> |
| 3453 | +</li> |
| 3454 | +<li><p class="first">USB Serial devices were not handled by Android kernel.</p> |
| 3455 | +<p>> I heard some android phone handle USB Serial devices |
| 3456 | +> make /dev/ttyUSB0 in kernel level. |
| 3457 | +> In this case, Android does not be able to handle the device |
| 3458 | +> from OS level.</p> |
| 3459 | +<p>please check Android Applications be able to grab the target USB Devices, |
| 3460 | +such as <a class="reference external" href="https://play.google.com/store/apps/details?id=aws.apps.usbDeviceEnumerator">USB Device Info</a>.</p> |
| 3461 | +</li> |
| 3462 | +</ul> |
| 3463 | +</div> |
| 3464 | +<div class="section" id="status"> |
| 3465 | +<h2>Status<a class="headerlink" href="#status" title="Permalink to this headline">¶</a></h2> |
| 3466 | +<ul> |
| 3467 | +<li><p class="first">probably work with USB CDC, like FTDI, Arduino or else.</p> |
| 3468 | +</li> |
| 3469 | +<li><p class="first">2012/09/10: work with 78K0F0730 device (new RL78) with Tragi BIOS board.</p> |
| 3470 | +<p><a class="reference external" href="http://www.marutsu.co.jp/shohin_55296/">M78K0F0730</a></p> |
| 3471 | +</li> |
| 3472 | +<li><p class="first">2012/09/24: work with some pl2303 devcies.</p> |
| 3473 | +</li> |
| 3474 | +</ul> |
| 3475 | +</div> |
| 3476 | +<div class="section" id="author"> |
| 3477 | +<h2>Author<a class="headerlink" href="#author" title="Permalink to this headline">¶</a></h2> |
| 3478 | +<p>This facade developped by <a class="reference external" href="https://bitbucket.org/kuri65536/usbhostserialfacade">Kuri65536</a> |
| 3479 | +you can see the commit log in it.</p> |
| 3480 | +</div> |
| 3481 | +<div class="section" id="apis"> |
| 3482 | +<h2>APIs<a class="headerlink" href="#apis" title="Permalink to this headline">¶</a></h2> |
| 3483 | +<dl class="function"> |
| 3484 | +<dt id="usbserialGetDeviceList"> |
| 3485 | +<code class="descname">usbserialGetDeviceList</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#usbserialGetDeviceList" title="Permalink to this definition">¶</a></dt> |
| 3486 | +<dd><p>Returns USB devices reported by USB Host API.</p> |
| 3487 | +<table class="docutils field-list" frame="void" rules="none"> |
| 3488 | +<col class="field-name" /> |
| 3489 | +<col class="field-body" /> |
| 3490 | +<tbody valign="top"> |
| 3491 | +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Returns “Map of id and string information Map<String, String></td> |
| 3492 | +</tr> |
| 3493 | +</tbody> |
| 3494 | +</table> |
| 3495 | +</dd></dl> |
| 3496 | +<dl class="function"> |
| 3497 | +<dt id="usbserialDisconnect"> |
| 3498 | +<code class="descname">usbserialDisconnect</code><span class="sig-paren">(</span><em>connID</em><span class="sig-paren">)</span><a class="headerlink" href="#usbserialDisconnect" title="Permalink to this definition">¶</a></dt> |
| 3499 | +<dd><p>Disconnect all USB-device</p> |
| 3500 | +<table class="docutils field-list" frame="void" rules="none"> |
| 3501 | +<col class="field-name" /> |
| 3502 | +<col class="field-body" /> |
| 3503 | +<tbody valign="top"> |
| 3504 | +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>connID</strong> (<em>str</em>) – connection ID</td> |
| 3505 | +</tr> |
| 3506 | +</tbody> |
| 3507 | +</table> |
| 3508 | +</dd></dl> |
| 3509 | +<dl class="function"> |
| 3510 | +<dt id="usbserialActiveConnections"> |
| 3511 | +<code class="descname">usbserialActiveConnections</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#usbserialActiveConnections" title="Permalink to this definition">¶</a></dt> |
| 3512 | +<dd><p>Returns active USB-device connections.</p> |
| 3513 | +<table class="docutils field-list" frame="void" rules="none"> |
| 3514 | +<col class="field-name" /> |
| 3515 | +<col class="field-body" /> |
| 3516 | +<tbody valign="top"> |
| 3517 | +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Returns “Active USB-device connections by Map UUID vs device-name.”</td> |
| 3518 | +</tr> |
| 3519 | +</tbody> |
| 3520 | +</table> |
| 3521 | +</dd></dl> |
| 3522 | +<dl class="function"> |
| 3523 | +<dt id="usbserialWriteBinary"> |
| 3524 | +<code class="descname">usbserialWriteBinary</code><span class="sig-paren">(</span><em>base64</em>, <em>connID</em><span class="sig-paren">)</span><a class="headerlink" href="#usbserialWriteBinary" title="Permalink to this definition">¶</a></dt> |
| 3525 | +<dd><p>Send bytes over the currently open USB Serial connection.</p> |
| 3526 | +<table class="docutils field-list" frame="void" rules="none"> |
| 3527 | +<col class="field-name" /> |
| 3528 | +<col class="field-body" /> |
| 3529 | +<tbody valign="top"> |
| 3530 | +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> |
| 3531 | +<li><strong>base64</strong> (<em>str</em>) – </li> |
| 3532 | +<li><strong>connId</strong> (<em>str</em>) – </li> |
| 3533 | +</ul> |
| 3534 | +</td> |
| 3535 | +</tr> |
| 3536 | +</tbody> |
| 3537 | +</table> |
| 3538 | +</dd></dl> |
| 3539 | +<dl class="function"> |
| 3540 | +<dt id="usbserialReadBinary"> |
| 3541 | +<code class="descname">usbserialReadBinary</code><span class="sig-paren">(</span><em>bufferSize</em>, <em>connID</em><span class="sig-paren">)</span><a class="headerlink" href="#usbserialReadBinary" title="Permalink to this definition">¶</a></dt> |
| 3542 | +<dd><p>Read up to bufferSize bytes and return a chunked, base64 encoded string</p> |
| 3543 | +<table class="docutils field-list" frame="void" rules="none"> |
| 3544 | +<col class="field-name" /> |
| 3545 | +<col class="field-body" /> |
| 3546 | +<tbody valign="top"> |
| 3547 | +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> |
| 3548 | +<li><strong>bufferSize</strong> (<em>int</em>) – </li> |
| 3549 | +<li><strong>connId</strong> (<em>str</em>) – </li> |
| 3550 | +</ul> |
| 3551 | +</td> |
| 3552 | +</tr> |
| 3553 | +</tbody> |
| 3554 | +</table> |
| 3555 | +</dd></dl> |
| 3556 | +<dl class="function"> |
| 3557 | +<dt id="usbserialConnect"> |
| 3558 | +<code class="descname">usbserialConnect</code><span class="sig-paren">(</span><em>hash</em>, <em>options</em><span class="sig-paren">)</span><a class="headerlink" href="#usbserialConnect" title="Permalink to this definition">¶</a></dt> |
| 3559 | +<dd><p>Connect to a device with USB-Host. request the connection and exit</p> |
| 3560 | +<table class="docutils field-list" frame="void" rules="none"> |
| 3561 | +<col class="field-name" /> |
| 3562 | +<col class="field-body" /> |
| 3563 | +<tbody valign="top"> |
| 3564 | +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
| 3565 | +<li><strong>hash</strong> (<em>str</em>) – </li> |
| 3566 | +<li><strong>options</strong> (<em>str</em>) – </li> |
| 3567 | +</ul> |
| 3568 | +</td> |
| 3569 | +</tr> |
| 3570 | +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Returns messages the request status</p> |
| 3571 | +</td> |
| 3572 | +</tr> |
| 3573 | +</tbody> |
| 3574 | +</table> |
| 3575 | +</dd></dl> |
| 3576 | +<dl class="function"> |
| 3577 | +<dt id="usbserialHostEnable"> |
| 3578 | +<code class="descname">usbserialHostEnable</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#usbserialHostEnable" title="Permalink to this definition">¶</a></dt> |
| 3579 | +<dd><p>Requests that the host be enable for USB Serial connections.</p> |
| 3580 | +<table class="docutils field-list" frame="void" rules="none"> |
| 3581 | +<col class="field-name" /> |
| 3582 | +<col class="field-body" /> |
| 3583 | +<tbody valign="top"> |
| 3584 | +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">True if the USB Device is accesible</td> |
| 3585 | +</tr> |
| 3586 | +</tbody> |
| 3587 | +</table> |
| 3588 | +</dd></dl> |
| 3589 | +<dl class="function"> |
| 3590 | +<dt id="usbserialWrite"> |
| 3591 | +<code class="descname">usbserialWrite</code><span class="sig-paren">(</span><em>String ascii</em>, <em>String connID</em><span class="sig-paren">)</span><a class="headerlink" href="#usbserialWrite" title="Permalink to this definition">¶</a></dt> |
| 3592 | +<dd><p>Sends ASCII characters over the currently open USB Serial connection</p> |
| 3593 | +<table class="docutils field-list" frame="void" rules="none"> |
| 3594 | +<col class="field-name" /> |
| 3595 | +<col class="field-body" /> |
| 3596 | +<tbody valign="top"> |
| 3597 | +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> |
| 3598 | +<li><strong>ascii</strong> (<em>str</em>) – </li> |
| 3599 | +<li><strong>connID</strong> (<em>str</em>) – </li> |
| 3600 | +</ul> |
| 3601 | +</td> |
| 3602 | +</tr> |
| 3603 | +</tbody> |
| 3604 | +</table> |
| 3605 | +</dd></dl> |
| 3606 | +<dl class="function"> |
| 3607 | +<dt id="usbserialReadReady"> |
| 3608 | +<code class="descname">usbserialReadReady</code><span class="sig-paren">(</span><em>connID</em><span class="sig-paren">)</span><a class="headerlink" href="#usbserialReadReady" title="Permalink to this definition">¶</a></dt> |
| 3609 | +<dd><table class="docutils field-list" frame="void" rules="none"> |
| 3610 | +<col class="field-name" /> |
| 3611 | +<col class="field-body" /> |
| 3612 | +<tbody valign="top"> |
| 3613 | +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>connID</strong> (<em>str</em>) – </td> |
| 3614 | +</tr> |
| 3615 | +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">True if the next read is guaranteed not to block</td> |
| 3616 | +</tr> |
| 3617 | +</tbody> |
| 3618 | +</table> |
| 3619 | +</dd></dl> |
| 3620 | +<dl class="function"> |
| 3621 | +<dt id="usbserialRead"> |
| 3622 | +<code class="descname">usbserialRead</code><span class="sig-paren">(</span><em>connID</em>, <em>bufferSize</em><span class="sig-paren">)</span><a class="headerlink" href="#usbserialRead" title="Permalink to this definition">¶</a></dt> |
| 3623 | +<dd><p>Read up to bufferSize ASCII characters.</p> |
| 3624 | +<table class="docutils field-list" frame="void" rules="none"> |
| 3625 | +<col class="field-name" /> |
| 3626 | +<col class="field-body" /> |
| 3627 | +<tbody valign="top"> |
| 3628 | +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> |
| 3629 | +<li><strong>connID</strong> (<em>str</em>) – </li> |
| 3630 | +<li><strong>bufferSize</strong> (<em>int</em>) – </li> |
| 3631 | +</ul> |
| 3632 | +</td> |
| 3633 | +</tr> |
| 3634 | +</tbody> |
| 3635 | +</table> |
| 3636 | +</dd></dl> |
| 3637 | +<dl class="function"> |
| 3638 | +<dt id="usbserialGetDeviceName"> |
| 3639 | +<code class="descname">usbserialGetDeviceName</code><span class="sig-paren">(</span><em>connID</em><span class="sig-paren">)</span><a class="headerlink" href="#usbserialGetDeviceName" title="Permalink to this definition">¶</a></dt> |
| 3640 | +<dd><p>Queries a remote device for it’s name or null if it can’t be resolved</p> |
| 3641 | +<table class="docutils field-list" frame="void" rules="none"> |
| 3642 | +<col class="field-name" /> |
| 3643 | +<col class="field-body" /> |
| 3644 | +<tbody valign="top"> |
| 3645 | +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>connID</strong> (<em>str</em>) – </td> |
| 3646 | +</tr> |
| 3647 | +</tbody> |
| 3648 | +</table> |
| 3649 | +</dd></dl> |
| 3650 | +</div> |
| 3651 | +</div> |
3430 | 3652 | </div> |
3431 | 3653 | <div class="articleComments"> |
3432 | 3654 | </div> |
|
0 commit comments