0

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?

  • "Stuck on reboot" is not a clear problem statement. Is it stuck during shut-down phase, or boot-up phase? What messages appear in the logs? – Dmitry Grigoryev Jul 3 '18 at 8:39
  • It won't finish booting on power up. It stalls at Hostname Services started. – Pedro Jul 3 '18 at 11:49
  • Is that the moment when your script starts? – Dmitry Grigoryev Jul 3 '18 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.