Object <- Server <- HardwareStream <- CommunicationStream |
|
|
Abort CanConnect ClearAbort Connect Disconnect ReadWithCallback WriteWithCallback |
|
Aborted Connected |
| Field | Type | |
|---|---|---|
| Server: | enabled: | Boolean |
| Stream: | target: | Object |
| HardwareStream: | state: | Unsigned |
| readRate: | Unsigned | |
| writeRate: | Unsigned | |
| maxReadRate: | Unsigned | |
| maxWriteRate: | Unsigned | |
| defaultTimeout: | Unsigned |
Define Class CommunicationStream; abstract; inherits from HardwareStream; inherits interface from Connectable; overrides CanConnect; // returns true if state is other than kConnected overrides Connect; // at this level just sets the state of the stream to kConnected overrides Connected; // return whether state is kConnected overrides Disconnect; // at this level just sets the state of the stream to kDisconnected overrides Abort; // at this level, sets the state of the stream to kAborted. If have // CommunicationStream_ target, Abort is also called on it. overrides Aborted; // if have CommunicationStream_ target, returns Aborted for the target. // Otherwise returns whether state is kAborted. overrides ClearAbort; // at this level, sets the state of the stream back to kDisconnected. If have // CommunicationStream_ target, ClearAbort is also called on it. // Serial streams are commonly data-link escaped, so per-character callbacks // are useful to avoid double buffering // The callback is called each byte, and returns false when there is no more data // Override these to allow subclass to call the callback function directly for speed operation WriteWithCallback(callback: EachByteFunction; params: Pointer); // while the callback function returns true, write the byte to self the callback returns // if the instance has a target then just delegate to it instead operation ReadWithCallback(callback: EachByteFunction; params: Pointer): Unsigned; // continue to read from self until callback returns false // if the instance has a target then just delegate to it instead end class;