2015-01-25 Fred Gleason <fredg@paravelsystems.com>

* Added 'RDMatrix::ModemLines' to the 'RDMatrix::Type' enumeration
	in 'lib/rdmatrix.cpp' and 'lib/rdmatrix.h'.
	* Added a driver for using tty modem lines for GPIO in
	'ripcd/modemlines.cpp' and 'ripcd/modemlines.h'.
This commit is contained in:
Fred Gleason
2015-01-25 16:00:34 -05:00
parent 4e2b3ab0dd
commit 5de990367d
8 changed files with 373 additions and 7 deletions

View File

@@ -14717,3 +14717,8 @@
'ripcd/btgpi16.cpp' and 'ripcd/btgpi16.h'.
2015-01-24 Fred Gleason <fredg@paravelsystems.com>
* Incremented the package version to 2.10.2int01.
2015-01-25 Fred Gleason <fredg@paravelsystems.com>
* Added 'RDMatrix::ModemLines' to the 'RDMatrix::Type' enumeration
in 'lib/rdmatrix.cpp' and 'lib/rdmatrix.h'.
* Added a driver for using tty modem lines for GPIO in
'ripcd/modemlines.cpp' and 'ripcd/modemlines.h'.

View File

@@ -22,6 +22,7 @@ LiveWire Multicast GPIO
Local Audio Adapter
Logitek vGuest
Quartz Electronics Type 1 Routing Protocol
Serial Port Modem Control Lines
Sierra Automated Systems 32000 Audio Router
Sierra Automated Systems 64000 Audio Router
Sierra Automated Systems Universal Serial Interface (USI)
@@ -508,6 +509,32 @@ Control can done either by means of an RS-232C connection or by means of
TCP/IP to TCP port 23.
----------------------------------------------------------------------------
SERIAL PORT MODEM CONTROL LINES
Driver Name: Serial Port Modem Control Lines
Supported RML Commands:
GPO Set ('GO')
GENERAL NOTES:
This driver enables GPIO via the modem control lines on an RS-232C serial
device. The lines map as follows:
GPI SIGNAL
-------------------------------
1 Data Set Ready (DSR)
2 Clear To Send (CTS)
3 Carrier Detect (CI)
4 Ring Indicator (RI)
GPO SIGNAL
-------------------------------
1 Data Terminal Ready (DTR)
2 Ready To Send (RTS)
----------------------------------------------------------------------------
SIERRA AUTOMATED SYSTEMS 32000 AUDIO ROUTER
Driver Name: SAS 32000

View File

@@ -62,7 +62,8 @@ bool __mx_primary_controls[RDMatrix::LastType][RDMatrix::LastControl]=
{0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0}, // 360 AM16
{0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0}, // LiveWire LWRP GPIO
{0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0}, // BT Sentinel 4 Web
{0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0} // BT GPI-16
{0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0}, // BT GPI-16
{0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0} // Modem Lines
};
bool __mx_backup_controls[RDMatrix::LastType][RDMatrix::LastControl]=
{
@@ -99,7 +100,8 @@ bool __mx_backup_controls[RDMatrix::LastType][RDMatrix::LastControl]=
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, // 360 AM16
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, // LiveWire LWRP GPIO
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, // BT Sentinel 4 Web
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} // BT GPI-16
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, // BT GPI-16
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} // Modem Lines
};
int __mx_default_values[RDMatrix::LastType][RDMatrix::LastControl]=
@@ -137,7 +139,8 @@ int __mx_default_values[RDMatrix::LastType][RDMatrix::LastControl]=
{0,0,0,0,0,0,0,0,0,0,0,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}, // 360 AM16
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0}, // LiveWire LWRP GPIO
{1,0,0,0,0,0,0,0,0,0,0,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}, // BT Sentinel 4 Web
{0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0} // BT GPI-16
{0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}, // BT GPI-16
{0,0,0,0,0,0,0,0,0,0,0,0,0,4,2,0,0,0,0,0,0,0,0,0,0,0,0,1,0} // Modem Lines
};
RDMatrix::RDMatrix(const QString &station,int matrix)
@@ -677,6 +680,10 @@ QString RDMatrix::typeString(RDMatrix::Type type)
return QString("BroadcastTools GPI-16");
break;
case RDMatrix::ModemLines:
return QString("Serial Port Modem Control Lines");
break;
default:
return QString("Unknown Type");
break;

View File

@@ -2,9 +2,7 @@
//
// Abstract a Rivendell Switcher Matrix
//
// (C) Copyright 2002-2003 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: rdmatrix.h,v 1.28.8.9 2014/02/17 02:19:02 cvs Exp $
// (C) Copyright 2002-2015 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
@@ -39,7 +37,8 @@ class RDMatrix
LogitekVguest=16,BtSs164=17,StarGuideIII=18,BtSs42=19,
LiveWireLwrpAudio=20,Quartz1=21,BtSs44=22,BtSrc8III=23,BtSrc16=24,
Harlond=25,Acu1p=26,LiveWireMcastGpio=27,Am16=28,
LiveWireLwrpGpio=29,BtSentinel4Web=30,BtGpi16=31,LastType=32};
LiveWireLwrpGpio=29,BtSentinel4Web=30,BtGpi16=31,ModemLines=32,
LastType=33};
enum Endpoint {Input=0,Output=1};
enum Mode {Stereo=0,Left=1,Right=2};
enum VguestAttribute {VguestEngine=0,VguestDevice=1,VguestSurface=2,

View File

@@ -55,6 +55,7 @@ dist_ripcd_SOURCES = acu1p.cpp acu1p.h\
local_gpio.cpp local_gpio.h\
local_macros.cpp maint_routines.cpp\
loaddrivers.cpp\
modemlines.cpp modemlines.h\
quartz1.cpp quartz1.h\
ripcd.cpp ripcd.h globals.h\
ripcd_connection.cpp ripcd_connection.h\
@@ -92,6 +93,7 @@ nodist_ripcd_SOURCES = moc_am16.cpp\
moc_livewire_mcastgpio.cpp\
moc_local_audio.cpp\
moc_local_gpio.cpp\
moc_modemlines.cpp\
moc_quartz1.cpp\
moc_ripcd.cpp\
moc_ripcd_socket.cpp\

View File

@@ -47,6 +47,7 @@
#include <livewire_mcastgpio.h>
#include <local_audio.h>
#include <local_gpio.h>
#include <modemlines.h>
#include <quartz1.h>
#include <sas32000.h>
#include <sas64000.h>
@@ -153,6 +154,10 @@ bool MainObject::LoadSwitchDriver(int matrix_num)
ripcd_switcher[matrix_num]=new VGuest(matrix,this);
break;
case RDMatrix::ModemLines:
ripcd_switcher[matrix_num]=new ModemLines(matrix,this);
break;
case RDMatrix::Quartz1:
ripcd_switcher[matrix_num]=new Quartz1(matrix,this);
break;

248
ripcd/modemlines.cpp Normal file
View File

@@ -0,0 +1,248 @@
// modemlines.cpp
//
// A Rivendell switcher driver for using TTY modem lines for GPIO
//
// (C) Copyright 2015 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.
//
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <globals.h>
#include <modemlines.h>
ModemLines::ModemLines(RDMatrix *matrix,QObject *parent,const char *name)
: Switcher(matrix,parent,name)
{
gpio_poll_state=0;
gpio_poll_timer=NULL;
gpio_gpi_oneshot=NULL;
gpio_gpi_table[0]=TIOCM_DSR;
gpio_gpi_table[1]=TIOCM_CTS;
gpio_gpi_table[2]=TIOCM_CAR;
gpio_gpi_table[3]=TIOCM_RNG;
gpio_gpo_table[0]=TIOCM_DTR;
gpio_gpo_table[1]=TIOCM_RTS;
for(int i=0;i<4;i++) {
gpio_gpi_mask[i]=false;
}
//
// Get Matrix Parameters
//
gpio_matrix=matrix->matrix();
gpio_gpis=matrix->gpis();
gpio_gpos=matrix->gpos();
//
// Open TTY
//
gpio_tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary));
if((gpio_fd=open(gpio_tty->port(),O_RDONLY))<0) {
syslog(LOG_ERR,"unable to open tty \"%s\"",(const char *)gpio_tty->port());
return;
}
for(int i=0;i<gpio_gpos;i++) { // So we don't false trigger
ioctl(gpio_fd,TIOCMBIC,&gpio_gpo_table[i]);
}
gpio_poll_timer=new QTimer(this);
connect(gpio_poll_timer,SIGNAL(timeout()),this,SLOT(pollTtyData()));
gpio_poll_timer->start(MODEMLINES_POLL_INTERVAL);
//
// Interval OneShot
//
gpio_gpi_oneshot=new RDOneShot(this);
connect(gpio_gpi_oneshot,SIGNAL(timeout(int)),this,SLOT(gpiOneshotData(int)));
//
// GPO Timers
//
gpio_gpo_mapper=new QSignalMapper(this);
connect(gpio_gpo_mapper,SIGNAL(mapped(int)),this,SLOT(gpoResetData(int)));
for(int i=0;i<gpio_gpos;i++) {
gpio_gpo_timers[i]=new QTimer(this);
gpio_gpo_mapper->setMapping(gpio_gpo_timers[i],i);
connect(gpio_gpo_timers[i],SIGNAL(timeout()),gpio_gpo_mapper,SLOT(map()));
gpio_gpo_pending_states[i]=false;
}
}
ModemLines::~ModemLines()
{
if(gpio_fd>=0) {
close(gpio_fd);
delete gpio_poll_timer;
delete gpio_gpi_oneshot;
delete gpio_gpo_mapper;
delete gpio_gpo_timers[0];
delete gpio_gpo_timers[1];
}
delete gpio_tty;
}
RDMatrix::Type ModemLines::type()
{
return RDMatrix::ModemLines;
}
unsigned ModemLines::gpiQuantity()
{
return gpio_gpis;
}
unsigned ModemLines::gpoQuantity()
{
return gpio_gpos;
}
bool ModemLines::primaryTtyActive()
{
return true;
}
bool ModemLines::secondaryTtyActive()
{
return false;
}
void ModemLines::processCommand(RDMacro *cmd)
{
switch(cmd->command()) {
case RDMacro::GO:
if((gpio_fd<0)||(cmd->argQuantity()!=5)||
((cmd->arg(1).toString().lower()!="i")&&
(cmd->arg(1).toString().lower()!="o"))||
(cmd->arg(2).toInt()<1)||(cmd->arg(2).toInt()>gpio_gpos)||
((cmd->arg(3).toInt()!=1)&&(cmd->arg(3).toInt()!=0)&&
(cmd->arg(3).toInt()!=-1))||(cmd->arg(4).toInt()<0)) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
return;
}
if(cmd->arg(1).toString().lower()=="i") {
if(cmd->arg(3).toInt()==0) {
emit gpiChanged(gpio_matrix,cmd->arg(2).toInt()-1,false);
gpio_gpi_mask[cmd->arg(2).toInt()-1]=true;
if(cmd->arg(4).toInt()>0) {
gpio_gpi_oneshot->
start(cmd->arg(2).toInt()-1,cmd->arg(4).toInt());
}
}
else {
if(cmd->arg(3).toInt()==1) {
emit gpiChanged(gpio_matrix,cmd->arg(2).toInt()-1,true);
gpio_gpi_mask[cmd->arg(2).toInt()-1]=true;
if(cmd->arg(4).toInt()>0) {
gpio_gpi_oneshot->
start(cmd->arg(2).toInt()-1,cmd->arg(4).toInt());
}
}
else {
gpiOneshotData(cmd->arg(2).toInt()-1);
}
}
cmd->acknowledge(true);
emit rmlEcho(cmd);
return;
}
if(cmd->arg(1).toString().lower()=="o") {
if(cmd->arg(3).toInt()==0) {
ioctl(gpio_fd,TIOCMBIC,&gpio_gpo_table[cmd->arg(2).toInt()-1]);
if(cmd->arg(4).toInt()>0) {
gpio_gpo_timers[cmd->arg(2).toInt()-1]->
start(cmd->arg(4).toInt(),true);
gpio_gpo_pending_states[cmd->arg(2).toInt()-1]=true;
}
}
else {
if(cmd->arg(3).toInt()==1) {
ioctl(gpio_fd,TIOCMBIS,&gpio_gpo_table[cmd->arg(2).toInt()-1]);
if(cmd->arg(4).toInt()>0) {
gpio_gpo_timers[cmd->arg(2).toInt()-1]->
start(cmd->arg(4).toInt(),true);
gpio_gpo_pending_states[cmd->arg(2).toInt()-1]=false;
}
}
else {
cmd->acknowledge(false);
emit rmlEcho(cmd);
return;
}
}
cmd->acknowledge(true);
emit rmlEcho(cmd);
return;
}
break;
default:
cmd->acknowledge(false);
emit rmlEcho(cmd);
break;
}
}
void ModemLines::pollTtyData()
{
int lines=0;
if(ioctl(gpio_fd,TIOCMGET,&lines)==0) {
if(lines==gpio_poll_state) {
return;
}
for(int i=0;i<gpio_gpis;i++) {
if((lines&gpio_gpi_table[i])!=(gpio_poll_state&gpio_gpi_table[i])) {
emit gpiChanged(gpio_matrix,i,(lines&gpio_gpi_table[i])!=0);
}
}
gpio_poll_state=lines;
}
}
void ModemLines::gpiOneshotData(int value)
{
int lines=0;
gpio_gpi_mask[value]=false;
if(ioctl(gpio_fd,TIOCMGET,&lines)==0) {
emit gpiChanged(gpio_matrix,value,(lines&gpio_gpi_table[value])!=0);
}
}
void ModemLines::gpoResetData(int gpo)
{
if(gpio_gpo_pending_states[gpo]) {
ioctl(gpio_fd,TIOCMBIS,&gpio_gpo_table[gpo]);
}
else {
ioctl(gpio_fd,TIOCMBIC,&gpio_gpo_table[gpo]);
}
}

73
ripcd/modemlines.h Normal file
View File

@@ -0,0 +1,73 @@
// modemlines.h
//
// A Rivendell switcher driver for using TTY modem lines for GPIO
//
// (C) Copyright 2015 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.
//
#ifndef MODEMLINES_H
#define MODEMLINES_H
#include <qtimer.h>
#include <qsignalmapper.h>
#include <rd.h>
#include <rdmatrix.h>
#include <rdmacro.h>
#include <rdoneshot.h>
#include <rdtty.h>
#include <switcher.h>
#define MODEMLINES_POLL_INTERVAL 100
class ModemLines : public Switcher
{
Q_OBJECT
public:
ModemLines(RDMatrix *matrix,QObject *parent=0,const char *name=0);
~ModemLines();
RDMatrix::Type type();
unsigned gpiQuantity();
unsigned gpoQuantity();
bool primaryTtyActive();
bool secondaryTtyActive();
void processCommand(RDMacro *cmd);
private slots:
void pollTtyData();
void gpiOneshotData(int value);
void gpoResetData(int gpo);
private:
int gpio_matrix;
int gpio_gpis;
int gpio_gpos;
int gpio_fd;
int gpio_poll_state;
QTimer *gpio_poll_timer;
unsigned gpio_gpi_table[4];
int gpio_gpo_table[2];
QSignalMapper *gpio_gpo_mapper;
QTimer *gpio_gpo_timers[2];
bool gpio_gpo_pending_states[2];
RDTty *gpio_tty;
RDOneShot *gpio_gpi_oneshot;
bool gpio_gpi_mask[4];
};
#endif // LOCAL_GPIO_H