APDE USB / OTG communication

Last update 2021-05-20T00:00:00Z
this post will be constantly updated, so someone will be interested, but do not want to scroll through the posts further, they will see and know everything, show what has already been done and where we are now stuck

Conditions and purpose: to write a working program on a smartphone using APDE of any version, without touching a personal computer. Connect any smartphone or tablet via OTG cable via serial port to any microcontroller via their RX TX pins. Please do not offer to communicate via bluetooth or otherwise, and do not offer to find a computer anywhere yet. The point is to solve the problem without touching the PC via the UART.

what has been achieved:

jump to the post in the thread where the last big success happened.

APDE USB / OTG communication - #11 by jafal

5 libraries for APDE found, 2 of them are installed. Solved the issue of downloading from github if you are on a phone or tablet. Complete instructions for manually installing libraries in APDE.

library

Installing Contributed Libraries · Calsign/APDE Wiki · GitHub
manual_mode_install_library_through_dfx_for_APDE
https://youtu.be/Ua8rquFrukQ
.
GitHub - inventit/processing-android-serial: Android Serial Library for Processing
.
Release 0.2.0 · inventit/processing-android-serial · GitHub
.
GitHub - mik3y/usb-serial-for-android: Android USB host serial driver library for CDC, FTDI, Arduino and other devices.
.
Arduino ADK support as a library for the latest version of Processing (Android mode) · Issue #7197 · arduino/Arduino · GitHub
.
GitHub - geetarista/processing-arduino: Arduino library for Processing
.
the green code is never displayed in the mobile version of the browser, it is imperative to switch the display to the version for the personal computer, and this is on all browsers for smartphones and tablets.

https://youtu.be/1goRSG9b0wc

.
current problem: Android phone system requires two extra lines in the generated output apk file in the manifest and having one xml file inside the apk. the problem is to put them there when generating the APDE of the output apk. Without them, there is no access to usb.

detals problem


.

{processing project root}\res\xml

Filename: device_filter.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
   <!-- 0x0403 / 0x6001: FTDI FT232R UART -->
   <usb-device vendor-id="1027" product-id="24577" />

   <!-- 0x2341 / Arduino -->
   <usb-device vendor-id="9025" />

   <!-- 0x16C0 / 0x0483: Teensyduino -->
   <usb-device vendor-id="5824" product-id="1155" />

   <!-- 0x10C4 / 0xEA60: CP210x UART Bridge -->
   <usb-device vender-id="4292" product-id="60000" />
  
</resources>

.


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
         package=""
         android:versionCode="1"
         android:versionName="1.0">
 <uses-sdk android:minSdkVersion="10" />
 <application android:label=""
              android:icon="@drawable/icon"
              android:debuggable="true">
   <activity android:name="">
     <intent-filter>
       <action android:name="android.intent.action.MAIN" />
       <category android:name="android.intent.category.LAUNCHER" />
       <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" />
   </activity>
 </application>
</manifest>

.

.http://journeytounknownsoundscapes.blogspot.com/2013/12/how-to-arduino-with-android-really-good.html
Arduino Android Serial Communication | by hingxyu | Medium
.
Impossible to grant access to USB port through AndroidManifest · Issue #84 · Calsign/APDE · GitHub
.

.

permision

.
if you make changes to the native manifest file in APDE 5.2, then whenever I run APDE5.2, it overwrites all my changes and restores the original file state.

it turned out to place all the files in an external folder

https://youtu.be/T85_DxDLT9U

hardware: two smartphones, one has a full system root. testing on standard arduono uno

List
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- - - - default prober - - - -->

    <!-- 0x0403 / 0x60??: FTDI -->
    <usb-device vendor-id="1027" product-id="24577" /> <!-- 0x6001: FT232R -->
    <usb-device vendor-id="1027" product-id="24592" /> <!-- 0x6010: FT2232H -->
    <usb-device vendor-id="1027" product-id="24593" /> <!-- 0x6011: FT4232H -->
    <usb-device vendor-id="1027" product-id="24596" /> <!-- 0x6014: FT232H -->
    <usb-device vendor-id="1027" product-id="24597" /> <!-- 0x6015: FT230X, FT231X, FT234XD -->

    <!-- 0x10C4 / 0xEA??: Silabs CP210x -->
    <usb-device vendor-id="4292" product-id="60000" /> <!-- 0xea60: CP2102 and other CP210x single port devices -->
    <usb-device vendor-id="4292" product-id="60016" /> <!-- 0xea70: CP2105 -->
    <usb-device vendor-id="4292" product-id="60017" /> <!-- 0xea71: CP2108 -->

    <!-- 0x067B / 0x2303: Prolific PL2303 -->
    <usb-device vendor-id="1659" product-id="8963" />

    <!-- 0x1a86 / 0x?523: Qinheng CH34x -->
    <usb-device vendor-id="6790" product-id="21795" /> <!-- 0x5523: CH341A -->
    <usb-device vendor-id="6790" product-id="29987" /> <!-- 0x7523: CH340 -->

    <!-- CDC driver -->
    <usb-device vendor-id="9025" />                   <!-- 0x2341 / ......: Arduino -->
    <usb-device vendor-id="5824" product-id="1155" /> <!-- 0x16C0 / 0x0483: Teensyduino  -->
    <usb-device vendor-id="1003" product-id="8260" /> <!-- 0x03EB / 0x2044: Atmel Lufa -->
    <usb-device vendor-id="7855" product-id="4"    /> <!-- 0x1eaf / 0x0004: Leaflabs Maple -->
    <usb-device vendor-id="3368" product-id="516"  /> <!-- 0x0d28 / 0x0204: ARM mbed -->

    <!-- - - - custom prober - - - -->

    <!-- CDC driver -->
    <usb-device vendor-id="5840" product-id="2174" /> <!-- 0x16d0 / 0x087e: Digispark -->
</resources>

.

Software: APDE any version, (latest 5.2)

APDE all

GitHub - Calsign/APDE: Source code for APDE: Create and run Processing sketches on an Android device.

.
.
I also noticed that when using the word android here, there is confusion, it has three meanings, this is confusing.

ANDROD system phone.
Processing for ANDROID (PC).
APDE processing for ANDROID.

when communicating, clarify which of these three options do you mean
.
this new branch is a continuation of a large other branch.

No serial library processing for smartphone. Help

No serial library Processing for smartphone. Help

.

here I will try to collect all the useful materials on this topic

Android processing app crashes when using usb / processing serial library (Serial.list(this)) probs - Processing 2.x and 3.x Forum

http://journeytounknownsoundscapes.blogspot.com/2013/12/how-to-arduino-with-android-really-good.html?m=1

jSerialComm

processing-android usb serial error · Issue #11 · inventit/processing-android-serial · GitHub

https://www.allaboutcircuits.com/projects/communicate-with-your-arduino-through-android/

Issue with app crashing when reading serial-related code. Help! · Issue #16 · inventit/processing-android-serial · GitHub

http://arduino.ru/forum/processing/processing-na-planshete

No serial library Processing for smartphone. Help - #37 by jafal

Using Serial with Processing for Android - #8 by noel

Anyone possible make project

From java to android - #8 by svan

.

to facilitate work.

for those who want to help.
you will be working on a phone or tablet, I recommend installing Hacker’s Keyboard or its analogues. It has ready-made templates that you can fill in frequently used code fragments, as well as remember everything that got into the clipboard - you need to hold down Enter. end of line, start of line, shift + <-, shift + ->, ctrl + c, ctrl + v, ctrl + x.

This is for a tablet, but the phone does not fit a lot of useful keys on the screen, then it is probably better to use the Gboard keyboard, it has a separate mode with arrows and still has memory for the clipboard.
It may require development of xml files or some other, for this it is best to use an external text editor for programming.
Acode.

This post is not yet complete, if possible I will supplement it with information.

you need android compiler APK to add needed files

1 Like

do you mean that?

.

.

I agree to everything, I even have a phone with full root rights.

Just wondering if this would be an acceptable solution?

Whilst apde does not accept libs(without great difficulty) but it does have tabs.

Now we can extract files in jar files, and open the original java files and some libs have a github repo with the java files.

So we can at least get the code into apde. Maybe not a complete solution especially when considering large libs, but should be able to get you the functionality.

If this is acceptable, let me know which files you need and ill creat a github for them. Ideally i will concat internal files into just one file, to simplify copy paste.

1 Like

APK Tools is an unofficial application and is classified most of the time as a hacker program

You need programs like this

1 Like

Any thoughts on last post?

1 Like
1 Like

your idea is great and can save time and acknowledgment also

3 Likes

you can click on raw top right to get only the text, copy paste wherever you want.

Whilst this seems straightforward the only downside is you then need to do the same for all the library depencies.

2 Likes

here is the usb serial android lib as one giant file. Ive tried to run it on my device and pc and I keep running into compiling errors, though eclipse is saying it should be good to go.

original repo

ive also included sketch files with all the required java files in tabs

I get the following error a lot and dont know how to resolve it.

expecting "class", found 'Map'

for line

        final Map<Integer, int[]> supportedDevices = new LinkedHashMap<>();

not sure how I can test or help further at this point so I’ll leave it here for now.

2 Likes

@ZENAR57 hi I think I made it, for now the sketch recognized the Arduino because when i concocted the Arduino via otg the android gives 2 options the terminal apk or my sketch to connect the Arduino

2 Likes

Does it run? Any info?

1 Like

@paulgoux see the photo the sketch i made just to recognized the connection with Arduino and it did that

2 Likes

@paulgoux

i am going to make Arduino sketch and other apde sketch later… the hard part is over now i think, the sketch communicate with Arduino with out crash

2 Likes

Are you using the linked files i posted or is this your own solution?

1 Like

@paulgoux i am using pc android mode when i make complete project via pc it is easier then to move to APDE

2 Likes

the hard part was the configuration that was my main point from the start of the issue

1 Like

Ok please describe the steps you took to achieve this. The whole point of the thread is to establish what works and doesnt work.

1 Like

yes sure i am going to i have read for more 100 hour over the net and tried many posted sketches the problem all was for old versions

3 Likes

Hi.
this is a big break, I have no choice for my program.