narges narges - 1 month ago 15
Bash Question

enable HDMI port after Disable it with shell programing in raspberry pi 3

I used a raspberry pi 3 model b v1.2. raspberry connected to a TV with HDMI port. I want to disable and enable HDMI port with shell program. I use this code for doing that. also, i install a teamviewer in raspberry and can control that with my laptop. when i run

sh rpi-hdmi.sh off
in terminal, HDMI port disable correctly and see this message in terminal:

Power off HDMI


but when i run
sh rpi-hdmi.sh on
, i see in TV that clear "no signal" message. but it not showing anything and i see just black tv.
when i run
sh rpi-hdmi.sh on
for first one, i see this message:

Power on HDMI with preferred settings
Couldn't get a file descriptor referring to the console


but for second one, i see just this message:

Power on HDMI with preferred settings


What must i do, for showing desktop in TV after enable HDMI port?

Answer

When you run sh rpi-hdmi.sh on, the line of tvservice -p need some time to run correctly. if you want to enable HDMI port quickly, you may run this code:

tvservice -p
xset dpms force on