FUNCTIONS

The following is a list of external functions in DRIVER.C. Each has an explanation of how it functions and what parameters need to be passed.

    void delay( int seconds );

A negative value delays the program for the number of ticks specified by the parameter. A positive number delays the program for a number of seconds. A tick is 1/60 of one second.

     int sendToOnspec( char table, char status, int index, double value, int taged );

Sends a message to ONSPEC over the communication queue. This function checks the value against ONSPEC's tables; if the value is the same the message will not be sent. The value returned by this function states whether the write to the queue was successful, 0 = success.
Parameters:

table    : This is the ONSPEC table which will receive the message. 1 = EUR, 2 = EUI, 3 = FLG, 6 =DII, 7 = DOO
status   : Value for FLG, DII or DOO table or a status for the value. Bit 0 is for status; set indicates a bad value, reset indicates value is okay. Bit 1 is for value; set indicates an ON value, reset indicates an OFF value.
index   : Offset into the table where the value will be placed.
value   : Value for the EUR or EUI table.
taged   : Identifies whether the table location being referenced has been tagged for historical data. Equal to 1 if true, 0 if false.

     int getFromOnspec ( char *table, char *status, int *index, double *val );

Attempts to read a message from ONSPEC's communication queue. If the value returned by the function is 0 we received a message, otherwise no message was received.

table   : This is the ONSPEC table from which the message came. 1 = EUR, 2 = EUI, 3 = FLG, 6 = DII, 7 = DOO
status   : Value for FLG, DII or DOO table. Bit 1 reset indicates an OFF value, set indicate an ON value.
index   : Offset into the table where the value came from.
val   : Value for the EUR or EUI table.
Note:   All the parameters must be passed as pointers.  

Reads a string from STR table and returns its length.
Parameters:
s = Pointer to a buffer that will store the string.
index = Offset into the STR table where the string came from.

     void writeString(char *s, int index);

Writes a string to STR table.
Parameters:
s = Pointer to a string that will be written to STR table.
index = Offset into the STR table where the string will be placed.

     void gaurdian ( void );

This function ensures that no other processes are using the same communications port at startup.

    int getBuffer( unsigned char *s, int len );

Returns a string from the input buffer.

    int sendStr( unsigned char *str, int usBuffLen );

Sends a string of length usBuffLen out the communications port. If the port is not sending bytes, the value of the function will return 1, indicating that a time-out has occurred.

    int timeToQuit( void )

Check if port MX queue has been deleted or if ONSPEC has gone down. If either case is found, the function returns 1 and the I/O template must abort.

    int tailer( int argc, char **argv )

Reads and passes the command tail, setting options specified in command tail.

Command tail format:

   < program name > [[config file] < / > [option] < / >...< / > [option]]
Program name = Name of your I/O template.
Config file = Name of configuration file read by the I/O template. The default name is CONFIG.TXT
Option = Option preceded by a slash (/).

Options:
M = Monitor mode. Bytes sent and received on communications port will be displayed.
Cn = COMM port to use. n = 1 or 2.
Ln = DEC terminal server port to use.
N = No communications port used.
Dn = For multiple I/O template systems. n = 1- 9. A l indicates the
   first driver, a 2 the next and so on. The last I/O template in
   system must by followed by an "X" to indicate that it will be the
   last one, e.g. /D3X.
Sbr, p, 1, s = Port configuration, where br = baud rate, p = parity, l = data bits, and s = stop bits.

    void initialize( void );

Open all queues and run all initialization routines.

     void watchdog( void );

Send status messages to ONSPEC. Called each time through the main loop but only updates every ten cycles. The watch index for a single I/O template is 128, in a multiple system it's I/O template number + 127.
n = watchdog index
Dll[n] = Communications status
FLG[n] = Queue overload status
EUR[n] = Number of messages sent on queue to ONSPEC

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!