-
Notifications
You must be signed in to change notification settings - Fork 607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ArrayIndexOutOfBoundsException From PL2303SerialDevice #142
Comments
This issue seems to be related to this one. Then that looks like an OS level bug |
Another of those beautiful Android USB related bugs. I will look at it next weekend to be if some fix can be implemented. |
I just ran into this bug today as well, on Android 5.1. My project's at a standstill until I can figure this one out. I might take a crack at a workaround if you haven't had a chance yet, @felHR85 . |
Sure! @lordjabez It would be great. |
I did some reading today, and the fixes so far are all within the Android code itself, not the application side (see the link @eyedol posted). Rebuilding/upgrading the OS isn't an option for me, do you have any thoughts on what could be done app-side? This is the best idea someone in the above thread had:
|
I have been investigating this issue and it is basically not possible to solve this from android user-space. Sadly I think the only way is not using Android 5.1 if possible. |
I added a note #145 to the readme regarding this issue. Essentially recommending against the use of I was thinking we drop support for |
@lordjabez or @felHR85, might you know what this entails? |
@eyedol I only know enough about it to know I couldn't actually get it to work, and if somehow it did work it wouldn't be nearly robust enough to recommend to anyone else. |
@eyedol @lordjabez The only way I see would be using Android NDK, JNI and C/C++ code taking advantage that PL2303, CP2102 and all of those drivers have their drivers implemented in the linux kernel that powers Android. int init_serial()
{
fd_serial_port = open("/dev/ttyS1", O_RDWR); // Must be open in blocking mode
if(fd_serial_port == -1)
return -1;
/*
Configure Termios
*/
struct termios current_config;
tcgetattr(fd_serial_port, &old_config);
current_config = old_config;
current_config.c_iflag = 0;
current_config.c_oflag = 0;
current_config.c_cflag = CS8 | CREAD | CLOCAL;
current_config.c_lflag = 0;
current_config.c_cc[VMIN] = 1;
current_config.c_cc[VTIME] = 0;
// Baud rate config
cfsetispeed(¤t_config, B115200);
cfsetospeed(¤t_config, B115200);
// Set configuration
tcsetattr(fd_serial_port, TCSANOW, ¤t_config);
is_initialized = 1;
return fd_serial_port;
} This method returns a file descriptor if the connection has been opened properly. Writing and reading should be simple using write(2) and read(2). But I think this is overly complicated (more because of NDK and JNI than the C code itself) so I discourage anybody to try this approach. |
I know I'm bumping this (sorry), however my team is ordering a batch of tablets running 5.1 for our app. What exactly raises this exception? Does this bug render UsbSerial useless on 5.1? Our app is just a simple interface that sends basic serial commands so it isn't too complex. |
UsbSerial can be used, but it's a pain. Only the last USB device plugged in to the tablet will be functional. |
@ltd9938 @lordjabez I understand it should work normally if you only plug one device right? |
Probably, but if you restart the tablet and don't unplug and re-plug in the device it might not work until you do. The enumeration order of USB devices can be somewhat arbitrary. |
Thanks for the info guys. We're probably just going to avoid it all together. |
@ltd9938 I'm not sure how fixed of a constraint you've to use Android 5.1 but my team and I have successfully used it on Android 6.0.1 Marshmallow with two USB devices. If you're able to upgrade to a later version of Android you won't have this particular issue. |
Anyone know if the CP2102SerialDevice driver has the same issue? We are stuck with 5.1.1 and are getting the same exception on occasion. The device fails to be detected from a cold start, unplugging-replugging the device seems to be the only way to properly detect and use the device. |
@mtinnes As far as We know there is no way to solve this in 5.1.1 |
Hi, I want a clarification on something, since I don't have many devices to test with. The problem only occurred in 5.1.1 exclusively, or affected all devices running API level 22? I am confused since it looks like some of you guys, presumably, scoped the affected devices down to version 5.1.1, but some discussed the issue with broader version range, especially on the Google issue tracker thread mentioned by |
Also, can we |
I have used https://github.com/mik3y/usb-serial-for-android for connecting for PL2303 my problem is that connection is successful but if there is nothing to read and write for sometime 15-20 sec then I am unable to read or write further, The exception is raised sometimes but sometimes it is successful any help, please? |
@fah33mkhan If you are using https://github.com/mik3y/usb-serial-for-android
as an alternative USB-SERIAL library, you need to use another fork by
kai-morich who is the current maintainer of that library. In that case,
please try his real-world sample app
https://github.com/kai-morich/SimpleUsbTerminal and his forked library
https://github.com/kai-morich/usb-serial-for-android
Update: the sample app has the class CustomProber (https://github.com/kai-morich/SimpleUsbTerminal/blob/master/app/src/main/java/de/kai_morich/simple_usb_terminal/CustomProber.java) which only checks specific VID/PID to invoke CdcAcmSerialDriver. You may need to modify this code to match your device instead.
…On Wed, Apr 24, 2019 at 6:42 PM fah33mkhan ***@***.***> wrote:
I have used https://github.com/mik3y/usb-serial-for-android for
connecting for PL2303 my problem is that connection is successful but if
there is nothing to read and write for sometime 15-20 sec then I am unable
to read or write further, The exception is raised sometimes but sometimes
it is successful any help, please?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#142 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AALCU4CTHVYFYFFCCOO2S73PSA2QXANCNFSM4EKXTMQA>
.
|
Here's the relevant stacktrace:
The text was updated successfully, but these errors were encountered: