RTno is communicating library and framework which allows you to make your embedded device capable of communicating with RT-middleware world. RT-middleware is a platform software to realize Robotic system. In RTM, robots are developed by constructing robotics technologies\' elements (components) named RT-component. Therefore, the RTno helps you to create your own RT-component with your mbed and arduino. To know how to use your RTno device, visit here: http://ysuga.net/robot_e/rtm_e/rtc_e/1065?lang=en To know about RT-middleware and RT-component, visit http://www.openrtm.org
Dependencies: EthernetInterface mbed-rtos
Diff: SerialDevice.cpp
- Revision:
- 1:f74116b37bc9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SerialDevice.cpp Mon Jul 08 07:14:30 2013 +0000 @@ -0,0 +1,37 @@ +#include "mbed.h" +#include "SerialDevice.h" + +// static value declaration. +void(*SerialDevice_putc)(const char c); +uint8_t(*SerialDevice_available)(); +uint8_t(*SerialDevice_getc)(); + +int32_t INFINITE = -1; + +#if 1 +static Timer timer; +#endif + +int8_t SerialDevice_read(uint8_t* buffer, const uint8_t size, const int32_t &wait_usec) +{ + int32_t us; + timer.reset(); + timer.start(); + for(unsigned int i = 0;i < size;i++) { + while (1) { + if(SerialDevice_available() > 0) { + break; + } + us = timer.read_us(); + if (us >= wait_usec && wait_usec != INFINITE) { + timer.stop(); + return -TIMEOUT; + } + } + buffer[i] = SerialDevice_getc(); + } + timer.stop(); + return size; +} + +