Edited by guoxiaokai527 at Dec 21, 2015 02:01
- sshd-2.1.2-44.apk, ssh server under android, allows you toconnect a computer terminal banana pie;
3. In fact, the above code is verysimple principle, that is: - The first step: You need to know that you want to control pin in theregister, with "IO-1", for example, it is connected to PH2;
- Step Two: On the View board / sys / class / gpio / Which of the followingis the PH register, the following is just an chestnuts (because this is writtenin the company to write things in the home,I can not screenshot = .=)
GPIOfirst obtain information, type the following command in the terminal
1$ cd / sys / class / gpio
$2 for i in gpiochip *; do echo `cat $ i / label`:` cat $ i / base`; done
Theterminal is shown below (to get the starting number of each register, followingonly GPH I remember, the other is not correct)
1GPA: 0
2GPE: 128
3GPF: 160
4GPG: 192
5GPH: 167
6GPB: 32
7GPC: 64
8 GPD: 96
- Thethird step: gpio number calculated to be controlled: GPH0 is 167, then PH2 is167 + 2 = 169;
- Stepfour: $ echo 139> / sys / class / gpio / export, then there will be agpio169 file shows a success
- StepFive: $ echo out> / sys / class / gpio / gpio169 / direction, setting gpiodirection, "out" output, "in" input;
- PartVI: $ echo 1> / sys / class / gpio / gpio169 / value, write or read GPIOvalue, read gpio use the command: $ cat / sys / class / gpio / gpio169 / value
4. The actual procedure is very simple: Thefollowing "IO-1" as an example, first of all ,find the IO pins connected to theCPU on whichthe Banana Pro Schematic.pdf document:
Because the texture, ultra limit, so to find theirby your own , the "IO-1" corresponds to the " H2".
5. Below I posted above, according to the document that was tested inthe next ssh isindeed feasible, but the strangething is that I directly put this file on my project, the execution did not appear abnormal but each time failedto perform, let mehundred puzzled, and then stumbled, our bananapie android systemitself has to have root privileges,and so put "su -c" parameter to remove the front, and then put the "echo"and other parameters on the array, so magic is happened , Hooray! ~ ~ ~ ~
- java
- // Other similar
- public int exportPin() {
- try {
- Process process =
- Runtime.getRuntime().exec( newString[] {
- "echo",
- String.valueOf(this.number),
- ">",
- this.export });
- process.waitFor();
- if (process.exitValue() == 0)
- return 0;
- } catch (IOException e) {
- e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- return -1;
- }
Copy the CodeCall the method is relatively simple: - Pins mGpio = new Pins("gpio1:PH2",169);
- mGpio.exportPin();
- mGpio.setDirection("out");
- mGpio.setLevel("1");
Copy the Code
Complete, ha ha, the first post, and some of thebad place you bearwith me ....
|