2007-06-22 22:10:49 +00:00
|
|
|
//
|
|
|
|
// Digital Modem Program for the Fast Light Toolkit
|
|
|
|
//
|
|
|
|
// Copyright W1HKJ, Dave Freese 2006
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 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
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA.
|
|
|
|
//
|
|
|
|
// Please report all bugs and problems to "w1hkj@w1hkj.com".
|
|
|
|
//
|
2007-07-21 12:15:41 +00:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/ipc.h>
|
|
|
|
#include <sys/msg.h>
|
|
|
|
|
2007-06-22 22:10:49 +00:00
|
|
|
#include <FL/Fl_Shared_Image.H>
|
2007-06-22 22:25:46 +00:00
|
|
|
#ifdef PORTAUDIO
|
|
|
|
#include <portaudiocpp/PortAudioCpp.hxx>
|
|
|
|
#endif
|
2007-06-22 22:04:50 +00:00
|
|
|
#include "main.h"
|
|
|
|
#include "waterfall.h"
|
2007-06-22 22:10:49 +00:00
|
|
|
#include "fft.h"
|
2007-06-22 22:04:50 +00:00
|
|
|
#include "sound.h"
|
|
|
|
#include "complex.h"
|
|
|
|
#include "fl_digi.h"
|
|
|
|
#include "rigio.h"
|
|
|
|
#include "globals.h"
|
|
|
|
#include "psk.h"
|
|
|
|
#include "cw.h"
|
|
|
|
#include "mfsk.h"
|
|
|
|
#include "Config.h"
|
|
|
|
#include "configuration.h"
|
|
|
|
#include "macros.h"
|
|
|
|
#include "status.h"
|
|
|
|
|
|
|
|
#ifndef NOHAMLIB
|
|
|
|
#include "rigclass.h"
|
|
|
|
#endif
|
|
|
|
#include "rigsupport.h"
|
|
|
|
|
|
|
|
#include "log.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
string scDevice = "/dev/dsp1";
|
|
|
|
char szHomedir[120] = "";
|
2007-06-22 22:10:49 +00:00
|
|
|
char szPskMailDir[120] = "";
|
|
|
|
string PskMailDir;
|
|
|
|
string PskMailFile;
|
2007-07-21 12:15:41 +00:00
|
|
|
string ArqFilename;
|
2007-06-22 22:04:50 +00:00
|
|
|
string HomeDir;
|
|
|
|
string xmlfname;
|
|
|
|
|
2007-06-22 22:25:46 +00:00
|
|
|
bool gmfskmail = false;
|
|
|
|
|
2007-06-22 22:04:50 +00:00
|
|
|
PTT *push2talk = (PTT *)0;
|
|
|
|
#ifndef NOHAMLIB
|
|
|
|
Rig *xcvr = (Rig *)0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
cLogfile *logfile = 0;;
|
|
|
|
|
|
|
|
cLogfile *Maillogfile = (cLogfile *)0;
|
|
|
|
FILE *server;
|
|
|
|
FILE *client;
|
2007-07-21 12:15:41 +00:00
|
|
|
bool mailserver = false, mailclient = false, arqmode = false;
|
2007-06-22 22:04:50 +00:00
|
|
|
extern void start_pskmail();
|
|
|
|
|
2007-07-21 12:15:41 +00:00
|
|
|
RXMSGSTRUC rxmsgst;
|
|
|
|
int rxmsgid = -1;
|
2007-06-22 22:04:50 +00:00
|
|
|
|
2007-07-21 12:15:41 +00:00
|
|
|
TXMSGSTRUC txmsgst;
|
|
|
|
int txmsgid = -1;
|
2007-06-22 22:25:46 +00:00
|
|
|
|
2007-07-21 12:15:41 +00:00
|
|
|
void arqchecks()
|
|
|
|
{
|
|
|
|
txmsgid = msgget( (key_t) 6789, 0666 );
|
|
|
|
if (txmsgid != -1)
|
|
|
|
return;
|
2007-06-22 22:04:50 +00:00
|
|
|
|
2007-06-22 22:10:49 +00:00
|
|
|
fl_filename_expand(szPskMailDir, 119, "$HOME/pskmail.files/");
|
|
|
|
PskMailDir = szPskMailDir;
|
|
|
|
PskMailFile = PskMailDir;
|
|
|
|
PskMailFile += "PSKmailserver";
|
|
|
|
ifstream testFile;
|
|
|
|
testFile.open(PskMailFile.c_str());
|
|
|
|
if (testFile.is_open()) {
|
2007-06-22 22:04:50 +00:00
|
|
|
mailserver = true;
|
2007-06-22 22:10:49 +00:00
|
|
|
testFile.close();
|
|
|
|
} else {
|
|
|
|
PskMailFile = PskMailDir;
|
|
|
|
PskMailFile += "PSKmailclient";
|
|
|
|
testFile.open(PskMailFile.c_str());
|
|
|
|
if (testFile.is_open()) {
|
|
|
|
mailclient = true;
|
|
|
|
testFile.close();
|
|
|
|
} else {
|
|
|
|
PskMailDir = "./";
|
|
|
|
PskMailFile = PskMailDir;
|
|
|
|
PskMailFile += "PSKmailserver";
|
|
|
|
testFile.open(PskMailFile.c_str());
|
|
|
|
if (testFile.is_open()) {
|
|
|
|
mailserver = true;
|
|
|
|
testFile.close();
|
|
|
|
gmfskmail = true;
|
|
|
|
} else {
|
|
|
|
PskMailFile = PskMailDir;
|
|
|
|
PskMailFile += "PSKmailclient";
|
|
|
|
testFile.open(PskMailFile.c_str());
|
|
|
|
if (testFile.is_open()) {
|
|
|
|
mailclient = true;
|
|
|
|
testFile.close();
|
|
|
|
gmfskmail = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-06-22 22:04:50 +00:00
|
|
|
}
|
2007-07-21 12:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char ** argv) {
|
|
|
|
|
|
|
|
fl_filename_expand(szHomedir, 119, "$HOME/.fldigi/");
|
|
|
|
if (fl_filename_isdir(szHomedir) == 0)
|
|
|
|
HomeDir = "./";
|
|
|
|
else
|
|
|
|
HomeDir = szHomedir;
|
|
|
|
xmlfname = HomeDir;
|
|
|
|
xmlfname.append("rig.xml");
|
|
|
|
|
|
|
|
string lfname = HomeDir;
|
|
|
|
lfname.append("fldigi.log");
|
|
|
|
logfile = new cLogfile(lfname);
|
|
|
|
logfile->log_to_file_start();
|
|
|
|
|
|
|
|
arqchecks();
|
2007-06-22 22:10:49 +00:00
|
|
|
|
2007-06-22 22:04:50 +00:00
|
|
|
Fl::lock(); // start the gui thread!!
|
|
|
|
Fl::visual(FL_RGB); // insure 24 bit color operation
|
|
|
|
fl_register_images();
|
2007-06-22 22:19:01 +00:00
|
|
|
Fl::set_fonts(0);
|
2007-06-22 22:25:46 +00:00
|
|
|
|
2007-06-22 22:04:50 +00:00
|
|
|
rigcontrol = createRigDialog();
|
|
|
|
create_fl_digi_main();
|
2007-06-22 22:24:50 +00:00
|
|
|
|
2007-06-22 22:04:50 +00:00
|
|
|
createConfig();
|
|
|
|
macros.loadDefault();
|
|
|
|
|
|
|
|
#ifndef NOHAMLIB
|
|
|
|
xcvr = new Rig();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
push2talk = new PTT();
|
|
|
|
|
|
|
|
if (progdefaults.openDefaults())
|
|
|
|
push2talk->reset( progdefaults.btnPTTis,
|
|
|
|
progdefaults.btnRTSDTRis,
|
|
|
|
progdefaults.btnPTTREVis );
|
|
|
|
|
2007-06-22 22:25:46 +00:00
|
|
|
#ifndef PORTAUDIO
|
2007-06-22 22:26:36 +00:00
|
|
|
scDevice = progdefaults.SCdevice;
|
2007-06-22 22:25:46 +00:00
|
|
|
#else
|
2007-06-22 22:26:36 +00:00
|
|
|
if (progdefaults.btnAudioIOis == 0)
|
|
|
|
scDevice = progdefaults.OSSdevice;
|
|
|
|
else if (progdefaults.btnAudioIOis == 1)
|
|
|
|
scDevice = progdefaults.PAdevice;
|
2007-06-22 22:25:46 +00:00
|
|
|
#endif
|
|
|
|
|
2007-06-22 22:26:36 +00:00
|
|
|
glob_t gbuf;
|
|
|
|
glob("/dev/dsp*", 0, NULL, &gbuf);
|
|
|
|
for (size_t i = 0; i < gbuf.gl_pathc; i++)
|
|
|
|
menuOSSDev->add(gbuf.gl_pathv[i]);
|
|
|
|
globfree(&gbuf);
|
|
|
|
|
2007-06-22 22:25:46 +00:00
|
|
|
#ifdef PORTAUDIO
|
2007-06-22 22:26:36 +00:00
|
|
|
portaudio::AutoSystem autoSys;
|
|
|
|
portaudio::System &sys = portaudio::System::instance();
|
|
|
|
for (portaudio::System::DeviceIterator idev = sys.devicesBegin();
|
|
|
|
idev != sys.devicesEnd(); ++idev) {
|
|
|
|
string s;
|
|
|
|
s.append(idev->hostApi().name()).append("/").append(idev->name());
|
|
|
|
string::size_type i = s.find('/') + 1;
|
|
|
|
|
|
|
|
// backslash-escape any slashes in the device name
|
|
|
|
while ((i = s.find('/', i)) != string::npos) {
|
|
|
|
s.insert(i, 1, '\\');
|
|
|
|
i += 2;
|
|
|
|
}
|
|
|
|
menuPADev->add(s.c_str());
|
|
|
|
}
|
|
|
|
btnAudioIO[1]->activate();
|
2007-06-22 22:25:46 +00:00
|
|
|
#endif
|
|
|
|
|
2007-06-22 22:26:36 +00:00
|
|
|
glob("/dev/mixer*", 0, NULL, &gbuf);
|
|
|
|
for (size_t i = 0; i < gbuf.gl_pathc; i++)
|
|
|
|
menuMix->add(gbuf.gl_pathv[i]);
|
|
|
|
globfree(&gbuf);
|
2007-06-22 22:25:46 +00:00
|
|
|
|
|
|
|
if (progdefaults.MXdevice == "") {
|
|
|
|
int n = 0;
|
|
|
|
progdefaults.MXdevice = "/dev/mixer";
|
|
|
|
if (sscanf(progdefaults.SCdevice.c_str(), "/dev/dsp%d", &n) == 1)
|
|
|
|
progdefaults.MXdevice += n;
|
|
|
|
menuMix->value(progdefaults.MXdevice.c_str());
|
|
|
|
}
|
|
|
|
|
2007-06-22 22:26:36 +00:00
|
|
|
resetMixerControls();
|
2007-06-22 22:25:46 +00:00
|
|
|
|
2007-06-22 22:04:50 +00:00
|
|
|
trx_start(scDevice.c_str());
|
|
|
|
|
|
|
|
progdefaults.initInterface();
|
|
|
|
|
2007-06-22 22:26:36 +00:00
|
|
|
fl_digi_main->show();
|
|
|
|
|
2007-06-22 22:19:01 +00:00
|
|
|
progStatus.initLastState();
|
|
|
|
wf->opmode();
|
|
|
|
|
2007-06-22 22:04:50 +00:00
|
|
|
if (mailserver || mailclient) {
|
2007-06-22 22:10:49 +00:00
|
|
|
std::cout << "Starting pskmail transport layer" << std::endl; fflush(stdout);
|
|
|
|
string PskMailLogName = PskMailDir;
|
|
|
|
|
2007-07-21 12:15:41 +00:00
|
|
|
if (gmfskmail == true)
|
2007-06-22 22:10:49 +00:00
|
|
|
PskMailLogName += "gMFSK.log";
|
2007-07-21 12:15:41 +00:00
|
|
|
else
|
|
|
|
PskMailLogName += "mail-io.log";
|
2007-06-22 22:10:49 +00:00
|
|
|
|
|
|
|
Maillogfile = new cLogfile(PskMailLogName.c_str());
|
2007-06-22 22:04:50 +00:00
|
|
|
Maillogfile->log_to_file_start();
|
|
|
|
}
|
2007-07-21 12:15:41 +00:00
|
|
|
Fl::add_timeout(1.0, pskmail_loop);
|
2007-06-22 22:04:50 +00:00
|
|
|
|
|
|
|
return Fl::run();
|
2007-06-22 22:10:49 +00:00
|
|
|
}
|
|
|
|
|