summaryrefslogtreecommitdiffstats
path: root/servers/fpga_programming_server_lin/src/fpga_conn.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-07-06 01:49:44 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-07-06 01:49:44 -0500
commit9a3bfffc76e52b18a952016a1793af57b7d92cd4 (patch)
tree1cfef56e86ea6b85daa0480d94ad160fbc751b96 /servers/fpga_programming_server_lin/src/fpga_conn.cpp
parent7bd40e9b56445d509cddebfff79062770708b0e6 (diff)
downloadulab-9a3bfffc76e52b18a952016a1793af57b7d92cd4.tar.gz
ulab-9a3bfffc76e52b18a952016a1793af57b7d92cd4.zip
Fix a number of problems and add skeleton FPGA prog server
Diffstat (limited to 'servers/fpga_programming_server_lin/src/fpga_conn.cpp')
-rw-r--r--servers/fpga_programming_server_lin/src/fpga_conn.cpp78
1 files changed, 4 insertions, 74 deletions
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()));