Coder Social home page Coder Social logo

usbserial4a's Introduction

usbserial4a

PayPal Donate PyPI version Downloads

Python package for Kivy Android USB serial port.

Please try the Android App built with usbserial4a on Google Play: PyTool USB Serial F, PyTool Modbus Free.

Implemented drivers are listed below:

  • FTDI serial driver - done and tested with FT230X.
  • CDC ACM serial driver - done and tested with MCP2200, BBC micro:bit V1(nRF51).
  • CP210x serial driver - done and tested with CP2102.
  • CH34x serial driver - done and tested with CH340.
  • PL2303 serial driver - done and tested with PL2303.

How to use it:

To make quick prototype or to test and debug the script before building an App:

It works on Android 6.0+.

If there is any usb serial device, connect it to the Android phone/tablet through USB OTG cable (It's needed for Android USB host function).

Get Pydroid Apps from here, or get the latest versions on Google Play.

In Pydroid, go to Menu->Pip and install usbserial4a.

Or go to Menu->Terminal and enter pip install usbserial4a.

Save example.py in the storage of the Android device.

Open example.py and run it. When it runs for the first time, it might prompt you for permission to access the USB device. Accept the permission and run this script again, then it should send the data b'Hello world!' as expected.

Go to Menu->Graphical program output.

Scroll to the last line, it should list all the USB devices connected to the Android phone/tablet with vendor id, vendor name, product id and product name.

To build dedicated Apps with buildozer:

(These instructions are outdated and need update.)

It works on Android 4.0+.

In buildozer.spec add termios.so to the whitelist.

Include usb4a and usbserial4a in requirements.

Add intent-filter.xml.

# (list) python-for-android whitelist
android.p4a_whitelist = lib-dynload/termios.so

# (list) Application requirements
# comma seperated e.g. requirements = sqlite3,kivy
requirements = kivy, pyjnius, usb4a, usbserial4a

# (str) XML file to include as an intent filters in <activity> tag
android.manifest.intent_filters = intent-filter.xml 

Build the project for the first time and it will fail with an error as expected.

buildozer android debug

In the generated .buildozer folder find a res folder like this one:

.buildozer/android/platform/build/dists/YOU_PROJECT_NAME/src/main/res

Create a xml folder in res folder.

Add device_filter.xml to this res/xml/ folder.

Find a manifest template file like this one:

.buildozer/android/platform/build/dists/YOUR_PROJECT_NAME/templates/AndroidManifest.tmpl.xml

Add <uses-feature android:name="android.hardware.usb.host" /> to this AndroidManifest.tmpl.xml at a good position.

Build the project again and it should pass.

usbserial4a's People

Contributors

jacklinquan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.