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!";
|
||||
|
||||
@@ -159,6 +159,12 @@ public:
|
||||
bool isRNG() const;
|
||||
bool isDSR() const;
|
||||
|
||||
//! Switch transmission line in break if enabled.
|
||||
//! i.e. sends a continuous stream of zero bits.
|
||||
//! If successful, returns true; otherwise returns false.
|
||||
//! The serial port has to be open before trying to send a break duration; otherwise returns false
|
||||
bool setBreak(bool enabled);
|
||||
|
||||
void setVTime(int t) {vtime = t; applySettings();}
|
||||
|
||||
//! Returns device name
|
||||
|
||||
Reference in New Issue
Block a user