Getting Runtime Error when trying to use Serial to communicate to Arduino

There is a small change in the latest version (debug 22-10-19), so it should work with all versions of Android incl. Android12. I don’t have access to an Android12 device, so I really want to hear that it’s working with Android12.

Dear Sir,
Wound you please do the same thing for potencimetro.aia? Or Tell us how can we fix it by ourself. Many thanks!

Im having the exact same error except im on android 13 on a google phone, does anyone know how to fix it?

Dear Sir:
Many thanks for your help. The updated version is working! However, I still have problems drawing the line. Would you please help me with this problem?
Really appreciated!



For a better test on the incoming Y value, use the IS A NUMBER block.

Dear Sir:

Many thanks for your help. I used IS A NUMBER block. The APP seems to receive two sending data at one time. The Timer interval(10ms) is half of the sending interval(20ms). Any suggestions



?
Really appreciated!!

Don't use an AND block for your tests.
Nest the < comparison inside the IS A NUMBER test to prevent it from running if not a number.

Actually, you could use the and block here since it is lazily evaluated left to right. The problem is that the checks need to be ordered such that the is a number? check comes first so if it fails the rest of the code won't run (which the above code doesn't do).

1 Like

Hi !
I still have this issue with an application using the serial OTG component with Arduino.
What is the result of your investigation into the Physicaloid library ?
I've been looking for a while for an update...Is there any available ?
Regards

Are you using the Serial component or the SerialOTG extension? I cannot speak for the extension, but there is an update for the Serial component in process to address the Android 12+ issues. You can try out the test server at http://nb190a-bugfixes.ai2-ewpatton-temp.appspot.com/.

Thanks for answering !
Yes i'm using the serialOTG extension.
FYI the code is working with the AI companion 2.64. But i have the run
time error with version 2.65

And it never works with the .apk build (on the test server also).
IHM_208.aia (231.6 KB)

An idea when the update addressing the Android 12+ issues will be released ?
Regards

Unfortunately I can't assist with the OTG extension since it's not published by MIT. @rkl099 may want to have a look though.

As discussed in Using serial with FTDI - #117 by rkuba
the SerialOTG version in GitHub - rkl099/Appinventor_Debug: Debug versions: SerialOTG, Modbus and test programs (Note: can be changed any time). has been updated so it should work with Android12 and has been tested by some users, as I don't have access to an Android12 device.
Your error code is probably from your block code and not from the extension.
It seems that you do a Read in your timer function without testing if you have received something. Read is a nowait function and returns an empty string or all character that have been received since last call. See Appinventor-SerialOTG/SerialOTG_1.4.pdf about Read and discussion about message handling.

1 Like

The extension works on Android12 on the normal server. Test server is not necessary.

I believe it is ai feature (it has always been that way) that when you request substring fully or partially outside the input string parameter instead of returning existing part (or empty) it raises uncatchable error. It is so different than any language I know that I consider it bug or at least impovement candidate. Rationale:

  1. It can be cheaply imemented in library once (dry)
  2. It requires lot of ugly and old-fashioned if-thens on every use instance in every app from every developer made further complicated by modest string function set (anti-dry)
  3. It is not logical as 2-element subset of empty set is a perfectly valid empty set and most (all?) other languages to it that way

Eg substring ("key",2,5) = "ey", substring("key",5,5)="", substring("",1,5)="".

@ewpatton pls include such improvement in nearest ai2 release.

Thank you, it is working now on my Samsung A51
(Android 12)

hello,
I have read this chat to solve the problem about the App inventor Serial component and the FLAG IMMUTABLE /MUTABLE. My app has to talk with arduino by serial too.
I built my app in december 2022 and the apk worked fine with android 11 but failed with android 12 and 13.
Reading this chat I can understand how to solve the problem can you help me?
Thanks in advance
Mirko

sorry I cannot understand how to solve.....

See the answer here

Taifun