![](/media/cache/profiles/94aef38441efa3380a3bed3faf1f9d5d.50x50_q85.jpg)
This program is porting rosserial_arduino for mbed http://www.ros.org/wiki/rosserial_arduino This program supported the revision of 169 of rosserial. This program contains an example.
Dependencies: rosserial_mbed_lib mbed Servo
Diff: MbedHardware.h
- Revision:
- 4:2cbca0ac2569
- Parent:
- 3:dff241b66f84
--- a/MbedHardware.h Sat Nov 12 23:53:04 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* - * MbedHardware - * - * Created on: Aug 17, 2011 - * Author: nucho - */ - -#ifndef MBEDHARDWARE_H_ -#define MBEDHARDWARE_H_ - -#include"mbed.h" -#include"MODSERIAL.h" - -#ifndef ROSSERIAL_BAUDRATE -#define ROSSERIAL_BAUDRATE 57600 -#endif - - -class MbedHardware { -public: - MbedHardware(MODSERIAL* io , int baud= ROSSERIAL_BAUDRATE) - :iostream(*io){ - baud_ = baud; - t.start(); - } - MbedHardware() - :iostream(USBTX, USBRX) { - baud_ = ROSSERIAL_BAUDRATE; - t.start(); - } - MbedHardware(MbedHardware& h) - :iostream(h.iostream) { - this->baud_ = h.baud_; - - t.start(); - } - - void setBaud(int baud) { - this->baud_= baud; - } - - int getBaud() { - return baud_; - } - - void init() { - iostream.baud(baud_); - } - - int read() { - if (iostream.readable()) { - return iostream.getc(); - } else { - return -1; - } - }; - void write(uint8_t* data, int length) { - for (int i=0; i<length; i++) iostream.putc(data[i]); - } - - unsigned long time() { - return t.read_ms(); - } - -protected: - int baud_; - MODSERIAL iostream; - Timer t; -}; - - -#endif /* MBEDHARDWARE_H_ */