»
(008)CubeIDE实现USB外设*
(012)ARM架构防烧脚本
(018)C99 的指针*
(019)C99 只有值赋值,没有move*
(022)POSIX线程库pthread的同步锁*
(023)POSIX线程库pthread的多线程*
(027)C99标准库中的计时与等待 *
(028)C语言中的高精度计算库GMP *
(029)C语言中的Web服务*
(030)C语言中的字符转码ICU*
(031)从几个方面显然C语言比C++效率高*
1. 从网上总结得到的Arm系统温度检测监测程序(linux-temperature.sh): #!/bin/sh # 系统最高温度,80.0度 max_temp=80000 # 系统最低温度,-70.0度 min_temp=-70000 # 过热连续出现次数 too_high_count=0 # 过冷连续出现次数 too_low_count=0 while (true) do # temp=`/opt/vc/bin/vcgencmd measure_temp|awk -F= '{print $2}'|awk -F\' '{print $1}'` temp=`cat /sys/class/thermal/thermal_zone0/temp` echo $temp # 网上有实验表明,树莓派温度达到 -78°C 的低温下会停止工作 # http://shumeipai.nxez.com/2019/04/02/what-is-the-ideal-raspberry-pi-cpu-temperature-range.html if [ `expr "$temp < $min_temp"` ]; then if [ $too_low_count > 3 ]; then echo `date` "系统已过冷" $too_low_count >> ./wait-halt.log #halt -p reboot break else let too_low_count+=1 fi elif [ `expr "$temp > $max_temp"` ]; then if [ $too_high_count > 3 ]; then echo `date` "系统已过热" $too_high_count >> ./wait-halt.log #halt -p reboot break else let too_high_count+=1 fi else # 连续出现过热或过冷次数超过3次才关机,必须是连续出现 too_low_count=0 too_high_count=0 fi sleep 1 done 2、做成服务(linux-temperature.service) [Unit] Description=Temperature Monitor After=network.target [Service] ExecStart=/root/linux-temperature.sh 2>&1 > /dev/null & Restart=on-abort [Install] WantedBy=multi-user.target 3、使能服务 systemctl enable linux-temperature 附上: Linux环境,转换windows环境的\r\n为\n的最简单方法(也就是Linux环境转换windows换行的最简单方法): sed -i 's/\r//' linux-temperature.sh sed -i 's/\r//' linux-temperature.service