Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => A13 => Topic started by: mohammadfa91 on April 09, 2014, 11:32:28 AM

Title: Android UART
Post by: mohammadfa91 on April 09, 2014, 11:32:28 AM
Is There Anyone Can Use UART In Android Directly?
(Not Using FT232 , PT2303 , ...)
Title: Re: Anroid UART
Post by: dave-at-axon on April 09, 2014, 01:03:22 PM
Yes, use this.

https://code.google.com/p/android-serialport-api/

Title: Re: Anroid UART
Post by: mohammadfa91 on April 09, 2014, 08:22:46 PM
Quote from: dave-at-axon on April 09, 2014, 01:03:22 PM
Yes, use this.

https://code.google.com/p/android-serialport-api/
Thanks, Great code but is there any codes that not use NDK?
I was thinking we can add a lib to kernel and a lib to SDK and control UART in a simple command in Eclipse.
Is that necessary to disable serial debug to use UART-1?
Title: Re: Anroid UART
Post by: dave-at-axon on April 10, 2014, 04:26:26 AM
There is no native support for serial ports under Android. Even if you have a kernel driver and by the way, the existing UART driver is in the kernel, you will still need a JNI and the NDK to access it.

It is very easy to setup the NDK under Eclipse. I even have it under Android Studio with a couple script files to create the final builds and move the files so that AS sees them.

Your lib idea still need to would be a JNI too, as is the SerialPort API I linked to. Use it as it works great. I have an Android system talking to a fingerprint reader on a UART and it is rock solid.
Title: Re: Anroid UART
Post by: mohammadfa91 on April 10, 2014, 12:54:43 PM
Thanks, Can you explain how to set NDK for Android Studio? And is that necessary disable serial debug to use UART 1?
Title: Re: Anroid UART
Post by: dave-at-axon on April 10, 2014, 01:37:38 PM
For NDK see here.

https://developer.android.com/tools/sdk/ndk/index.html

As for the UART, I don't know much about the A13, sorry.
Title: Re: Anroid UART
Post by: mohammadfa91 on April 10, 2014, 10:35:30 PM
Excuse me, is there codes for using PWM,ADC,GPIO ?
Title: Re: Anroid UART
Post by: dave-at-axon on April 11, 2014, 06:14:53 AM
Not seen anything for PWM yet but GPIO and I2C are fully working under Android.

I wrote an I2C driver for another Android platform but it is very easily ported to the A20/A13 etc

http://sourceforge.net/projects/mini6410-i2c/

GPIO is easy too. Same principle. Do a search for Android GPIO on Google as there is a load of stuff on this.

As for ADC, I use an external ADC over I2C (MCP3428) as it's easier than writing a driver for the internal ADC.
Title: Re: Anroid UART
Post by: mohammadfa91 on April 11, 2014, 07:00:59 AM
I don't know how to thank you for these. I will have more question inside the codes. ;D