Merge branch 'master' of github.com:pimoroni/enviroplus-python
authorPhil Howard <phil@gadgetoid.com>
Thu, 13 Jun 2019 09:15:24 +0000 (10:15 +0100)
committerPhil Howard <phil@gadgetoid.com>
Thu, 13 Jun 2019 09:15:24 +0000 (10:15 +0100)
install.sh
uninstall.sh

index 1205c0cc09ac5628a44e623b7b72841967c7603d..c1d36d64258eb5bc535aad03197dd8c640edba52 100755 (executable)
@@ -2,6 +2,8 @@
 
 LIBRARY_VERSION=`cat library/setup.py | grep version | awk -F"'" '{print $2}'`
 LIBRARY_NAME=`cat library/setup.py | grep name | awk -F"'" '{print $2}'`
+CONFIG=/boot/config.txt
+DATESTAMP=`date "+%Y-%M-%d-%H-%M-%S"`
 
 printf "$LIBRARY_NAME $LIBRARY_VERSION Python Library: Installer\n\n"
 
@@ -22,4 +24,18 @@ fi
 
 cd ..
 
+printf "Backing up $CONFIG\n"
+cp $CONFIG "config.preinstall-$DATESTAMP.txt"
+
+printf "Setting up serial for PMS5003..\n"
+# Disable serial terminal over /dev/ttyAMA0
+raspi-config nonint do_serial 1
+# Enable serial port
+raspi-config nonint set_config_var enable_uart 1 $CONFIG
+# Switch serial port to full UART for stability (may adversely affect bluetooth)
+sed -i 's/^#dtoverlay=pi3-miniuart-bt/dtoverlay=pi3-miniuart-bt/' $CONFIG
+if ! grep -q -E "^dtoverlay=pi3-miniuart-bt" $CONFIG; then
+       printf "dtoverlay=pi3-miniuart-bt\n" >> $CONFIG
+fi
+
 printf "Done!\n"
index 0709cc0625f12119b9b596838f5ce14317d61cfe..aaac11b280bdfc32ddb60df03aaa2a3ad55cd065 100755 (executable)
@@ -22,4 +22,12 @@ fi
 
 cd ..
 
+printf "Disabling serial..\n"
+# Enable serial terminal over /dev/ttyAMA0
+raspi-config nonint do_serial 0
+# Disable serial port
+raspi-config nonint set_config_var enable_uart 0 /boot/config.txt
+# Switch serial port back to miniUART
+sed -i 's/^dtoverlay=pi3-miniuart-bt/#dtoverlay=pi3-miniuart-bt/' /boot/config.txt
+
 printf "Done!\n"