i’m trying to read and write on a char device in ubuntu but when i create the outputstream i get this exception:
java.io.FileNotFoundException: /dev/usb/legousbtower0 (Device or resource busy)
This is my code:
myInputStream = new FileInputStream("/dev/usb/legousbtower0");
myOutputStream = new FileOutputStream("/dev/usb/legousbtower0");
The inputstream works and i can write to the device using the terminal
echo test > /dev/usb/legousbtower0
I try to detect what is using the device using fuser but nothing results.
When you open the device as an
InputStream, it is marked as open by the operating system. Since only one program should access the device at a time, the secondopenwill fail. You need to open the device in read-write mode, probably using theRandomAccessFile.