Dantalion / nrjavaserial

Automatically exported from code.google.com/p/nrjavaserial
0 stars 0 forks source link

android app crashes due to “stack corruption detected: aborted” #33

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.call getCommPort("ttySAC0", 1)
2.before returning an new RXTXPort object
3.my app was crashing

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?
svn/trunk/NRAndroidSerial/libs/armeabi/libNRJavaSerial.so
FriendlyARM Tiny210v2(android 4.0.3)

Please provide any additional information below.

Original issue reported on code.google.com by gugu.abr...@gmail.com on 24 Apr 2013 at 12:42

GoogleCodeExporter commented 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

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
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