| 69 | } |
| 70 | |
| 71 | void |
| 72 | SerialStream::Open(const std::string& fileName, |
| 73 | const std::ios_base::openmode& openMode) |
| 74 | try |
| 75 | { |
| 76 | // Create a new SerialStreamBuf if one does not exist. |
| 77 | if (mIOBuffer == nullptr) |
| 78 | { |
| 79 | mIOBuffer = std::make_unique<SerialStreamBuf>() ; |
| 80 | assert(mIOBuffer != nullptr) ; // NOLINT (cppcoreguidelines-pro-bounds-array-to-pointer-decay) |
| 81 | this->rdbuf(mIOBuffer.get()) ; |
| 82 | } |
| 83 | |
| 84 | // Open the serial port. |
| 85 | mIOBuffer->Open(fileName, openMode) ; |
| 86 | } |
| 87 | catch (const std::exception&) |
| 88 | { |
| 89 | setstate(std::ios_base::failbit) ; |
| 90 | throw ; |
| 91 | } |
| 92 | |
| 93 | void |
| 94 | SerialStream::Close() |