Skip to content

Commit

Permalink
Added getStream() support.
Browse files Browse the repository at this point in the history
  • Loading branch information
bakercp committed Jul 26, 2019
1 parent de1bd5a commit 91fdf51
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
12 changes: 11 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Changed

- Updated README.
- None

### Removed

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

- None

## [1.4.0] 2019-07-26

### Added

- Added `const Stream* getStream() const` and `Stream* getStream()` methods. Thanks @orgicus.

### Changed

- Updated README.

## [1.3.0] 2019-07-25

### Removed
Expand Down
1 change: 1 addition & 0 deletions docs/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
- Antoine Villeret [@avilleret](https://github.com/avilleret) - SLIP Encoding.
- Anton Viktorov [@latonita](https://github.com/latonita) - Bugfixes.
- [@per1234](https://github.com/per1234) - Metadata.
- George Profenza [@orgicus](https://github.com/orgicus) - API Suggestions.

_For and up-to-date list of contributors, see [contributors](../graphs/contributors)._
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=PacketSerial
version=1.3.0
version=1.4.0
author=Christopher Baker <info@christopherbaker.net>
maintainer=Christopher Baker <info@christopherbaker.net>
sentence=An Arduino Library that facilitates packet-based serial communication using COBS or SLIP encoding.
Expand Down
24 changes: 24 additions & 0 deletions src/PacketSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,30 @@ class PacketSerial_
_stream = stream;
}

/// \brief Get a pointer to the current stream.
/// \warning Reading from or writing to the stream managed by PacketSerial_
/// may break the packet-serial protocol if not done so with care.
/// Access to the stream is allowed because PacketSerial_ never
/// takes ownership of the stream and thus does not have exclusive
/// access to the stream anyway.
/// \returns a non-const pointer to the stream, or nullptr if unset.
Stream* getStream()
{
return _stream;
}

/// \brief Get a pointer to the current stream.
/// \warning Reading from or writing to the stream managed by PacketSerial_
/// may break the packet-serial protocol if not done so with care.
/// Access to the stream is allowed because PacketSerial_ never
/// takes ownership of the stream and thus does not have exclusive
/// access to the stream anyway.
/// \returns a const pointer to the stream, or nullptr if unset.
const Stream* getStream() const
{
return _stream;
}

/// \brief The update function services the serial connection.
///
/// This must be called often, ideally once per `loop()`, e.g.:
Expand Down

0 comments on commit 91fdf51

Please sign in to comment.