Using Streams: 1 Using Streams: The Basics

Up: GEOS SDK TechDocs | Up | Down | Prev: Using Streams | Next: 2 Using the Serial Ports

A stream is a path along which information flows in one direction. At one end of the stream is a writer , who puts data into the stream. At the opposite end of the stream is a reader , who receives data from the stream. The writer and reader can be GEOS programs or device drivers. Data flow in both directions can be achieved by using two streams, one in each direction; this is how the serial port driver is implemented.

Even though the stream driver is loaded automatically when a stream is created, you will need to initialize, configure, and destroy any streams you use. The specific steps involved in this process are

  1. Get the handle of the stream driver.
    You will need to get this handle to use most of the stream-library routines. You can get this handle by calling GeodeUseDriver() .
  2. Create the stream.
    You must create each stream you plan on using. When a stream is initialized, it is designated a token that is used when calling the stream driver's strategy routine.
  3. Configure the stream.
    Arrange how your geode will be notified by the stream driver when certain situations (error received or buffer full/empty) arise, and make sure that all geodes accessing the stream have been given the stream's token.
  4. Use the stream.
  5. Shut down the stream.
    Not a trivial task, shutting down a stream can involve several synchronization issues.

Streams are created and managed by the Stream Driver . Programs written in Object-Assembly can call the driver directly. Goc programs cannot do this; instead, they make calls to the Stream Library , which in turn calls the Stream Driver, and passes back any return values.


Up: GEOS SDK TechDocs | Up | Down | Prev: Using Streams | Next: 2 Using the Serial Ports