I have this python script:
import warnings
warnings.filterwarnings('ignore')
import os, signal, subprocess
import RPi.GPIO as GPIO
class SwitchStatus:
def __init__(self, input_pin=18) -> None:
self.input_pin = input_pin
# Pin Setup:
GPIO.setmode(GPIO.BCM) # BCM pin-numbering scheme from Raspberry Pi
GPIO.setup(self.input_pin, GPIO.IN) # set pin as an
def play_status(self):
"""
0 -> play non-com
1 -> play premium_com
"""
try:
value = GPIO.input(self.input_pin)
return 0 if value == GPIO.HIGH else 1
except Exception as e:
print("[ERROR] Can't check switch status due to: ", e)
def play_cmd(cmd: str):
pro = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, preexec_fn=os.setsid)
return pro
def kill_cmd(pro):
os.killpg(os.getpgid(pro.pid), signal.SIGUSR1) # Send the signal to all the process groups
switch_status = SwitchStatus()
cmd = [
"gst-launch-1.0 v4l2src device=/dev/video0 ! capsfilter caps='image/jpeg, width=(int)1920, height=(int)1080, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1' ! jpegdec ! nvvidconv ! nvoverlaysink sync=False qos=True",
"gst-launch-1.0 filesrc location=./video.mkv ! matroskademux name=demux demux.video_0 ! queue ! h264parse ! nvv4l2decoder ! nvvidconv flip-method=0 ! nvoverlaysink",
]
#DEFAULTS
switch_prev_status = 0 #default non-com
pro = play_cmd(cmd[0]) #default play non com
while True:
try:
curr_state = switch_status.play_status()
if curr_state != switch_prev_status:
switch_prev_status = curr_state
kill_cmd(pro)
pro = play_cmd(cmd[curr_state])
except KeyboardInterrupt:
kill_cmd(pro)
GPIO.cleanup()
break
The script checks a certain GPIO (pin 12 on the nano) and depending on the pin status it runs a certain gstreamer pipeline. Code works as expected, only problem when a switch happens between both pipelines the terminal appears as the jetson is connected to a monitor using an hdmi, I don’t mind that behaviour, what I do mind is tegra-xusb spamming 'buffer overrun even on endpoint" warnings which I want to close. Note that the GUI of the nano was closed using:
sudo systemctl set-default multi-user.target
TLDR I want to turn off any type of console text outputting to the terminal when the nano is connected to the monitor via HDMI, the more blank the screen the better.
Any help is appreciated !