夸克开发板 TFT屏 控制台自动运行 s-tui
初步设想通过 $LINES $COLUMNS 判定当前是否处于 tft-LCD 对应的控制台下,再执行 s-tui 。
手头这块夸克开发板, $LINES=16 $COLUMNS=30
----背景知识----
bashrc和profile的差异在于:
1. bashrc是在系统启动后就会自动运行。
2. profile是在用户登录后才会运行。
3. 进行设置后,可运用source bashrc命令更新bashrc,也可运用source profile命令更新profile。
----
~/.bash_profile 是交互式、login 方式进入bash 运行的;
~/.bashrc 是交互式 non-login 方式进入bash 运行的;
通常二者设置大致相同,所以通常前者会调用后者。
设置生效:可以重启生效,也可以使用命令:source
----
Often, on modern systems, the $COLUMNS and $LINES variables are not environment variables. The shell sets these values dynamically after each command and we usually cannot access them from non-interactive scripts.
因此不能直接使用环境变量 $COLUMNS 和 $LINES , 用 tput 命令获取。
----
首先, npi-config 里,已经 enabled 'Console Autologin'
然后, 需要修改 ~/.bashrc 添加需要(每次非交互登录)自动运行的命令。
(注意,通过 ssh 登录,无法调试 .bashrc )
.bashrc 末尾,加入下列段落:
echo LINES: $(tput lines) echo COLUMNS: $(tput cols) if [[ $(tput lines) -eq 16 && $(tput cols) -eq 30 ]] then /usr/local/bin/s-tui fi
最后,在 tft-LCD 控制台上,exit退出,触发系统重新自动登录,即可看到效果
==== 下面这些内容不相干 ====
sudo cat /proc/tty/driver/serial
可见, tx: rx: 计数会增加。
这里对应 连接开发主机的USB串口。

执行 w 命令,查看在用控制台。

可知 tft LCD 控制台对应 tty1
浙公网安备 33010602011771号