PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 line
1.2KB

  1. /*
  2. Extends the Serial class to encode SLIP over serial
  3. */
  4. #ifndef SLIPEncodedSerial_h
  5. #define SLIPEncodedSerial_h
  6. #include "Arduino.h"
  7. #include <Stream.h>
  8. #include <HardwareSerial.h>
  9. class SLIPEncodedSerial: public Stream{
  10. private:
  11. enum erstate {CHAR, FIRSTEOT, SECONDEOT, SLIPESC } rstate;
  12. //the serial port used
  13. HardwareSerial * serial;
  14. public:
  15. //the serial port used
  16. SLIPEncodedSerial(HardwareSerial & );
  17. int available();
  18. int read();
  19. int peek();
  20. void flush();
  21. //same as Serial.begin
  22. void begin(unsigned long);
  23. //SLIP specific method which begins a transmitted packet
  24. void beginPacket();
  25. //SLIP specific method which ends a transmittedpacket
  26. void endPacket();
  27. // SLIP specific method which indicates that an EOT was received
  28. bool endofPacket();
  29. //the arduino and wiring libraries have different return types for the write function
  30. #if defined(WIRING) || defined(BOARD_DEFS_H)
  31. void write(uint8_t b);
  32. void write(const uint8_t *buffer, size_t size);
  33. #else
  34. //overrides the Stream's write function to encode SLIP
  35. size_t write(uint8_t b);
  36. size_t write(const uint8_t *buffer, size_t size);
  37. //using Print::write;
  38. #endif
  39. };
  40. #endif