Commit 3f90a544 authored by rswindell's avatar rswindell
Browse files

Added optional terminator character to comReadBuf().

parent 3bbcef92
......@@ -79,7 +79,8 @@ BOOL comWriteByte(COM_HANDLE, BYTE);
int comWriteBuf(COM_HANDLE, const BYTE*, size_t buflen);
int comWriteString(COM_HANDLE, const char*);
BOOL comReadByte(COM_HANDLE, BYTE*);
size_t comReadBuf(COM_HANDLE, char* buf, size_t buflen, int timeout /* in milliseconds */);
size_t comReadBuf(COM_HANDLE, char* buf, size_t buflen
,char terminator, int timeout /* in milliseconds */);
BOOL comPurgeInput(COM_HANDLE);
BOOL comPurgeOutput(COM_HANDLE);
......
......@@ -150,7 +150,7 @@ BOOL comReadByte(COM_HANDLE handle, BYTE* ch)
return ReadFile(handle, ch, sizeof(BYTE), &rd, NULL) && rd==sizeof(BYTE);
}
size_t comReadBuf(COM_HANDLE handle, char* buf, size_t buflen, int timeout)
size_t comReadBuf(COM_HANDLE handle, char* buf, size_t buflen, char terminator, int timeout)
{
BYTE ch;
size_t len=0;
......@@ -163,6 +163,8 @@ size_t comReadBuf(COM_HANDLE handle, char* buf, size_t buflen, int timeout)
YIELD();
continue;
}
if(len && terminator && ch==terminator)
break;
buf[len++]=ch;
}
......@@ -178,3 +180,4 @@ BOOL comPurgeOutput(COM_HANDLE handle)
{
return PurgeComm(handle, PURGE_TXCLEAR);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment