| 265 | } |
| 266 | |
| 267 | void |
| 268 | SerialStream::SetBaudRate(const BaudRate& baudRate) |
| 269 | try |
| 270 | { |
| 271 | auto my_buffer = dynamic_cast<SerialStreamBuf *>(this->rdbuf()) ; |
| 272 | |
| 273 | // Make sure that we are dealing with a SerialStreamBuf before |
| 274 | // proceeding. This check also makes sure that we have a non-NULL |
| 275 | // buffer associated with this stream. |
| 276 | if (my_buffer != nullptr) |
| 277 | { |
| 278 | // Try to set the baud rate with the corresponding function of |
| 279 | // the SerialStreamBuf class. |
| 280 | my_buffer->SetBaudRate(baudRate) ; |
| 281 | } |
| 282 | else |
| 283 | { |
| 284 | // If the dynamic_cast above failed then we either have a NULL |
| 285 | // streambuf associated with this stream or we have a buffer |
| 286 | // of class other than SerialStreamBuf. In either case, we |
| 287 | // have a problem and we should stop all I/O using this stream. |
| 288 | setstate(badbit) ; |
| 289 | } |
| 290 | } |
| 291 | catch (const std::exception&) |
| 292 | { |
| 293 | setstate(std::ios_base::failbit) ; |
| 294 | throw ; |
| 295 | } |
| 296 | |
| 297 | BaudRate |
| 298 | SerialStream::GetBaudRate() |