I am developing using python for a Raspberry Pi application. I changed the c-program that plays full-screen movies for entering data from FIFO.
Same:
$ ./hello_video.bin test.h264 < .my_fifo
$ echo 3 > .my_fifo
I can send numbers to FIFO, and hello_video.bin starts the corresponding video clip and cyclically terminates it.
The next step should be to make the video possible from the remote control. This is what I have:
import socket
import threading
import Queue
import subprocess
import sys
from time import sleep
host = ''
port = 5005
buffer = 2
player = "/opt/vc/src/hello_pi/hello_video/hello_video.bin"
clip = "/opt/vc/src/hello_pi/hello_video/test.h264"
p = subprocess.Popen([player, clip], stdin=subprocess.PIPE)
class readFromUDPSocket(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
def run(self):
while True:
data,addr = socketUDP.recvfrom(buffer)
try:
p.stdin.write(data)
p.stdin.flush()
except:
pass
if __name__ == '__main__':
socketUDP = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
socketUDP.bind((host, port))
myServer = readFromUDPSocket()
myServer.daemon = True
myServer.start()
while 1:
pass
UDPSock.close()
Unfortunately, hello_video.bin does not respond as intended. Teams do not start any other video.
I tried using p.communicate (input = data). It works, but only once. Then it blocks and I cannot get other data from the socket.
I have no idea how to fix this - I hope you can help me, Thank you