UNIX Pipes


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




The UNIX 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 UNIX 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:




From the UNIX 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 UNIX terminal window will be directed into dsppipe. After you type in a line of text, UNIX 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 UNIX terminal window. CNTL-D quits the UNIX 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.