UNIX/LINUX Pipes

 

On UNIX/LINUX machines, DADiSP allows programs to communicate via a named pipe. A LINUX named pipe is a shared file that two or more programs can read and write. Create a pipe with the LINUX mknod command. In addition to being sharable, LINUX pipes allow two programs to communicate via system memory directly, bypassing the disk drive, increasing overall processing speed and limiting overhead.

 

Example

 

The LINUX command:

 

mknod dsppipe p

 

creates a named pipe (FIFO) called dsppipe. A directory listing (e.g., ls -l ) will show that dsppipe is a file with a "p" attribute.

 

Because a LINUX pipe is really just a file, one technique is to load the pipe from DADiSP as a command file. For example, type at the DADiSP command line:

 

load("dsppipe")

 

From the LINUX side, enter commands interactively into the pipe with the following statement issued from a terminal window:

 

cat > dsppipe

 

In the above example, the cat command allows you to interactively issue commands to DADiSP from a terminal window. An executable program would use standard file functions to write text to the pipe.

 

All text typed from the LINUX terminal window will be directed into dsppipe. After you type in a line of text, LINUX will automatically send the text to DADiSP. Because the pipe was loaded as a command file, DADiSP will interpret the text as DADiSP commands.

 

For example, typing: gsin(100,.01) @cr from the terminal window causes DADiSP to generate a 100 point sine wave. The @cr command simulates pressing the RETURN key in DADiSP (just like in a command file).

 

DADiSP will read from the pipe, and execute all commands it retrieves from the pipe. Terminate the link by sending DADiSP the @return command. @return instructs DADiSP to stop reading the command file and return to the interactive mode. In the above example, you can also terminate the link by pressing CNTL-D from the LINUX terminal window. CNTL-D quits the LINUX cat command and sends DADiSP an EOF (end-of-file) character via the pipe. DADiSP interprets the EOF as the end of the command file and returns to interactive mode.

 

If the DADiSP session is running as a captive session, (i.e., a slave to the controlling program), the control program can send the DADiSP command exit(0) to terminate the DADiSP session.