Serial OTG. Arduino CH340. FTDI. rkl099's Extension

7.- Testing version 2022-10-19.

p10A_OTG_Add.aia (190.4 KB)

https://github.com/rkl099/Appinventor_Debug

  • Arduino UNO (CH340). Cable OTG. Cable USB.

otg17b

  • Settings / Additional settings / OTG / Enable OTG.
    otg26

  • Android 9. MIT Companion and installed.

  • Arduino UNO (CH340)
String a;
String b;
int c;
int d;

void setup() { 
  Serial.begin(9600);
}

void loop() { 
  if(Serial.available()) {
    a = Serial.readStringUntil(',');
    b = Serial.readStringUntil('\n');
    c = a.toInt() + b.toInt();
    d = a.toInt() * b.toInt();
    Serial.print(c);
    Serial.print(",");
    Serial.println(d);
}
}
  • App sends two numbers separated by commas.
  • Arduino receives them via Serial.
  • Separate the two numbers.
  • Add them and multiply them.
  • Returns the addition and multiplication separated by commas.
  • App receives the data, converts it into a list and displays it.

otg_5

otg_6

1 Like

This version of aix is working fine for me , the others updated NO.

can you send me that old AIX ?

That example uses Date Built 2020-11-21

com.SerialOTG_201121.aix (185.4 KB)
For more security, contact the author of the extension @rkl099

1 Like

thank you !

What is not working?

actually , I want to replace the bluetooth conexion with OTG..
I'm searching how to replace the blocs.

Ok, you are using an old version with the suffix “serial” in the names. This has been removed since it’s redundant, and only makes the names longer. See the documentation for the extension.
With this extension, it should be possible to use serial, BT or TCP/IP in the same way, except for timing.

I checked the extension for the ability to send ANSI characters (А,Б,В,Г,Д,Е,Ж,З,И,Й,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Ъ,Ы,Ь,Э,Ю,Я,а,б,в,г,д,е,ж,з,и,й,к,л,м,н,о,п,р,с,т,у,ф,х,ц,ч,ш,щ,ъ,ы,ь,э,ю,я)
This extension couldn't help me.
Are there any other extensions that can send and receive ANSI characters?

Tell us what you want to receive by sending these characters and what you are getting now.

I need to manage a JDY-41 module.
JDY-41 transmits and receives ANSI table characters,
from "\0" to "я"
For example, the standard extension ai2 "BluetoothClient" ,
supports transmission of all ANSI characters (255 pcs.).
Standard component ai2. "Serial" (as well as "SerialOTG" views here),
only half of the ANSI character table (127 pieces) is transmitted.
I need the transmission to be characters (like "µ,¶, ,ё,№,є,",ј,S,ѕ,ї,А,Б,В....."),
the JDY-41 module then responds to the commands.

Here is a picture from my terminal

as you can see byte exchange
happens not .hex numbers, but characters from "\0" to "я"
Here I want to ask the experts
is it possible
expand the range of transmitted characters for "SerialOTG"?

Appinventor uses UTF8 encoding for strings/characters. It’s not compatible with ANSI.
ANSI encoding is normally associated with Microsoft and uses code pages to define characters with hex codes 0x80 – 0xff. Characters 0X00 – 0x7f are the same for ASCII, ANSI, UTF8 and can be used without problems in Appinventor to communicate with Arduino etc.
If you need access to characters 0x80 – 0xff you have to use bytes, that allows you to send/receive all 256 values. That was one reason for implementing SerialOTG.

Appinventor can work well with ANSI encoding as well.
Here is an example of how I set the encoding,
for the standard "BluetoothClient" component.


With such settings, the "BluetoothClient" component
successfully broadcast
hex code "0xff" as character "я".

OK, this is a property of the built in component for bluetooth communication.

SerialOTG already is a complex software that can handle many USB/serial adapters, communication as byte streams for bluetooth client/server, tcp/ip client/server, serial, as well as arduino programming. It’s to much work to expand it with ANSI characters with code page selection, signed/unsigned 1/2/4 byte numbers, byte order and more features that has been asked for.
So for now, you have to translate to/from bytes if you want to use SerialOTG.

Thanks for your work.
I already made an ANSI worksheet, for Java

  static final String[]  digitsHex1 = new String[]{"\u0000","\u0001","\u0002","\u0003","\u0004","\u0005","\u0006","\u0007","\b","\t","\n","\u000B","\f","\r","\u000E","\u000F","\u0010","\u0011"
          ,"\u0012","\u0013","\u0014","\u0015","\u0016","\u0017","\u0018","\u0019","\u001A","\u001B","\u001C","\u001D","\u001E","\u001F"," ","!","\"","#","$","%","&","'","(",")","*","+"
          ,",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W"
          ,"X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f", "g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~","\u007F"
          ,"Ђ","Ѓ","‚","ѓ","„","…","†","‡","€","‰","Љ","‹","Њ","Ќ","Ћ","Џ","ђ","‘","’","“","”","•","–","—","\u0098","™","љ","›","њ","ќ","ћ","џ"," ","Ў","ў","Ј","¤","Ґ","¦","§","Ё","©"
          ,"Є","«","¬","­","®","Ї","°","±","І","і","ґ","µ","¶","·","ё","№","є","»","ј","Ѕ","ѕ","ї","А","Б","В","Г","Д","Е","Ж","З","И","Й","К","Л","М","Н","О","П","Р","С","Т","У"
          ,"Ф","Х","Ц","Ч","Ш","Щ","Ъ","Ы","Ь","Э","Ю","Я","а","б","в","г","д","е","ж","з","и","й","к","л","м","н","о","п","р","с","т","у","ф","х","ц","ч","ш","щ","ъ","ы","ь","э","ю","я"};
 

perhaps this will help somehow.
(I'm sorry in advance if i read your post wrong, because i am writing and reading a message through Google Translate)

Hope that will solve your problem. Good luck.

Have you tested the bluetooth component by setting the Windows-1251 encoding? Does it work for sure?

Yes, when I set the Windows-1251 encoding in the BluetoothClient.
The mobile app transmitted directly all the characters from "Ђ" to "я". (0x80 - 0xff).
Checked in the "iron" (Checked in hardware).
The receiving side was the arduino HC06 module.

So this extension could help?
orientation
Is hexadecimal data required or is decimal also accepted?

No, I have no problem converting ANSI characters to other number systems.

The problem is that it is not possible to broadcast these ANSI
symbols.
For example, when I, from a mobile application, transmit the character "я",
The receiving side receives , some two values "d18f".
And there's no way I can change it
2023599

SerialOtg has a WriteBytes block? Then convert the text to bytes and send the bytes.