Arduino KVComm  master
Key-Value pair communication library for Arduino
SLIP-Send-CRC.ino

SLIP-Send-CRC

Send a SLIP package over the serial port every 5 seconds.

Boards:
AVR, AVR USB, Nano Every, Nano 33, Due, Teensy 3.x, ESP8266, ESP32
  1. Upload this sketch to one Arduino.
  2. Upload the SLIP-Receive-CRC.ino sketch to a second Arduino.
  3. Connect the TX pin of this Arduino to the RX pin of the second Arduino.
  4. Open the Serial monitor of the second Arduino.

It should print the following:

Received packet: Hello, world!
Size:            OK
Checksum:        OK

For boards where Serial is not a hardware UART, use Serial1 as the stream for the SLIPStream.

Written by PieterP, 2020-02-07
https://github.com/tttapa/Arduino-KVComm

#include <KVComm.h>
#include <boost/crc.hpp>
// The CRC settings to use, must be the same as the receiver.
using CRC = boost::crc_optimal<16, 0x1021, 0xFFFF, 0, false, false>;
// The actual SLIP Stream: it sends and receives packets, adds framing
// bytes, and computes a checksum using the CRC specified above.
Serial, // stream
CRC(), // sender CRC
nullptr, // no parser
CRC(), // parser CRC
};
void setup() {
Serial.begin(115200);
}
void loop() {
uint8_t data[] = "Hello, world!";
slip.writePacket(data, sizeof(data) - 1);
delay(5000);
}
KVComm.h
SLIPStreamCRC
Class that implements SLIP, a simple packet framing protocol, and that uses cyclic redundancy checks ...
Definition: SLIPStream.hpp:84
SLIPStream.hpp
SLIPStreamCRC::writePacket
size_t writePacket(const uint8_t *data, size_t len)
Sends a packet.
Definition: SLIPStream.ipp:6