binaryCommunication.cpp 726 Bytes
Newer Older
Poseidon's avatar
Poseidon committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "binaryCommunication.h"

BinCommunication::BinCommunication(void *dataPtr, int dataLen){ 
    this->dataPtr = (char*)dataPtr;
    this->dataLen = dataLen;    
}

void BinCommunication::begin(long int baudRate){
    Serial.begin(baudRate);
}

bool BinCommunication::send(){
    Serial.write(this->dataLen);
    if(Serial.write(this->dataPtr, this->dataLen) == this->dataLen)
        return true;
    return false;
}

int BinCommunication::getDataLen(){
    return this->dataLen;
}

void BinCommunication::setDataLen(int dataLen){
    this->dataLen = dataLen;
}

void* BinCommunication::getDataPtr(){
    return this->dataLen;
}

void BinCommunication::setDataPtr(void* dataPtr){
    this->dataPtr = (char*) dataPtr;
}