Stream I/O—Reading and Writing Streams
Streaming I/O and Device Drivers 7-11
Example 7.5. Basic SIO Function (continued)
* ======== doStreaming ========
* This function is the body of the pre-created TSK thread
* streamTask.
*/
Void doStreaming(Uns nloops)
{
Int i, j, nbytes;
Int *buf;
status = SIO_staticbuf(input, (Ptr *)&buf);
if (status ! = SYS_ok) {
SYS_abort(“could not acquire static frame:);
}
for (i = 0; i < nloops; i++) {
if ((nbytes = SIO_get(input, (Ptr *)&buf)) < 0) {
SYS_abort("Error reading buffer %d", i);
}
LOG_printf(&trace, "Read %d bytes\nBuffer %d data:",
nbytes, i);
for (j = 0; j < nbytes / sizeof(Int); j++) {
LOG_printf(&trace, "%d", buf[j]);
}
}
LOG_printf(&trace, "End SIO example #1");
}