RigCAT INIT/CLOSE

* This modification submitted by:
    Arvo Jarve, ES1JA, <arvo@softshark.ee>
  * Added CLOSE port rigcat command
  * Added user control to enable/disable restortation
    of serial port status bits when closing port
    - use <RESTORE>bool_value</RESTORE> in xml definition
      file.
pull/1/head
David Freese 2013-02-02 12:15:56 -06:00
rodzic 5a2412115c
commit dc65247a8b
9 zmienionych plików z 79 dodań i 22 usunięć

Wyświetl plik

@ -2467,6 +2467,14 @@ btnInitRIGCAT->redraw_label();
btnRevertRIGCAT->activate();
}
Fl_Check_Button *chk_restore_tio=(Fl_Check_Button *)0;
static void cb_chk_restore_tio(Fl_Check_Button*, void*) {
btnInitRIGCAT->labelcolor(FL_RED);
btnInitRIGCAT->redraw_label();
btnRevertRIGCAT->activate();
}
Fl_Button *btnRevertRIGCAT=(Fl_Button *)0;
static void cb_btnRevertRIGCAT(Fl_Button*, void*) {
@ -6368,7 +6376,7 @@ ng)"));
} // Fl_Tabs* tabsModems
tabModems->end();
} // Fl_Group* tabModems
{ tabRig = new Fl_Group(1, 25, 598, 345, _("Rig"));
{ tabRig = new Fl_Group(0, 23, 540, 345, _("Rig"));
tabRig->tooltip(_("Transceiver control"));
tabRig->hide();
{ tabsRig = new Fl_Tabs(2, 25, 596, 345);
@ -6577,42 +6585,48 @@ ng)"));
btnRigCatCMDptt->callback((Fl_Callback*)cb_btnRigCatCMDptt);
o->value(progdefaults.RigCatCMDptt);
} // Fl_Round_Button* btnRigCatCMDptt
{ Fl_Round_Button* o = btnRigCatRTSptt = new Fl_Round_Button(102, 248, 160, 20, _("Toggle RTS for PTT"));
{ Fl_Round_Button* o = btnRigCatRTSptt = new Fl_Round_Button(70, 246, 160, 20, _("Toggle RTS for PTT"));
btnRigCatRTSptt->tooltip(_("RTS is ptt line"));
btnRigCatRTSptt->down_box(FL_DOWN_BOX);
btnRigCatRTSptt->callback((Fl_Callback*)cb_btnRigCatRTSptt);
o->value(progdefaults.RigCatRTSptt);
} // Fl_Round_Button* btnRigCatRTSptt
{ Fl_Round_Button* o = btnRigCatDTRptt = new Fl_Round_Button(308, 248, 160, 20, _("Toggle DTR for PTT"));
{ Fl_Round_Button* o = btnRigCatDTRptt = new Fl_Round_Button(276, 244, 160, 20, _("Toggle DTR for PTT"));
btnRigCatDTRptt->tooltip(_("DTR is ptt line"));
btnRigCatDTRptt->down_box(FL_DOWN_BOX);
btnRigCatDTRptt->callback((Fl_Callback*)cb_btnRigCatDTRptt);
o->value(progdefaults.RigCatDTRptt);
} // Fl_Round_Button* btnRigCatDTRptt
{ Fl_Check_Button* o = btnRigCatRTSplus = new Fl_Check_Button(102, 283, 100, 20, _("RTS +12 v"));
{ Fl_Check_Button* o = btnRigCatRTSplus = new Fl_Check_Button(70, 275, 100, 20, _("RTS +12 v"));
btnRigCatRTSplus->tooltip(_("Initial state of RTS"));
btnRigCatRTSplus->down_box(FL_DOWN_BOX);
btnRigCatRTSplus->callback((Fl_Callback*)cb_btnRigCatRTSplus);
o->value(progdefaults.RigCatRTSplus);
} // Fl_Check_Button* btnRigCatRTSplus
{ Fl_Check_Button* o = btnRigCatDTRplus = new Fl_Check_Button(308, 283, 100, 20, _("DTR +12 v"));
{ Fl_Check_Button* o = btnRigCatDTRplus = new Fl_Check_Button(276, 272, 100, 20, _("DTR +12 v"));
btnRigCatDTRplus->tooltip(_("Initial state of DTR"));
btnRigCatDTRplus->down_box(FL_DOWN_BOX);
btnRigCatDTRplus->callback((Fl_Callback*)cb_btnRigCatDTRplus);
o->value(progdefaults.RigCatDTRplus);
} // Fl_Check_Button* btnRigCatDTRplus
{ Fl_Check_Button* o = chkRigCatRTSCTSflow = new Fl_Check_Button(102, 318, 170, 20, _("RTS/CTS flow control"));
{ Fl_Check_Button* o = chkRigCatRTSCTSflow = new Fl_Check_Button(70, 303, 170, 20, _("RTS/CTS flow control"));
chkRigCatRTSCTSflow->tooltip(_("Rig uses RTS/CTS handshake"));
chkRigCatRTSCTSflow->down_box(FL_DOWN_BOX);
chkRigCatRTSCTSflow->callback((Fl_Callback*)cb_chkRigCatRTSCTSflow);
o->value(progdefaults.RigCatRTSCTSflow);
} // Fl_Check_Button* chkRigCatRTSCTSflow
{ Fl_Check_Button* o = chk_restore_tio = new Fl_Check_Button(70, 332, 205, 20, _("Restore Settings on Close"));
chk_restore_tio->tooltip(_("Restore the serial (COM) port settings"));
chk_restore_tio->down_box(FL_DOWN_BOX);
chk_restore_tio->callback((Fl_Callback*)cb_chk_restore_tio);
o->value(progdefaults.RigCatRestoreTIO);
} // Fl_Check_Button* chk_restore_tio
{ btnRevertRIGCAT = new Fl_Button(417, 287, 113, 24, _("Revert"));
btnRevertRIGCAT->tooltip(_("Initialize hamlib interface"));
btnRevertRIGCAT->callback((Fl_Callback*)cb_btnRevertRIGCAT);
btnRevertRIGCAT->deactivate();
} // Fl_Button* btnRevertRIGCAT
{ Fl_Check_Button* o = chkRigCatVSP = new Fl_Check_Button(308, 313, 100, 25, _("VSP Enable"));
{ Fl_Check_Button* o = chkRigCatVSP = new Fl_Check_Button(276, 300, 100, 25, _("VSP Enable"));
chkRigCatVSP->tooltip(_("Virtual Serial Port Emulator - suppress WARNINGS"));
chkRigCatVSP->down_box(FL_DOWN_BOX);
chkRigCatVSP->callback((Fl_Callback*)cb_chkRigCatVSP);

Wyświetl plik

@ -2788,8 +2788,8 @@ progdefaults.changed = true;}
}
}
Fl_Group tabRig {
label Rig
tooltip {Transceiver control} xywh {1 25 598 345} hide
label Rig open
tooltip {Transceiver control} xywh {0 23 540 345} hide
} {
Fl_Tabs tabsRig {open
xywh {2 25 596 345} selection_color 50
@ -3063,7 +3063,7 @@ btnRevertRIGCAT->activate();}
btnInitRIGCAT->labelcolor(FL_RED);
btnInitRIGCAT->redraw_label();
btnRevertRIGCAT->activate();}
tooltip {RTS is ptt line} xywh {102 248 160 20} down_box DOWN_BOX
tooltip {RTS is ptt line} xywh {70 246 160 20} down_box DOWN_BOX
code0 {o->value(progdefaults.RigCatRTSptt);}
}
Fl_Round_Button btnRigCatDTRptt {
@ -3076,7 +3076,7 @@ btnRevertRIGCAT->activate();}
btnInitRIGCAT->labelcolor(FL_RED);
btnInitRIGCAT->redraw_label();
btnRevertRIGCAT->activate();}
tooltip {DTR is ptt line} xywh {308 248 160 20} down_box DOWN_BOX
tooltip {DTR is ptt line} xywh {276 244 160 20} down_box DOWN_BOX
code0 {o->value(progdefaults.RigCatDTRptt);}
}
Fl_Check_Button btnRigCatRTSplus {
@ -3084,7 +3084,7 @@ btnRevertRIGCAT->activate();}
callback {btnInitRIGCAT->labelcolor(FL_RED);
btnInitRIGCAT->redraw_label();
btnRevertRIGCAT->activate();}
tooltip {Initial state of RTS} xywh {102 283 100 20} down_box DOWN_BOX
tooltip {Initial state of RTS} xywh {70 275 100 20} down_box DOWN_BOX
code0 {o->value(progdefaults.RigCatRTSplus);}
}
Fl_Check_Button btnRigCatDTRplus {
@ -3092,7 +3092,7 @@ btnRevertRIGCAT->activate();}
callback {btnInitRIGCAT->labelcolor(FL_RED);
btnInitRIGCAT->redraw_label();
btnRevertRIGCAT->activate();}
tooltip {Initial state of DTR} xywh {308 283 100 20} down_box DOWN_BOX
tooltip {Initial state of DTR} xywh {276 272 100 20} down_box DOWN_BOX
code0 {o->value(progdefaults.RigCatDTRplus);}
}
Fl_Check_Button chkRigCatRTSCTSflow {
@ -3100,9 +3100,17 @@ btnRevertRIGCAT->activate();}
callback {btnInitRIGCAT->labelcolor(FL_RED);
btnInitRIGCAT->redraw_label();
btnRevertRIGCAT->activate();}
tooltip {Rig uses RTS/CTS handshake} xywh {102 318 170 20} down_box DOWN_BOX
tooltip {Rig uses RTS/CTS handshake} xywh {70 303 170 20} down_box DOWN_BOX
code0 {o->value(progdefaults.RigCatRTSCTSflow);}
}
Fl_Check_Button chk_restore_tio {
label {Restore Settings on Close}
callback {btnInitRIGCAT->labelcolor(FL_RED);
btnInitRIGCAT->redraw_label();
btnRevertRIGCAT->activate();}
tooltip {Restore the serial (COM) port settings} xywh {70 332 205 20} down_box DOWN_BOX
code0 {o->value(progdefaults.RigCatRestoreTIO);}
}
Fl_Button btnRevertRIGCAT {
label Revert
callback {btnInitRIGCAT->labelcolor(FL_FOREGROUND_COLOR);
@ -3116,7 +3124,7 @@ rigCAT_restore_defaults();}
callback {btnInitRIGCAT->labelcolor(FL_RED);
btnInitRIGCAT->redraw_label();
btnRevertRIGCAT->activate();}
tooltip {Virtual Serial Port Emulator - suppress WARNINGS} xywh {308 313 100 25} down_box DOWN_BOX
tooltip {Virtual Serial Port Emulator - suppress WARNINGS} xywh {276 300 100 25} down_box DOWN_BOX
code0 {o->value(progdefaults.RigCatVSP);}
}
}

Wyświetl plik

@ -330,6 +330,7 @@ extern Fl_Round_Button *btnRigCatDTRptt;
extern Fl_Check_Button *btnRigCatRTSplus;
extern Fl_Check_Button *btnRigCatDTRplus;
extern Fl_Check_Button *chkRigCatRTSCTSflow;
extern Fl_Check_Button *chk_restore_tio;
#include "rigio.h"
extern Fl_Button *btnRevertRIGCAT;
extern Fl_Check_Button *chkRigCatVSP;

Wyświetl plik

@ -909,6 +909,9 @@
ELEM_(bool, RigCatVSP, "RIGCATVSP", \
"VSP support enabled", \
false) \
ELEM_(bool, RigCatRestoreTIO, "RIGCATRESTORETIO", \
"Restore original state of comm port when closing", \
false) \
/* Hamlib parameters */ \
ELEM_(bool, HamlibRTSplus, "HAMLIBRTSPLUS", \
"RTS +12", \

Wyświetl plik

@ -76,6 +76,7 @@ struct XMLRIG {
bool rts;
bool rtsptt;
bool rtscts;
bool restore_tio;
int write_delay;
int post_write_delay;
int timeout;
@ -91,6 +92,7 @@ struct XMLRIG {
rts = false;
rtsptt = false;
rtscts = false;
restore_tio = true;
echo = false;
cmdptt = false;
write_delay = 0;

Wyświetl plik

@ -52,6 +52,9 @@ public:
bool RTSCTS(){return rtscts;}
void SetPTT(bool b);
void RestoreTIO(bool b) { restore_tio = b; }
bool RestoreTIO() { return restore_tio; }
void Stopbits(int n) {stopbits = (n == 1 ? 1 : 2);}
int Stopbits() { return stopbits;}
@ -75,6 +78,7 @@ private:
bool rts;
bool rtsptt;
bool rtscts;
bool restore_tio;
int stopbits;
char bfr[2048];
//Methods
@ -157,6 +161,9 @@ public:
bool RTSCTS(){return rtscts;}
void SetPTT(bool b);
void RestoreTIO(bool b) { restore_tio = b; }
bool RestoreTIO() { return restore_tio; }
void Stopbits(int n) {stopbits = (n == 1 ? 1 : 2);}
int Stopbits() { return stopbits;}
@ -194,6 +201,7 @@ private:
bool rts;
bool rtsptt;
bool rtscts;
bool restore_tio;
int stopbits;
};

Wyświetl plik

@ -919,8 +919,7 @@ void rigCAT_pttOFF()
LOG_VERBOSE("Retries failed");
}
void rigCAT_sendINIT()
{
void rigCAT_sendINIT(const string& icmd){
XMLIOS modeCmd;
list<XMLIOS>::iterator itrCmd;
string strCmd;
@ -930,7 +929,7 @@ void rigCAT_sendINIT()
itrCmd = commands.begin();
while (itrCmd != commands.end()) {
if ((*itrCmd).SYMBOL == "INIT")
if ((*itrCmd).SYMBOL == icmd)
break;
++itrCmd;
}
@ -980,6 +979,7 @@ void rigCAT_defaults()
btnRigCatDTRplus->value(xmlrig.dtr);
btnRigCatRTSptt->value(xmlrig.rtsptt);
btnRigCatDTRptt->value(xmlrig.dtrptt);
chk_restore_tio->value(xmlrig.restore_tio);
chkRigCatRTSCTSflow->value(xmlrig.rtscts);
cntRigCatRetries->value(xmlrig.retries);
cntRigCatTimeout->value(xmlrig.timeout);
@ -997,6 +997,7 @@ void rigCAT_restore_defaults()
btnRigCatDTRplus->value(progdefaults.RigCatDTRplus);
btnRigCatRTSptt->value(progdefaults.RigCatRTSptt);
btnRigCatDTRptt->value(progdefaults.RigCatDTRptt);
chk_restore_tio->value(progdefaults.RigCatRestoreTIO);
chkRigCatRTSCTSflow->value(progdefaults.RigCatRTSCTSflow);
cntRigCatRetries->value(progdefaults.RigCatRetries);
cntRigCatTimeout->value(progdefaults.RigCatTimeout);
@ -1019,6 +1020,7 @@ void rigCAT_init_defaults()
progdefaults.RigCatDTRplus = btnRigCatDTRplus->value();
progdefaults.RigCatRTSptt = btnRigCatRTSptt->value();
progdefaults.RigCatDTRptt = btnRigCatDTRptt->value();
progdefaults.RigCatRestoreTIO = chk_restore_tio->value();
progdefaults.RigCatRTSCTSflow = chkRigCatRTSCTSflow->value();
progdefaults.RigCatRetries = static_cast<int>(cntRigCatRetries->value());
progdefaults.RigCatTimeout = static_cast<int>(cntRigCatTimeout->value());
@ -1047,6 +1049,7 @@ bool rigCAT_init(bool useXML)
rigio.DTR(progdefaults.RigCatDTRplus);
rigio.RTSptt(progdefaults.RigCatRTSptt);
rigio.DTRptt(progdefaults.RigCatDTRptt);
rigio.RestoreTIO(progdefaults.RigCatRestoreTIO);
rigio.RTSCTS(progdefaults.RigCatRTSCTSflow);
rigio.Stopbits(progdefaults.RigCatStopbits);
@ -1062,6 +1065,7 @@ initial rts: %+d\n\
use rts ptt: %c\n\
initial dtr: %+d\n\
use dtr ptt: %c\n\
restore tio: %c\n\
flowcontrol: %c\n\
echo : %c\n",
rigio.Device().c_str(),
@ -1072,6 +1076,7 @@ echo : %c\n",
progdefaults.RigCatWait,
(rigio.RTS() ? +12 : -12), (rigio.RTSptt() ? 'T' : 'F'),
(rigio.DTR() ? +12 : -12), (rigio.DTRptt() ? 'T' : 'F'),
(rigio.RestoreTIO() ? 'T' : 'F'),
(rigio.RTSCTS() ? 'T' : 'F'),
progdefaults.RigCatECHO ? 'T' : 'F');
@ -1085,6 +1090,7 @@ echo : %c\n",
sRigWidth = "";
nonCATrig = false;
rigCAT_sendINIT("INIT");
// must be able to get frequency 3 times in sequence or serial port might
// be shared with another application (flrig)
@ -1104,7 +1110,6 @@ echo : %c\n",
return false;
} else {
nonCATrig = false;
rigCAT_sendINIT();
init_Xml_RigDialog();
}
} else {
@ -1137,6 +1142,8 @@ void rigCAT_close(void)
if (rigCAT_thread == 0) return;
rigCAT_sendINIT("CLOSE");
pthread_mutex_lock(&rigCAT_mutex);
rigCAT_exit = true;
pthread_mutex_unlock(&rigCAT_mutex);

Wyświetl plik

@ -74,6 +74,7 @@ void parseRTSPLUS(size_t &);
void parseDTRPLUS(size_t &);
void parseRTSPTT(size_t &);
void parseDTRPTT(size_t &);
void parseRESTORE_TIO(size_t &);
void parseECHO(size_t &);
void parseIOSsymbol(size_t &);
@ -141,6 +142,7 @@ TAGS rigdeftags[] = {
{"<DTRPLUS", parseDTRPLUS},
{"<RTSPTT", parseRTSPTT},
{"<DTRPTT", parseDTRPTT},
{"<RESTORE_TIO", parseRESTORE_TIO},
{"<ECHO", parseECHO},
{"<CMDPTT", parseCMDPTT},
{"<STOPBITS", parseSTOPBITS},
@ -588,6 +590,14 @@ void parseDTRPTT(size_t &p0)
p0 = pend;
}
void parseRESTORE_TIO(size_t &p0)
{
bool val = getBool(p0);
xmlrig.restore_tio = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
void parseCMDPTT(size_t &p0) {
bool val = getBool(p0);
xmlrig.cmdptt = val;

Wyświetl plik

@ -54,6 +54,7 @@ Cserial::Cserial() {
status = 0;
stopbits = 2;
fd = -1;
restore_tio = true;
}
Cserial::~Cserial() {
@ -214,8 +215,10 @@ void Cserial::ClosePort()
{
if (fd < 0) return;
LOG_DEBUG("Serial port closed, fd = %d", fd);
ioctl(fd, TIOCMSET, &origstatus);
tcsetattr (fd, TCSANOW, &oldtio);
if (restore_tio) {
ioctl(fd, TIOCMSET, &origstatus);
tcsetattr (fd, TCSANOW, &oldtio);
}
close(fd);
fd = -1;
return;
@ -339,7 +342,8 @@ BOOL Cserial::OpenPort()
void Cserial::ClosePort()
{
if (hComm) {
bPortReady = SetCommTimeouts (hComm, &CommTimeoutsSaved);
if (restore_tio)
bPortReady = SetCommTimeouts (hComm, &CommTimeoutsSaved);
CloseHandle(hComm);
hComm = INVALID_HANDLE_VALUE;
}