mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-27 22:03:43 -06:00
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:
parent
60add2c64d
commit
d4603161c8
3 changed files with 165 additions and 66 deletions
|
|
@ -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 )
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue