Wednesday, February 12, 2014

Android jni serial read permissions problem


            
I Bianliaoge Android program, with jni read USB to serial data into the terminal every time input chmod 777 / dev/ttyUSB0 to read or can not open the serial port. Is there any way you can modify the port authority, not every time you enter the terminal, or code there any way to execute "chmod 777 / dev/ttyUSB0" this statement do?
Reply:
There are three methods:
1 In init.rc in mentioning the right chmod 777 / dev/ttyUSB0
2 mention in device.c permissions, the more subtle and difficult to find, you can refer to my detailed blog: http://blog.csdn.net/yiyaaixuexi/article/details/6803593
3 each layer in java to mention the right, cmd to mention the right to command
 
public void exeShell (String cmd) {

try {
Process p = Runtime.getRuntime () exec (cmd);.
BufferedReader in = new BufferedReader (
new InputStreamReader (
p.getInputStream ()));
String line = null;
while ((line = in.readLine ())! = null) {
Log.i ("exeShell", line);
}

}
catch (Throwable t)
{
t.printStackTrace ();
}
}



Reply:
cited a floor yiyaaixuexi reply:
There are three ways:
1 In init.rc in mentioning the right chmod 777 / dev/ttyUSB0
2 mention in device.c permissions, the more subtle and difficult to find, you can refer to my detailed blog: http://blog.csdn.net/yiyaaixuexi/article/details/6803593
3 each layer in java to mention the right, cmd to mention the right to command
Java code

public void exeSh ......

But first I tried to plug the USB to serial is generated when the immediate, not the device at boot time, add the command useless.
I did not find the second core in the system where ...
/ System # ls
bin
build.prop
media
app
framework
fonts
xbin
usr
busybox
etc
lib

The third I tried, I used your function added cmd = chmod 777 / dev/ttyUSB0 but still useless. exec can identify this order?

Get this for a few days to get depressed ah seek advice Great God
Reply:
Open backstage monitor, listens to the usb device is plugged into execution chmod 777
Reply:
We just did the whole
Reply:
chmod ("/ dev/ttyUSB0", 0666);
Reply:
In this case plug the device to be lost each command, so can be made, but I have to do is, from the terminal, modify the permissions in the code, or every time to open a terminal connected to the computer before you can use. I was in the development board to do.
Reply:
Anyway Monitor run in the background there, and do not lose your hand
Reply:
minicom on the computer, ah, how to open the board. . . . .
Reply:
Monitor runs on the board, when it detects the device / dev/ttyUSB0 is created in the Monitor in the implementation of chmod ("/ dev/ttyUSB0", 0666);

This is How minicom in a relationship?
Reply:
reference to the 9th floor lovelife_821106 reply:
Monitor runs on the board, when it detects the device / dev/ttyUSB0 is created in the Monitor in the implementation of chmod ("/ dev/ttyUSB0 ", 0666);

This is How minicom in a relationship?


The original demand LZ is this ...... I'm mistaken, this is what ~ 9L +1
Reply:
cited a floor yiyaaixuexi reply:
There are three ways:
1 In init.rc in mentioning the right chmod 777 / dev/ttyUSB0
2 mention in device.c permissions, the more subtle and difficult to find, you can refer to my detailed blog: http://blog.csdn.net/yiyaaixuexi/article/details/6803593
3 each layer in java to mention the right, cmd to mention the right to command
Java code

public void exeSh ......


1 If the system is running hot insertion usb to serial to die
(2) This is the only standard practice: the kernel detects the device into uevent issued to notify the user layer ---> User Layer uevent init process creates the device nodes receive and give permission
3.chmod itself requires root privileges, java layer of wood, even with this code added Strange

Reply:
reference to the 9th floor lovelife_821106 reply:
Monitor runs on the board, when it detects the device / dev/ttyUSB0 is created in the Monitor in the implementation of chmod ("/ dev/ttyUSB0 ", 0666);

This is How minicom in a relationship?


How to run monitor on the board, but not seeking advice. .

Reply:
Can refer to the system directory vold, netd other procedures, is a service that runs in the background just friends
Reply:
Change under the drive just fine. The easiest is to replace the 0666 like
0600
Write a monitor is not necessary to engage in such a complex

Reply:
Can add some content which can be achieved only in the code every time you open the program will be able to open the serial port and give read and write privileges?
Reply:
reference to the 14th floor freshui reply:
reform drive down just fine. The easiest is to replace the 0666 like
0600
Write a monitor is not necessary to engage in such a complex
how change can be more specific?

No comments:

Post a Comment