XBee API operation library for mbed for miniprojects
Dependencies: SmartLabXBeeCore
Fork of SmartLabXBeeAPI2 by
SerialData.cpp
- Committer:
- yangcq88517
- Date:
- 2015-10-22
- Revision:
- 0:415f4b1b988e
- Child:
- 2:723cccd7659a
File content as of revision 0:415f4b1b988e:
#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() { if (serialPort->readable()) return serialPort->getc(); else return -1; } void SerialData::writeByte(char data) { serialPort->putc(data); } bool SerialData::isOpen() { if (serialPort->readable()) return true; else return false; } void SerialData::open() {} void SerialData::close() {}