XBee API operation library for mbed for miniprojects

Dependencies:   SmartLabXBeeCore

Fork of SmartLabXBeeAPI2 by CHENGQI YANG

SerialData.cpp

Committer:
yangcq88517
Date:
2015-11-14
Revision:
7:6a9c4d7da3a1
Parent:
6:a7da3da4e053

File content as of revision 7:6a9c4d7da3a1:

#include "SerialData.h"

SerialData::SerialData(PinName tx, PinName rx)
{
    serialPort = new Serial(tx, rx);
    serialPort->baud(9600);
}

SerialData::SerialData(PinName tx, PinName rx, int baudRate)
{
    serialPort = new Serial(tx, rx);
    serialPort->baud(baudRate);
}

SerialData::~SerialData()
{
    if (serialPort != NULL)
        delete serialPort;
}

int SerialData::readByte()
{
    return serialPort->getc();
}

void SerialData::writeByte(char data)
{
    serialPort->putc(data);
}

bool SerialData::peek()
{
    if (serialPort->readable())
        return true;
    else return false;
}

bool SerialData::isOpen()
{
    return true;
}

void SerialData::open()
{}

void SerialData::close()
{}