I have a Raspberry Pi that is stuck on reboot. I wish to use the Pi to send a CEC command to a television to turn it on or off over the HDMI connection. I have it run the following python script at startup:
import socket import sys import os host = "" port = 8888 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((host, port)) s.listen(10) while True: conn, addr = s.accept() data = conn.recv(1024) print (data) if data == "OFF" os.system('echo standby 0 | cec-client -s -d 1') if data == "ON" os.system('echo on 0 | cec-client -s -d 1')
Is it possible that leaving the socket server listening when the Pi powers down causes it to crash on reboot?
If that's the case, can anyone offer another way to have the Pi listen for socket commands in order to process the CEC commands?