From d5316f5795e3557d032af9a95ba4e5fa88191834 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Wed, 4 Jul 2012 20:29:14 -0500 Subject: Add interface mode selection Make servers use less CPU --- servers/fpga_server_lin/src/fpga_conn.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'servers/fpga_server_lin/src') diff --git a/servers/fpga_server_lin/src/fpga_conn.cpp b/servers/fpga_server_lin/src/fpga_conn.cpp index 6f4cecf..3acd499 100644 --- a/servers/fpga_server_lin/src/fpga_conn.cpp +++ b/servers/fpga_server_lin/src/fpga_conn.cpp @@ -161,13 +161,16 @@ int FPGASocket::setupSerial() { 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()) { @@ -176,12 +179,18 @@ void FPGASocket::commandLoop() { 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); } } } m_criticalSection--; - if (m_loopTimer) m_loopTimer->start(0, TRUE); + if (transferred_data) { + if (m_loopTimer) m_loopTimer->start(0, TRUE); + } + else { + if (m_loopTimer) m_loopTimer->start(100, TRUE); + } return; } catch (...) { -- cgit v1.2.1