Closed GoogleCodeExporter closed 8 years ago
To use NRJavaSerial on android you need to make sure your app has permission to
access the specified serial port. This requires chmod 777 <port name> to work.
In the android kernel the default mapping is root only, and will not be
available to an app unless you jailbreak the phone.
Also, you need to give the entire file path to a serial port, IE /dev/ttySAC0
not just ttySAC0. This is a common mistake from windows developers moving to
Linux based OS's. In linux all hardware is a file mapped absolutely in the
filesystem.
If this is a USB device, you can look at using the raw USB API provided in
android 3.2 and up. This is a much more complicated process, but you get
greater control and do not need any JNI to talk to hardware. Here is an example
i use with a USB serial device:
https://code.google.com/p/nr-sdk/source/browse/trunk#trunk%2FAndroid%2FAndroidNR
DK_3.2_USB
Original comment by Mad.Hephaestus@gmail.com
on 24 Apr 2013 at 2:04
Thanks!
I use the rooted devices and I add logging in these two methods:
public CommPort getCommPort(String portName, int portType) {
...
Log.e(TAG, ">>>>>> !!! <<<<<<");
return new RXTXPort(deviceDirectory + portName);
...
}
public RXTXPort(String name) throws PortInUseException {
Log.e(TAG, ">>>>>> :D <<<<<<");
}
run and let's see what happened:
ERROR/TAG(1436): >>>>>> !!! <<<<<<
ASSERT//system/bin/app_process(1436): stack corruption detected: aborted
Original comment by gugu.abr...@gmail.com
on 25 Apr 2013 at 4:42
What is the final string that gets passed in to the serial port parameters?
can you call ls -al <port> and show me what the file permissions are for the
port you are trying to access? Also keep in mind device access permissions are
set each time the device boots and/or when the device is plugged in. You will
need to change the udev rules to make any permissions perminant, see:
http://developer.android.com/tools/device.html
Also, can you use the demo from here
http://developer.android.com/tools/device.html for testing so i have an exact
basis for comparson?
Original comment by Mad.Hephaestus@gmail.com
on 25 Apr 2013 at 4:49
The final string is "/dev/ttySAC0"
ls -al ttySAC*
crwxrwxrwx root root 204, 64 2013-04-25 08:19 ttySAC0
crwxrwxrwx root root 204, 65 2013-04-25 08:00 ttySAC1
crwxrwxrwx root root 204, 66 2013-04-25 08:00 ttySAC2
crwxrwxrwx root root 204, 67 2013-04-25 08:00 ttySAC3
Sorry I can't find the demo link from
http://developer.android.com/tools/device.html. But I can run this app from
http://code.google.com/p/android-serialport-api for read/write my ttySAC serial
port.
Original comment by gugu.abr...@gmail.com
on 25 Apr 2013 at 5:36
Original issue reported on code.google.com by
gugu.abr...@gmail.com
on 24 Apr 2013 at 12:42