Allow for setting DTR on a serial port
This commit is contained in:
parent
1996d34650
commit
0279aafb97
2 changed files with 48 additions and 0 deletions
|
|
@ -660,6 +660,53 @@ void serial_port::serial_break()
|
|||
#endif
|
||||
}
|
||||
|
||||
void serial_port::serial_set_dtr(bool dtr)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Windows-specific code path for serial set DTR |
|
||||
\*-----------------------------------------------------*/
|
||||
#ifdef _WIN32
|
||||
if(dtr)
|
||||
{
|
||||
EscapeCommFunction(file_descriptor, SETDTR);
|
||||
}
|
||||
else
|
||||
{
|
||||
EscapeCommFunction(file_descriptor, CLRDTR);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Linux-specific code path for serial set DTR |
|
||||
\*-----------------------------------------------------*/
|
||||
#ifdef __linux__
|
||||
const int DTRFLAG = TIOCM_DTR;
|
||||
if(dtr)
|
||||
{
|
||||
ioctl(file_descriptor, TIOCMBIS, &DTRFLAG);
|
||||
}
|
||||
else
|
||||
{
|
||||
ioctl(file_descriptor, TIOCMBIC, &DTRFLAG);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| MacOS-specific code path for serial set DTR |
|
||||
\*-----------------------------------------------------*/
|
||||
#ifdef __APPLE__
|
||||
const int DTRFLAG = TIOCM_DTR;
|
||||
if(dtr)
|
||||
{
|
||||
ioctl(file_descriptor, TIOCMBIS, &DTRFLAG);
|
||||
}
|
||||
else
|
||||
{
|
||||
ioctl(file_descriptor, TIOCMBIC, &DTRFLAG);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void serial_port::serial_set_rts(bool rts)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue