summaryrefslogtreecommitdiffstats
path: root/servers/fpga_programming_server_lin/src
diff options
context:
space:
mode:
Diffstat (limited to 'servers/fpga_programming_server_lin/src')
-rw-r--r--servers/fpga_programming_server_lin/src/Makefile.am8
-rw-r--r--servers/fpga_programming_server_lin/src/fpga_conn.cpp78
-rw-r--r--servers/fpga_programming_server_lin/src/fpga_conn.h3
-rw-r--r--servers/fpga_programming_server_lin/src/main.cpp8
4 files changed, 13 insertions, 84 deletions
diff --git a/servers/fpga_programming_server_lin/src/Makefile.am b/servers/fpga_programming_server_lin/src/Makefile.am
index 6224e0c..bd6b9ee 100644
--- a/servers/fpga_programming_server_lin/src/Makefile.am
+++ b/servers/fpga_programming_server_lin/src/Makefile.am
@@ -1,11 +1,11 @@
INCLUDES= $(all_includes) $(KDE_INCLUDES)/tde -I/usr/include/sasl
KDE_CXXFLAGS = $(USE_EXCEPTIONS)
-bin_PROGRAMS = remotefpga_fpgaserver
+bin_PROGRAMS = remotefpga_fpgaprogserver
-remotefpga_fpgaserver_SOURCES = main.cpp fpga_conn.cpp
+remotefpga_fpgaprogserver_SOURCES = main.cpp fpga_conn.cpp
-remotefpga_fpgaserver_METASOURCES = AUTO
-remotefpga_fpgaserver_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -lktexteditor -ltdekrbsocket -ltqtrla
+remotefpga_fpgaprogserver_METASOURCES = AUTO
+remotefpga_fpgaprogserver_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -lktexteditor -ltdekrbsocket -ltqtrla
KDE_OPTIONS = nofinal
diff --git a/servers/fpga_programming_server_lin/src/fpga_conn.cpp b/servers/fpga_programming_server_lin/src/fpga_conn.cpp
index 3acd499..1ed0e09 100644
--- a/servers/fpga_programming_server_lin/src/fpga_conn.cpp
+++ b/servers/fpga_programming_server_lin/src/fpga_conn.cpp
@@ -57,7 +57,7 @@ struct exit_exception {
instance of this class.
*/
FPGASocket::FPGASocket(int sock, TQObject *parent, const char *name) :
- TDEKerberosServerSocket(parent, name), m_criticalSection(0), m_loopTimer(NULL), m_config(static_cast<FPGAServer*>(parent)->m_config) {
+ TDEKerberosServerSocket(parent, name), m_criticalSection(0), m_loopTimer(NULL), m_config(static_cast<FPGAServer*>(parent)->m_config), m_commandLoopState(0) {
setServiceName("remotefpga");
@@ -92,7 +92,6 @@ void FPGASocket::connectionClosedHandler() {
}
int FPGASocket::initiateKerberosHandshake() {
- // RAJA FIXME
setUsingKerberos(true);
while (kerberosStatus() == TDEKerberosServerSocket::KerberosInitializing) {
tqApp->processEvents();
@@ -108,80 +107,15 @@ int FPGASocket::initiateKerberosHandshake() {
}
}
-int FPGASocket::setupSerial() {
- struct termios oldtio, newtio;
-
- m_config->setGroup("FPGA");
- TQString serialDevice = m_config->readEntry("serialdevice", "/dev/ttyS0");
- TQString desiredBaudRate = m_config->readEntry("baudrate", "9600");
-
- m_fd_tty = ::open(serialDevice.ascii(), O_RDWR | O_NOCTTY | O_NONBLOCK | O_APPEND);
- if (m_fd_tty < 0) {
- printf("[FAIL] Unable to open serial device %s\n\r", serialDevice.ascii()); fflush(stdout);
- return 1;
- }
-
- tcgetattr(m_fd_tty, &oldtio); // Save current port settings
-
- long serialBaud;
- if (desiredBaudRate == "1200") {
- serialBaud = B1200;
- }
- else if (desiredBaudRate == "9600") {
- serialBaud = B9600;
- }
- else if (desiredBaudRate == "19200") {
- serialBaud = B19200;
- }
- else if (desiredBaudRate == "115200") {
- serialBaud = B115200;
- }
- else {
- printf("[WARNING] Invalid baudrate %s specified, selecting 9600 instead\n\r", desiredBaudRate.ascii()); fflush(stdout);
- serialBaud = B9600;
- }
-
- bzero(&newtio, sizeof(newtio));
- newtio.c_cflag = serialBaud | CS8 | CLOCAL | CREAD;
- newtio.c_iflag = IGNPAR;
- newtio.c_oflag = 0;
-
- // Set input mode (non-canonical, no echo,...)
- newtio.c_lflag = 0;
-
- newtio.c_cc[VTIME] = 0; // Inter-character timer unused
- newtio.c_cc[VMIN] = 0; // Blocking read unused
-
- tcflush(m_fd_tty, TCIFLUSH);
- tcsetattr(m_fd_tty, TCSANOW, &newtio);
-
- return 0;
-}
-
void FPGASocket::commandLoop() {
- int cc;
- char buffer[10000];
bool transferred_data;
m_criticalSection++;
try {
transferred_data = false;
if (state() == TQSocket::Connected) {
- cc = read(m_fd_tty, buffer, 10000);
- if (cc > 0) {
- writeBlock(buffer, cc);
- transferred_data = true;
- printf("[DEBUG] Got %d bytes from the serial port\n\r", cc); fflush(stdout);
- }
- if (canReadData()) {
- cc = readBlock(buffer, 10000);
- if (cc > 0) {
- if (write(m_fd_tty, buffer, cc) < 0) {
- // ERROR
- }
- transferred_data = true;
- printf("[DEBUG] Got %d bytes from the network interface\n\r", cc); fflush(stdout);
- }
+ if (m_commandLoopState == 0) {
+ // RAJA FIXME
}
}
m_criticalSection--;
@@ -200,6 +134,7 @@ void FPGASocket::commandLoop() {
}
int FPGASocket::enterCommandLoop() {
+ m_commandLoopState = 0;
if (!m_loopTimer) {
m_loopTimer = new TQTimer();
connect(m_loopTimer, SIGNAL(timeout()), this, SLOT(commandLoop()));
@@ -253,11 +188,6 @@ void FPGAServer::newConnection(int socket) {
ABORT_SOCKET(s)
return;
}
- if (s->setupSerial() != 0) {
- printf("[DEBUG] Connection from %s closed due to serial port initialization failure\n\r", s->m_remoteHost.ascii());
- ABORT_SOCKET(s)
- return;
- }
else {
m_numberOfConnections++;
connect(s, SIGNAL(connectionClosed()), s, SLOT(deleteLater()));
diff --git a/servers/fpga_programming_server_lin/src/fpga_conn.h b/servers/fpga_programming_server_lin/src/fpga_conn.h
index 717a35b..69c7c73 100644
--- a/servers/fpga_programming_server_lin/src/fpga_conn.h
+++ b/servers/fpga_programming_server_lin/src/fpga_conn.h
@@ -53,18 +53,17 @@ class FPGASocket : public TDEKerberosServerSocket
private slots:
void connectionClosedHandler();
- int setupSerial();
void commandLoop();
private:
int line;
int m_criticalSection;
TQString m_remoteHost;
- int m_fd_tty;
TQTimer* m_loopTimer;
KSimpleConfig* m_config;
+ int m_commandLoopState;
friend class FPGAServer;
};
diff --git a/servers/fpga_programming_server_lin/src/main.cpp b/servers/fpga_programming_server_lin/src/main.cpp
index 5a264d5..5295bc4 100644
--- a/servers/fpga_programming_server_lin/src/main.cpp
+++ b/servers/fpga_programming_server_lin/src/main.cpp
@@ -39,13 +39,13 @@
#include "fpga_conn.h"
-static const char description[] = I18N_NOOP("RemoteFPGA Kerberos Authentication Server");
+static const char description[] = I18N_NOOP("RemoteFPGA FPGA Programming Server");
static const char version[] = "v0.0.1";
int main(int argc, char *argv[])
{
- KAboutData aboutData( "remotefpga_auth_server", I18N_NOOP("RemoteFPGA AuthServer"),
+ KAboutData aboutData( "remotefpga_fpgaprog_server", I18N_NOOP("RemoteFPGA FPGA Programming Server"),
version, description, KAboutData::License_GPL,
"(c) 2012, Timothy Pearson");
aboutData.addAuthor("Timothy Pearson",0, "kb9vqf@pearsoncomputing.net");
@@ -56,9 +56,9 @@ int main(int argc, char *argv[])
KStartupInfo::appStarted();
- KSimpleConfig config(TQDir::currentDirPath() + "/remotefpga_fpgaserver.conf", false);
+ KSimpleConfig config(TQDir::currentDirPath() + "/remotefpga_fpgaprogserver.conf", false);
config.setGroup("Server");
- FPGAServer fpgasvr(0, config.readNumEntry("port", 4010), &config);
+ FPGAServer fpgasvr(0, config.readNumEntry("port", 4012), &config);
return app.exec();
}