* auto i/o - Added socket interface to allow separate program to access
    - CONNECT
    - DISCONNECT
    - CONNECTION_STATE
    - SEND_TEXT
    - RECEIVE_TEXT
    Allows similarly modified flmsg to send/recv messages using
    flarq / ARQ transport protocol.
  * ARQ reset - force complete reset of all ARQ processes
    - drops link without any indicator to connected station
    - equivalent of stopping and restarting flarq
    - courtesy demands that you inform the CONNECTED station
      to also kill the connection at that end of the link.
    - use Control-Left_click on the "CONNECT / DISCONNECT"
      button to initiate the forced reset.
  * Update ARQ icons
  * Disable auto-open flmsg when flmsg->flarq->fldigi data path
    is active.
pull/4/head
David Freese 2016-04-12 13:38:23 -05:00
rodzic 9c04f07877
commit 76ab77cd0c
13 zmienionych plików z 3077 dodań i 1148 usunięć

2287
data/flarq.pdf 100644

File diff suppressed because one or more lines are too long

Plik diff jest za duży Load Diff

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 12 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 361 KiB

Wyświetl plik

@ -35,19 +35,25 @@ $EXTRA_LIBS $FLXMLRPC_LIBS"
# CPPFLAGS
FLARQ_BUILD_CPPFLAGS="-I\$(srcdir) -I\$(srcdir)/include -I\$(srcdir)/fileselector \
-I\$(srcdir)/flarq-src -I\$(srcdir)/flarq-src/include"
if test "x$ac_cv_flxmlrpc" != "xyes"; then
FLARQ_BUILD_CPPFLAGS="$FLARQ_BUILD_CPPFLAGS -I\$(srcdir)/xmlrpcpp"
fi
# CXXFLAGS
FLARQ_BUILD_CXXFLAGS="$FLTK_CFLAGS $X_CFLAGS $MAC_UNIVERSAL_CFLAGS $INTL_CFLAGS $PTW32_CFLAGS \
$BFD_CFLAGS -pipe -Wall -fexceptions $OPT_CFLAGS $DEBUG_CFLAGS"
if test "x$target_mingw32" = "xyes"; then
FLARQ_BUILD_CXXFLAGS="-mthreads $FLARQ_BUILD_CXXFLAGS"
fi
if test "x$ac_cv_flxmlrpc" != "xyes"; then
FLARQ_BUILD_CXXFLAGS="$FLARQ_BUILD_CXXFLAGS -I\$(srcdir)/xmlrpcpp"
fi
# LDFLAGS
FLARQ_BUILD_LDFLAGS="$MAC_UNIVERSAL_LDFLAGS"
if test "x$target_mingw32" = "xyes"; then
FLARQ_BUILD_LDFLAGS="-mthreads $FLARQ_BUILD_LDFLAGS"
fi
# LDADD
FLARQ_BUILD_LDADD="$FLTK_LIBS $X_LIBS $INTL_LIBS $PTW32_LIBS $BFD_LIBS $EXTRA_LIBS"
FLARQ_BUILD_LDADD="$FLTK_LIBS $X_LIBS $INTL_LIBS $PTW32_LIBS $BFD_LIBS $EXTRA_LIBS $FLXMLRPC_LIBS"
if test "x$ac_cv_debug" = "xyes"; then
FLDIGI_BUILD_CXXFLAGS="$FLDIGI_BUILD_CXXFLAGS -UNDEBUG"

Wyświetl plik

@ -35,16 +35,25 @@ include/hamlib.h \
rigcontrol/hamlib.cxx \
include/rigclass.h \
rigcontrol/rigclass.cxx
XMLRPC_SRC = \
include/xmlrpc.h \
misc/xmlrpc.cxx
FLDIGI_WIN32_RES_SRC = fldigirc.rc
FLARQ_WIN32_RES_SRC = flarq-src/flarqrc.rc
COMMON_WIN32_RES_SRC = common.rc
BENCHMARK_SRC = include/benchmark.h misc/benchmark.cxx
REGEX_SRC = compat/regex.h compat/regex.c
STACK_SRC = include/stack.h misc/stack.cxx
MINGW32_SRC = include/compat.h compat/getsysinfo.c compat/mingw.c compat/mingw.h
NLS_SRC = misc/nls.cxx include/nls.h
# We distribute these but do not always compile them
@ -77,7 +86,7 @@ XMLRPCPP_SRC = \
EXTRA_fldigi_SOURCES = $(HAMLIB_SRC) $(XMLRPC_SRC) $(FLDIGI_WIN32_RES_SRC) $(COMMON_WIN32_RES_SRC) \
$(BENCHMARK_SRC) $(REGEX_SRC) $(STACK_SRC) $(MINGW32_SRC) $(NLS_SRC) $(XMLRPCPP_SRC)
EXTRA_flarq_SOURCES = $(FLARQ_WIN32_RES_SRC) $(COMMON_WIN32_RES_SRC)
EXTRA_flarq_SOURCES = $(FLARQ_WIN32_RES_SRC) $(COMMON_WIN32_RES_SRC) $(XMLRPCPP_SRC)
fldigi_SOURCES =
flarq_SOURCES =
@ -86,11 +95,16 @@ fldigi_SOURCES += $(XMLRPC_SRC)
if !ENABLE_FLXMLRPC
fldigi_SOURCES += $(XMLRPCPP_SRC)
flarq_SOURCES += $(XMLRPCPP_SRC)
else
fldigi_CPPFLAGS += @FLXMLRPC_CFLAGS@
fldigi_CXXFLAGS += @FLXMLRPC_CFLAGS@
fldigi_CFLAGS += @FLXMLRPC_CFLAGS@
fldigi_LDFLAGS += @FLXMLRPC_LIBS@
flarq_CPPFLAGS += @FLXMLRPC_CFLAGS@
flarq_CXXFLAGS += @FLXMLRPC_CFLAGS@
flarq_CFLAGS += @FLXMLRPC_CFLAGS@
flarq_LDFLAGS += @FLXMLRPC_LIBS@
endif
if ENABLE_HAMLIB
@ -734,11 +748,13 @@ flarq_SOURCES += \
flarq-src/b64.cxx \
flarq-src/flarq.cxx \
flarq-src/flarqenv.cxx \
flarq-src/xml_server.cxx \
flarq-src/include/arq.h \
flarq-src/include/arqdialogs.h \
flarq-src/include/b64.h \
flarq-src/include/flarq.h \
flarq-src/include/flarqenv.h \
flarq-src/include/xml_server.h \
include/Fl_Text_Display_mod.H \
include/Fl_Text_Editor_mod.H \
include/FTextView.h \

Wyświetl plik

@ -280,7 +280,7 @@ void arq::connectFrame()
addToTxQue(Frame);
LinkState = CONNECTING;
LinkState = ARQ_CONNECTING;
printSTATUS(TXCONNECT, 5.0);
}
@ -411,7 +411,7 @@ void arq::pingFrame()
// talk frame
// similar to UNPROTO frame
// but only sent if CONNECTED
// but only sent if ARQ_CONNECTED
void arq::talkFrame(string txt)
{
IdHeader();
@ -603,7 +603,7 @@ void arq::parseCONREQ()
size_t p1 = 0, p2 = rcvPayload.find(':');
if (p2 == string::npos)
return;
// if (LinkState == CONNECTED || LinkState == WAITFORACK) return; // disallow multiple connects
// if (LinkState == ARQ_CONNECTED || LinkState == WAITFORACK) return; // disallow multiple connects
// requesting stations callsign
UrCall = upcase(rcvPayload.substr(p1, p2 - p1));
@ -676,7 +676,7 @@ void arq::parseCONREQ()
if (rxUrCall) rxUrCall(UrCall);
TxTextQueue.clear();//erase();
TxTextQueue.clear();
ackFrame();
immediate = true;
printSTATUS(RXCONREQ, 5.0);
@ -685,7 +685,7 @@ void arq::parseCONREQ()
void arq::parseCONACK()
{
if (LinkState < CONNECTING ) { //!= CONNECTING) {
if (LinkState < ARQ_CONNECTING ) { //!= ARQ_CONNECTING) {
return; // Connect Acknowledge only valid during a connect
}
@ -716,7 +716,7 @@ void arq::parseCONACK()
RxTextQueue.clear();//erase();
LinkState = CONNECTED;
LinkState = ARQ_CONNECTED;
timeout = Timeout / ARQLOOPTIME;
statFrame();
@ -753,14 +753,14 @@ void arq::parseABORT()
if (abortfnc) abortfnc();
ackAbortFrame();
immediate = true;
LinkState = CONNECTED;
LinkState = ARQ_CONNECTED;
}
void arq::parseACKABORT()
{
reset();
if (abortfnc) abortfnc();
LinkState = CONNECTED;
LinkState = ARQ_CONNECTED;
}
void arq::parseUNPROTO()
@ -787,7 +787,7 @@ void arq::parseSTATUS()
{
// create the missing list
// all reported missing blocks
if (LinkState >= CONNECTED) {
if (LinkState >= ARQ_CONNECTED) {
UrLastHeader = rcvPayload[0] - 0x20; // Other station's Header last sent
UrGoodHeader = rcvPayload[1] - 0x20; // Other station's Good Header
UrEndHeader = rcvPayload[2] - 0x20; // Other station's last received Header
@ -846,19 +846,19 @@ void arq::parseSTATUS()
switch (LinkState) {
case WAITFORACK :
LinkState = CONNECTED;
LinkState = ARQ_CONNECTED;
break;
case DISCONNECTING :
if (rxUrCall) rxUrCall("");
LinkState = DOWN;
break;
case WAITING :
LinkState = CONNECTED;
LinkState = ARQ_CONNECTED;
break;
// case ABORTING :
// reset();
// if (abortfnc) abortfnc();
// LinkState = CONNECTED;
// LinkState = ARQ_CONNECTED;
// break;
// case ABORT :
// break;
@ -876,7 +876,7 @@ void arq::parsePOLL()
statFrame();
immediate = true;
LinkState = CONNECTED;
LinkState = ARQ_CONNECTED;
printSTATUS(RXPOLL, 5.0);
}
@ -885,7 +885,7 @@ void arq::parseDATA()
vector<cTxtBlk>::iterator p1, p2;
int n1, n2;
if (LinkState < CONNECTED) return; // do not respond if DOWN or TIMEDOUT
if (LinkState < ARQ_CONNECTED) return; // do not respond if DOWN or TIMEDOUT
for (p1 = RxPending.begin(); p1 < RxPending.end(); p1++)
if (blknbr == p1->nbr()) {
@ -988,7 +988,7 @@ int arq::parseFrame(string txt)
// treat unproto TALK as a special case
// no effort made to confirm the data by the CRC value
if (fID == _TALK) {
if (LinkState >= CONNECTED) {
if (LinkState >= ARQ_CONNECTED) {
timeout = Timeout / ARQLOOPTIME;
parseTALK();
retries = Retries;
@ -1108,7 +1108,7 @@ int arq::parseFrame(string txt)
}
if (LinkState == CONNECTED)
if (LinkState == ARQ_CONNECTED)
timeout = Timeout / ARQLOOPTIME;
return fID;
@ -1152,7 +1152,7 @@ void arq::sendText (string txt)
{
size_t offset = 0;
cTxtBlk tempblk;
if (LinkState < CONNECTED) return;
if (LinkState < ARQ_CONNECTED) return;
Blocks2Send = 0;
while (offset < txt.length()) {
@ -1215,7 +1215,7 @@ void arq::connect(string callsign)
if (rxUrCall) rxUrCall(UrCall);
TxTextQueue.clear();
connectFrame();
LinkState = CONNECTING;
LinkState = ARQ_CONNECTING;
immediate = true;
}
@ -1310,7 +1310,7 @@ void arqloop(void *who)
me->immediate = false;
} else {
switch (me->LinkState) {
case CONNECTING :
case ARQ_CONNECTING :
break;
case DISCONNECT :
me->LinkState = DISCONNECTING;
@ -1384,7 +1384,7 @@ void arqloop(void *who)
}
break;
case CONNECTED :
case ARQ_CONNECTED :
default:
if (me->TxTextQueue.empty() == false) {
me->transmitdata();
@ -1399,7 +1399,7 @@ void arqloop(void *who)
}
me->timeout--;
if (me->timeout == 0 // 10000 / ARQLOOPTIME // 10 seconds remaining
&& me->LinkState == CONNECTED // link is connected
&& me->LinkState == ARQ_CONNECTED // link is connected
&& me->primary == true ) { // this is the connecting station
if (--me->retries) { // repeat Retries and then allow timeout
me->TxTextQueue.clear();
@ -1409,7 +1409,7 @@ void arqloop(void *who)
}
}
if (me->timeout == 0) {
if (me->LinkState == CONNECTED)
if (me->LinkState == ARQ_CONNECTED)
me->LinkState = TIMEDOUT;
else
me->LinkState = DOWN;
@ -1446,8 +1446,29 @@ void arqloop(void *who)
}
}
if (me->arqstop)
if (me->arqstop) {
me->LinkState = STOPPED;
me->arqstop = false;
me->LinkState = DOWN;
me->Retries = me->baseRetries;
me->Timeout = me->baseTimeout;
me->RetryTime = me->baseRetryTime;
me->retries = me->Retries;
me->retrytime = me->rtry();
me->TxMissing.clear();
me->TxBlocks.clear();
me->TxTextQueue.clear();
me->TxPlainTextQueue.clear();
me->timeout = me->Timeout / ARQLOOPTIME;
if (me->rxUrCall) me->rxUrCall("");
me->printSTATUS(STIMEDOUT, 10.0);
Fl::repeat_timeout( 1.0, arqloop, me);
return;
}
Fl::repeat_timeout( ARQLOOPTIME/1000.0, arqloop, me);
}
@ -1458,4 +1479,8 @@ void arq::start_arq()
Fl::add_timeout(1.0, arqloop, this);
}
void arq::restart_arq() {
arqstop = true;
}
//---------------------------------------------------------------------

Wyświetl plik

@ -77,9 +77,13 @@
#include "b64.h"
#include "gettext.h"
#include "xml_server.h"
#define FLDIGI_port "7322"
#define MPSK_port "3122"
#define FLARQ_XML_PORT 7422
#define MPSK_TX "TX"
#define MPSK_RX "RX"
#define MPSK_TX2RX "RX_AFTER_TX"
@ -946,6 +950,7 @@ void arqCLOSE()
{
tcpip->close();
saveConfig();
exit_server();
exit(0);
}
@ -974,7 +979,14 @@ void restart()
void arqCONNECT()
{
if (digi_arq->state() < CONNECTED) {
int state = Fl::event_state();
if ((state & FL_CTRL) == FL_CTRL) {
digi_arq->restart_arq();
txtURCALL->value("");
restart();
return;
}
if (digi_arq->state() < ARQ_CONNECTED) {
if (strlen(txtURCALL->value()) > 0)
digi_arq->connect(txtURCALL->value());
} else {
@ -1140,7 +1152,6 @@ void payloadText(string s)
}
if (incomingText.find(arqemail) != string::npos)
haveemail = true;
incomingText = "";
startpos = string::npos;
endpos = string::npos;
fnamepos = string::npos;
@ -1151,6 +1162,9 @@ void payloadText(string s)
rxARQfile = false;
rxARQhavesize = false;
rxTextReady = true;
if (incomingText.find("FLMSG_XFR") != std::string::npos)
xml_rx_text_ready = true;
incomingText = "";
txtStatus->value("");
prgStatus->value(0.0);
prgStatus->label("");
@ -1220,7 +1234,7 @@ void moveEmailFile()
void sendEmailFile()
{
if (arqstate < CONNECTED) {
if (arqstate < ARQ_CONNECTED) {
fl_alert2("Not connected");
return;
}
@ -1284,7 +1298,7 @@ void sendEmailFile()
void sendAsciiFile()
{
if (arqstate < CONNECTED) {
if (arqstate < ARQ_CONNECTED) {
fl_alert2("Not connected");
return;
}
@ -1336,7 +1350,7 @@ void sendAsciiFile()
void sendImageFile()
{
if (arqstate < CONNECTED) {
if (arqstate < ARQ_CONNECTED) {
fl_alert2("Not connected");
return;
}
@ -1385,7 +1399,7 @@ void sendImageFile()
void sendBinaryFile()
{
if (arqstate < CONNECTED) {
if (arqstate < ARQ_CONNECTED) {
fl_alert2("Not connected");
return;
}
@ -1432,6 +1446,43 @@ void sendBinaryFile()
sendingfile = false;
}
void send_xml_text(std::string fname, std::string txt)
{
if (arqstate < ARQ_CONNECTED) {
fl_alert2("Not connected");
return;
}
size_t txtsize;
char sizemsg[40];
if (!txt.empty()) {
TX.erase();
TX.append(arqfile);
TX.append(fname);
TX.append("\n");
TX.append(arqascii);
txtsize = txt.length();
arqPayloadSize = txtsize;
blocksSent = 0;
snprintf(sizemsg, sizeof(sizemsg), "ARQ:SIZE::%d\n",
static_cast<int>(txtsize));
TX.append(sizemsg);
TX.append(arqstart);
TX.append(txt);
TX.append(arqend);
traffic = true;
sendingfile = true;
statusmsg = "Sending XML payload: ";
statusmsg.append(fname);
txtStatus->value(statusmsg.c_str());
cbClearText();
return;
}
traffic = false;
sendingfile = false;
}
char statemsg[80];
void dispState()
@ -1450,7 +1501,7 @@ void dispState()
// mnuSend->deactivate();
mnu->redraw();
}
else if (arqstate == CONNECTED || arqstate == WAITING) {
else if (arqstate == ARQ_CONNECTED || arqstate == WAITING) {
if (btnCONNECT->active())
btnCONNECT->label("Disconnect");
if (!autobeacon)
@ -1467,7 +1518,7 @@ void dispState()
if (currstate <= 0x7F) // receiving
switch (currstate) {
case CONNECTING :
case ARQ_CONNECTING :
snprintf(statemsg, sizeof(statemsg), "CONNECTING: %d", digi_arq->getTimeLeft());
txtState->value(statemsg);
txtState->redraw();
@ -1486,7 +1537,7 @@ void dispState()
autobeacon = false;
break;
case WAITING :
case CONNECTED :
case ARQ_CONNECTED :
char szState[80];
snprintf(szState, sizeof(szState),"CONNECTED - Quality = %4.2f",
digi_arq->quality());
@ -1573,7 +1624,7 @@ void mainloop(void *)
if (rxTextReady) {
if (haveemail)
saveEmailFile();
else
else if (!xml_rx_text_ready)
saveRxFile();
}
Fl::repeat_timeout(0.1, mainloop);
@ -1893,6 +1944,8 @@ int main (int argc, char *argv[] )
arqwin->icon((char *)flarq_icon_pixmap);
#endif
start_xml_server(FLARQ_XML_PORT);
arqwin->show(argc, argv);
return Fl::run();
}

Wyświetl plik

@ -88,16 +88,30 @@ using namespace std;
#define ARQLOOPTIME 100 // # msec for loop timing
//=====================================================================
//link states
#define DOWN 0
#define TIMEDOUT 1
#define ABORT 3
#define CONNECTING 4
#define CONNECTED 5
#define WAITING 6
#define WAITFORACK 7
#define DISCONNECT 8
#define DISCONNECTING 9
#define ABORTING 10
enum LINK_STATES {
DOWN = 0,
TIMEDOUT,
ABORT,
ARQ_CONNECTING,
ARQ_CONNECTED,
WAITING,
WAITFORACK,
DISCONNECT,
DISCONNECTING,
ABORTING,
STOPPED
};
//#define DOWN 0
//#define TIMEDOUT 1
//#define ABORT 3
//#define ARQ_CONNECTING 4
//#define ARQ_CONNECTED 5
//#define WAITING 6
//#define WAITFORACK 7
//#define DISCONNECT 8
//#define DISCONNECTING 9
//#define ABORTING 10
#define SENDING 0x80;
@ -166,7 +180,7 @@ public:
class arq {
private:
bool arqstop;
bool arqstop;
string MyCall;
string UrCall;
@ -261,7 +275,6 @@ private:
// Link quality for sending *** used for testing only !! ***
// double sendquality;
void reset();
void resetTx();
void resetRx();
@ -338,6 +351,8 @@ public:
friend void arqloop(void *me);
void start_arq();
void restart_arq();
string checksum(string &s);
void myCall(string s) { MyCall = upcase(s);}
@ -391,7 +406,7 @@ public:
string getText() { return RxTextQueue;}
void sendText(string txt);
bool connected() { return (LinkState == CONNECTED); }
bool connected() { return (LinkState == ARQ_CONNECTED); }
void disconnect();
void abort();

Wyświetl plik

@ -47,10 +47,19 @@ extern long iwaittime;
extern long itimeout;
extern int bcnInterval;
// used by xmlrpc interface
extern int arqstate;
extern bool sendingfile;
extern bool rxTextReady;
extern bool rxARQfile;
extern std::string txtarqload;
extern void cb_SaveComposeMail();
extern void cb_CancelComposeMail();
extern void cb_UseTemplate();
extern void cb_OpenComposeMail();
extern void ComposeMail();
extern void send_xml_text(std::string, std::string);
#endif

Wyświetl plik

@ -0,0 +1,51 @@
// ---------------------------------------------------------------------
//
// xml_server.h, a part of flarq
//
// Copyflarqht (C) 2016
// Dave Freese, W1HKJ
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This library 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 the program; if not, write to the
//
// Free Software Foundation, Inc.
// 51 Franklin Street, Fifth Floor
// Boston, MA 02110-1301 USA.
//
// ---------------------------------------------------------------------
#ifndef XML_SERVER_H
#define XML_SERVER_H
#include <fstream>
#include <vector>
#include <string>
#include <math.h>
#ifndef WIN32
#include <sys/ipc.h>
#include <sys/msg.h>
#include <sys/shm.h>
#endif
#include "status.h"
#include <FL/fl_show_colormap.H>
#include <FL/fl_ask.H>
extern void start_xml_server(int port = 12345);
extern void exit_server();
extern bool xml_rx_text_ready;
#endif

Wyświetl plik

@ -0,0 +1,216 @@
// ---------------------------------------------------------------------
//
// xml_server.cxx, a part of flarq
//
// Copyflarqht (C) 2016
// Dave Freese, W1HKJ
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This library 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 the program; if not, write to the
//
// Free Software Foundation, Inc.
// 51 Franklin Street, Fifth Floor
// Boston, MA 02110-1301 USA.
//
// ---------------------------------------------------------------------
#include <config.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <pthread.h>
#include <FL/Fl.H>
#include <FL/Fl_Box.H>
#include <FL/Enumerations.H>
//#include "support.h"
//#include "debug.h"
#include "arq.h"
#include "flarq.h"
#include "xml_server.h"
#include "xmlrpcpp/XmlRpc.h"
using namespace XmlRpc;
// The server
XmlRpcServer flarq_server;
//----------------------------------------------------------------------
// get interface
//----------------------------------------------------------------------
bool xml_rx_text_ready = false;
//----------------------------------------------------------------------
// Request for flarq version
//----------------------------------------------------------------------
class flarq_get_version : public XmlRpcServerMethod {
public:
flarq_get_version(XmlRpcServer* s) : XmlRpcServerMethod("flarq.get_version", s) {}
void execute(XmlRpcValue& params, XmlRpcValue& result) {
result = VERSION;
}
std::string help() { return std::string("returns version number of flarq"); }
} flarq_get_version(&flarq_server);
//----------------------------------------------------------------------
// Request for ARQ state
//----------------------------------------------------------------------
class flarq_get_state : public XmlRpcServerMethod {
public:
flarq_get_state(XmlRpcServer* s) : XmlRpcServerMethod("flarq.get_state", s) {}
// x00 - unconnected
// x81 - connected
// x82 - sending
// x83 - receiving
// x84 - send completed
// x85 - recv completed
void execute(XmlRpcValue& params, XmlRpcValue& result) {
int state = 0;
if (arqstate != ARQ_CONNECTED)
state = 0;
else if (sendingfile)
state = 0x82;
else if (rxARQfile)
state = 0x83;
else if (xml_rx_text_ready)
state = 0x85;
else
state = 0x81;
result = state;
}
std::string help() { return std::string("returns state of connection"); }
} flarq_get_state(&flarq_server);
//----------------------------------------------------------------------
// Request for received text
//----------------------------------------------------------------------
class flarq_rcvd_text : public XmlRpcServerMethod {
public:
flarq_rcvd_text(XmlRpcServer* s) : XmlRpcServerMethod("flarq.rcvd_text", s) {}
void execute(XmlRpcValue& params, XmlRpcValue& result) {
std::string result_string = "none";
if (xml_rx_text_ready) result_string = txtarqload;
xml_rx_text_ready = false;
result = result_string;
txtarqload = "";
}
std::string help() { return std::string("returns received text"); }
} flarq_rcvd_text(&flarq_server);
//----------------------------------------------------------------------
// set interface
//----------------------------------------------------------------------
//------------------------------------------------------------------------------
// Send text
//------------------------------------------------------------------------------
class flarq_send_text : public XmlRpcServerMethod {
public:
flarq_send_text(XmlRpcServer* s) : XmlRpcServerMethod("flarq.send_text", s) {}
void execute(XmlRpcValue& params, XmlRpcValue &result) {
std::string txt_to_send = string(params[0]);
send_xml_text("FLMSG_XFR", txt_to_send);
}
std::string help() { return std::string("send_text"); }
} flarq_send_text(&flarq_server);
struct MLIST {
string name; string signature; string help;
} mlist[] = {
{ "flarq.rcvd_text", "s:n", "return MODE of current VFO" },
{ "flarq.get_state", "s:n", "return PTT state" },
{ "flarq.send_text", "i:i", "set MODE iaw MODE table" }
};
class flarq_list_methods : public XmlRpcServerMethod {
public:
flarq_list_methods(XmlRpcServer *s) : XmlRpcServerMethod("flarq.list_methods", s) {}
void execute(XmlRpcValue& params, XmlRpcValue& result) {
vector<XmlRpcValue> methods;
for (size_t n = 0; n < sizeof(mlist) / sizeof(*mlist); ++n) {
XmlRpcValue::ValueStruct item;
item["name"] = mlist[n].name;
item["signature"] = mlist[n].signature;
item["help"] = mlist[n].help;
methods.push_back(item);
}
result = methods;
}
std::string help() { return std::string("get flarq methods"); }
} flarq_list_methods(&flarq_server);
//------------------------------------------------------------------------------
// support thread xmlrpc clients
//------------------------------------------------------------------------------
pthread_t *xml_thread = 0;
void * xml_thread_loop(void *d)
{
for(;;) {
flarq_server.work(-1.0);
}
return NULL;
}
void start_xml_server(int port)
{
XmlRpc::setVerbosity(0);
// Create the server socket on the specified port
flarq_server.bindAndListen(port);
// Enable introspection
flarq_server.enableIntrospection(true);
xml_thread = new pthread_t;
if (pthread_create(xml_thread, NULL, xml_thread_loop, NULL)) {
perror("pthread_create");
exit(EXIT_FAILURE);
}
}
void exit_server()
{
flarq_server.exit();
}

Wyświetl plik

@ -62,13 +62,14 @@ Save tags and all enclosed text to date-time stamped file, ie:\n\
~/.nbems/WRAP/recv/extract-20090127-092515.wrap");
#endif
#define bufsize 16
#define bufsize 32
char rx_extract_buff[bufsize + 1];
string rx_buff;
string rx_extract_msg;
bool extract_wrap = false;
bool extract_flamp = false;
bool extract_arq = false;
bool bInit = false;
@ -81,6 +82,7 @@ void rx_extract_reset()
rx_extract_buff[bufsize] = 0;
extract_wrap = false;
extract_flamp = false;
extract_arq = false;
put_status("");
}
@ -286,16 +288,40 @@ void rx_extract_add(int c)
memmove(rx_extract_buff, &rx_extract_buff[1], bufsize - 1);
rx_extract_buff[bufsize - 1] = ch;
if ( strstr(rx_extract_buff, wrap_beg) && !extract_flamp) {
if (!extract_arq && strstr(rx_extract_buff, "ARQ:FILE::FLMSG_XFR")) {
extract_arq = true;
REQ(rx_remove_timer);
REQ(rx_add_timer);
memset(rx_extract_buff, ' ', bufsize);
rx_extract_msg = "Extracting ARQ msg";
put_status(rx_extract_msg.c_str());
return;
} else if (extract_arq) {
REQ(rx_remove_timer);
REQ(rx_add_timer);
if (strstr(rx_extract_buff, "ARQ::ETX"))
rx_extract_reset();
return;
} else if (!extract_flamp && strstr(rx_extract_buff, flamp_beg)) {
extract_flamp = true;
memset(rx_extract_buff, ' ', bufsize);
rx_extract_msg = "Extracting FLAMP";
put_status(rx_extract_msg.c_str());
return;
} else if (extract_flamp) {
REQ(rx_remove_timer);
REQ(rx_add_timer);
if (strstr(rx_extract_buff, flamp_end) != NULL)
rx_extract_reset();
return;
} else if (!extract_wrap && strstr(rx_extract_buff, wrap_beg)) {
rx_buff.assign(wrap_beg);
rx_extract_msg = "Extracting WRAP/FLMSG";
put_status(rx_extract_msg.c_str());
memset(rx_extract_buff, ' ', bufsize);
extract_wrap = true;
REQ(rx_remove_timer);
REQ(rx_add_timer);
return;
} else if (extract_wrap) {
rx_buff += ch;
REQ(rx_remove_timer);
@ -304,16 +330,6 @@ void rx_extract_add(int c)
invoke_flmsg();
rx_extract_reset();
}
} else if (strstr(rx_extract_buff, flamp_beg) && ! extract_wrap) {
extract_flamp = true;
rx_extract_msg = "Extracting FLAMP";
put_status(rx_extract_msg.c_str());
} else if (extract_flamp == true) {
REQ(rx_remove_timer);
REQ(rx_add_timer);
if (strstr(rx_extract_buff, flamp_end) != NULL) {
rx_extract_reset();
}
}
}