Using CitectSCADA > Communicating with I/O Devices > Scheduled Communications > Keeping data up-to-date during prolonged connections
Keeping data up-to-date during prolonged connections

Normally, communication is terminated as soon as every read and write request is complete. Sometimes, however, you may want to prolong the communication (for example by calling the IODeviceControl() function with Type 7).

In this situation (if Read-Through Caching is disabled), when client computers request device data from the I/O Server, it retrieves the data from its cache, not from the I/O Device. This occurs even though the I/O Server maintains a connection to the device.

To retrieve fresh data from the I/O Device, you can force a periodic read using Cicode, or change the cache timeout by setting the IODeviceControl() function to Type 11.

For example:

INT hTask;
// Initiate communications and read tags.
// Sleep time will depend on how fast your
// modems connect.
FUNCTION
DialDevice(STRING sDevice)
INT bConnected = 0;
INT nRetry = 5;
hTask = TaskHnd("");
IODeviceControl(sDevice, 7, 0);
Sleep(20);
WHILE bConnected <> 1 AND nRetry > 0 DO
bConnected = IODeviceInfo(sDevice, 18);
nRetry = nRetry - 1;
Sleep(10);
END
IF bConnected = 1 THEN
WHILE TRUE DO
Sleep(2);
IODeviceControl(sDevice, 16, 0);
END
END
END
// Kill the read task and terminate the connection.
FUNCTION
HangupDevice(STRING sDevice)
TaskKill(hTask);
IODeviceControl(sDevice, 8, 0);
END

You can also force the I/O Server to read data directly from an I/O Device by enabling Read-Through Caching. With [Dial]ReadThroughCache set, while the I/O Server is connected to a device it will supply data to requesting clients directly from the device. The cache is not updated during this time, but is refreshed with the most recent device data just before the server disconnects.

Note: If using modems, you might need to adjust or deactivate the inactivity timer in your modems to stop them from disconnecting while no data is being read. The inactivity timer is controlled by the S30 register. If your modem doesn't support this register, please consult your modem's manual.