Stackable Devices
Streaming I/O and Device Drivers 7-19
Example 7-9. Data Exchange Through a Pipe Device
/*
* ======== siotest5.c ========
* In this program two tasks are created that exchange data
* through a pipe device. The source task reads sine wave data
* from a DGN device through a DTR device stacked on the sine
* device, and then writes it to a pipe device. The sink task
* reads the data from the pipe device and writes it to the
* printData DGN device. The data exchange between the tasks
* and the devices is done in a device independent fashion
* using the SIO module APIs.
*
* The streams in this example follow the SIO_STANDARD streaming
* model and are created statically.
*/
#include <std.h>
#include <dtr.h>
#include <log.h>
#include <mem.h>
#include <sio.h>
#include <sys.h>
#include <tsk.h>
#define BUFSIZE 128
#ifdef _62_
#define SegId IDRAM
extern Int IDRAM; /* MEM segment ID defined with conf tool */
#endif
#ifdef _55_
#define SegId DATA
extern Int DATA; /* MEM segment ID defined with conf tool */
#endif
extern LOG_Obj trace; /* LOG object created with conf tool */
extern TSK_Obj sourceTask; /* TSK thread objects created via conf tool */
extern TSK_Obj sinkTask;
extern SIO_Obj inStreamSrc; /* SIO streams created via conf tool */
extern SIO_Obj outStreamSrc;
extern SIO_Obj inStreamSink;
extern SIO_Obj outStreamSink;
/* Parameters for the stacking device "/scale" */
DTR_Params DTR_PRMS = {
20, /* Scaling factor */
NULL,
NULL
};
Void source(Uns nloops); /* function body for sourceTask above */
Void sink(Uns nloops); /* function body for sinkTask above */
static Void doStreaming(SIO_Handle input, SIO_Handle output, Uns nloops);
/*