PISerial setBreak
This commit is contained in:
@@ -289,6 +289,29 @@ bool PISerial::isRNG() const {return isBit(TIOCM_RNG, "RNG");}
|
||||
bool PISerial::isDSR() const {return isBit(TIOCM_DSR, "DSR");}
|
||||
|
||||
|
||||
bool PISerial::setBreak(bool enabled) {
|
||||
if (fd < 0) {
|
||||
piCoutObj << "sendBreak error: \"" << path() << "\" is not opened!";
|
||||
return false;
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
if (enabled) {
|
||||
if (!SetCommBreak(PRIVATE->hCom)) return false;
|
||||
} else {
|
||||
if (!ClearCommBreak(PRIVATE->hCom)) return false;
|
||||
}
|
||||
#else
|
||||
if (::ioctl(descriptor, enabled ? TIOCSBRK : TIOCCBRK) < 0) {
|
||||
piCoutObj << "setBreak error: " << errorString();
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool PISerial::setBit(int bit, bool on, const PIString & bname) {
|
||||
if (fd < 0) {
|
||||
piCoutObj << "setBit" << bname << " error: \"" << path() << "\" is not opened!";
|
||||
|
||||
Reference in New Issue
Block a user