androidthings / sample-uartloopback Goto Github PK
View Code? Open in Web Editor NEWEcho received characters over a UART with Android Things
License: Apache License 2.0
Echo received characters over a UART with Android Things
License: Apache License 2.0
this issue is not for this project but related to UART
i working with Android things UART am getting exception like
noclassdeffounderror-lcom-google-android-things-pio-uartdevicecallback
i created thread on stack overflow
any one faced this type of error if yes then how to solve it
Dear all,
We are trying to communicate android device to dsPIC series MCU using PL2303 USB to Uart converter.
We check all hardware on windows and linux PC and it is working ok.
We just download this sample source code for JAVA language and open it in linux pc where android studio 4.0 with gradle version 6.1 are available.
We connect physical device (MOTO G5 with Android 8, Redmi Note 9 pro with Android 10) on PC USB and run app from android studio both both device individually.
But both time we got same error as mentioned below.
Installation did not succeed.
The application could not be installed: INSTALL_FAILED_MISSING_SHARED_LIBRARY
List of apks:
[0] '/home/user/AndroidStudioProjects/UARTLoopback/app/build/outputs/apk/debug/app-debug.apk'
Installation failed due to: 'null'
To resolve this issue we tried some google search where most common solution we found is as below link.
[https://github.com/androidthings/new-project-template/issues/1]
After adding android:required="false"
this line in AndroidManifest.xml file we are able to run app on device.
But whenever we open app on device app got forced stop and showing below error logcat.
consollog.txt
We would link to overcome with this problem ASAP.
Waiting for your quick reply.
Thanks and Best Regards,
Jehan Patel
E/Exception: UART cant opencom.google.android.things.pio.PioException: android.os.ServiceSpecificException: UART0 is already in use (code 16)
Hi,
I want to know if it's possible to know when the uart has transmitted the data out of the interface.
My experience is that uart write method buffers the data, but I need to know the exact moment that there are no more bytes to send so I can toggle a GPIO. One way is to make write method blocking, which I understand is not possible.
I was trying to see if the native API offer additional control over this so I can write my low level app in C++ but it seems there is no additional uart core support different than AT API.
Will appreciate your comments,
Hello,
I tired this project on my RPi3B. the read function seemed cannot read the data.
the following while function cannot be entered.
while ((read = mLoopbackDevice.read(buffer, buffer.length)) > 0) { mLoopbackDevice.write(buffer, read); }
I have tested the mLoopbackDevice.write() function singly, and that worked well.
But when I tested the mLoopbackDevice.read() function singly (without write() function). My serial port debug tools on computer still can received the data what I sent, it seemed like the data was returned by other level but not the app.
10/22 12:17:24: Launching 'app' on rockchip rk3399-mid.
Installation did not succeed.
The application could not be installed: INSTALL_FAILED_MISSING_SHARED_LIBRARY
Installation failed due to: 'null'
Hi,
I'm using this sample code with a PICO PI IMX6UL.
The problem is when I send a String like "abcdefghijklmno". I receive it on the other side divided, it means not as a single string, like "abc" then "de" then "fghijk" then "lmno".
And messages are received into random way, not the same number of parts, and not the same length of each part.
My UART config is as following:
BAUD_RATE = 115200;
DATA_BITS = 8;
STOP_BITS = 1;
CHUNK_SIZE = 256;
and PARITY_NONE
On the other side, I use UsbSerial library on an android phone (https://github.com/felHR85/UsbSerial)
No problem when reading data.
I need to read data in one piece. Any help please!
Thanks.
UART callbacks not triggering on Raspberry Pi, running Android Things DP 6.0. Do we need edit the config or cmdline files to change serial & bluetooth parameters, as we did in previous developer previews? I use a USB serial software called CoolTerm for Mac to check the connection. I also checked with a UART device ( Rs232 converted to UART) too. It is not working. The connections are correct. When the Rapsberry pi boots, I am able to read console log from the Usb serial software.
log:
............
[ 3.591832] usb 1-1: New USB device found, idVendor=0424, idProduct=9514
[ 3.591837] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 3.595054] hub 1-1:1.0: USB hub found
[ 3.595113] hub 1-1:1.0: 5 ports detected
[ 3.606690] mmc1: new high speed SDIO card at address 0001
[ 3.622230] Key type dns_resolver registered
[ 3.627361] Registering SWP/SWPB emulation handler
[ 3.632860] registered taskstats version 1
[ 3.640041] runtimepinconfig: UART0 stopping at 2 pins out of 3
[ 3.646069] runtimepinconfig: UART0 stopping at 2 pins out of 3
rpi3:/ $
But unable to get the UART callback when try to give input either from the serial software or from UART device.
Hello, I tried this sample and it does not work for me.
I tried it on RPI3 with Android Things developer preview 4.
I turned off the UART debugging mode of RP3 by changing "console=serial0,115200" to "console=tty0" in cmdline.txt, and adding "dtoverlay=pi3-disable-bt" and removing "enabled_uart=1" & "core_freq=400" in config.txt file.
When I run this sample, I typed some characters in terminal program but I cannot get any echo back.
From the logs, I guess there are some problems opening some files related to communication pipe.
Can you give me any ideas to solve this situation?
Thanks
Below is the logs from logcat.
06-14 00:34:15.117 7959-7959/? E/cutils-trace: Error opening trace file: No such file or directory (2)
[ 06-14 00:34:15.145 156: 156 I/ ]
free_cache(3075) avail 2575781888
06-14 00:34:15.268 7959-7959/? W/art: Unknown instruction set features for ARM CPU variant (generic) using conservative defaults
06-14 00:34:15.283 7959-7959/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
[ 06-14 00:34:15.295 156: 156 I/ ]
free_cache(28380) avail 2575777792
06-14 00:34:15.358 7959-7959/? E/memtrack: Couldn't load memtrack module (No such file or directory)
06-14 00:34:15.358 7959-7959/? E/android.os.Debug: failed to load memtrack module: -2
06-14 00:34:15.361 7959-7959/? I/Radio-JNI: register_android_hardware_Radio DONE
06-14 00:34:15.397 7959-7959/? D/AndroidRuntime: Calling main entry com.android.commands.wm.Wm
06-14 00:34:15.402 7959-7959/? D/AndroidRuntime: Shutting down VM
06-14 00:34:15.756 156-156/? I/SELinux: SELinux: Loaded file_contexts contexts from /file_contexts.bin.
06-14 00:34:15.758 410-435/system_process I/PackageManager.DexOptimizer: Running dexopt (dex2oat) on: /data/app/vmdl1792012311.tmp/base.apk pkg=com.example.androidthings.loopback isa=arm vmSafeMode=false debuggable=true target-filter=interpret-only oatDir = /data/app/vmdl1792012311.tmp/oat sharedLibraries=/system/framework/com.google.android.things.jar
06-14 00:34:15.891 8038-8038/? W/dex2oat: Unknown instruction set features for ARM CPU variant (generic) using conservative defaults
06-14 00:34:15.892 8038-8038/? I/dex2oat: /system/bin/dex2oat --compiler-filter=interpret-only --debuggable
06-14 00:34:15.892 8038-8038/? E/cutils-trace: Error opening trace file: No such file or directory (2)
06-14 00:34:16.066 8038-8038/? I/dex2oat: dex2oat took 175.564ms (threads: 4) arena alloc=9KB (9800B) java alloc=111KB (114104B) native alloc=1199KB (1228760B) free=1360KB (1392680B)
--------- beginning of system
06-14 00:34:16.281 410-435/system_process E/PackageManager: Backup Manager not found!
06-14 00:34:16.303 410-435/system_process I/art: Starting a blocking GC Explicit
06-14 00:34:16.429 410-435/system_process I/art: Explicit concurrent mark sweep GC freed 24161(1639KB) AllocSpace objects, 26(868KB) LOS objects, 33% free, 6MB/9MB, paused 2.442ms total 125.404ms
[ 06-14 00:34:16.430 156: 156 E/ ]
Couldn't opendir /data/app/vmdl1792012311.tmp: No such file or directory
06-14 00:34:16.434 410-988/system_process I/System.out: Success
06-14 00:34:16.489 410-449/system_process I/InputReader: Reconfiguring input devices. changes=0x00000010
06-14 00:34:16.557 410-423/system_process W/Searchables: No global search activity found
06-14 00:34:16.593 809-8050/com.google.android.gms I/PeopleContactsSync: triggerPendingContactsCleanup: no accounts
06-14 00:34:16.600 809-8050/com.google.android.gms D/Wear_Controller: Received broadcast action=android.intent.action.PACKAGE_ADDED and uri=com.example.androidthings.loopback
06-14 00:34:16.696 809-911/com.google.android.gms I/Icing: Usage reports 0 indexed 0 rejected 0 imm upload false
06-14 00:34:16.706 809-911/com.google.android.gms I/Icing: Usage reports 0 indexed 0 rejected 0 imm upload false
06-14 00:34:16.712 809-8051/com.google.android.gms W/IcingInternalCorpora: getNumBytesRead when not calculated.
06-14 00:34:17.715 809-7908/com.google.android.gms I/Icing: Indexing 552A18E96A12CBAD55F637AC8023C0E0F78C68F3 from com.google.android.gms
06-14 00:34:17.794 809-7908/com.google.android.gms D/Icing: Loaded CLD2 Version V2.0 - 20141016
06-14 00:34:17.804 809-7908/com.google.android.gms I/Icing: Indexing done 552A18E96A12CBAD55F637AC8023C0E0F78C68F3
06-14 00:34:18.209 8054-8054/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 2000 <<<<<<
06-14 00:34:18.219 8054-8054/? D/AndroidRuntime: CheckJNI is OFF
06-14 00:34:18.220 8054-8054/? E/cutils-trace: Error opening trace file: No such file or directory (2)
06-14 00:34:18.356 8054-8054/? W/art: Unknown instruction set features for ARM CPU variant (generic) using conservative defaults
06-14 00:34:18.371 8054-8054/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
06-14 00:34:18.447 8054-8054/? E/memtrack: Couldn't load memtrack module (No such file or directory)
06-14 00:34:18.447 8054-8054/? E/android.os.Debug: failed to load memtrack module: -2
06-14 00:34:18.450 8054-8054/? I/Radio-JNI: register_android_hardware_Radio DONE
06-14 00:34:18.485 8054-8054/? D/AndroidRuntime: Calling main entry com.android.commands.am.Am
06-14 00:34:18.523 410-649/system_process I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.androidthings.loopback/.LoopbackActivity} from uid 2000 on display 0
06-14 00:34:18.548 8054-8054/? D/AndroidRuntime: Shutting down VM
06-14 00:34:18.565 410-422/system_process I/ActivityManager: Start proc 8064:com.example.androidthings.loopback/u0a29 for activity com.example.androidthings.loopback/.LoopbackActivity
06-14 00:34:18.576 8064-8064/? I/art: Late-enabling -Xcheck:jni
06-14 00:34:18.578 8064-8064/? W/art: Unknown instruction set features for ARM CPU variant (generic) using conservative defaults
06-14 00:34:18.761 8064-8064/com.example.androidthings.loopback W/System: ClassLoader referenced unknown path: /data/app/com.example.androidthings.loopback-1/lib/arm
06-14 00:34:18.893 8064-8064/com.example.androidthings.loopback D/LoopbackActivity: Loopback Created
06-14 00:34:18.887 163-163/? I/peripheralman: type=1400 audit(0.0:36): avc: denied { dac_override } for capability=1 scontext=u:r:peripheralman:s0 tcontext=u:r:peripheralman:s0 tclass=capability permissive=1
06-14 00:34:18.887 163-163/? I/peripheralman: type=1400 audit(0.0:37): avc: denied { read write } for name="ttyAMA0" dev="tmpfs" ino=9297 scontext=u:r:peripheralman:s0 tcontext=u:object_r:device:s0 tclass=chr_file permissive=1
06-14 00:34:18.887 163-163/? I/peripheralman: type=1400 audit(0.0:38): avc: denied { open } for path="/dev/ttyAMA0" dev="tmpfs" ino=9297 scontext=u:r:peripheralman:s0 tcontext=u:object_r:device:s0 tclass=chr_file permissive=1
06-14 00:34:18.887 163-163/? I/peripheralman: type=1400 audit(0.0:39): avc: denied { ioctl } for path="/dev/ttyAMA0" dev="tmpfs" ino=9297 ioctlcmd=5401 scontext=u:r:peripheralman:s0 tcontext=u:object_r:device:s0 tclass=chr_file permissive=1
06-14 00:34:19.097 410-649/system_process W/art: Long monitor contention with owner android.display (431) at void com.android.server.wm.WindowAnimator$1.doFrame(long)(WindowAnimator.java:138) waiters=0 in float com.android.server.wm.WindowManagerService.getCurrentAnimatorScale() for 149ms
06-14 00:34:19.879 410-440/system_process W/art: Long monitor contention with owner android.display (431) at void com.android.server.wm.WindowAnimator$1.doFrame(long)(WindowAnimator.java:138) waiters=0 in int com.android.server.wm.WindowManagerService.addWindow(com.android.server.wm.Session, android.view.IWindow, int, android.view.WindowManager$LayoutParams, int, int, android.graphics.Rect, android.graphics.Rect, android.graphics.Rect, android.view.InputChannel) for 342ms
06-14 00:34:20.287 410-440/system_process W/art: Long monitor contention with owner android.display (431) at void com.android.server.wm.WindowAnimator$1.doFrame(long)(WindowAnimator.java:138) waiters=0 in int com.android.server.wm.WindowManagerService.addWindow(com.android.server.wm.Session, android.view.IWindow, int, android.view.WindowManager$LayoutParams, int, int, android.graphics.Rect, android.graphics.Rect, android.graphics.Rect, android.view.InputChannel) for 407ms
06-14 00:34:20.329 8064-8064/com.example.androidthings.loopback I/Choreographer: Skipped 46 frames! The application may be doing too much work on its main thread.
06-14 00:34:20.474 410-431/system_process I/ActivityManager: Displayed com.example.androidthings.loopback/.LoopbackActivity: +1s927ms
06-14 00:34:20.536 410-661/system_process I/WindowManager: Destroying surface Surface(name=com.android.iotlauncher/com.android.iotlauncher.IoTLauncher) called by com.android.server.wm.WindowStateAnimator.destroySurface:2014 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:881 com.android.server.wm.WindowState.destroyOrSaveSurface:2073 com.android.server.wm.AppWindowToken.destroySurfaces:363 com.android.server.wm.AppWindowToken.notifyAppStopped:389 com.android.server.wm.WindowManagerService.notifyAppStopped:4456 com.android.server.am.ActivityStack.activityStoppedLocked:1252 com.android.server.am.ActivityManagerService.activityStopped:6902
06-14 00:34:20.981 410-431/system_process I/WindowManager: Destroying surface Surface(name=Starting com.example.androidthings.loopback) called by com.android.server.wm.WindowStateAnimator.destroySurface:2014 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:881 com.android.server.wm.WindowState.destroyOrSaveSurface:2073 com.android.server.wm.AppWindowToken.destroySurfaces:363 com.android.server.wm.WindowStateAnimator.finishExit:565 com.android.server.wm.WindowStateAnimator.stepAnimationLocked:491 com.android.server.wm.WindowAnimator.updateWindowsLocked:303 com.android.server.wm.WindowAnimator.animateLocked:704
06-14 00:34:21.547 410-480/system_process E/TaskPersister: File error accessing recents directory (directory doesn't exist?).
06-14 00:35:09.632 163-270/? E/peripheralman: [0614/003509:ERROR:uart_driver_sysfs.cc(388)] Can't write to the communication pipe. Something is not right with client
Hi,
The sample was tried using an Intel Edison but it seems not to work at all.
The data you are seeing is not sent by me.
The code for transferUartData() is mentioned below
private void transferUartData() {
if (mLoopbackDevice != null) {
// Loop until there is no more data in the RX buffer.
try {
//Log.e(TAG, "Reading1");
byte[] buffer = new byte[CHUNK_SIZE];
mLoopbackDevice.write(buffer, 45);
int read;
while ((read = mLoopbackDevice.read(buffer, buffer.length))!=0) {
mLoopbackDevice.write(buffer, read);
Log.e(TAG, String.valueOf(read));
}
} catch (IOException e) {
Log.w(TAG, "Unable to transfer data over UART", e);
}
}
}
And I am not sending anything through the cable.
If possible, guide me to implement the same thing on an Intel Edison on an Arduino breakout board. Do I need to do any extra steps for the UART or anything will be helpful.
Hi,
How to know that I lost connection on the UART port? any event/listener to detect if there is no more receiver for the data sent on uart?
THX.
Hi ,
The app is getting chrashed when i use PeripheralManager.getInstance();
below is error given.
Caused by: java.lang.RuntimeException: Stub!
at com.google.android.things.pio.PeripheralManager.getInstance(PeripheralManager.java:21)
at com.asiczen.usb1.UartActivity.onCreate(UartActivity.java:43)
at android.app.Activity.performCreate(Activity.java:6858)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.