summaryrefslogtreecommitdiffstats
path: root/servers/fpga_server_lin/src/fpga_conn.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'servers/fpga_server_lin/src/fpga_conn.cpp')
-rw-r--r--servers/fpga_server_lin/src/fpga_conn.cpp39
1 files changed, 28 insertions, 11 deletions
diff --git a/servers/fpga_server_lin/src/fpga_conn.cpp b/servers/fpga_server_lin/src/fpga_conn.cpp
index ed4c012..fdd54fd 100644
--- a/servers/fpga_server_lin/src/fpga_conn.cpp
+++ b/servers/fpga_server_lin/src/fpga_conn.cpp
@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * (c) 2012 Timothy Pearson
+ * (c) 2012-2013 Timothy Pearson
* Raptor Engineering
* http://www.raptorengineeringinc.com
*/
@@ -63,7 +63,12 @@ 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_pollInterval(10), enableDebug(false), m_loopTimer(NULL), m_config(static_cast<FPGAServer*>(parent)->m_config) {
+
+ // Read settings
+ m_config->setGroup("Tuning");
+ m_pollInterval = m_config->readNumEntry("pollInterval", m_pollInterval);
+ enableDebug = m_config->readBoolEntry("enableDebug", enableDebug);
// Initialize timers
m_kerberosInitTimer = new TQTimer();
@@ -99,7 +104,9 @@ void FPGASocket::close() {
}
void FPGASocket::connectionClosedHandler() {
- printf("[DEBUG] Connection from %s closed\n\r", m_remoteHost.ascii());
+ if (enableDebug) {
+ printf("[DEBUG] Connection from %s closed\n\r", m_remoteHost.ascii()); fflush(stdout);
+ }
if (m_criticalSection > 0) {
throw exit_exception(-1);
@@ -124,12 +131,16 @@ void FPGASocket::finishKerberosHandshake() {
masterRealm = "(NULL)";
}
if ((m_authenticatedUserName != masterUser) || (m_authenticatedRealmName != masterRealm)) {
- printf("[DEBUG] Connection from %s closed due to authentication failure (attempted connection as user %s@%s)\n\r", m_remoteHost.ascii(), m_authenticatedUserName.ascii(), m_authenticatedRealmName.ascii());
+ if (enableDebug) {
+ printf("[DEBUG] Connection from %s closed due to authentication failure (attempted connection as user %s@%s)\n\r", m_remoteHost.ascii(), m_authenticatedUserName.ascii(), m_authenticatedRealmName.ascii()); fflush(stdout);
+ }
close();
return;
}
if (setupSerial() != 0) {
- printf("[DEBUG] Connection from %s closed due to serial port initialization failure\n\r", m_remoteHost.ascii());
+ if (enableDebug) {
+ printf("[DEBUG] Connection from %s closed due to serial port initialization failure\n\r", m_remoteHost.ascii()); fflush(stdout);
+ }
close();
return;
}
@@ -143,7 +154,9 @@ void FPGASocket::finishKerberosHandshake() {
return;
}
else {
- printf("[DEBUG] Connection from %s closed due to Kerberos failure\n\r", m_remoteHost.ascii()); fflush(stdout);
+ if (enableDebug) {
+ printf("[DEBUG] Connection from %s closed due to Kerberos failure\n\r", m_remoteHost.ascii()); fflush(stdout);
+ }
close();
return;
}
@@ -214,7 +227,9 @@ void FPGASocket::commandLoop() {
writeBlock(buffer, cc);
flush();
transferred_data = true;
- printf("[DEBUG] Got %d bytes from the serial port\n\r", cc); fflush(stdout);
+ if (enableDebug) {
+ printf("[DEBUG] Got %d bytes from the serial port\n\r", cc); fflush(stdout);
+ }
}
if (canReadData()) {
cc = readBlock(buffer, 1024);
@@ -238,7 +253,9 @@ void FPGASocket::commandLoop() {
}
ioctl(m_fd_tty, TCFLSH, FLUSH_OUT);
transferred_data = true;
- printf("[DEBUG] Got %d bytes from the network interface\n\r", cc); fflush(stdout);
+ if (enableDebug) {
+ printf("[DEBUG] Got %d bytes from the network interface\n\r", cc); fflush(stdout);
+ }
}
}
}
@@ -247,7 +264,7 @@ void FPGASocket::commandLoop() {
if (m_loopTimer) m_loopTimer->start(0, TRUE);
}
else {
- if (m_loopTimer) m_loopTimer->start(100, TRUE);
+ if (m_loopTimer) m_loopTimer->start(m_pollInterval, TRUE);
}
return;
}
@@ -289,9 +306,9 @@ FPGAServer::~FPGAServer() {
void FPGAServer::newConnection(int socket) {
FPGASocket *s = new FPGASocket(socket, this);
s->m_remoteHost = s->peerAddress().toString();
- printf("[DEBUG] New connection from %s\n\r", s->m_remoteHost.ascii());
+ printf("[DEBUG] New connection from %s\n\r", s->m_remoteHost.ascii()); fflush(stdout);
if (m_numberOfConnections > 0) {
- printf("[DEBUG] Connection from %s closed due to multiple access attempt\n\r", s->m_remoteHost.ascii());
+ printf("[DEBUG] Connection from %s closed due to multiple access attempt\n\r", s->m_remoteHost.ascii()); fflush(stdout);
ABORT_SOCKET(s)
return;
}