Firstly install Longmynd from the instruction on the GitHub site https://github.com/myorangedragon/longmynd
Then create the file longmynda.sh with the following text in the home directory of the Nano. Change the udpsink host address to your local address if you want to upd stream to something else i.e OBS. Then from a terminal window type chmod +x ./longmynda.sh to make it executable.
Code: Select all
#!/bin/bash
clear
resize -s 12 26
clear
cd ~/longmynd # Longmynd install directory
./lm_display.py &
while true; do
clear
echo "listening on port 6789"
netcat -ul 6789 | while read line #send commands via Multi Quick Tune on port 6789
do
echo "$line"
freq=$( awk -F',' '{print $2}' <<< $line | awk -F'=' '{print $2}' )
sr=$( awk -F',' '{print $5}' <<< $line | awk -F'=' '{print $2}' )
lnb_offset=$( awk -F',' '{print $3}' <<< $line | awk -F'=' '{print $2}' )
echo "$freq"
echo "$sr"
echo "$lnb_offset"
freq2=$((freq - lnb_offset))
echo "Rx $freq with a symbolrate of $sr"
# Start Rx process
killall totem
totem udp://230.0.0.10:1234 & # Start player
killall gst-launch-1.0
killall gst-launch-1.0
gst-launch-1.0 udpsrc port=1234 ! tee name='repeat' ! queue ! udpsink host=192.168.1.101 port=5000 & # change address to set up udp stream
killall longmynd
./longmynd -i 230.0.0.10 1234 $freq2 $sr & # restart longmynd with params
done &
while read -sn 1 quit && [[ $quit != " " ]]; # Press the space bar at any time to quit
do
xdotool getactivewindow windowkill
done
done
Code: Select all
#!/usr/bin/env python
# Original script By Rob M0DTS modified by John G7JTT
# Copy this script to the installed directory of Longmynd
import time
import os
import signal
import json
import struct
import fcntl
lm_states =['Initialising','Searching','Got Headers','Locked DVB-S','Locked DVB-S2']
lm_DVBS_modcodes =['1/2','2/3','3/4','5/6','6/7','7/8']
lm_DVBS2_modcodes =['Dummy','QPSK 1/4','QPSK 1/3','QPSK 2/5','QPSK 1/2','QPSK 3/5','QPSK 2/3','QPSK 3/4','QPSK 4/5','QPSK 5/6','QPSK 8/9','QPSK 9/10','8PSK 3/5','8PSK 2/3','8PSK 3/4','8PSK 5/6','8PSK 8/9','8PSK 9/10','16APSK 2/3','16APSK 3/4','16APSK 4/5','16APSK 5/6','16APSK 8/9','16APSK 9/10','32APSK 3/4','32APSK 4/5','32APSK 5/6','32APSK 8/9','32APSK 9/10']
lm_Dnum_DVBS =['2.7','4.4','5.5','6.5','7.2']
lm_Dnum_DVBS2=['Dummy','-2.4','-1.2','0.0','1.0','2.2','3.1','4.0','4.6','5.2','6.2','6.5','5.5','6.6','7.9','9.4','10.6','11','9','10.2','11','11.6','12.9','13.1','12.6','13.6','14.3','15.7','16.1']
def handler(signum, frame):
time.sleep(0.5)
print '\nClosing...\n'
exit()
signal.signal(signal.SIGINT, handler) #catch ctrl-c better!
def read_lm_status(fifo):
global threadLock
global lm_final_status
global newstatus
global lm_status
readpid = False
lm_status = {'Rx': '0','Freq': '','LO':'', 'SR': '', 'MODCODE': '', 'Call': '', 'Provider': '', 'State': '', 'Viterbi': '', 'BER': '', 'MER': '', 'Nulls': '', 'ShortFrames': '', 'Pilots': '','APID':'','ATYPE':'','VPID':'','VTYPE':''}
f = open(fifo, "r")
VT="No Video"
AT="No Audio"
Dn=0
a=0
b=0
while True:
try:
line = f.readline().strip("\n").split(",")
#print line
except:
print "Can't open fifo"
exit()
if line[0]=="$1":
lm_status["State"]=lm_states[int(line[1])]
if line[0]=="$6":
lm_status["Freq"]=line[1]
if line[0]=="$9":
lm_status["SR"]=line[1]
if line[0]=="$10":
lm_status["Viterbi"]=line[1]
if line[0]=="$11":
lm_status["BER"]=line[1]
if line[0]=="$12":
#print int(line[1])
if int(line[1])>512:
lm_status["MER"]=-(float(1024-int(line[1])))/10
else:
lm_status["MER"]=float(line[1])/10
if line[0]=="$13":
lm_status["Call"]=line[1]
if line[0]=="$14":
lm_status["Provider"]=line[1]
if line[0]=="$15":
lm_status["Nulls"]=line[1]
if line[0]=="$16":
if readpid:
lm_status["APID"]=line[1]
else:
lm_status["VPID"]=line[1]
if line[0]=="$17":
if readpid:
lm_status["ATYPE"]=line[1]
readpid=False
else:
lm_status["VTYPE"]=line[1]
readpid=True
if line[0]=="$18":
if lm_status['State']=="Locked DVB-S":
lm_status["MODCODE"]=lm_DVBS_modcodes[int(line[1])]
if lm_status['State']=="Locked DVB-S2":
try:
lm_status["MODCODE"]=lm_DVBS2_modcodes[int(line[1])]
except:
lm_status["MODCODE"]="invalid"
if line[0]=="$18":
if lm_status['State']=="Locked DVB-S":
b=float(lm_Dnum_DVBS[int(line[1])])
if lm_status['State']=="Locked DVB-S2":
try:
b=float(lm_Dnum_DVBS2[int(line[1])])
except:
b=0
if line[0]=="$19":
if lm_status['State']=="Locked DVB-S2":
lm_status['ShortFrames']=line[1]
if lm_status["VTYPE"]=="36":
VT="H265"
if lm_status["VTYPE"]=="27":
VT="H264"
if lm_status["VTYPE"]=="2":
VT="MPEG-2"
if lm_status["ATYPE"]=="3":
AT="MPGA"
if lm_status["ATYPE"]=="15":
AT="AAC"
if lm_status["ATYPE"]=="129":
AT="AC-3"
if line[0]=="$20":
if lm_status['State']=="Locked DVB-S2":
lm_status['Pilots']=line[1]
a=lm_status["MER"]
Dn = a - b
#last line of output
###########################################################################################
#add lines here to display in cosole
print "\nCall: "+str(lm_status["Call"])
print "Provider: "+str(lm_status["Provider"])
print "Mod: "+str(lm_status["MODCODE"])
print "MER: "+str(lm_status["MER"])+"db"
print "D:",Dn
print "Freq: "+str(lm_status["Freq"])+"KHz"
print "SR: "+str(lm_status["SR"])
print "Nulls: "+str(lm_status["Nulls"])+"%"
print "Aud: "+(AT)
print "Vid: "+(VT)
print "Status: "+str(lm_status["State"])
###########################################################################################
time.sleep(0.001)
# print lm_status
f.close()
#run the loop reading status fifo and display the nice version.
read_lm_status("/home/g7jtt-nano/longmynd/longmynd_main_status") #this is the path to the status fifo file
Hopefully some may find this useful and remember I'm no expert at any of this just like tinkering ! Once again thanks to Rob for the original script.
73 John G7JTT