next up previous contents
Next: Command String Format Up: System Overview Previous: Communications   Contents


Program Interface

Early in the life of the Metrology project, it was clear that the software controlling the ranger would have to become a remote, embedded system, separate from the software used to control the entire system. This would require some sort of program interface that would allow another program to communicate with the ZY. The first interface used on the ZY was a binary interface over a serial port. This interface used function numbers, followed by a size word to specify the size of any following data stream. It was up to the function called to decode the data stream properly. This worked well with a serial port, but required a dedicated client program to operate. Later, when the hardware interface was changed to ethernet, I decided to scrap the binary interface and use an ASCII interface instead. In this interface, the ZY receives a command string, which essentially consists of a command name optionally followed by comma delimited parameters. The newline character is used as a delimiter between command strings. Such interfaces are common in the instrumentation world. Examples include HPIB (IEEE 488) interfaces, which commonly use an ASCII command interface, and HPGL, the HP plotting command language. The advantages of using such an interface include:

Figure 2.9: ZY Interface: Command Parser & Hash Table
\begin{figure}
\setlength{\unitlength}{1pt}
\begin{picture}(433, 500)
\p...
...handler\\
through the {\it CmdParam} object}}
\end{picture}
\end{figure}

The disadvantage to this interface is that it is potentially slower than a binary interface, as the ZY has to parse the command string, do a hash table lookup on the function for that command, and the handler function has to first convert all numerical parameters from ASCII to a numerical representation that the computer can use. I feel that the advantages far outweigh this potential disadvantage, particularly given the processing power available today. Actual measurements show that in reality this overhead is not significant: the overhead of reading and writing to a socket far exceeds the overhead of the numerical conversion and hash table lookup. Also, if I were to use a binary interface in a non architecture dependent way (such as with Sun RPCs) I would have to encode all data in a network byte order first, which also takes some time, and the overhead of reading and writing to the TCP socket would still be present. For the most part, the ZY interface is fast enough. In at least one instance, where large amounts of data must be sent as quickly as possible, these data are sent as an opaque, binary block. This allows the transfer to be performed with the fewest possible socket writes. For the moment, however, no attempt is made to make this binary data architecture independent.

Subsections
next up previous contents
Next: Command String Format Up: System Overview Previous: Communications   Contents
Ramon E. Creager 2002-03-11