Description-
This function attempts to get a packet of desired length. The input buffer length specified during the OpenComPort() function may be less than the requested packet size. This function will wait for up to the amount of time set by SetTimeout() before returning failure if the entire packet is not read.
Syntax-
count = GetPacket(port,len,pkt);
On Entry-
int port;
Port previously opened with InitializePort() or OpenComPort().
int len;
Desired length of packet to read.
char *pkt;
Pointer to buffer to store the packet.
On Exit-
int count;
Length of packet actually read.
else
-1 If port was not initialized.
See Also-
GetByte() GetString()
Example-
#include <comm.h>
int count; int port=0; char buf[256];
if ((count = GetPacket(port,sizeof(buf),buf)) != 0) { printf("Port was not initialized\n");
/* Take remedial action*/
break;
}