Recent

Author Topic: LAMW arduino serial comm via android usb otg  (Read 2269 times)


jmpessoa

  • Hero Member
  • *****
  • Posts: 2329
Re: LAMW arduino serial comm via android usb otg
« Reply #1 on: December 17, 2023, 05:59:46 am »

Done!

New "jsArduinoAflakSerial" component!  (need tests!)

New demo: "AppCompatArduinoAflakSerialDemo1" (need tests!)

Thank you!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Mongkey

  • Sr. Member
  • ****
  • Posts: 446
Re: LAMW arduino serial comm via android usb otg
« Reply #2 on: December 17, 2023, 11:59:43 am »
@mr jmpessoa this spinner need to be commited,

https://forum.lazarus.freepascal.org/index.php/topic,65168.0.html

Thank you

jmpessoa

  • Hero Member
  • *****
  • Posts: 2329
Re: LAMW arduino serial comm via android usb otg
« Reply #3 on: December 17, 2023, 05:52:51 pm »

Done!
2 days ago!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Mongkey

  • Sr. Member
  • ****
  • Posts: 446
Re: LAMW arduino serial comm via android usb otg
« Reply #4 on: December 18, 2023, 04:03:01 am »
Ok

Mongkey

  • Sr. Member
  • ****
  • Posts: 446
Re: LAMW arduino serial comm via android usb otg
« Reply #5 on: May 11, 2025, 05:23:58 pm »
after 2 years  ::), failed to load aflak serial, thank you

jmpessoa

  • Hero Member
  • *****
  • Posts: 2329
Re: LAMW arduino serial comm via android usb otg
« Reply #6 on: May 21, 2025, 11:21:46 pm »
Hi, Mongkey!

Can you look for:
Code: Pascal  [Select][+][-]
  1. public java.lang.Object jsArduinoAflakSerial_jCreate(long _self) {
  2.   return (java.lang.Object)(new jsArduinoAflakSerial(this,_self));
  3. }
  4.  
in your project "Controls.java" file?  (at end of file....)
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Mongkey

  • Sr. Member
  • ****
  • Posts: 446
Re: LAMW arduino serial comm via android usb otg
« Reply #7 on: May 24, 2025, 09:25:41 am »
i could not find this object, mr. pessoa, i even not seeing jsArduinoAflakSerial.java at source directory.

i used https://github.com/ksksue/PhysicaloidLibrary/tree/master , openotg aia sample, this lib using ai2 inventor for arduino it succeed reading cdc type usb, ch340x type usb
« Last Edit: May 24, 2025, 09:41:51 am by Mongkey »

jmpessoa

  • Hero Member
  • *****
  • Posts: 2329
Re: LAMW arduino serial comm via android usb otg
« Reply #8 on: May 24, 2025, 07:38:54 pm »

Can you try/reload   "AppCompatArduinoAflakSerialDemo1"  ??
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Mongkey

  • Sr. Member
  • ****
  • Posts: 446
Re: LAMW arduino serial comm via android usb otg
« Reply #9 on: May 25, 2025, 04:33:58 am »
i got this error, thank you

Mongkey

  • Sr. Member
  • ****
  • Posts: 446
Re: LAMW arduino serial comm via android usb otg
« Reply #10 on: May 25, 2025, 09:01:19 am »
it was run, but nothing happened, i did wireless debugging for testing, i got this, ha ha this kind of a hard component development

Code: Pascal  [Select][+][-]
  1. type=1400 audit(0.0:270327): avc:  denied  { getopt } for  path="/dev/socket/usap_pool_secondary" scontext=u:r:untrusted_app_30:s0:c18,c257,c512,c768 tcontext=u:r:zygote:s0 tclass=unix_stream_socket permissive=0 app=org.lamw.applamwproject1

thank you
« Last Edit: May 25, 2025, 09:13:07 am by Mongkey »

Mongkey

  • Sr. Member
  • ****
  • Posts: 446
Re: LAMW arduino serial comm via android usb otg
« Reply #11 on: May 25, 2025, 11:15:07 am »
May be this jar library is more easy to use on pascal, thank you,

https://github.com/ksksue/PhysicaloidLibrary/blob/master/PhysicaloidLibrary/bin/physicaloidlibrary.jar

Code: Pascal  [Select][+][-]
  1. package com.physicaloid.tutorial1;
  2.  
  3. import java.io.UnsupportedEncodingException;
  4.  
  5. import android.app.Activity;
  6. import android.os.Bundle;
  7. import android.util.Log;
  8. import android.view.View;
  9. import android.widget.Button;
  10. import android.widget.EditText;
  11. import android.widget.TextView;
  12.  
  13. import com.physicaloid.lib.Physicaloid;
  14.  
  15. public class Tutorial1Activity extends Activity {
  16.     private static final String TAG = Tutorial1Activity.class.getSimpleName();
  17.     /*
  18.      * !!! You need to import PhysicaloidLibrary. !!!
  19.      * If you have errors, check Project -> Properties -> Android -> Library.
  20.      */
  21.  
  22.     /*
  23.      * In this tutorial, You can learn
  24.      *  - how to use open/close/read/write
  25.      *  
  26.      *  You might check TODO tags.
  27.      */
  28.  
  29.     //****************************************************************
  30.     // TODO : Add <uses-feature android:name="android.hardware.usb.host" /> to AndroidManifest.xml
  31.     //****************************************************************
  32.     Button btOpen, btClose, btRead, btWrite;
  33.     EditText etWrite;
  34.     TextView tvRead;
  35.  
  36.     Physicaloid mPhysicaloid;
  37.  
  38.     @Override
  39.     protected void onCreate(Bundle savedInstanceState) {
  40.         super.onCreate(savedInstanceState);
  41.         setContentView(R.layout.activity_tutorial1);
  42.  
  43.         btOpen  = (Button) findViewById(R.id.btOpen);
  44.         btClose = (Button) findViewById(R.id.btClose);
  45.         btRead  = (Button) findViewById(R.id.btRead);
  46.         btWrite = (Button) findViewById(R.id.btWrite);
  47.         etWrite = (EditText) findViewById(R.id.etWrite);
  48.         tvRead  = (TextView) findViewById(R.id.tvRead);
  49.  
  50.         setEnabledUi(false);
  51.  
  52.         //****************************************************************
  53.         // TODO : create a new instance
  54.         mPhysicaloid = new Physicaloid(this);
  55.         //****************************************************************
  56.     }
  57.  
  58.     public void onClickOpen(View v) {
  59.         //****************************************************************
  60.         // TODO : open a device
  61.         if(mPhysicaloid.open()) { // default 9600bps
  62.             setEnabledUi(true);
  63.         }
  64.         //****************************************************************
  65.     }
  66.  
  67.     public void onClickClose(View v) {
  68.         //****************************************************************
  69.         // TODO : close the device
  70.         if(mPhysicaloid.close()) {
  71.             setEnabledUi(false);
  72.         }
  73.         //****************************************************************
  74.     }
  75.  
  76.     public void onClickRead(View v) {
  77.         byte[] buf = new byte[256];
  78.         int readSize=0;
  79.  
  80.         //****************************************************************
  81.         // TODO : read from the device to a buffer and get read size
  82.         readSize = mPhysicaloid.read(buf);
  83.         //****************************************************************
  84.  
  85.         if(readSize>0) {
  86.             String str;
  87.             try {
  88.                 str = new String(buf, "UTF-8");
  89.                 tvRead.append(str);
  90.             } catch (UnsupportedEncodingException e) {
  91.                 Log.e(TAG,e.toString());
  92.             }
  93.         }
  94.     }
  95.  
  96.     public void onClickWrite(View v) {
  97.         String str = etWrite.getText().toString();
  98.         if(str.length()>0) {
  99.             byte[] buf = str.getBytes();
  100.             //****************************************************************
  101.             // TODO : write a buffer to the device
  102.             mPhysicaloid.write(buf, buf.length);
  103.             //****************************************************************
  104.         }
  105.     }
  106.  
  107.     private void setEnabledUi(boolean on) {
  108.         if(on) {
  109.             btOpen.setEnabled(false);
  110.             btClose.setEnabled(true);
  111.             btRead.setEnabled(true);
  112.             btWrite.setEnabled(true);
  113.             etWrite.setEnabled(true);
  114.             tvRead.setEnabled(true);
  115.         } else {
  116.             btOpen.setEnabled(true);
  117.             btClose.setEnabled(false);
  118.             btRead.setEnabled(false);
  119.             btWrite.setEnabled(false);
  120.             etWrite.setEnabled(false);
  121.             tvRead.setEnabled(false);
  122.         }
  123.     }
  124. }
  125.  
« Last Edit: May 25, 2025, 11:17:15 am by Mongkey »

 

TinyPortal © 2005-2018