Bazaar/Serial : added functions to control DTR and RTS lines

git-svn-id: svn://ultimatepp.org/upp/trunk@10765 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
micio 2017-01-26 09:52:56 +00:00
parent 60add2c64d
commit d4603161c8
3 changed files with 165 additions and 66 deletions

View file

@ -233,6 +233,27 @@ void Serial::Close ( void )
fd = INVALID_HANDLE_VALUE;
}
// control DTR and RTS lines
bool Serial::SetDTR(bool on)
{
if(on)
EscapeCommFunction(hComPort, SETDTR);
else
EscapeCommFunction(hComPort, CLRDTR);
return true;
}
bool Serial::SetRTS(bool on)
{
if(on)
EscapeCommFunction(hComPort, SETRTS);
else
EscapeCommFunction(hComPort, CLRRTS);
return true;
}
// flush data
bool Serial::FlushInput ( void )
{
@ -249,6 +270,20 @@ bool Serial::FlushAll ( void )
return PurgeComm ( fd, PURGE_RXCLEAR ) & PurgeComm ( fd, PURGE_TXCLEAR );
}
// check if data is available on serial port
int Serial::Avail(void)
{
dword errors;
COMSTAT stat;
if(!ClearCommError(fd, &errors, &stat))
return 0;
return stat.cbInQue;
);
// read a single byte, block 'timeout' milliseconds
bool Serial::Read ( byte &c, uint32_t timeout )
{