Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged with madsci1016 using Streams #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions EasyTransfer/EasyTransfer.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
#include "EasyTransfer.h"




//Captures address and size of struct
#if defined(CORE_TEENSY)
void EasyTransfer::begin(uint8_t * ptr, uint8_t length, usb_serial_class *theStream){
#elif defined(SoftwareSerial_h)
void EasyTransfer::begin(uint8_t * ptr, uint8_t length, SoftSerial *theStream){
#elif defined(__AVR_ATmega32U4__)
void EasyTransfer::begin(uint8_t * ptr, uint8_t length, Serial_ *theStream){
#else
void EasyTransfer::begin(uint8_t * ptr, uint8_t length, Stream *theStream){
#endif
//Captures address and size of struct
address = ptr;
size = length;

_stream = theStream;

//dynamic creation of rx parsing buffer in RAM
rx_buffer = (uint8_t*) malloc(size);
}
Expand Down
26 changes: 22 additions & 4 deletions EasyTransfer/EasyTransfer.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,39 @@ GNU General Public License for more details.
#include "WProgram.h"
#endif
#include "Stream.h"
//#include <NewSoftSerial.h>
#if !defined(CORE_TEENSY)
#include <SoftwareSerial.h>
#endif
#include <math.h>
#include <stdio.h>
#include <stdint.h>
#include <avr/io.h>

class EasyTransfer {
public:
void begin(uint8_t *, uint8_t, Stream *theStream);
//void begin(uint8_t *, uint8_t, NewSoftSerial *theSerial);
#if defined(CORE_TEENSY)
void begin(uint8_t *, uint8_t, usb_serial_class *theStream);
#elif defined(SoftwareSerial_h)
void begin(uint8_t *, uint8_t, SoftSerial *theStream);
#elif defined(__AVR_ATmega32U4__)
void begin(uint8_t *, uint8_t, Serial_ *theStream);
#else
void begin(uint8_t *, uint8_t, Stream *theStream);
#endif

void sendData();
boolean receiveData();
private:
#if defined(CORE_TEENSY)
usb_serial_class *_stream;
#elif defined(SoftwareSerial_h)
SoftSerial *_stream;
#elif defined(__AVR_ATmega32U4__)
Serial_ *_stream;
#else
Stream *_stream;
//NewSoftSerial *_serial;
#endif

uint8_t * address; //address of struct
uint8_t size; //size of struct
uint8_t * rx_buffer; //address for temporary storage and parsing buffer
Expand Down