2019-07-23 Fred Gleason <fredg@paravelsystems.com>

* Fixed regressions that made serial device operation unreliable.
This commit is contained in:
Fred Gleason
2019-07-23 14:19:06 -04:00
parent 70c88ec498
commit c3cc94143a
29 changed files with 216 additions and 217 deletions

View File

@@ -61,8 +61,7 @@ BtAdms4422::BtAdms4422(RDMatrix *matrix,QObject *parent)
bt_device->setParity(tty->parity());
if(bt_device->open(QIODevice::Unbuffered|QIODevice::ReadWrite)) {
// Set Mix Mode
bt_device->
writeBlock(QString().sprintf("*%uUM0\r\n",BTADMS4422_UNIT_ID),7);
bt_device->write(QString().sprintf("*%uUM0\r\n",BTADMS4422_UNIT_ID),7);
}
else {
rda->syslog(LOG_WARNING,"failed to open port \"%s\"",
@@ -161,12 +160,12 @@ void BtAdms4422::processCommand(RDMacro *cmd)
if(cmd->arg(2).toInt()<=4) {
sprintf(str,"*%dOR%dF\r\n",BTADMS4422_UNIT_ID,
cmd->arg(2).toInt());
bt_device->writeBlock(str,8);
bt_device->write(str,8);
}
else {
sprintf(str,"*%dOO%dF\r\n",BTADMS4422_UNIT_ID,
cmd->arg(2).toInt()-4);
bt_device->writeBlock(str,9);
bt_device->write(str,9);
}
emit gpoChanged(bt_matrix,cmd->arg(2).toInt()-1,false);
}
@@ -182,7 +181,7 @@ void BtAdms4422::processCommand(RDMacro *cmd)
else {
if(cmd->arg(3).toInt()==-1) { // Clear input
bt_gpi_mask[cmd->arg(2).toInt()-1]=false;
bt_device->writeBlock("*0SPA",5);
bt_device->write("*0SPA",5);
}
else {
if(cmd->arg(4).toInt()==0) { // Turn ON
@@ -198,12 +197,12 @@ void BtAdms4422::processCommand(RDMacro *cmd)
if(cmd->arg(1).lower()=="o") {
if(cmd->arg(2).toInt()<=4) {
sprintf(str,"*%dOR%dL\r\n",BTADMS4422_UNIT_ID,cmd->arg(2).toInt());
bt_device->writeBlock(str,8);
bt_device->write(str,8);
}
else {
sprintf(str,"*%dOO%dL\r\n",BTADMS4422_UNIT_ID,
cmd->arg(2).toInt()-4);
bt_device->writeBlock(str,9);
bt_device->write(str,9);
}
emit gpoChanged(bt_matrix,cmd->arg(2).toInt()-1,true);
}
@@ -221,12 +220,12 @@ void BtAdms4422::processCommand(RDMacro *cmd)
if(cmd->arg(2).toInt()<=4) {
sprintf(str,"*%dOR%dP\r\n",BTADMS4422_UNIT_ID,
cmd->arg(2).toInt());
bt_device->writeBlock(str,8);
bt_device->write(str,8);
}
else {
sprintf(str,"*%dOO%dP\r\n",BTADMS4422_UNIT_ID,
cmd->arg(2).toInt()-4);
bt_device->writeBlock(str,8);
bt_device->write(str,8);
}
emit gpoChanged(bt_matrix,cmd->arg(2).toInt()-1,true);
bt_gpo_oneshot->start(cmd->arg(2).toInt()-1,500);
@@ -249,7 +248,7 @@ void BtAdms4422::processCommand(RDMacro *cmd)
}
sprintf(str,"*%d%02d%d\r\n",BTADMS4422_UNIT_ID,
cmd->arg(1).toInt(),cmd->arg(2).toInt());
bt_device->writeBlock(str,7);
bt_device->write(str,7);
cmd->acknowledge(true);
emit rmlEcho(cmd);
break;
@@ -263,7 +262,7 @@ void BtAdms4422::processCommand(RDMacro *cmd)
}
sprintf(str,"*%d%02dMA%d\r\n",BTADMS4422_UNIT_ID,
cmd->arg(1).toInt(),cmd->arg(2).toInt());
bt_device->writeBlock(str,8);
bt_device->write(str,8);
cmd->acknowledge(true);
emit rmlEcho(cmd);
break;
@@ -277,21 +276,21 @@ void BtAdms4422::processCommand(RDMacro *cmd)
}
if(cmd->arg(1).toInt()==0) {
sprintf(str,"*%dM%d\r\n",BTADMS4422_UNIT_ID,cmd->arg(2).toInt());
bt_device->writeBlock(str,6);
bt_device->write(str,6);
}
else {
sprintf(str,"*%d%02d%d\r\n",BTADMS4422_UNIT_ID,
cmd->arg(1).toInt(),cmd->arg(2).toInt());
bt_device->writeBlock(str,7);
bt_device->write(str,7);
for(int i=1;i<cmd->arg(1).toInt();i++) {
sprintf(str,"*%d%02dMA%d\r\n",BTADMS4422_UNIT_ID,
i,cmd->arg(2).toInt());
bt_device->writeBlock(str,9);
bt_device->write(str,9);
}
for(int i=cmd->arg(1).toInt()+1;i<9;i++) {
sprintf(str,"*%d%02dMA%d\r\n",BTADMS4422_UNIT_ID,
i,cmd->arg(2).toInt());
bt_device->writeBlock(str,9);
bt_device->write(str,9);
}
}
cmd->acknowledge(true);
@@ -308,15 +307,15 @@ void BtAdms4422::processCommand(RDMacro *cmd)
if(cmd->arg(2).toInt()==0) {
sprintf(str,"*%dDME%d00\r\n",BTADMS4422_UNIT_ID,
cmd->arg(1).toInt());
bt_device->writeBlock(str,10);
bt_device->write(str,10);
}
else {
sprintf(str,"*%dDML%d%d.0\r\n",BTADMS4422_UNIT_ID,
cmd->arg(1).toInt(),cmd->arg(2).toInt());
bt_device->writeBlock(str,13);
bt_device->write(str,13);
sprintf(str,"*%dDME%d01\r\n",BTADMS4422_UNIT_ID,
cmd->arg(1).toInt());
bt_device->writeBlock(str,10);
bt_device->write(str,10);
}
cmd->acknowledge(true);
emit rmlEcho(cmd);
@@ -336,7 +335,7 @@ void BtAdms4422::processStatus()
int n;
int gpi;
while((n=bt_device->readBlock(buffer,255))>0) {
while((n=bt_device->read(buffer,255))>0) {
for(int i=0;i<n;i++) {
switch(bt_istate) {
case 0:
@@ -450,7 +449,7 @@ void BtAdms4422::processStatus()
void BtAdms4422::gpiOneshotData(int value)
{
bt_gpi_mask[value]=false;
bt_device->writeBlock("*0SPA",5);
bt_device->write("*0SPA",5);
}