ROS Serial library for Mbed platforms for ROS Kinetic Kame. Check http://wiki.ros.org/rosserial_mbed/ for more information.

Dependencies:   BufferedSerial

Dependents:   mbed-os-example-blinky

Revision:
0:9e9b7db60fd5
diff -r 000000000000 -r 9e9b7db60fd5 MbedHardware.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MbedHardware.h	Sat Dec 31 00:48:34 2016 +0000
@@ -0,0 +1,60 @@
+/*
+ * MbedHardware
+ *
+ *  Created on: Aug 17, 2011
+ *      Author: nucho
+ */
+
+#ifndef ROS_MBED_HARDWARE_H_
+#define ROS_MBED_HARDWARE_H_
+
+#include "mbed.h"
+
+#include "BufferedSerial.h"
+
+class MbedHardware {
+  public:
+    MbedHardware(PinName tx, PinName rx, long baud = 57600)
+      :iostream(tx, rx){
+      baud_ = baud;
+      t.start();
+    }
+
+    MbedHardware()
+      :iostream(USBTX, USBRX) {
+        baud_ = 57600;
+        t.start();
+    }
+
+    void setBaud(long 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:
+    BufferedSerial iostream;
+    long baud_;
+    Timer t;
+};
+
+
+#endif /* ROS_MBED_HARDWARE_H_ */