Tool title image

Streams

By using a general stream "concept" it is possible to e.g simulate a serial port by feeding data from a file.

 

File Stream

Represents a file on disk, either for reading or writing, but never both.

 

Serial Stream

A serial port (usually RS-232) is a very common interface to use for talking to embedded devices, either directly or using some standard protocol such as a Modbus.

 

String Stream

Sometimes it is usable to stream data to a receiver (or read from a sender) without having to rely on an existing resource, here the string stream can be very usable by provding a stream interface for an input string and an output string.

 

Buffer Stream

A buffer supports both reading and writing, data written to it can be read from it again in a FIFO (first-in-first-out) manner. This makes it look slightly like a String Stream, but without any need to fiddle with too many strings.

 

Methods

Read String

Reads a number of characters from a stream and stores them in a string.

 

Read Until

Read a string terminated by a number of characters from a stream, e.g. to read a string terminated by a ":" character.

 

Read Line

A specialisation of the Read Until method, but where the string is terminated by one or more new line character. Using this method is usually easier because you do not have to remember how a particular newline combination looks on a specific operating system.

 

Write String

Writes a string to a stream.

 

Optionally you can tell the tool to automatically add a newline at the end of the string to write.

 

Errors

All read/write tool methods in the stream tool can report the following errors back.

 

TimeoutExecutionError

The operation timed out.

 

StreamNotOpenExecutionError

Reported when trying to read/write to a stream that is not yet open.

 

OperationNotSupportedError

If you try to write to a stream that does not support writing (e.g. a file opened in read mode) - or reading from a stream that does not support reading.