diff --git a/src/dialogs/confdialog.cxx b/src/dialogs/confdialog.cxx index 857209f3..8d05b8e2 100644 --- a/src/dialogs/confdialog.cxx +++ b/src/dialogs/confdialog.cxx @@ -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); diff --git a/src/dialogs/confdialog.fl b/src/dialogs/confdialog.fl index a3a741ed..74b6b15f 100644 --- a/src/dialogs/confdialog.fl +++ b/src/dialogs/confdialog.fl @@ -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);} } } diff --git a/src/include/confdialog.h b/src/include/confdialog.h index 6f9236b3..16aeb518 100644 --- a/src/include/confdialog.h +++ b/src/include/confdialog.h @@ -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; diff --git a/src/include/configuration.h b/src/include/configuration.h index 2b315808..f9dd769f 100644 --- a/src/include/configuration.h +++ b/src/include/configuration.h @@ -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", \ diff --git a/src/include/rigxml.h b/src/include/rigxml.h index 55d3a422..cc7c0734 100644 --- a/src/include/rigxml.h +++ b/src/include/rigxml.h @@ -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; diff --git a/src/include/serial.h b/src/include/serial.h index 70c0d410..0de937c6 100644 --- a/src/include/serial.h +++ b/src/include/serial.h @@ -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; }; diff --git a/src/rigcontrol/rigio.cxx b/src/rigcontrol/rigio.cxx index cbe7fd2e..acc5f106 100644 --- a/src/rigcontrol/rigio.cxx +++ b/src/rigcontrol/rigio.cxx @@ -919,8 +919,7 @@ void rigCAT_pttOFF() LOG_VERBOSE("Retries failed"); } -void rigCAT_sendINIT() -{ +void rigCAT_sendINIT(const string& icmd){ XMLIOS modeCmd; list::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(cntRigCatRetries->value()); progdefaults.RigCatTimeout = static_cast(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); diff --git a/src/rigcontrol/rigxml.cxx b/src/rigcontrol/rigxml.cxx index b083b325..caf10165 100644 --- a/src/rigcontrol/rigxml.cxx +++ b/src/rigcontrol/rigxml.cxx @@ -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[] = { {"