INtime SDK Help
ReadRtFile
INtime SDK v6 > About INtime > INtime Kernel > Files > ReadRtFile

Reads data from the specified file or device. Data may be read asynchronously or synchronously.

BOOLEAN ReadRtFile(
RTHANDLE hFile,
LPVOID lpBuffer,
DWORD cbBufferSize,
LPDWORD lpcbBytesRead,
LPASYNCIO lpAsync);

Parameters

hFile
A handle for a file object
lpBuffer
A pointer to a contiguous buffer where the data is to be stored.
cbBufferSize
The size in bytes of the buffer
lpcbBytesRead
A pointer to a variable where the number of bytes read in the operation is actually stored (synchronous operation only). This pointer may be NULL. For an asynchronous operation this pointer is ignored.
lpAsync
A pointer to an ASYNCHIO structure which has been initialized, or NULL if the operation is to be synchronous.

Remarks

A synchronous operation is started by supplying NULL for the lpAsynch parameter, and returns after the operation is complete, or an error was detected. If the operation was successful, and a non-null value has been provided for lpcbBytesRead, then the actual count of bytes read is returned through that pointer.

An asynchronous operation is started by supplying a pointer to an initialized ASYNCIO structure in the lpAsync parameter, and the function returns after the parameters have been verified and the read operation has been started but before the entire operation has completed.

The structure must be initialized with at least a handle for a data mailbox through which the ASYNCIO structure is returned on completion of the operation. To complete the operation, wait on the mailbox for the structure to be returned, or call WaitForRtIo with the file handle and the same async pointer supplied to the ReadRtFile call.

Note: Asynchronous file operations are not currently supported on INtime Distributed RTOS

Return value

Returns TRUE on success, else FALSE on failure. Status codes returned by GetLastRtError on failure include:

Status value Meaning
E_EXIST The handle provided is not a valid handle
E_TYPE The handle provided is not a handle for a file
E_PARAM The file was opened in asynchronous mode, but the lpAsync parameter is NULL, or the file was opened in synchronous mode and the lpAsync parameter is not NULL.
E_IO_HARD An I/O error occurred during the operation
E_BAD_BUF The buffer provided is not writable, or the address is invalid
E_CONN_NOT_OPEN The handle provided does not refer to an open file
E_SLOT No more GDT slots are available. This can occur when a very large number of asynchronous operations are outstanding.
E_NOT_CONFIGURED Call is not supported in INtime Distributed RTOS.

Requirements

Versions Defined in Include Link to
INtime 6.0 intime/rt/include/rtbase.h rt.h rt.lib

See Also