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: InPort.h
- Revision:
- 0:5f7bc45bc2e8
diff -r 000000000000 -r 5f7bc45bc2e8 InPort.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/InPort.h Mon Jun 24 06:42:11 2013 +0000 @@ -0,0 +1,60 @@ +#ifndef INPORT_HEADER_INCLUDED +#define INPORT_HEADER_INCLUDED + +/******************************************* + * InPort.h + * @author Yuki Suga + * @copyright Yuki Suga (ysuga.net) Nov, 10th, 2010. + * @license LGPLv3 + *****************************************/ + +#include <stdint.h> +#include "PortBase.h" +#include "NullBuffer.h" +#include <string.h> +#include <stdlib.h> + +class InPortBase : public PortBase{ + private: + + public: + InPortBase(char* name, char tCode) { + PortBase_init(this, name, tCode, NullBuffer_create()); + } + + public: + +}; + +template<typename T> +class InPort : public InPortBase { + public: + T* m_pData; + public: + InPort(char* name, T& data) : InPortBase(name, data.typeCode) { + m_pData = &data; + } + + ~InPort() {} + public: + uint8_t isNew() { + return pPortBuffer->hasNext(pPortBuffer); + } + + uint8_t read() { + uint8_t dataSize = pPortBuffer->getNextDataSize(pPortBuffer); + if(TypeCode_isSequence(m_pData->typeCode)) { + ((SequenceBase*)&(m_pData->data))->length(dataSize/TypeCode_getElementSize(m_pData->typeCode)); + pPortBuffer->pop(pPortBuffer, (int8_t*)((SequenceBase*)&(m_pData->data))->getData(), dataSize); + } else { + // This code must be okay for little endian system. + pPortBuffer->pop(pPortBuffer, (int8_t*)&(m_pData->data), dataSize); + } + return dataSize; + } + +}; + + + +#endif