That reminds me of one of my very first paid programming gigs. The client had an ancient piece of legacy machinery that communicated via a serial port to a DOS-based user interface. The trouble was that the machine was somewhere in mainland Europe and they wanted to move the user interface over to their head office here in the UK. Nowadays I might just run the UI in VMWare or something on a small embedded PC next to the machine and access it via VNC, but back then bandwidth limitations ruled that out.
The solution I came up with involved the UI running under DosEMU on a Linux PC in their office, the machine plugged into a second Linux box in Europe, and a couple of custom programs I wrote that transferred the serial data and control signals via a TCP/IP connection.
It seemed to work OK in testing but the client kept complaining of terrible latency problems. After much time spent monitoring the network traffic between the two sites, I eventually traced the problem to a bug in my own code: for efficiency reasons it was buffering the serial data into 1KB chunks before writing it across the network. Where this failed is when the UI sent a short query and then sat around waiting for the machine's response. The query wasn't long enough to fill the buffer, so it didn't get sent out until the UI had timed out and resent the query several times. The solution was to set up a timer that automatically flushed the buffer if it wasn't full after 100ms or so.
no subject
Date: 2010-02-01 12:43 pm (UTC)That reminds me of one of my very first paid programming gigs. The client had an ancient piece of legacy machinery that communicated via a serial port to a DOS-based user interface. The trouble was that the machine was somewhere in mainland Europe and they wanted to move the user interface over to their head office here in the UK. Nowadays I might just run the UI in VMWare or something on a small embedded PC next to the machine and access it via VNC, but back then bandwidth limitations ruled that out.
The solution I came up with involved the UI running under DosEMU on a Linux PC in their office, the machine plugged into a second Linux box in Europe, and a couple of custom programs I wrote that transferred the serial data and control signals via a TCP/IP connection.
It seemed to work OK in testing but the client kept complaining of terrible latency problems. After much time spent monitoring the network traffic between the two sites, I eventually traced the problem to a bug in my own code: for efficiency reasons it was buffering the serial data into 1KB chunks before writing it across the network. Where this failed is when the UI sent a short query and then sat around waiting for the machine's response. The query wasn't long enough to fill the buffer, so it didn't get sent out until the UI had timed out and resent the query several times. The solution was to set up a timer that automatically flushed the buffer if it wasn't full after 100ms or so.