Power & Source of Big Ideas

problem with garbage collection [SOLVED]

Moderators: chensy, FATechsupport

when work with serial port, after "GC_CONCURRENT" in logcat,
file descriptor "FileImputStream" is "-1 and error "java.io.IOException: read failed: EBADF (Bad file number)"
why? how to solve it?
hey guys, solved...
this method get you a file descriptor >> "int fd = HardwareControler.openSerialPort(......);"
after that create ParcelFileDescriptor >> "pfd = ParcelFileDescriptor.fromFd(fd);"
and then create FileInputStream >> "FileInputStream mFileInputStream = new FileInputStream(pfd.getFileDescriptor());"

Note: if "ParcelFileDescriptor" is in method scope after garbage collection, file descriptor of FileInputStream change to "-1"
then "ParcelFileDescriptor" must in class scope.

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 825 on Wed Aug 28, 2019 3:18 pm

Users browsing this forum: No registered users and 1 guest