Hello, I am starting a development with dragonBoard 410C, in Android Studio, but I cannot find an example to use the serial port, can you help me? please
Could you give more details about what you are trying to do with the serial port? Android applications generally don’t address hardware directly. You would write a HAL driver for the particular type of device, and your application would use the appropriate subsystem for that device class.
For example, if you want to interface with a sound playback device, you would probably use; MediaPlayer overview | Android Developers – your application doesn’t need to know anything about the sound hardware you are using, however if necessary, you would write an Audio HAL | Android Open Source Project to connect Android with the hardware.
Thanks doitright, for answering, I am making a terminal, to connect with an arduino, from the dragonBoard410C, and to be able to turn on and off some LEDs and Relay, the connection is via serial port, and I am doing the application in Android Studio for me dragonBoard410C,
The first test I’m doing is an echo, connecting the RX and TX of the dragonBoard410C, from android studio, but I can’t find a library to use the serial port.
from the adb terminal I have performed some tests
I am using port ttyHS0 from adb, using
echo “Hello”> /dev/ttyHSL0 → sent
and to read in another adb terminal I use
“Hello” <— received
That’s a pretty broad concept and not easily implemented in a safe/sane manner. Serial really may not be the best choice for interfacing with something like that with Android. USB would be a much better choice. Lots of microcontrollers have native USB support, like Microchip ATSAMD. Then you could set your microcontroller to use USB-HID and your Android application to interface with it using UsbManager.
Also note that if your goal is to design a mezzanine board, 96boards CE (like db410c) has USB pins available on the high-speed connector for this purpose, so it doesn’t have to be exclusively over a wire.
I’d also suggest avoiding arduino, its pretty terrible. Look into using Zephyr RTOS on the microcontroller instead https://www.zephyrproject.org/ – its much more powerful and much more sane since it doesn’t drive you towards bad practices like the “setup” and “loop” (infinite loop for polling) functions. Rather it will push you more towards proper interrupt driven code that will result in much more readable/maintainable, and efficient firmware.
I haven’t tried this so I have no idea if it works or not, but here is an example of accessing the serial port java - How to read and write data to COM/Serial ports in Android? - Stack Overflow
If this doesn’t work there are dozens of examples on how to access a serial device on Android, google search is your friend.
+1 for Zephyr. All of my current projects are Zephyr based.
You may search and have a look to my forum case back in 2016. Title: “Mezzanine sensor board” I remember to have some problems linked to Android and the serial port. See at the end of the case some attribution of the ttyHSL0 and HSO.
I never succeded in making the serial port worked properly but maybe you will find a way
I have proposed to develop a library in c ++ with the android NDK, which I have attached, I have managed to open the port, but it still cannot write. maybe with this, you can suggest me an idea.
Reviewing the documentation at Peripherals Programming Guide Linux Android
makes reference to a library in c, on page 15. Even though I’m not using them yet, I decided to first make the code that is attached, as an initial test.
Running the App on android, I get the following messages that I attach
of the aforementioned I have previously made a modification in the init.qcom.post_boot in the image I show the lines that it adds.
and in the android studio app
I get these results
@r.gonzalez uaaah, excellent… This will certainly help for the use of the serial…
Unfortunatly, personaly I won’t have time to test this since I am working on other projects. Thanks anyway.
If anyone can help me, I would appreciate it, it is still not working at all, some help is received
Hi, I made some comments that may interest you
Anything I remember (it was in 2016) is that I could send the data from the Dragonboard serial port using java with Android Developer (not using NDK) and it was fine but I would never received my data back correctly. The string was always truncated or mixed with other data. Like the port input serial was already used by some other activities.
I was using the official Android 5 supplied by Linaro.
I have not yet been able to send a single data
I do not have it in github but here a compressed version of my trial at one time:
After several hours of work, I have managed to use the serial port of the dragomboard410c, with Android Studio, I have created a library in c ++, using the Android NDK. I am using the official version of Android 5 provided by Linaro, the serial port is the /dev/ttyHS4 and the pins UART0_RX and UART0_TX,
Here is my example project as a contribution, it is a Drive, then I upload it to a Git