COMM-DRV/Lib: PeekChar() Returns the next character from receive buffer non-destructively

Description-

Returns the next character from receive buffer non-destructively. This function will wait for up to the amount of time set by SetTimeout() before returning failure if a byte is not present.

Syntax-

byte = PeekChar(port);

On Entry-

int port;

Port previously opened with InitializePort() or OpenComPort().

On Exit-

int byte;

The returned byte.

else

-1 If port not initialized or no byte to be read.

See Also-

GetByte()
GetPacket()
GetString()

Example-

#include "comm.h"
int port=0;
 int byte;
if ((byte = PeekChar(port)) == -1)
    {
    printf("No bytes to read\n");
   }