Skip to content

Instantly share code, notes, and snippets.


tvass/ Secret

Created Oct 21, 2020
What would you like to do?
# -*- coding: utf-8 -*-
My version of the Internet Radio project.
import serial
import subprocess, os
from time import sleep
print("starting radio ...")
my_env = os.environ
#my_env["MPD_HOST"] = ""
ser = serial.Serial('/dev/ttyS0', 9600)
while True:
line = ser.readline().decode().strip('\r\n')
if line.startswith('mpc next') or line.startswith('mpc prev'):
proc = subprocess.Popen(line, shell=True)
proc = subprocess.Popen('mpc current -f %file% -h|cut -d"#" -f4', stdout=subprocess.PIPE, shell=True)
result = proc.communicate()[0]
ser.write("lcd %s".encode() % result)
if line.startswith('mpc vol'):
proc = subprocess.Popen(line, shell=True)
proc = subprocess.Popen("mpc volume -h |tr -dc '0-9'", stdout=subprocess.PIPE, shell=True)
volume = proc.communicate()[0]
ser.write("vol %s".encode() % volume)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment