2018-12-20 Fred Gleason <fredg@paravelsystems.com>

* Added a 'pypad_serial.py' PyPAD script.
	* Removed the 'rlm_serial' RLM.
This commit is contained in:
Fred Gleason
2018-12-21 18:58:18 -05:00
parent 8d1660d13f
commit b3846cd08c
6 changed files with 192 additions and 462 deletions

View File

@@ -30,6 +30,8 @@ install-exec-am:
cp pypad_live365.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_live365.exemplar
../../../helpers/install_python.sh pypad_liqcomp.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_liqcomp.py
cp pypad_liqcomp.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_liqcomp.exemplar
../../../helpers/install_python.sh pypad_serial.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_serial.py
cp pypad_serial.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_serial.exemplar
../../../helpers/install_python.sh pypad_spinitron.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_spinitron.py
cp pypad_spinitron.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_spinitron.exemplar
../../../helpers/install_python.sh pypad_udp.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_udp.py
@@ -48,6 +50,8 @@ uninstall-local:
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_live365.py
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_liqcomp.exemplar
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_liqcomp.py
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_serial.exemplar
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_serial.py
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_spinitron.exemplar
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_spinitron.py
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_udp.exemplar

View File

@@ -0,0 +1,116 @@
; This is the configuration for the 'pypad_serial.py' script for
; Rivendell, which can be used to output Now & Next data via one or more
; serial ports.
;
; NOTE: The serial ports configured here have NOTHING TO DO with the
; ports configured in RDAdmin! These ports are used strictly by the
; 'pypad_serial.py' plugin, 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
; Serial Baud Rate (in bps)
Speed=9600
; Parity (0=none, 1=even, 2=odd)
Parity=0
; Number of bits per data 'word'.
WordSize=8
; Format String. The string to be 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.txt'
; file in the Rivendell documentation directory.
;
FormatString=NOW: %d(ddd MMM d hh:mm:ss yyyy): %t - %a\r\nNEXT: %D(ddd MMM d hh:mm:ss yyyy): %T - %A\r\n
; Encoding. Defines the set of escapes to be applied to the PAD fields.
; The following options are available:
;
; 0 - Perform no character escaping.
; 1 - "XML" escaping: Escape reserved characters as per XML-v1.0
; 2 - "Web" escaping: Escape reserved characters as per RFC 2396 Section 2.4
Encoding=0
; Null Update Handling. Defines how 'null' updates --i.e. those with a cart
; number of '0' -- should be handled.
;
; 0 - Process all updates regardless of cart values.
; 1 - Process update only if the 'now' cart is not null.
; 2 - Process update only if the 'next' cart is not null.
; 3 - Process update only if both the 'now' and 'next' carts are not null.
ProcessNullUpdates=0
; 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=9600
;Parity=0
;WordSize=8
;FormatString=%t
;ProcessNullUpdates=0
;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

View File

@@ -0,0 +1,69 @@
#!%PYTHON_BANGPATH%
# pypad_serial.py
#
# Write PAD updates to arbitrary URLs
#
# (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 PyPAD
import serial
from io import BytesIO
def eprint(*args,**kwargs):
print(*args,file=sys.stderr,**kwargs)
def ProcessPad(update):
n=1
try:
while(True):
section='Serial'+str(n)
if update.shouldBeProcessed(section):
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)
fmtstr=update.config().get(section,'FormatString')
esc=int(update.config().get(section,'Encoding'))
dev.write(update.resolvePadFields(fmtstr,esc).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_serial.py: you must specify a configuration file')
sys.exit(1)
rcvr.setCallback(ProcessPad)
rcvr.start(sys.argv[1],int(sys.argv[2]))