Added sending a command
This commit is contained in:
19
README.md
19
README.md
@@ -44,3 +44,22 @@ void loop()
|
||||
```
|
||||
|
||||
Any time the cycle method is called it scans the serial buffer for any new commands and if there's something it processes those incomming commands it automatically processes that command, checks it's integrity and executes any handler functions associated with it.
|
||||
|
||||
## Sending A Command
|
||||
|
||||
The instance of the `SerialConnector` class contains a method called `sendCommand` which takes in two parameters as Strings. The first parameter is the name of the command being sent and the second parameter are any arguments associated with the command. So if we wanted to send the example command from above `ERR#Something went wrong#4342@` it would look something like this
|
||||
|
||||
```cpp
|
||||
#include <serialConnector.h>
|
||||
|
||||
SerialConnector *conn = new SerialConnector()
|
||||
|
||||
void setup() {}
|
||||
|
||||
void loop()
|
||||
{
|
||||
conn->sendCommand("ERR", "Something went wrong");
|
||||
}
|
||||
```
|
||||
|
||||
The code above will automatically generate the command packet and send it, and process the incomming acknowledge or repeat packets from the receiver.
|
||||
Reference in New Issue
Block a user