Skip to content

Commit d79c519

Browse files
committed
Merge pull request #5 from Marc010/master
Software serial
2 parents fe633e0 + 9e9bc8a commit d79c519

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@ Where:
6969
| `Serial2` | 2 |
7070
| `Serial3` | 3 |
7171
72+
To use a software serial port you can also use the `begin` method, this time with only a Stream* as argument, i.e.
73+
```c++
74+
void begin(Stream* serial)
75+
```
76+
77+
Usage:
78+
```c++
79+
PacketSerial packet_serial;
80+
SoftwareSerial software_serial(10, 11);
81+
82+
// in this case the serial port has to be initialized already when passing it to PacketSerial!
83+
software_serial.begin(38400);
84+
packet_serial.begin(&software_serial);
85+
```
86+
87+
7288
To receive decoded packets automatically, the user should register a packet callback. The packet callback should be placed in your main Arduino Sketch and should have a method that looks like this signatur that looks like:
7389
7490
```c++

src/PacketSerial.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ class PacketSerial_
7474
_serial = &Serial;
7575
}
7676
}
77+
78+
void begin(Stream* serial)
79+
{
80+
_serial = serial;
81+
}
7782

7883
void update()
7984
{

0 commit comments

Comments
 (0)