diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-06-28 18:28:19 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-06-28 18:28:19 -0500 |
commit | 65ea633f475c7ab2b524dc1ffb369f6607df3e6b (patch) | |
tree | 8fac782af0723eba4e3110cafe59cb521444eaa2 /servers/fpga_server_lin/src/fpga_conn.cpp | |
parent | 8392c611054a5bb058cd778163a7aa4ef8311c94 (diff) | |
download | ulab-65ea633f475c7ab2b524dc1ffb369f6607df3e6b.tar.gz ulab-65ea633f475c7ab2b524dc1ffb369f6607df3e6b.zip |
Convert servers to cooperative multitasking
Diffstat (limited to 'servers/fpga_server_lin/src/fpga_conn.cpp')
-rw-r--r-- | servers/fpga_server_lin/src/fpga_conn.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/servers/fpga_server_lin/src/fpga_conn.cpp b/servers/fpga_server_lin/src/fpga_conn.cpp index ddd430a..4c6f65e 100644 --- a/servers/fpga_server_lin/src/fpga_conn.cpp +++ b/servers/fpga_server_lin/src/fpga_conn.cpp @@ -41,10 +41,6 @@ #include "fpga_conn.h" #define ABORT_SOCKET(s) s->close(); \ - tqApp->processEvents(); \ - while (s->state() == TQSocket::Closing) { \ - tqApp->processEvents(); \ - } \ s->disconnect(); \ delete s; \ s = NULL; @@ -153,13 +149,13 @@ int FPGASocket::setupSerial() { return 0; } -int FPGASocket::enterCommandLoop() { +void FPGASocket::commandLoop() { int cc; char buffer[10000]; m_criticalSection++; try { - while (state() == TQSocket::Connected) { + if (state() == TQSocket::Connected) { cc = read(m_fd_tty, buffer, 10000); if (cc > 0) { writeBlock(buffer, cc); @@ -175,16 +171,21 @@ int FPGASocket::enterCommandLoop() { } } } - m_criticalSection--; - return 0; + TQTimer::singleShot(0, this, SLOT(commandLoop())); + return; } catch (...) { m_criticalSection--; - return -1; + return; } } +int FPGASocket::enterCommandLoop() { + TQTimer::singleShot(0, this, SLOT(commandLoop())); + return 0; +} + /* The FPGAServer class handles new connections to the server. For every client that connects, it creates a new FPGASocket -- that instance is now |