update: 20. 09. 2016
Pozice: Linux / NanoPi NEO /
Užitečné skripty pro NanoPI (armbian)
NanoPI NEO (wiki)
ARMBIAN (NanoPI NEO)
Ovládání GPIO: ARMBIAN (jessie) 3.4.112-sun8i
Příklad použití:
$ gpio gpio (port:0,1,2,3,6,64,65,67,93,198,199,200,201,203) (dir:in,out,unexp) (value_out:0,1) GPIO DIR VALUE ---------------------- ---------------------- $ gpio 203 out 1 $ gpio 6 in 0 $ gpio gpio (port:0,1,2,3,6,64,65,67,93,198,199,200,201,203) (dir:in,out,unexp) (value_out:0,1) GPIO DIR VALUE ---------------------- gpio203 out 1 gpio6 in 0 ---------------------- $ gpio 6 unexp $ gpio gpio (port:0,1,2,3,6,64,65,67,93,198,199,200,201,203) (dir:in,out,unexp) (value_out:0,1) GPIO DIR VALUE ---------------------- gpio203 out 1 ---------------------- $ gpio 203 in 0 $ gpio 203 0 $ gpio gpio (port:0,1,2,3,6,64,65,67,93,198,199,200,201,203) (dir:in,out,unexp) (value_out:0,1) GPIO DIR VALUE ---------------------- gpio203 in 0 ----------------------/usr/local/sbin/gpio
#!/bin/sh SELPORT="$1" DIRPORT="$2" VALPORT="$3" if [ "$SELPORT" = "" ]; then echo "$0 (port:0,1,2,3,6,64,65,67,93,198,199,200,201,203) (dir:in,out,unexp) (value_out:0,1)" echo echo "GPIO DIR VALUE" echo "----------------------" for LIST in `ls /sys/class/gpio/|grep -v "gpiochip0\|export"`; do DIR="`cat /sys/class/gpio/$LIST/direction`" VAL="`cat /sys/class/gpio/$LIST/value`" echo "$LIST $DIR $VAL" done echo "----------------------" else # -- UNEXPORT GPIO -- if [ "$DIRPORT" = "unexp" ]; then if [ -d "/sys/class/gpio/gpio$SELPORT/" ]; then echo $SELPORT > /sys/class/gpio/unexport fi else # -- Default DIRT -- if [ "$DIRPORT" = "" ]; then # -- Exist Open GPIO -- if [ ! -d "/sys/class/gpio/gpio$SELPORT/" ]; then echo "not export gpio$SELPORT !" exit fi if [ "`cat /sys/class/gpio/gpio$SELPORT/direction`" = "in" ]; then DIRPORT="in" else DIRPORT="out" fi fi # -- Default VALUE -- if [ "$VALPORT" = "" ]; then VALPORT="0" fi # -- CREATE GPIO -- if [ -d "/sys/class/gpio/gpio$SELPORT/" ]; then if [ "`cat /sys/class/gpio/gpio$SELPORT/direction`" != "$DIRPORT" ]; then echo $DIRPORT > /sys/class/gpio/gpio$SELPORT/direction fi else echo $SELPORT > /sys/class/gpio/export echo $DIRPORT > /sys/class/gpio/gpio$SELPORT/direction fi # -- SET OUT VALUE -- if [ -d "/sys/class/gpio/gpio$SELPORT/" ]; then if [ "`cat /sys/class/gpio/gpio$SELPORT/direction`" = "in" ]; then cat /sys/class/gpio/gpio$SELPORT/value else echo $VALPORT > /sys/class/gpio/gpio$SELPORT/value fi fi fi fi
Zobrazení teploty CPU: ARMBIAN (jessie) 3.4.112-sun8i
Příklad použití:
$ temp hwmon1_temp: 29°C / crit: 65°C hwmon2_temp: 29°C / crit: 105°C thermal_zone0: 29°C thermal_zone1: 29°C/usr/local/sbin/temp
#!/bin/sh if [ -d "/sys/devices/virtual/hwmon/hwmon1/" ]; then TEMP="`cat /sys/devices/virtual/hwmon/hwmon1/temp1_input`" CRIT="`cat /sys/devices/virtual/hwmon/hwmon1/temp1_crit`" echo "hwmon1_temp: $TEMP°C / crit: $CRIT°C" fi if [ -d "/sys/devices/virtual/hwmon/hwmon2/" ]; then TEMP="`cat /sys/devices/virtual/hwmon/hwmon2/temp1_input`" CRIT="`cat /sys/devices/virtual/hwmon/hwmon2/temp1_crit`" echo "hwmon2_temp: $TEMP°C / crit: $CRIT°C" fi if [ -d "/sys/devices/virtual/thermal/thermal_zone0/" ]; then board_temp1=`cat /sys/devices/virtual/thermal/thermal_zone0/temp` echo "thermal_zone0: $board_temp1°C" fi if [ -d "/sys/devices/virtual/thermal/thermal_zone1/" ]; then board_temp2=`cat /sys/devices/virtual/thermal/thermal_zone1/temp` echo "thermal_zone1: $board_temp2°C" fi
Soubory ke stažení
Nazev | typ | Delka | Vytvořeno |
---|---|---|---|
temp | temp | 830 B | 16. 11. 2016 |
gpio | gpio | 1 KB | 16. 11. 2016 |