This program is porting rosserial_arduino for mbed http://www.ros.org/wiki/rosserial_arduino This program supported the revision of 169 of rosserial.

Dependencies:  

Dependents:   rosserial_mbed robot_S2

Committer:
nucho
Date:
Sun Oct 16 07:19:36 2011 +0000
Revision:
1:ff0ec969dad1
Parent:
0:77afd7560544
Child:
3:1cf99502f396
This program supported the revision of 143 of rosserial.
And the bug fix of receive of array data.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nucho 0:77afd7560544 1 /*
nucho 1:ff0ec969dad1 2 * MbedHardware
nucho 0:77afd7560544 3 *
nucho 0:77afd7560544 4 * Created on: Aug 17, 2011
nucho 0:77afd7560544 5 * Author: nucho
nucho 0:77afd7560544 6 */
nucho 0:77afd7560544 7
nucho 0:77afd7560544 8 #ifndef MBEDHARDWARE_H_
nucho 0:77afd7560544 9 #define MBEDHARDWARE_H_
nucho 0:77afd7560544 10
nucho 0:77afd7560544 11 #include"mbed.h"
nucho 1:ff0ec969dad1 12 #include"MODSERIAL.h"
nucho 1:ff0ec969dad1 13
nucho 0:77afd7560544 14
nucho 0:77afd7560544 15 class MbedHardware {
nucho 0:77afd7560544 16 public:
nucho 1:ff0ec969dad1 17 MbedHardware(MODSERIAL* io , int baud= 57600)
nucho 0:77afd7560544 18 :iostream(*io){
nucho 0:77afd7560544 19 baud_ = baud;
nucho 0:77afd7560544 20 t.start();
nucho 0:77afd7560544 21 }
nucho 0:77afd7560544 22 MbedHardware()
nucho 0:77afd7560544 23 :iostream(USBTX, USBRX) {
nucho 0:77afd7560544 24 baud_ = 57600;
nucho 0:77afd7560544 25 t.start();
nucho 0:77afd7560544 26 }
nucho 0:77afd7560544 27 MbedHardware(MbedHardware& h)
nucho 0:77afd7560544 28 :iostream(h.iostream) {
nucho 0:77afd7560544 29 this->baud_ = h.baud_;
nucho 0:77afd7560544 30
nucho 0:77afd7560544 31 t.start();
nucho 0:77afd7560544 32 }
nucho 0:77afd7560544 33
nucho 1:ff0ec969dad1 34 void setBaud(int baud) {
nucho 0:77afd7560544 35 this->baud_= baud;
nucho 0:77afd7560544 36 }
nucho 0:77afd7560544 37
nucho 0:77afd7560544 38 int getBaud() {
nucho 0:77afd7560544 39 return baud_;
nucho 0:77afd7560544 40 }
nucho 0:77afd7560544 41
nucho 0:77afd7560544 42 void init() {
nucho 0:77afd7560544 43 iostream.baud(baud_);
nucho 0:77afd7560544 44 }
nucho 0:77afd7560544 45
nucho 0:77afd7560544 46 int read() {
nucho 0:77afd7560544 47 if (iostream.readable()) {
nucho 0:77afd7560544 48 return iostream.getc();
nucho 0:77afd7560544 49 } else {
nucho 0:77afd7560544 50 return -1;
nucho 0:77afd7560544 51 }
nucho 0:77afd7560544 52 };
nucho 0:77afd7560544 53 void write(uint8_t* data, int length) {
nucho 0:77afd7560544 54 for (int i=0; i<length; i++) iostream.putc(data[i]);
nucho 0:77afd7560544 55 }
nucho 0:77afd7560544 56
nucho 0:77afd7560544 57 unsigned long time() {
nucho 0:77afd7560544 58 return t.read_ms();
nucho 0:77afd7560544 59 }
nucho 0:77afd7560544 60
nucho 0:77afd7560544 61 protected:
nucho 1:ff0ec969dad1 62 int baud_;
nucho 1:ff0ec969dad1 63 MODSERIAL iostream;
nucho 0:77afd7560544 64 Timer t;
nucho 0:77afd7560544 65 };
nucho 0:77afd7560544 66
nucho 0:77afd7560544 67
nucho 0:77afd7560544 68 #endif /* MBEDHARDWARE_H_ */