|IODevice||IOVIRTUAL_Create (size_t buf_size, int number_of_gates)|
|void||IOVIRTUAL_Destroy (IODevice iodevice)|
|HALRESULT||IOVIRTUAL_Connect (IODevice iodev1, IODevice iodev2)|
|HALRESULT||IOVIRTUAL_Disconnect (IODevice iodev1, IODevice iodev2)|
The IOVirtual is an IODevice used mainly for unit testing.
It allows to emulate the behavior of connected IODevices. Each IOVirtual device has a number of gates, that allow it to be connected to other IOVirtual devices. When two or more IOVirtual devices are connected, writing to one of them will cause the data to be received by all the others.
Creating and destroying IOVirtual devices.
All IOVirtual device objects are created at runtime, by a call to IOVIRTUAL_Create function. This call allocates memory for a new IOVIRTUAL device descriptor (plus additional memory for data buffer). Such IOVirtual device is then ready to operate as a regular IODevice object. When done using, all IOVirtual devices should be destroyed to free allocated memory, by a call to IOVIRTUAL_Destroy function.
Using IOVirtual devices.
Once created, the IOVirtual devices are usually being connected to each other. This is done by a call to IOVIRTUAL_Connect. A complementary IOVIRTUAL_Disconnect function is also provided, allowing to disconnect the devices.
A typical usage scenario is presented below:
Connects IOVirtual devices together.
iodev1 first IOVirtual device iodev2 second IOVirtual device
- Return values
HALRESULT_OK if the devices were connected HALRESULT_NOT_ENOUGH_GATES if one (or both) of the devices has no more free gates for connecting
Creates a new virtual IODevice.
buf_size size of the data buffer (in bytes) number_of_gates number of gates to connect other IOVirtual devices
- new virtual IODevice or NULL if creation failed
Destroys a virtual IODevice and frees all memory allocated for it. Note, that this function should NOT be used to free other types of IODevices.
iodevice virtual IODevice
Generated on Thu Feb 22 2018 13:14:55 for RCM API C++ Library by 184.108.40.206