I/O templates are the part of ONSPEC's supporting code that must vary from one device to another. Each I/O template is customized to convert data coming in from the given device to a form usable by ONSPEC, and to convert data incoming from ONSPEC to a form useful to the device. In addition to this, the I/O template is responsible for creating and maintaining an internal list of commands to send, and for keeping track of when they are to be sent.

Note: the following two paragraphs are intended to give a better understanding of communications. However, all routines handling communications are invisible to the programmer using this package.

To accomplish communication with the device an interrupt routine is usually used, interrupting whenever a byte of data comes in on a serial port. The interrupt routine simply places the incoming byte in a large buffer and then returns, leaving it up to other routines to read and empty the buffer, to interpret the contents. Also there is another routine to be called to send the entire command out for writing to a serial port. Although both writing and reading the port is done using pre-defined routines, it is important to include time-out logic in your routines handling the serial port, in order to prevent the program from locking-up in the case of a communications breakdown.

Information is sent and received from ONSPEC's tables primarily via two operating system queues. Data going to ONSPEC is written to the queue named PlREADS.32. Data incoming from ONSPEC is read from the queue named PlWRITE.32. Direct access of ONSPEC tables is also available, but not encouraged beyond what is built in to the Technology Package.

The creation of the scheduled command list is done by reading in and processing a text file. This file is created using an editor. In it reside the specifications for what command is to be sent when, and to what ONSPEC table location the resulting information is to be sent. This command file also instructs the I/O template as to what output command to send to the device in the case of a change in ONSPEC's tables.

Beyond this, the I/O template's operation is a simple loop. In each loop (a standard one second in length) the I/O template performs three major tasks.

  • It checks for messages incoming from ONSPEC. If it receives a valid table update, it locates the output command in its command list, then alters it appropriately and sends it out.

  • It searches through the command list and sends those commands that should occur at this moment in the timing cycle and returns the results to ONSPEC.

  • It finishes the cycle by updating the clock and going to sleep for several ticks (A tick is 1/60 of one second, see the section on timing accuracy) in order to allow the other processes, such as ONSPEC, to utilize the I/O template's share of the CPU time while the process delays in sleep mode.

In each computer, multiple ONSPEC I/O Templates can run at the same time to talk to different instruments. The I/O Template position in an ONSPEC system is illustrated in the ONSPEC System Architecture on the next page.

This chapter will discuss the following aspects:

Contact us

Feel free to contact us!

Give us a call or drop us an email to schedule a visit!