MbedHardware.h
Go to the documentation of this file.
1 /*
2  * MbedHardware
3  *
4  * Created on: Aug 17, 2011
5  * Author: nucho
6  */
7 
8 #ifndef ROS_MBED_HARDWARE_H_
9 #define ROS_MBED_HARDWARE_H_
10 
11 #include "mbed.h"
12 
13 #include "BufferedSerial.h"
14 
15 class MbedHardware {
16  public:
17  MbedHardware(PinName tx, PinName rx, long baud = 57600)
18  :iostream(tx, rx){
19  baud_ = baud;
20  t.start();
21  }
22 
24  :iostream(USBTX, USBRX) {
25  baud_ = 57600;
26  t.start();
27  }
28 
29  void setBaud(long baud){
30  this->baud_= baud;
31  }
32 
33  int getBaud(){return baud_;}
34 
35  void init(){
36  iostream.baud(baud_);
37  }
38 
39  int read(){
40  if (iostream.readable()) {
41  return iostream.getc();
42  } else {
43  return -1;
44  }
45  };
46  void write(uint8_t* data, int length) {
47  for (int i=0; i<length; i++)
48  iostream.putc(data[i]);
49  }
50 
51  unsigned long time(){return t.read_ms();}
52 
53 protected:
55  long baud_;
56  Timer t;
57 };
58 
59 
60 #endif /* ROS_MBED_HARDWARE_H_ */
BufferedSerial iostream
Definition: MbedHardware.h:54
Software buffers and interrupt driven tx and rx for Serial.
virtual int readable(void)
virtual int getc(void)
virtual int putc(int c)
void write(uint8_t *data, int length)
Definition: MbedHardware.h:46
void setBaud(long baud)
Definition: MbedHardware.h:29
int i
MbedHardware(PinName tx, PinName rx, long baud=57600)
Definition: MbedHardware.h:17
unsigned long time()
Definition: MbedHardware.h:51
Software Buffer - Extends mbed Serial functionallity adding irq driven TX and RX. ...


rosserial_mbed
Author(s): Gary Servin
autogenerated on Mon Jun 10 2019 14:53:26