aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlookshe <github@lookshe.org>2014-12-30 18:17:30 +0100
committerlookshe <github@lookshe.org>2014-12-30 18:17:30 +0100
commit6a4c7db21bb25c193d0faba891d3717762c1d2dd (patch)
tree9e65ec4292fbc3cd376cfa22e9176c3c51762796
parent998d008f8afad722aefb62a995bac16e02128b82 (diff)
parentc6ae2d3da1c073100fc6b80d44f25ab2408f7148 (diff)
Merge branch 'master' of github.com:lookshe/scripts
-rw-r--r--rasp_startup.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/rasp_startup.py b/rasp_startup.py
index 1cedf8f..4a1a426 100644
--- a/rasp_startup.py
+++ b/rasp_startup.py
@@ -2,6 +2,7 @@ import RPi.GPIO as GPIO
import time
import thread
import subprocess
+from subprocess import Popen, PIPE, STDOUT
# pin-setup
GPIO.setmode(GPIO.BOARD)
@@ -14,8 +15,10 @@ cmd_amixer1 = 'amixer -c 0 set PCM 98%'
cmd_amixer2 = 'amixer -c 0 set Speaker 98%'
# the process we want to start and its argument
-cmd_player = 'mplayer'
-arg_player = 'http://192.168.1.33:8000/mpd.ogg'
+#cmd_player = 'mplayer'
+cmd_player = 'ogg123'
+arg_player = []
+url_player = 'http://192.168.1.33:8000/mpd.ogg'
process = 0
def playerThreadFunc():
@@ -23,14 +26,24 @@ def playerThreadFunc():
global process
# kill if running
if process != 0:
- if process.poll() == None:
- process.terminate()
- subprocess.call(['killall', cmd_player], shell=True)
+ #if process.poll() == None:
+ #process.communicate(input='q')
+ if process.poll() == None:
+ process.terminate()
+ list_cmdarg = []
+ list_cmdarg.append('killall')
+ list_cmdarg.append(cmd_player)
+ subprocess.call(list_cmdarg, shell=False)
time.sleep(1)
# turn on led
GPIO.output(led_pin, True)
+ list_cmdarg = []
+ list_cmdarg.append(cmd_player)
+ list_cmdarg.extend(arg_player)
+ list_cmdarg.append(url_player)
# start process and wait for termination
- process = subprocess.Popen([cmd_player, arg_player])
+ process = subprocess.Popen(list_cmdarg)
+ #process = subprocess.Popen(list_cmdarg, stdin=PIPE)
process.wait()
# turn off led
GPIO.output(led_pin, False)