Skip to content

Commit 91fdf51

Browse files
committed
Added getStream() support.
1 parent de1bd5a commit 91fdf51

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

docs/CHANGELOG.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1313

1414
### Changed
1515

16-
- Updated README.
16+
- None
1717

1818
### Removed
1919

@@ -27,6 +27,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2727

2828
- None
2929

30+
## [1.4.0] 2019-07-26
31+
32+
### Added
33+
34+
- Added `const Stream* getStream() const` and `Stream* getStream()` methods. Thanks @orgicus.
35+
36+
### Changed
37+
38+
- Updated README.
39+
3040
## [1.3.0] 2019-07-25
3141

3242
### Removed

docs/CONTRIBUTORS.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
- Antoine Villeret [@avilleret](https://github.com/avilleret) - SLIP Encoding.
55
- Anton Viktorov [@latonita](https://github.com/latonita) - Bugfixes.
66
- [@per1234](https://github.com/per1234) - Metadata.
7+
- George Profenza [@orgicus](https://github.com/orgicus) - API Suggestions.
78

89
_For and up-to-date list of contributors, see [contributors](../graphs/contributors)._

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=PacketSerial
2-
version=1.3.0
2+
version=1.4.0
33
author=Christopher Baker <[email protected]>
44
maintainer=Christopher Baker <[email protected]>
55
sentence=An Arduino Library that facilitates packet-based serial communication using COBS or SLIP encoding.

src/PacketSerial.h

+24
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,30 @@ class PacketSerial_
171171
_stream = stream;
172172
}
173173

174+
/// \brief Get a pointer to the current stream.
175+
/// \warning Reading from or writing to the stream managed by PacketSerial_
176+
/// may break the packet-serial protocol if not done so with care.
177+
/// Access to the stream is allowed because PacketSerial_ never
178+
/// takes ownership of the stream and thus does not have exclusive
179+
/// access to the stream anyway.
180+
/// \returns a non-const pointer to the stream, or nullptr if unset.
181+
Stream* getStream()
182+
{
183+
return _stream;
184+
}
185+
186+
/// \brief Get a pointer to the current stream.
187+
/// \warning Reading from or writing to the stream managed by PacketSerial_
188+
/// may break the packet-serial protocol if not done so with care.
189+
/// Access to the stream is allowed because PacketSerial_ never
190+
/// takes ownership of the stream and thus does not have exclusive
191+
/// access to the stream anyway.
192+
/// \returns a const pointer to the stream, or nullptr if unset.
193+
const Stream* getStream() const
194+
{
195+
return _stream;
196+
}
197+
174198
/// \brief The update function services the serial connection.
175199
///
176200
/// This must be called often, ideally once per `loop()`, e.g.:

0 commit comments

Comments
 (0)