EasyManua.ls Logo

Texas Instruments TMS320

Texas Instruments TMS320
288 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Stream I/O—Reading and Writing Streams
Streaming I/O and Device Drivers 7-13
Example 7-6. Adding an Output Stream to Example 7-5
Note:
Non-pointer type function arguments to log_printf need explicit type casting
to (Arg) as shown in the following code example:
LOG_printf(&trace, "Task %d Done", (Arg)id);
======== Portion of siotest2.c ========
/* SIO objects created with conf tool */
extern far LOG_Obj trace;
extern far SIO_Obj inputStream;
extern far SIO_Obj outputStream;
extern far TSK_Obj streamTask;
SIO_Handle input = &inputStream;
SIO_Handle output = &outputStream;
...
Void doStreaming(Uns nloops)
{
Void doStreaming(Arg nloops_arg)
{
Int i, nbytes;
Int *buf;
Long nloops = (Long) nloops_arg;
if ( SIO_staticbuf(input, (Ptr *)&buf) == 0) {
SYS_abort("Error reading buffer ");
}
for (i = 0; i < nloops; i++) {
if ((nbytes = SIO_get(input, (Ptr *)&buf)) < 0) {
SYS_abort("Error reading buffer %d", (Arg)i);
}
if (SIO_put(output, (Ptr *)&buf, nbytes) < 0) {
SYS_abort("Error writing buffer %d", (Arg)i);
}
}
LOG_printf(&trace, "End SIO example #2");
}
/* ======== DGN_print2log ========
* User function for the DGN user device printData. It takes as an argument
* the address of the LOG object where the data stream should be printed. */
Void DGN_print2log(Arg arg, Ptr addr, Uns nbytes)
{
Int i;
Int *buf;
buf = (Int *)addr;
for (i = 0; i < nbytes/sizeof(Int); i++) {
LOG_printf((LOG_Obj *)arg, "%d", buf[i]);
}

Table of Contents

Other manuals for Texas Instruments TMS320

Related product manuals