From 7f6ec361a14f301bde69a58731b522782f54f443 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Thu, 23 Aug 2018 17:28:53 +0000 Subject: [PATCH] 2018-06-23 Fred Gleason * Fixed a regression that broke processing of the 'Serial Out' ['SO'] and 'UDP Out' ['UO'] RMLs. --- ChangeLog | 3 +++ lib/rdconf.cpp | 39 ++++++++++++++++++++------------------- lib/rdconf.h | 2 +- ripcd/local_macros.cpp | 15 ++++++--------- 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index d1ac551d..6e166e93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17512,3 +17512,6 @@ switcher/gpio driver. 2018-06-23 Fred Gleason * Fixed a regression in ripcd(8) that broke local RML processing. +2018-06-23 Fred Gleason + * Fixed a regression that broke processing of the 'Serial Out' ['SO'] + and 'UDP Out' ['UO'] RMLs. diff --git a/lib/rdconf.cpp b/lib/rdconf.cpp index e4b2b8d6..bee9b0d8 100644 --- a/lib/rdconf.cpp +++ b/lib/rdconf.cpp @@ -1158,48 +1158,49 @@ bool RDModulesActive() return RDProcessActive(cmds); } -/* + QByteArray RDStringToData(const QString &str) { - QByteArray ret; -#ifndef WIN32 int istate=0; - QString hexcode=""; + unsigned n; + QString code; + QByteArray ret; + bool ok=false; - for(unsigned i=0;i9)) { + istate=0; + } + code=str.mid(i,1); istate=2; break; case 2: - hexcode+=str.at(i); - ret.resize(ret.size()+1); - ret[ret.size()-1]=0xFF&hexcode.toUInt(NULL,16); - istate=0; - break; - - default: + n=str.mid(i,1).toUInt(&ok); + if((!ok)||(n>9)) { + istate=0; + } + code+=str.mid(i,1); + ret+=code.toUInt(NULL,16); istate=0; break; } } -#endif // WIN32 + return ret; } -*/ QList RDGetPids(const QString &program) diff --git a/lib/rdconf.h b/lib/rdconf.h index 01eb65b8..887eaa7a 100644 --- a/lib/rdconf.h +++ b/lib/rdconf.h @@ -113,7 +113,7 @@ QColor RDGetTextColor(const QColor &background_color); bool RDProcessActive(const QString &cmd); bool RDProcessActive(const QStringList &cmds); bool RDModulesActive(); -//QByteArray RDStringToData(const QString &str); +QByteArray RDStringToData(const QString &str); QList RDGetPids(const QString &program); #endif // RDCONF_H diff --git a/ripcd/local_macros.cpp b/ripcd/local_macros.cpp index b6a32e2c..487649a9 100644 --- a/ripcd/local_macros.cpp +++ b/ripcd/local_macros.cpp @@ -671,7 +671,7 @@ void MainObject::RunLocalMacros(RDMacro *rml_in) break; } break; - /* + case RDMacro::SO: tty_port=rml->arg(0).toInt(); if((tty_port<0)||(tty_port>MAX_TTYS)) { @@ -707,12 +707,12 @@ void MainObject::RunLocalMacros(RDMacro *rml_in) break; } data=RDStringToData(str); - ripcd_tty_dev[tty_port]->writeBlock((const char *)data,data.size()); + ripcd_tty_dev[tty_port]->write(data); rml->acknowledge(true); sendRml(rml); return; break; - */ + case RDMacro::CL: case RDMacro::FS: case RDMacro::GO: @@ -855,7 +855,7 @@ void MainObject::RunLocalMacros(RDMacro *rml_in) sendRml(rml); } break; - /* + case RDMacro::UO: if(rml->argQuantity()<3) { if(rml->echoRequested()) { @@ -886,17 +886,14 @@ void MainObject::RunLocalMacros(RDMacro *rml_in) sprintf("Sending \"%s\" to %s:%d",(const char *)str, (const char *)addr.toString(),rml->arg(1).toInt())); data=RDStringToData(str); - ripcd_rml_send->writeBlock((const char *)data,data.size(),addr, - (Q_UINT16)(rml->arg(1).toInt())); + ripcd_rml_send->writeDatagram(data,addr,(Q_UINT16)(rml->arg(1).toInt())); if(rml->echoRequested()) { rml->acknowledge(true); sendRml(rml); } break; - */ + default: -// LogLine(RDConfig::LogDebug,QString().sprintf("unhandled rml: \'%s\' from %s", -// (const char *)logstr,(const char *)rml->address())); break; } }