SerialCute++
Name credits go to Meredith Hunter. This is a Serial Object library to allow for Serial communication. This was primarily designed for communication between Raspberry Pi and Teensy or Raspberry Pi and ESP32. It was also used for SerialPrime (a deprecated Serial communication protocol to send ESP32 photos to Raspberry Pi)
Serial Object
Serial Object Header File.
Defines
-
SERIALOBJECT_H
-
class SerialObject
- #include <SerialObject.h>
Serial Communication object.
Public Functions
-
SerialObject()
Construct a new Serial Object object.
-
SerialObject(std::string input)
Construct a new Serial Object object.
- Parameters:
input – String representing Serial input
-
~SerialObject()
Destroy the Serial Object object.
-
void writeSerial(std::string str)
Writes message.
- Parameters:
str – The message
-
std::string readSerial()
Reads message.
- Returns:
The message
-
void readSerialImageOrganic()
Attempt to read image serially.
-
bool readSerialImage(const char *pic_name)
Another attempt to read image serially (see Serial Prime alive commit to find the real one)
- Parameters:
pic_name – Filename of image
- Returns:
true Successfully read image
- Returns:
false Error in reading image
-
std::string readSerial(int buff_size)
Reads serial message up to a certain size.
- Parameters:
buff_size – Maximum size of the message
- Returns:
The serial message
Private Members
-
int serial_port
Serial Port.
-
std::string input_
String input.
-
int counter_
Character counter.
-
char size_buf_[256]
Message buffer.
-
uint8_t photo_buf_[3000000]
Message buffer for photos.
-
int size_index_
Current index in size buffer.
-
int photo_index_
Current index in photo buffer.
-
std::string indicator_
Indicator string.
-
int indicator_index_
Index in the indicator string.
-
SerialObject()
SerialTest
Simple test of Serial Object.
Functions
-
int main()
Main method to test Serial communication with Arduino/Teensy.
- Returns:
int representing exit status
SerialWrite
Alternate Serial test (maybe used for images, probably should be deprecated)
Functions
-
int main()
Main method trying to test Serial Object.
- Returns:
int representing exit status