diff options
Diffstat (limited to 'servers/fpga_server_lin/src/fpga_conn.cpp')
-rw-r--r-- | servers/fpga_server_lin/src/fpga_conn.cpp | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/servers/fpga_server_lin/src/fpga_conn.cpp b/servers/fpga_server_lin/src/fpga_conn.cpp index 1b0927c..1335a5a 100644 --- a/servers/fpga_server_lin/src/fpga_conn.cpp +++ b/servers/fpga_server_lin/src/fpga_conn.cpp @@ -110,9 +110,15 @@ int FPGASocket::setupSerial() { tcgetattr(m_fd_tty, &oldtio); // Save current port settings long serialBaud; - if (desiredBaudRate == "9600") { + if (desiredBaudRate == "1200") { + serialBaud = B1200; + } + else if (desiredBaudRate == "9600") { serialBaud = B9600; } + else if (desiredBaudRate == "19200") { + serialBaud = B19200; + } else if (desiredBaudRate == "115200") { serialBaud = B115200; } @@ -139,22 +145,26 @@ int FPGASocket::setupSerial() { } int FPGASocket::enterCommandLoop() { + int cc; + char buffer[10000]; + m_criticalSection++; try { while (state() == TQSocket::Connected) { - // RAJA FIXME -// cc = read(fd_tty, readbuf, 100000); -// if (cc > 0) { -// write_data_to_client(fd, readbuf, cc); -// fsync(fd_tty); -// printf("[DEBUG] Got %d bytes from the serial port\n\r", cc); fflush(stdout); -// } -// cc = read(fd, writebuf, 100000); -// if (cc > 0) { -// write(fd_tty, writebuf, cc); -// fsync(fd); -// printf("[DEBUG] Got %d bytes from the network interface\n\r", cc); fflush(stdout); -// } + cc = read(m_fd_tty, buffer, 10000); + if (cc > 0) { + writeBlock(buffer, cc); + printf("[DEBUG] Got %d bytes from the serial port\n\r", cc); fflush(stdout); + } + if (canReadLine()) { + cc = readBlock(buffer, 10000); + if (cc > 0) { + if (write(m_fd_tty, buffer, cc) < 0) { + // ERROR + } + printf("[DEBUG] Got %d bytes from the network interface\n\r", cc); fflush(stdout); + } + } } m_criticalSection--; |