下图显示,tinker board 2s有三个状态led灯,分别为
Android系统需要通过adb登录进行操作,并且切换root权限。
使用usb type-c线连接tinker board 2s和电脑,启动adb命令窗口,输入如下命令:
$ adb shell setprop persist.sys.root_access 3
$ adb root
$ adb remount
$ adb shell
$ cd /sys/class/leds
$ ls
$ cd pwr-led
$ cd act-led
$ cd rsv-led
$ echo "1" > brightness #点亮
$ echo "0" > brightness #熄灭
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#define LED0 pwr-led/brightness
#define LED1 act-led/brightness
#define LED2 rsv-led/brightness
int main(int argc, char **argv)
{
char buf[50];
int gpiofd;
sprintf(buf, "/sys/class/leds/", LED0);
gpiofd = open(buf, O_WRONLY);
if(gpiofd < 0)
{
perror("Couldn't open IRQ file");
return -1;
}
write(gpiofd, 0, 1); //点亮LED
//write(gpiofd, 1, 1); //熄灭LED
close(gpiofd);
return 0;
}
public static void setLED(String date){
Process process = null;
String command1 = "echo 0 /sys/class/leds/act-led/brightness";
try {
process = Runtime.getRuntime().exec(command1);
process.waitFor();
} catch (IOException e) {
e.printStackTrace();
}finally{
if(process!=null){
process.destroy();
}
}
}