Platform: RK3288
OS: Android 7.1.2
Kernel: v4.4.143
需求:
应客户软件的需求,需要将Android系统里面的/dev/ttyS3节点名称修改为/dev/ttyS9;
实现:
1、判断 driver->name是否为"ttyS",index是否为3,如果是的话替换为ttyS9;
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
old mode 100644
new mode 100755
index 33f80b0..3945013
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1346,11 +1346,17 @@ static void pty_line_name(struct tty_driver *driver, int index, char *p)*/static ssize_t tty_line_name(struct tty_driver *driver, int index, char *p){
+ //int len = -1;if (driver->flags & TTY_DRIVER_UNNUMBERED_NODE)return sprintf(p, "%s", driver->name);
- else
- return sprintf(p, "%s%d", driver->name,
- index + driver->name_base);
+ else{
+ if ((index + driver->name_base) == 3)
+ return sprintf(p, "%s%d", driver->name,
+ index + driver->name_base + 6); // ttyS3->ttyS9
+ else
+ return sprintf(p, "%s%d", driver->name,
+ index + driver->name_base);
+ }}/**
2、给ttyS9赋予0777权限
diff --git a/ueventd.rockchip.rc b/ueventd.rockchip.rc
index 72c5111..4fa781b 100755
--- a/ueventd.rockchip.rc
+++ b/ueventd.rockchip.rc
@@ -407,3 +407,4 @@/dev/i2c-1 0660 system system#for ovr/dev/ovr0 0664 system system
+/dev/ttyS9 0777 root root
\ No newline at end of file
参考资料:
[rk3288—Android6.0]修改串口对应关系
Android8.1系统修改串口节点