2019-01-05 Fred Gleason <fredg@paravelsystems.com>

* Added a 'pypad_xmpad.py' PyPAD script.
	* Removed the 'rlm_xmpad' RLM.
This commit is contained in:
Fred Gleason
2019-01-05 11:19:23 -05:00
parent 5a57f51335
commit 04aa220a69
7 changed files with 294 additions and 551 deletions

View File

@@ -44,6 +44,8 @@ install-exec-am:
cp pypad_walltime.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_walltime.exemplar
../../../helpers/install_python.sh pypad_xds.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_xds.py
cp pypad_xds.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_xds.exemplar
../../../helpers/install_python.sh pypad_xmpad.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_xmpad.py
cp pypad_xmpad.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_xmpad.exemplar
uninstall-local:
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_ando.exemplar
@@ -68,6 +70,8 @@ uninstall-local:
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_walltime.py
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_xds.exemplar
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_xds.py
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_xmpad.exemplar
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_xmpad.py
EXTRA_DIST = pypad_ando.exemplar\
pypad_ando.py\
@@ -88,7 +92,9 @@ EXTRA_DIST = pypad_ando.exemplar\
pypad_walltime.exemplar\
pypad_walltime.py\
pypad_xds.exemplar\
pypad_xds.py
pypad_xds.py\
pypad_xmpad.exemplar\
pypad_xmpad.py
CLEANFILES = *~\
*.idb\

View File

@@ -0,0 +1,115 @@
; This is the configuration for the 'pypad_xmpad.py' script for
; Rivendell, which can be used to output Now & Next data for an XM
; Satellite Radio channel.
;
; NOTE: The serial ports configured here have NOTHING TO DO with the
; ports configured in rdadmin(1)! These ports are used strictly by this
; script, and will not be usable by any other Rivendell component.
; Section Header
;
; One per serial device to be configured, starting with 'Serial1' and
; working up consecutively
[Serial1]
; Serial Device
;
; The device file that corresponds to the serial device.
;Device=/dev/ttyS0
Device=/dev/ttyUSB0
; Serial Baud Rate (in bps)
Speed=4800
; Parity (0=none, 1=even, 2=odd)
Parity=0
; Number of bits per data 'word'.
WordSize=8
; Program ID
; A unique integer value, assigned by XM
ProgramID=1000000005
; Format Strings. There is one for each line of PAD data (total=2).
; The string is output each time RDAirPlay changes
; play state, including any wildcards as placeholders for metadata values.
;
; The list of available wildcards can be found in the 'Metadata Wildcards'
; appendix in the Rivendell Operations Guide.
;
FormatString1=%t
FormatString2=%a
; Display Size. The maximum length of text to be sent for each line.
DisplaySize1=8
DisplaySize2=10
; Record Flag. Set to 'Yes' to allow recording, or 'No' to disable.
Recording=Yes
; Heartbeat Interval. Should normally be set to '30'.
HeartbeatInterval=30
; Log Selection
;
; Set the status for each log to 'Yes', 'No' or 'Onair' to indicate whether
; state changes on that log should be output on this serial port. If set
; to 'Onair', then output will be generated only if RDAirPlay's OnAir flag
; is active.
MasterLog=Yes
Aux1Log=Yes
Aux2Log=Yes
VLog101=No
VLog102=No
VLog103=No
VLog104=No
VLog105=No
VLog106=No
VLog107=No
VLog108=No
VLog109=No
VLog110=No
VLog111=No
VLog112=No
VLog113=No
VLog114=No
VLog115=No
VLog116=No
VLog117=No
VLog118=No
VLog119=No
VLog120=No
; Additional serial ports can be configured by adding new sections...
;[Serial2]
;Device=/dev/ttyS1
;Speed=4800
;Parity=0
;WordSize=8
;FormatString1=%t
;FormatString2=%a
;MasterLog=Yes
;Aux1Log=No
;Aux2Log=Onair
;VLog101=No
;VLog102=No
;VLog103=No
;VLog104=No
;VLog105=No
;VLog106=No
;VLog107=No
;VLog108=No
;VLog109=No
;VLog110=No
;VLog111=No
;VLog112=No
;VLog113=No
;VLog114=No
;VLog115=No
;VLog116=No
;VLog117=No
;VLog118=No
;VLog119=No
;VLog120=No

166
apis/PyPAD/scripts/pypad_xmpad.py Executable file
View File

@@ -0,0 +1,166 @@
#!%PYTHON_BANGPATH%
# pypad_xmpad.py
#
# Write PAD updates to a Sirius/XM channel
#
# (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
import sys
import syslog
import configparser
import serial
import PyPAD
XMPAD_DELIMITER='\02'
# XMPAD_DELIMITER='\x7c' #(|)
def eprint(*args,**kwargs):
print(*args,file=sys.stderr,**kwargs)
def MakeA4(update,section):
a4='A4'
a4+=XMPAD_DELIMITER+'1'
field1=update.resolvePadFields(update.config().get(section,'FormatString1'),
PyPAD.ESCAPE_NONE)
a4+=XMPAD_DELIMITER+field1[0:16]
a4+='\n'
return a4
def MakeA5(update,section):
a5='A5'
a5+=XMPAD_DELIMITER+'1'
field2=update.resolvePadFields(update.config().get(section,'FormatString2'),
PyPAD.ESCAPE_NONE)
a5+=XMPAD_DELIMITER+field2[0:16]
a5+='\n'
return a5
def MakeB4(update,section):
b4='B-4'
#
# Recording flag
#
recording='1'
if update.config().get(section,'Recording').lower()=='yes':
recording='0'
b4+=XMPAD_DELIMITER+recording
b4+=XMPAD_DELIMITER+'1'
#
# Event duration
#
b4+=XMPAD_DELIMITER+str(update.padField(PyPAD.TYPE_NOW,PyPAD.FIELD_LENGTH)//432)
b4+=XMPAD_DELIMITER+'0'
#
# Display field sizes
#
disp1size=update.config().get(section,'DisplaySize1')
mask1=''
for i in range(int(disp1size)):
mask1+='1'
disp2size=update.config().get(section,'DisplaySize2')
mask2=''
for i in range(int(disp2size)):
mask2+='1'
disp2size=update.config().get(section,'DisplaySize2')
b4+=XMPAD_DELIMITER+disp1size
b4+=XMPAD_DELIMITER+disp2size
b4+=XMPAD_DELIMITER+mask1
b4+=XMPAD_DELIMITER+mask2
#
# Display field values
#
field1=update.resolvePadFields(update.config().get(section,'FormatString1'),
PyPAD.ESCAPE_NONE)
field2=update.resolvePadFields(update.config().get(section,'FormatString2'),
PyPAD.ESCAPE_NONE)
b4+=XMPAD_DELIMITER+field2[0:16]
b4+=XMPAD_DELIMITER+mask1
b4+=XMPAD_DELIMITER+mask2
b4+=XMPAD_DELIMITER+field1[0:16]
#
# Program ID
#
b4+=XMPAD_DELIMITER+update.config().get(section,'ProgramID')
#
# EOM
#
b4+='\n'
return b4
def ProcessPad(update):
n=1
try:
while(True):
section='Serial'+str(n)
if update.shouldBeProcessed(section) and update.hasPadType(PyPAD.TYPE_NOW):
devname=update.config().get(section,'Device')
speed=int(update.config().get(section,'Speed'))
parity=serial.PARITY_NONE
if int(update.config().get(section,'Parity'))==1:
parity=serial.PARITY_EVEN
if int(update.config().get(section,'Parity'))==2:
parity=serial.PARITY_ODD
bytesize=int(update.config().get(section,'WordSize'))
dev=serial.Serial(devname,speed,parity=parity,bytesize=bytesize)
b4=MakeB4(update,section)
a4=MakeA4(update,section)
a5=MakeA5(update,section)
dev.write(b4.encode('utf-8'))
dev.write(b4.encode('utf-8'))
dev.write(b4.encode('utf-8'))
dev.write(a4.encode('utf-8'))
dev.write(a5.encode('utf-8'))
dev.close()
n=n+1
except configparser.NoSectionError:
return
#
# 'Main' function
#
syslog.openlog(sys.argv[0].split('/')[-1])
rcvr=PyPAD.Receiver()
try:
rcvr.setConfigFile(sys.argv[3])
except IndexError:
eprint('pypad_xmpad.py: you must specify a configuration file')
sys.exit(1)
rcvr.setCallback(ProcessPad)
rcvr.start(sys.argv[1],int(sys.argv[2]))